Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Standard8 opened this issue May 15, 2019 · 1 comment · Fixed by #11552 · May be fixed by Omrisnyk/npm-lockfiles#130
Closed

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

Standard8 opened this issue May 15, 2019 · 1 comment · Fixed by #11552 · May be fixed by Omrisnyk/npm-lockfiles#130
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects

Comments

@Standard8
Copy link
Contributor

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.

@Standard8 Standard8 added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels May 15, 2019
@mysticatea mysticatea added accepted There is consensus among the team that this change meets the criteria for inclusion core Relates to ESLint's core APIs and features and removed triage An ESLint team member will look at this issue soon labels May 15, 2019
@mysticatea
Copy link
Member

Thank you for the report.

I confirmed it. I'm surprised that we didn't have the tests for that.

Fortunately, #11552 should fix this issue.

@mysticatea mysticatea added this to Ready to merge in v6.0.0 May 16, 2019
@mysticatea mysticatea moved this from Ready to merge to Implemented, pending review in v6.0.0 May 16, 2019
@mysticatea mysticatea added regression Something broke and removed regression Something broke labels May 18, 2019
v6.0.0 automation moved this from Implemented, pending review to Done May 25, 2019
ilyavolodin pushed a commit that referenced this issue May 25, 2019
* New: multiple processors support (fixes #11035)

* improve coverage

* trivial fix

* improve coverage

* improve document

Co-Authored-By: Ilya Volodin <ivolodin@gmail.com>

* improve document

Co-Authored-By: Ilya Volodin <ivolodin@gmail.com>

* improve document

Co-Authored-By: Ilya Volodin <ivolodin@gmail.com>

* improve document

Co-Authored-By: Ilya Volodin <ivolodin@gmail.com>

* add note that `filterCodeBlock` option overrides the default behavior

* improve document about code block name

* extRegExp → extensionRegExp

* processor → processorName

* share unIndent function
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Nov 22, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Nov 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly core Relates to ESLint's core APIs and features
Projects
No open projects
v6.0.0
  
Done
2 participants