eslint --init: config.extends.push
See original GitHub issueTell us about your environment Node version: v12.14.0 npm version: v6.13.4 Local ESLint version: v6.8.0 (Currently used) Global ESLint version: Not found
What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint. I want to enable eslint for my exists TypeScript project.
eslint --init
? How would you like to use ESLint? To check syntax, find problems, and enforce code style
? What type of modules does your project use? JavaScript modules (import/export)
? Which framework does your project use? React
? Does your project use TypeScript? Yes
? Where does your code run? Browser, Node
? How would you like to define a style for your project? Inspect your JavaScript file(s)
? Which file(s), path(s), or glob(s) should be examined? ./src/**.{ts,tsx}
? What format do you want your config file to be in? JavaScript
What actually happened? Please include the actual, raw output from ESLint. Several module not found:
- @typescript-eslint/parser
- eslint-plugin-react
- @typescript-eslint
After install them all, It show me an error:
Determining Config: 0% [------------------------------] 0.0s elapsed, eta 0.0s Warning: React version not specified in eslint-plugin-react settings. See https://github.com/yannickcr/eslint-plugin-react#configuration .
Determining Config: 100% [==============================] 0.1s elapsed, eta 0.0s
Enabled 275 out of 275 rules based on 2 files.
config.extends.push is not a function
TypeError: config.extends.push is not a function
at processAnswers (/MY_PROJ/node_modules/eslint/lib/init/config-initializer.js:331:24)
at /MY_PROJ/node_modules/eslint/lib/init/config-initializer.js:615:28
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Are you willing to submit a pull request to fix this bug? No, I found the problem, but don’t know how to fix it (in your way).
selected “react”:
https://github.com/eslint/eslint/blob/master/lib/init/config-initializer.js#L294
select “Inspect your JavaScript file(s)”:
https://github.com/eslint/eslint/blob/master/lib/init/config-initializer.js#L326
https://github.com/eslint/eslint/blob/master/lib/init/autoconfig.js#L336
extendFromRecommended
will set config.extends
to RECOMMENDED_CONFIG_NAME
, there are two problems:
- RECOMMENDED_CONFIG_NAME is a string, after
extendFromRecommended
return, the parent scope expectconfig.extends
is an array - It drop my selection of “react” (or “vue”)
selected “typescript”:
https://github.com/eslint/eslint/blob/master/lib/init/config-initializer.js#L329
Issue Analytics
- State:
- Created 4 years ago
- Reactions:3
- Comments:8 (4 by maintainers)
Top GitHub Comments
Unfortunately, it looks like there wasn’t enough interest from the team or community to implement this change. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that accepted issues failing to be implemented after 90 days tend to never be implemented, and as such, we close those issues. This doesn’t mean the idea isn’t interesting or useful, just that it’s not something the team can commit to.
Thanks for contributing to ESLint and we appreciate your understanding.
Ah, didn’t know this.