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

Manual extend without using "extends" #128

Closed
yvele opened this issue Jul 10, 2018 · 6 comments
Closed

Manual extend without using "extends" #128

yvele opened this issue Jul 10, 2018 · 6 comments

Comments

@yvele
Copy link

yvele commented Jul 10, 2018

Unfortunately I cannot use the recommended "extends": ["plugin:jest/recommended"] method because I'm using glob override config and extends is not supported, see eslint/eslint#8813

With ESLint v4 that wasn't a problem I just did some "manual" extend like that:

import { configs } from "eslint-plugin-jest";

export default {
  plugins : configs.recommended.plugins,
  env     : configs.recommended.env,
  "extends": [
    "plugin:jest/recommended"
  ]
  rules   : {
    ...configs.recommended.rules,
    ...OVERRIDES
  }
};

The problem came with ESLint v5 where I get the same error as #44

Environment key "jest/globals" is unknown

And I cannot @pauloborges use answer because of the glob override config and extends issue.

Is there a workaround? Why is this Environment key "jest/globals" is unknown appearing with ESLint v5? Is there a way to manually register jest/globals?

I'm a bit stuck 🤔

@yvele
Copy link
Author

yvele commented Jul 10, 2018

Ok I found a workaround, instead of using

      env: configs.recommended.env

Which is the exact same as

      env: {
        'jest/globals': true
      }

I'm actually using

      env: {
        'jest': true
      }

As described in https://eslint.org/docs/user-guide/configuring#specifying-environments

I let this issue open to make sure someone see it.. There maybe is a real problem.

Feel free to close

@SimenB
Copy link
Member

SimenB commented Aug 15, 2018

Note that the jest globals from eslint are not matching the ones we have in our own list.

Not sure why it doesn't work normally, though

@Graham42
Copy link

Graham42 commented Mar 14, 2019

I'm also seeing

Environment key "jest/globals" is unknown

with config

module.exports = {
  //...
  overrides: [
    {
      files: ["**/__tests__/**/*"],
      plugins: ["jest"],
      env: {
        "jest/globals": true,
      },
    },
  ]
}

versions:
[email protected]
[email protected]

@alias-mac
Copy link

Just for the record (in case someone has the same problem that I have) I was able to make this work by doing:

Object.assign({}, require('eslint-plugin-jest').configs.recommended, {
  files: ['node-tests/**/*.js'],
  plugins: ['jest'],
  env: {
    browser: false,
    node: true,
    jest: true,
  },
})

if I remove the env override, then it breaks like it is explained in comments above:

Object.assign({}, require('eslint-plugin-jest').configs.recommended, {
  files: ['node-tests/**/*.js'],
  plugins: ['jest'],
})

@hon2a
Copy link

hon2a commented Dec 2, 2019

Please note that support for extends in overrides has been added in ESLint 6. (So this may likely be closed.)

@G-Rath
Copy link
Collaborator

G-Rath commented Nov 3, 2020

Closing, since we're on ESLint 7 now.

@G-Rath G-Rath closed this as completed Nov 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants