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

Init wizard not generating flat config #18369

Closed
elygeo opened this issue Apr 19, 2024 · 8 comments
Closed

Init wizard not generating flat config #18369

elygeo opened this issue Apr 19, 2024 · 8 comments
Labels
bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days repro:needed

Comments

@elygeo
Copy link

elygeo commented Apr 19, 2024

Environment

Node version: v21.7.3
npm version: 10.5.2
Global ESLint version: v9.1.0
Operating System: MacOS

What parser are you using?

Default (Espree)

What did you do?

npm init @eslint/config

What did you expect to happen?

Generate eslint.config.js

What actually happened?

Generate .eslintrc.js

@elygeo elygeo added bug ESLint is working incorrectly repro:needed labels Apr 19, 2024
@egorFiNE
Copy link

Same here and it's 100% repeatable.

I have read docs through and through to try to figure out who's wrong here but no matter how I read the docs, I only get .eslintrc.js generated. They have released 9.1.0 and had docs updated regarding filename (#18298) but it's still false.

  1. Create empty folder.
  2. Run npm init, default values for everything
  3. Run npm init @eslint/config, answer as follows:
✔ How would you like to use ESLint? · style
✔ What type of modules does your project use? · esm
✔ Which framework does your project use? · none
✔ Does your project use TypeScript? · No 
✔ Where does your code run? · browser
✔ How would you like to define a style for your project? · prompt
✔ What format do you want your config file to be in? · JavaScript
✔ What style of indentation do you use? · tab
✔ What quotes do you use for strings? · double
✔ What line endings do you use? · unix
✔ Do you require semicolons? · Yes
Local ESLint installation not found.
The config that you've selected requires the following dependencies:

eslint@latest
✔ Would you like to install them now? · Yes
✔ Which package manager do you want to use? · npm
Installing eslint@latest

added 89 packages, and audited 90 packages in 2s

22 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

Expected result: generated eslint.config.js.

Actual result:

A config file was generated, but the config file itself may not follow your linting rules.
Successfully created .eslintrc.js file in /Users/egor/workspace/www

Additional information: selecting predefined code style instead of answering questions leads to even more errors as two of the predefined styles and outright incompatible with 9.x. Still a .eslintrc.js is generated.

@aladdin-add
Copy link
Member

it's mostly a caching issue. can you try npm init @eslint/config@latest?

@krichter722
Copy link

fyi, this also happens when using yarn run eslint --init when only eslint 9.1.0 is installed. Since this is the only way to run the init routine with yarn afaik it's probably necessary to fix something in eslint.

aladdin-add added a commit that referenced this issue Apr 21, 2024
aladdin-add added a commit that referenced this issue Apr 21, 2024
aladdin-add added a commit to eslint/create-config that referenced this issue Apr 22, 2024
We've received a few reports generated configs seem to be eslintrc format,
so I've updated the documentation to use the latest version.

refs: eslint/eslint#18369,
eslint/eslint#18361,
@egorFiNE
Copy link

npm init @eslint/config@latest?

It is "fixed" now by breaking the "Where does your code run?" prompt in a way that prevents further execution of the script. I have opened eslint/create-config#104.

@elygeo
Copy link
Author

elygeo commented Apr 22, 2024

it's mostly a caching issue. can you try npm init @eslint/config@latest?

Somewhat better for generating flat config, but still broken.

Accepting the defaults install the old version as well, and is pick-up by the CLI:

$ npx eslint --version
v8.57.0

nzakas pushed a commit to eslint/create-config that referenced this issue Apr 22, 2024
We've received a few reports generated configs seem to be eslintrc format,
so I've updated the documentation to use the latest version.

refs: eslint/eslint#18369,
eslint/eslint#18361,
@nzakas nzakas added the patch candidate This issue may necessitate a patch release in the next few days label Apr 22, 2024
@nzakas
Copy link
Member

nzakas commented Apr 22, 2024

To summarize what's probably going on here: npx aggressively caches dependencies, so if you ever ran --init before, it's probably still using that old version. We should always be using the latest version inside of ESLint, so we can fix that.

fyi, this also happens when using yarn run eslint --init when only eslint 9.1.0 is installed. Since this is the only way to run the init routine with yarn afaik it's probably necessary to fix something in eslint.

@krichter722 I believe you can use yarn create @eslint/config@latest.

it's mostly a caching issue. can you try npm init @eslint/config@latest?

Somewhat better for generating flat config, but still broken.

Accepting the defaults install the old version as well, and is pick-up by the CLI:

$ npx eslint --version v8.57.0

@elygeo we need to see what you're seeing and any reproduction steps. "still broken" doesn't give us any useful information.

@elygeo
Copy link
Author

elygeo commented Apr 22, 2024

It seems there are two issues. The issue of using a cached version of create-config is avoided by "latest":

npm init @eslint/config@latest

The second issue is that create-config installs two versions of eslint, and the CLI seems to favor the old version as far as I can tell. Noted here #18361 eslint/create-config#106. This is why I filed a separate issue. Perhaps a duplicate as you say, I don't know.

Reproduction steps:

$ npm init @eslint/config@latest
$ npx eslint --version

Result:

v8.57.0

package.json now contains:

  "devDependencies": {
    "@eslint/js": "^9.1.1",
    "eslint": "^8.57.0",
    "eslint-plugin-react": "^7.34.1",
    "globals": "^15.0.0"
  }

Expected result:

v9.1.1

@nzakas
Copy link
Member

nzakas commented Apr 22, 2024

Got it, I agree this seems like two different issues. I'll reopen eslint/create-config#106

fasttime pushed a commit that referenced this issue Apr 22, 2024
* docs: use @eslint/create-config latest

refs: #18369, #18361,

* chore: review suggestions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug ESLint is working incorrectly patch candidate This issue may necessitate a patch release in the next few days repro:needed
Projects
Status: Complete
Development

No branches or pull requests

5 participants