eslint: Environment key "jest/globals" is unknown

I’m getting this error on a fresh install of create-nuxt-app with linting tools of eslint and prettier enabled

> eslint --ext .js,.vue --ignore-path .gitignore . "--fix"

Error: .eslintrc.js » @nuxtjs/eslint-config-typescript » @nuxtjs/eslint-config:
        Environment key "jest/globals" is unknown

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

The .eslintrc.js is the default one

module.exports = {
  root: true,
  env: {
    browser: true,
    node: true
  },
  extends: [
    '@nuxtjs/eslint-config-typescript',
    'prettier',
    'prettier/vue',
    'plugin:prettier/recommended',
    'plugin:nuxt/recommended'
  ],
  plugins: [
    'prettier'
  ],
  // add your custom rules here
  rules: {
  }
}

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 2
  • Comments: 16 (2 by maintainers)

Most upvoted comments

This issue has been fix in latest eslint-config by updating eslint and jest plugin.

Can you try:


yarn upgrade @nuxtjs/eslint-config@latest @nuxtjs/eslint-config-typescript@latest 

// or

npm install @nuxtjs/eslint-config@latest   @nuxtjs/eslint-config-typescript@latest

we should re-open this @minblake

Weird I just ran into this issue after upgrading to eslint 8.0.0 I guess

Is there any special reason you are depending on eslint-plugin-jest? I know it may seem hard to believe, but some of us neither use jest nor want to install it. Making jest a hard-coded dependency to lint Nuxt code seems a bit opinionated.

@buecki Yeah, same thing happend to me. Strange… Anyways, thank you!

If you specify latest tag, the package will be updated to latest tag which includes major release.

I run into this today. Already deleted package-lock and node-modules and reinstalled everything, didn’t help 😦

  "devDependencies": {
    "@nuxtjs/eslint-config": "^6.0.1",
    "@nuxtjs/eslint-module": "^3.0.2",
    "babel-core": "7.0.0-bridge.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^8.0.1",
    "eslint-plugin-nuxt": "^2.0.0"
  }

I do not have typescript or jest

Version 3 of “@nuxtjs/eslint-config-typescript” doesn’t work at the moment. Same error.

"@nuxtjs/eslint-config-typescript": "^3.0.0",
"eslint": "^7.5.0",
"eslint-plugin-import": "^2.22.0", // <- Not sure why I suddenly need to install this with version 3?

Couldn’t figure out, but upgrading eslint worked for me:

"@nuxtjs/eslint-config-typescript": "2.0.0",
"eslint": "7.0.0",