Skip to content

ESLint 6.0.0-alpha.1 no longer passes the filename to processors #11725

Description

@Standard8

Tell us about your environment

  • ESLint Version: 6.0.0-alpha.1
  • Node Version: 8.16.0
  • npm Version: 6.4.1

What parser (default, Babel-ESLint, etc.) are you using?
default

Please show your full configuration:

Configuration
module.exports = {
  "plugins": [
    "spidermonkey-js"
  ],
};

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

module.exports = {
  processors: {
    ".js": {
      preprocess(text, filename) {
        console.log({filename});
        filename = filename.split(path.sep).join("/");
        // check filename.
      },
      postprocess(text, filename) {
        console.log({filename});
      },
    },
  },
};
./node_modules/.bin/eslint .

What did you expect to happen?

Output similar to:

{ filename: '/path/to/index.js' }
{ filename: '/path/to/index.js' }

What actually happened? Please include the actual, raw output from ESLint.

{ filename: undefined }
TypeError: Cannot read property 'split' of undefined
    at preprocess (/Users/mark/dev/gecko/tools/lint/eslint/eslint-plugin-spidermonkey-js/lib/processors/self-hosted.js:20:27)
    at Linter.verify (/Users/mark/dev/gecko/node_modules/eslint/lib/linter.js:1021:13)
    at Linter.verify (/Users/mark/dev/gecko/node_modules/eslint-plugin-html/src/index.js:143:21)
    at Linter._verifyWithConfigArray (/Users/mark/dev/gecko/node_modules/eslint/lib/linter.js:1078:21)
    at Linter.verify (/Users/mark/dev/gecko/node_modules/eslint/lib/linter.js:1008:25)
    at Linter.verify (/Users/mark/dev/gecko/node_modules/eslint-plugin-html/src/index.js:136:21)
    at Linter.verifyAndFix (/Users/mark/dev/gecko/node_modules/eslint/lib/linter.js:1176:29)
    at verifyText (/Users/mark/dev/gecko/node_modules/eslint/lib/cli-engine.js:229:48)
    at CLIEngine.executeOnFiles (/Users/mark/dev/gecko/node_modules/eslint/lib/cli-engine.js:768:28)
    at Object.execute (/Users/mark/dev/gecko/node_modules/eslint/lib/cli.js:209:111)

The error is because we're assuming that filename is a defined string.

According to the documentation page, filename should be passed as the second argument.

This worked in ESlint 5.16.0, and I couldn't see any breaking changes mentioned for it.

We need the filename as we use it to avoid processing various different files according to their path, as well as a few other checks.

Are you willing to submit a pull request to fix this bug?
Not at the moment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedThere is consensus among the team that this change meets the criteria for inclusionarchived due to ageThis issue has been archived; please open a new issue for any further discussionbugESLint is working incorrectlycoreRelates to ESLint's core APIs and features

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions