0

eslint . --ext .js

Error: .eslintrc: Environment key "es2021" is unknown

at Object.keys.forEach.id (Image api/node_modules/eslint/lib/shared/config-validator.js:169:19)
at Array.forEach (<anonymous>)
at validateEnvironment (Image api/node_modules/eslint/lib/shared/config-validator.js:163:30)
at validateConfigArray (Image api/node_modules/eslint/lib/shared/config-validator.js:334:9)
at CascadingConfigArrayFactory._finalizeConfigArray (Image api/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:417:13)
at CascadingConfigArrayFactory.getConfigArrayForFile (Image api/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:271:21)
at FileEnumerator._iterateFilesRecursive (Image api/node_modules/eslint/lib/cli-engine/file-enumerator.js:396:49)
at _iterateFilesRecursive.next (<anonymous>)
at FileEnumerator.iterateFiles (Image api/node_modules/eslint/lib/cli-engine/file-enumerator.js:251:49)
at iterateFiles.next (<anonymous>)

npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! [email protected] lint: eslint . --ext .js npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the [email protected] lint script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/marwan/.npm/_logs/2022-01-10T23_00_43_567Z-debug.log

.eslintrc

{ "env": { "browser": true, "es2021": true }, "parser": "@typescript-eslint/parser", "parserOptions": { "ecmaVersion": 12, "sourceType": "module" }, "plugins": [ "@typescript-eslint" ], "rules": { "indent": [ "error", 2 ], "linebreak-style": [ "error", "unix" ], "quotes": [ "error", "single" ], "semi": [ "error", "always" ], "no-multiple-empty-lines": [ 2, { "max": 1, "maxEOF": 0, "maxBOF": 0 } ], "no-trailing-spaces": "error", "import/no-extraneous-dependencies": 0 } }

4
  • Can you show us your .eslintrc.json config file please. Or alternatively whichever config file format you chose. config-validator.js is throwing an error implying there is an error in your configuration Commented Jan 10, 2022 at 23:33
  • the ask edited with eslintrc code Commented Jan 10, 2022 at 23:59
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Jan 18, 2022 at 20:21
  • Maybe you need to ignore node_modules folder eslint . --ext .js --ignore-pattern node_modules/ Commented May 18, 2024 at 22:40

1 Answer 1

0

The environment es2021 was added with ESLint 8 (ESLint 7 does not have it). The error message is a hint that you are using an older version of ESLint.

Look into your package.json, update the ESLint version to >= 8, then run npm install.

Sign up to request clarification or add additional context in comments.

2 Comments

I'm using eslint 8.4.0
@marwanAhmed I doubt that. Looking at your stack trace, an error is thrown in config-validator.js on line 169 for the code Object.keys.forEach.id, but in ESLint 8.4.0 that code is on line 176: github.com/eslint/eslint/blob/v8.4.0/lib/shared/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.