Eslint keeps requiring overridden parsers when extending config
See original GitHub issueI 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>)
Are you willing to submit a pull request to fix this bug?
I could if I would know how to fix this…
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Eslint keeps requiring overridden parsers when extending config
The problem from ESLint's point of view is that we cannot know whether or not a parser will end up in the final...
Read more >eslint disable extends in override - javascript - Stack Overflow
In the case where you have an override where you want to "downgrade" the js parser, how do you turn off the extends...
Read more >ESLint's new config system, Part 2: Introduction to flat config
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >Local Install of ESLint Breaks In-Editor Linting
It means that there is something wrong in VS because it doesn't use correct Node JS version for ESLint (it ignores settings in...
Read more >Linting in TypeScript using ESLint and Prettier - LogRocket Blog
extends : tells ESLint what configuration is set to extend from. The order matters, as the last extend option will override the previous...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
My understanding of the intended use case of peer deps is that you are specifying parent deps, ie my package is run by these packages.
The use of peer dependencies by CRA to attempt to merge or make packages optional seems like an “abuse” (for lack of a better term) of the non-automatic install quality of them…
That said, it’s intentional for us to set the parser to our parser in the new recommended config in 1.0.0.
The question here is that if you’re extending a config that sets a parser, then overriding it in the base config, does it still bug out?
To clarify, if something is a
peerDependency
of a package, then you always need to install it in order to use that package. This applies to ESLint configs and also everything else.It’s true that ESLint could probably avoid loading unneeded parsers as a performance optimization, but that is an implementation detail and isn’t defined behavior. If a package is missing its required
dependencies
orpeerDependencies
, there are no guarantees about whether it will work.