ESLint Jest, not recognizing globals

Viewed 44

I have ESLint 8.21.0 and Jest 27.0.6.

Also I have:

"eslint": "^8.21.0",
"eslint-config-semistandard": "^17.0.0",
"eslint-config-standard": "^17.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^26.7.0",
"eslint-plugin-n": "^15.2.4",
"eslint-plugin-promise": "^6.0.0"

describe and it are not recognized.

ESLint is working properly, but those Jest methods are like in this screenshot

enter image description here

With a previous configuration of plugin (airbnb, and another rules, another plugins) was working fine.

Now my config is:

{
  "extends": [
    "eslint:recommended",
    "semistandard",
    "plugin:jest/recommended"
  ],
  "env": {
    "es6": true,
    "jest/globals": true,
    "mocha": true
  },
  "globals": {
    "Atomics": "readonly",
    "SharedArrayBuffer": "readonly"
  },
  "parserOptions": {
    "ecmaVersion": 2020
  },
  "plugins": ["jest"],
  "rules": {
    "n/no-path-concat": "off",
    "no-console": "warn",
    "jest/no-disabled-tests": "warn",
    "jest/no-focused-tests": "error",
    "jest/no-identical-title": "error"
  }
}

I've tried:

  • Adding "plugins": ["jest"], and "jest/globals": true, to. env
  • And also just "extends": ["plugin:jest/recommended"]
1 Answers

Well, it was a types problem.

I had to install "@types/jest": "^28.1.6" and everything goes ok now.

enter image description here

Related