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

Bug: running eslint --init generates a .eslint.json file with parserOptions.ecmaversion set to 13 #15159

Closed
1 task done
oscar-bartman opened this issue Oct 13, 2021 · 8 comments · Fixed by #15162
Closed
1 task done
Assignees
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly cli Relates to ESLint's command-line interface documentation Relates to ESLint's documentation
Projects

Comments

@oscar-bartman
Copy link

Environment

Node version: v14.17.5
npm version: 6.14.14
Local ESLint version: 7.32.0
Global ESLint version: --
Operating System: Ubuntu Linux

What parser are you using?

Default (Espree)

What did you do?

Configuration
{
    "env": {
        "commonjs": true,
        "es2021": true,
        "node": true
    },
    "extends": [
        "standard"
    ],
    "parserOptions": {
        "ecmaVersion": 13
    },
    "rules": {
    }
}
function hello() {
  console.log('hello')
}

Configuration is result from running npx eslint --init after installing eslint locally in an empty project.

Eslint shows an error at the first line of function shown saying Parsing error: Invalid ecmaVersion.

What did you expect to happen?

When running npx eslint --init I expect that it generates an .eslintrc file with valid options. According to documentation, supported options for parserOptions.ecmaVersion are 3, 5 (default), 6, 7, 8, 9, 10, 11, or 12 .

What actually happened?

npx eslint --init generated an .eslintrc file with parserOptions.ecmaVersion set to 13.

Participation

  • I am willing to submit a pull request for this issue.

Additional comments

Would love to help if anything. Just not sure where to start.

@oscar-bartman oscar-bartman added bug ESLint is working incorrectly repro:needed labels Oct 13, 2021
@eslint-github-bot eslint-github-bot bot added this to Needs Triage in Triage Oct 13, 2021
@aladdin-add
Copy link
Member

aladdin-add commented Oct 13, 2021

