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 keeps requiring overridden parsers when extending config #11396

Closed
kirill-konshin opened this issue Feb 14, 2019 · 5 comments
Closed

Eslint keeps requiring overridden parsers when extending config #11396

kirill-konshin opened this issue Feb 14, 2019 · 5 comments
Labels
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 evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion

Comments

@kirill-konshin
Copy link

This is a follow up for autoclosed issue #11240

Can be reproduced here https://github.com/aladdin-add/eslint-issue-11240

I am using plugin:typescript/recommended (eslint-plugin-typescript) on top of react-app (eslint-config-react-app) and as I can see from eslint --print-config the parser field is overwritten from babel-eslint to correct /Users/dis/Sites/apple-music/node_modules/eslint-plugin-typescript/parser.js, but for some reason ESLint still tries to resolve the unneeded parser, which is not even in final config.

I'm kinda okay to still install the useless parser, but it is a bit annoying.

Tell us about your environment

  • ESLint Version: 5.8.0

Please show your full configuration:

Configuration
{
  "extends": [
    "eslint:recommended",
    "react-app",
    "plugin:typescript/recommended",
    "plugin:import/recommended",
    "plugin:jsx-a11y/recommended",
    "plugin:prettier/recommended"
  ],
  "rules": {
    "no-console": "off",
    "prettier/prettier": "error"
  },
  "env": {
    "browser": true,
    "mocha": true,
    "node": true
  },
  "settings": {
    "import/resolver": {
      "node": {
        "extensions": [
          ".js",
          ".jsx",
          ".ts",
          ".tsx"
        ]
      }
    }
  }
}
eslint --fix src/**/*.ts src/**/*.tsx

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

Error: Cannot find module 'babel-eslint'
Referenced from: /Users/dis/Sites/apple-music/.eslintrc
    at ModuleResolver.resolve (/Users/dis/Sites/apple-music/node_modules/eslint/lib/util/module-resolver.js:72:19)
    at loadFromDisk (/Users/dis/Sites/apple-music/node_modules/eslint/lib/config/config-file.js:514:42)
    at load (/Users/dis/Sites/apple-music/node_modules/eslint/lib/config/config-file.js:564:20)
    at configExtends.reduceRight (/Users/dis/Sites/apple-music/node_modules/eslint/lib/config/config-file.js:430:36)
    at Array.reduceRight (<anonymous>)
    at applyExtends (/Users/dis/Sites/apple-music/node_modules/eslint/lib/config/config-file.js:408:26)
    at loadFromDisk (/Users/dis/Sites/apple-music/node_modules/eslint/lib/config/config-file.js:528:22)
    at load (/Users/dis/Sites/apple-music/node_modules/eslint/lib/config/config-file.js:564:20)
    at configExtends.reduceRight (/Users/dis/Sites/apple-music/node_modules/eslint/lib/config/config-file.js:430:36)
    at Array.reduceRight (<anonymous>)
@kirill-konshin kirill-konshin added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Feb 14, 2019
@not-an-aardvark
Copy link
Member

Hi, thanks for opening an issue.

As I mentioned in #11240, I don't think this is a bug. ESLint does config validation at each step of the process, so it validates the contents of intermediate configs even if the contents don't appear in the final resolved config. If a shareable config references a parser that doesn't exist, that shareable config is invalid.

@kirill-konshin
Copy link
Author

I agree and disagree at the same time. I agree that it does make sense to verify each config to make clear which one produces the issue. At the same time, it does not make sense to actually require anything, especially if it will be overwritten. It is a waste of resources at least.

In my opinion it should be an effort from both sides: fix the require at ESLint side and fix the improper config from CRA side.

I have created an issue for create-react-app facebook/create-react-app#6129 but it is stale.

@nzakas nzakas added core Relates to ESLint's core APIs and features evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Feb 15, 2019
@nzakas
Copy link
Member

nzakas commented Feb 15, 2019

The problem from ESLint's point of view is that we cannot know whether or not a parser will end up in the final config. A new config is calculated for every file that ESLint lints, so we need to keep each config in memory and know that each config in memory is valid so we can quickly merge them multiple times.

Plus, we need to have some idea at which level the parser is being required from in order to resolve it correctly.

While this does seem annoying in your specific case, I think overall ESLint is doing the right thing.

@kirill-konshin
Copy link
Author

Agree. Both on validation and require path.

But. CRA is fairly popular product, so anyone who use their config is prone to the above mentioned issue, and, unfortunately, CRA turnaround is slow...

So looks like for now there's no way other than to drag all of it's deps...

@nzakas
Copy link
Member

nzakas commented Feb 18, 2019

@kirill-konshin yeah, I'm sorry we couldn't be of more help. This sounds like something you should work through with the CRA team, as this behavior has been in ESLint for quite some time.

@nzakas nzakas closed this as completed Feb 18, 2019
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Aug 18, 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 Aug 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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 evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants