standard / eslint-config-standard

ESLint Config for JavaScript Standard Style

Home Page:https://standardjs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Environment key "es2021" is unknown

sooroos opened this issue · comments

version: 15.0.0, didnt have error in previous version

Error: .eslintrc » eslint-config-standard:
Environment key "es2021" is unknown

.eslintrc
{ "extends": "standard", "rules": { "padded-blocks": ["error", "always"], "space-before-function-paren": ["error", "never"], "semi": ["error", "always"], "eol-last": ["error", "never"], "no-trailing-spaces": ["error", { "skipBlankLines": true, "ignoreComments": true }], "space-infix-ops": 0, "one-var": ["error", { "initialized": "consecutive" }], }, "globals": { "jQuery": true, "$": true } }

same here.

same here.

You need to update your ESLint then, es2021 was introduced in ESLint version 7.8.0: https://github.com/eslint/eslint/releases/tag/v7.8.0

Also, eslint-config-standard version 15.0.0 states that it requires at least ESLint 7.11.0, so you should be seeing some kind of warning about having wrong peer dependencies:

"eslint": ">=7.11.0",

A friendly suggestion to avoid this in the future:

If you use the install-peerdeps CLI tool to install a package like this, which has many peer dependencies, then it will automatically install the correct peer dependencies for you.

i'm already using eslint 7.11.0;

"eslint": "7.11.0",

@bonesoul Are you sure that's the ESLint that is used then?

Do you see this error on the command line or in eg. Visual Studio Code?

If on command line:

  1. Have you ensured that you are running the local eslint and not a globally installed one?
    1. If you run npx eslint --version – then it shows v7.11.0?
    2. If you run eslint --version – does it run? If so, does it also show v7.11.0?

If in Visual Studio Code or similar:

  1. Which extension are you using?
  2. Which version of that extension?
  3. Which version of Visual Studio Code?

i am also using the latest version from eslint (im using it globally)

$ npm list -g --depth 0

+-- eslint@7.11.0
+-- grunt-cli@1.3.2
+-- gulp-cli@2.3.0
+-- increase-memory-limit@1.0.7
+-- npm@6.14.8
`-- npm-check-updates@9.1.2

and still not working

@sooroos What eslint version is installed in the place where you are using eslint-config-standard?

@voxpelli i'm using a local installed eslint.

using command line;

D:\Coding\hypetraq (develop -> origin)
λ npx eslint --version
v7.11.0

@voxpelli i've installed eslint 7.11.0 in the project also but the error ist still there: The problem might be gulp-eslint

@sooroos yeah, gulp-eslint could have eslint as a dependency of its own, it likely has to be updated to a new major release whenever eslint is updated to a new major release

in my case i'm using grunt-eslint. could be related to it?

@bonesoul pretty sure

same here..

I ran into this as well. Reason was, I had an outdated eslint installed globally (7.6.0) that was picked up by neovim instead of the project wide dependency @ 7.14.0. A npm i -g eslint did it for me.

commented

Ran into this also. v7.15.0

@rdcx As stated in the thread, it's due to the ESLint that is running for you isn't up to date, that could be either because you haven't updated ESLint in your project or more likely because you're using some tool to run ESLint and that tool is using another ESLint than the one you have installed in your project.

Nothing this project can change to help you fix it

I still ran into this, and I'm using eslint@7.32.0, both locally and globally are the same.

I've degraded eslint-config-standard to 14.0.0, it works for me.

@oodzchen Must be that there’s some older ESLint somewhere which gets involved with your code

I have run into this problem recently.

ESLint error log

[Error - 12:07:00 PM] ESLint stack trace:
[Error - 12:07:00 PM] Error: .eslintrc.cjs » @chatie/eslint-config » eslint-config-standard:
	Environment key "es2021" is unknown

    at /Users/huan/git/huan/ducks/node_modules/eslint/lib/shared/config-validator.js:169:19
    at Array.forEach (<anonymous>)
    at validateEnvironment (/Users/huan/git/huan/ducks/node_modules/eslint/lib/shared/config-validator.js:163:30)
    at validateConfigArray (/Users/huan/git/huan/ducks/node_modules/eslint/lib/shared/config-validator.js:334:9)
    at CascadingConfigArrayFactory._finalizeConfigArray (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:417:13)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:271:21)
    at CLIEngine.isPathIgnored (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cli-engine.js:951:18)
    at CLIEngine.executeOnText (/Users/huan/git/huan/ducks/node_modules/eslint/lib/cli-engine/cli-engine.js:868:38)
    at _e.lintText (/Users/huan/.vscode/extensions/dbaeumer.vscode-eslint-2.1.25/server/out/eslintServer.js:1:177327)
    at /Users/huan/.vscode/extensions/dbaeumer.vscode-eslint-2.1.25/server/out/eslintServer.js:1:171074

NPM versions

ducks@0.11.1 /Users/huan/git/huan/ducks
└─┬ @chatie/eslint-config@0.14.1
  ├─┬ @typescript-eslint/eslint-plugin-tslint@4.31.1
  │ ├─┬ @typescript-eslint/experimental-utils@4.31.1
  │ │ ├─┬ eslint-utils@3.0.0
  │ │ │ └── eslint@7.32.0 deduped
  │ │ └── eslint@7.32.0 deduped
  │ └── eslint@7.32.0 deduped
  ├─┬ @typescript-eslint/eslint-plugin@4.31.1
  │ └── eslint@7.32.0 deduped
  ├─┬ @typescript-eslint/parser@4.31.1
  │ └── eslint@7.32.0 deduped
  ├─┬ babel-eslint@10.1.0
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-config-standard@16.0.3
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-import@2.24.2
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-node@11.1.0
  │ ├─┬ eslint-plugin-es@3.0.1
  │ │ └── eslint@7.32.0 deduped
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-promise@5.1.0
  │ └── eslint@7.32.0 deduped
  ├─┬ eslint-plugin-standard@5.0.0
  │ └── eslint@7.32.0 deduped
  └── eslint@7.32.0

✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:06 $ npx eslint --version
v7.32.0
✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ npm ls eslint-config-standard
ducks@0.11.1 /Users/huan/git/huan/ducks
└─┬ @chatie/eslint-config@0.14.1
  └── eslint-config-standard@16.0.3

✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ eslint --version
bash: eslint: command not found
✘-127 ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ esli^C
✘-INT ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ npx eslint --version
v7.32.0
✔ ~/git/huan/ducks [esm ↑·5|✚ 8] 
12:09 $ eslint --version
bash: eslint: command not found

Reproducible repo

https://github.com/huan/ducks

BTW: the above error only shows in vscode, but I can run eslint without any problem in command line.

This is maybe a longshot, but for future folks: I am working in a monorepo with nested packages, where the base repo had the correct version of eslint, but a child repo had its own version of eslint that was older. So if you have nested repos, double-check (and make sure npx eslint --version says what you think it should!)

For future reference, in my case, it turns out prettier-standard is the culprit. It is way behind standard releases nowadays.

I had the same issue with eslint v8.23.0 switching back to v8.22.0 solved the problem.