thanks for the report! 13 is an allowed value in eslint v8(but the docs was not updated somehow, should be fixed by #15162 )

you can:

  • upgrade to eslint 8.0
  • or set the ecmaversion to 12(with eslint v7)

@aladdin-add aladdin-add added documentation Relates to ESLint's documentation and removed repro:needed labels Oct 13, 2021
Triage automation moved this from Needs Triage to Complete Oct 13, 2021
mdjermanovic pushed a commit that referenced this issue Oct 13, 2021
* Docs: add 13 as allowed ecma version

* Update language-options.md
@mdjermanovic
Copy link
Member

mdjermanovic commented Oct 13, 2021

This is also a bug in eslint --init. I can reproduce this with ESLint 8.0.0, the problem is when --init downgrades ESLint to a version that doesn't support values that were already set by the version on which --init was run.

npx eslint --init steps, run on locally installed ESLint v8.0.0:

√ How would you like to use ESLint? · style
√ What type of modules does your project use? · commonjs
√ Which framework does your project use? · none
√ Does your project use TypeScript? · No / Yes
√ Where does your code run? · node
√ How would you like to define a style for your project? · guide
√ Which style guide do you want to follow? · standard
√ What format do you want your config file to be in? · JSON
Checking peerDependencies of eslint-config-standard@latest
The config that you've selected requires the following dependencies:

eslint-config-standard@latest eslint@^7.12.1 eslint-plugin-import@^2.22.1 eslint-plugin-node@^11.1.0 eslint-plugin-promise@^4.2.1 || ^5.0.0
√ Would you like to install them now with npm? · No / Yes
Installing eslint-config-standard@latest, eslint@^7.12.1, eslint-plugin-import@^2.22.1, eslint-plugin-node@^11.1.0, eslint-plugin-promise@^4.2.1 || ^5.0.0

This installs ESLint v7.32.0, and produces a config file that doesn't work with v7.32.0.

{
    "env": {
        "commonjs": true,
        "es2021": true,
        "node": true
    },
    "extends": [
        "standard"
    ],
    "parserOptions": {
        "ecmaVersion": 13
    },
    "rules": {
    }
}

@mdjermanovic mdjermanovic reopened this Oct 13, 2021
Triage automation moved this from Complete to Evaluating Oct 13, 2021
@mdjermanovic mdjermanovic moved this from Evaluating to Feedback Needed in Triage Oct 13, 2021
@aladdin-add
Copy link
Member

well, it will be fixed in #15150, by setting ecmaVersion to "latest". 😄

@bricss
Copy link

bricss commented Oct 14, 2021

Fix that has landed in latest version kinda missing es2022: true for env(s) 😶
Plus, a long standing annoying "feature" that setting ecmaVersion within 3rd-party parser options won't affect settings at all, leading linter to fallback into default ECMAScript version syntax 😢

@vicasas
Copy link

vicasas commented Dec 4, 2021

@aladdin-add What is the status? I see that #15162 was merged but at least from VS Code the warning still continues.

@aladdin-add
Copy link
Member

@vicasas we are working on a new cli @eslint/create-config to replace eslint --init. it will be fixed in the new repo, please follow #14768 .

aladdin-add added a commit to aladdin-add/eslint that referenced this issue Dec 20, 2021
Update: rm eslint auto config

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#1-remove-eslint-auto-config

Update: mv eslint --init to another package

moved `lib/init/config-rule` to tools, as it is also used by some others

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#2-move-eslint---init-related-files-to-a-separate-repo

chore: fix imports to make test passing

todo: use the new eslint api

fix: use the new eslint api (async)

fix: remove espree from deps

chore: fix a failing test

fix: a failing test

chore: cleanup TODOs

fix: allow to use local-installed eslint

wip: fix one-var

chore: lib => esm

chore: tests => esm

todo: proxyquire => td

chore: update deps to latest

fix: should write a file through fs when a ${fileType} path is passed

replaced proxyquire & sinon => td

fix: should include a newline character at EOF

chore: add testdouble

--wip-- [skip ci]

chore: remove package @eslint/create-eslint

feat: update npm --init to run `npm init @eslint/config`

docs: update getting-started

Update README.md

Update getting-started.md

chore: rm init fixtures

fix: `npm init @eslint/config` output

chore: rm unused files

chore: rm unused deps

Update bin/eslint.js

Co-authored-by: Brandon Mills <btmills@users.noreply.github.com>

chore: fix typo
aladdin-add added a commit to aladdin-add/eslint that referenced this issue Dec 20, 2021
fixes eslint#14768, fixes eslint#15159

Update: rm eslint auto config

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#1-remove-eslint-auto-config

Update: mv eslint --init to another package

moved `lib/init/config-rule` to tools, as it is also used by some others

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#2-move-eslint---init-related-files-to-a-separate-repo

chore: fix imports to make test passing

todo: use the new eslint api

fix: use the new eslint api (async)

fix: remove espree from deps

chore: fix a failing test

fix: a failing test

chore: cleanup TODOs

fix: allow to use local-installed eslint

wip: fix one-var

chore: lib => esm

chore: tests => esm

todo: proxyquire => td

chore: update deps to latest

fix: should write a file through fs when a ${fileType} path is passed

replaced proxyquire & sinon => td

fix: should include a newline character at EOF

chore: add testdouble

--wip-- [skip ci]

chore: remove package @eslint/create-eslint

feat: update npm --init to run `npm init @eslint/config`

docs: update getting-started

Update README.md

Update getting-started.md

chore: rm init fixtures

fix: `npm init @eslint/config` output

chore: rm unused files

chore: rm unused deps

Update bin/eslint.js

Co-authored-by: Brandon Mills <btmills@users.noreply.github.com>

chore: fix typo
@aladdin-add aladdin-add mentioned this issue Dec 31, 2021
1 task
@aladdin-add aladdin-add self-assigned this Dec 31, 2021
@aladdin-add aladdin-add added the cli Relates to ESLint's command-line interface label Dec 31, 2021
aladdin-add added a commit to aladdin-add/eslint that referenced this issue Jan 8, 2022
fixes eslint#14768, fixes eslint#15159

Update: rm eslint auto config

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#1-remove-eslint-auto-config

Update: mv eslint --init to another package

moved `lib/init/config-rule` to tools, as it is also used by some others

refs: https://github.com/aladdin-add/rfcs/blob/bdc12aa062750d837e5a3bbbf2f6e5e3a98da388/designs/2021-init-command-eslint-cli/README.md#2-move-eslint---init-related-files-to-a-separate-repo

chore: fix imports to make test passing

todo: use the new eslint api

fix: use the new eslint api (async)

fix: remove espree from deps

chore: fix a failing test

fix: a failing test

chore: cleanup TODOs

fix: allow to use local-installed eslint

wip: fix one-var

chore: lib => esm

chore: tests => esm

todo: proxyquire => td

chore: update deps to latest

fix: should write a file through fs when a ${fileType} path is passed

replaced proxyquire & sinon => td

fix: should include a newline character at EOF

chore: add testdouble

--wip-- [skip ci]

chore: remove package @eslint/create-eslint

feat: update npm --init to run `npm init @eslint/config`

docs: update getting-started

Update README.md

Update getting-started.md

chore: rm init fixtures

fix: `npm init @eslint/config` output

chore: rm unused files

chore: rm unused deps

Update bin/eslint.js

Co-authored-by: Brandon Mills <btmills@users.noreply.github.com>

chore: fix typo
@vicasas
Copy link

vicasas commented Jan 8, 2022

@aladdin-add From now on should we use npx @eslint/create-config to initialize eslint? I wonder since in the eslint docs still appears npx eslint --init

@aladdin-add
Copy link
Member

aladdin-add commented Jan 8, 2022

yes, I think the issue has been fixed in the new package, and the docs will be updated in #15150 (likely to be merged soon).

Triage automation moved this from Feedback Needed to Complete Jan 9, 2022
@eslint-github-bot eslint-github-bot bot locked and limited conversation to collaborators Jul 9, 2022
@eslint-github-bot eslint-github-bot bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jul 9, 2022
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 cli Relates to ESLint's command-line interface documentation Relates to ESLint's documentation
Projects
Archived in project
Triage
Complete
Development

Successfully merging a pull request may close this issue.

5 participants