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 --init: config.extends.push #12707

Closed
GongT opened this issue Dec 24, 2019 · 8 comments · Fixed by #12738
Closed

eslint --init: config.extends.push #12707

GongT opened this issue Dec 24, 2019 · 8 comments · Fixed by #12738
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 help wanted The team would welcome a contribution from the community for this issue

Comments

@GongT
Copy link

GongT commented Dec 24, 2019

Tell 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:

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 expect config.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

@GongT GongT added bug ESLint is working incorrectly triage An ESLint team member will look at this issue soon labels Dec 24, 2019
@trydalch
Copy link

I've run into the same problem trying to build the Typescript Node Starter project from Microsoft. There's no eslint config file, so I went to init it, and got the same error as @GongT

@yeonjuan
Copy link
Member

yeonjuan commented Jan 3, 2020

It looks like a bug. I reproduced it- https://github.com/yeonjuan/autoconfbug.

@kaicataldo
Copy link
Member

I get a totally different error when following the same steps. Seems like this is unfortunately quite broken at the moment.

Failed to load plugin 'react' declared in 'BaseConfig': Cannot find module 'eslint-plugin-react'

PRs to fix this are very welcome!

@kaicataldo kaicataldo 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 good first issue Good for people who haven't worked on ESLint before help wanted The team would welcome a contribution from the community for this issue and removed triage An ESLint team member will look at this issue soon good first issue Good for people who haven't worked on ESLint before help wanted The team would welcome a contribution from the community for this issue labels Jan 4, 2020
@koenpunt
Copy link

koenpunt commented Feb 5, 2020

I get a totally different error when following the same steps. Seems like this is unfortunately quite broken at the moment.

To fix that you should just add eslint-plugin-react to your dev dependencies;

yarn add --dev eslint-plugin-react

Or

npm i --save-dev eslint-plugin-react

@kaicataldo
Copy link
Member

@koenpunt Check out the issue above. This is referring to the eslint --init functionality which should install deps for you.

@koenpunt
Copy link

koenpunt commented Feb 5, 2020

which should install deps for you.

Ah, didn't know this.

@kaicataldo kaicataldo added the help wanted The team would welcome a contribution from the community for this issue label Feb 7, 2020
@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Mar 24, 2020
@eslint-deprecated
Copy link

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.

@mdjermanovic
Copy link
Member

Reopening since there is PR #12738 to fix this.

@mdjermanovic mdjermanovic reopened this Apr 6, 2020
@mdjermanovic mdjermanovic removed the auto closed The bot closed this issue label Apr 6, 2020
kaicataldo pushed a commit that referenced this issue Apr 6, 2020
* Fix: error in extending recommended config (fixes #12707)

* change to push

* add test cases

* add test case

* fix typo, add test case

* change to put eslint:recommended at the beginning.
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Oct 4, 2020
@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 Oct 4, 2020
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 help wanted The team would welcome a contribution from the community for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants