question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manual extend without using "extends"

See original GitHub issue

Unfortunately I cannot use the recommended "extends": ["plugin:jest/recommended"] method because I’m using glob override config and extends is not supported, see https://github.com/eslint/eslint/issues/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 https://github.com/jest-community/eslint-plugin-jest/issues/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 🤔

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
yvelecommented, 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

1reaction
Graham42commented, 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: eslint@5.15.1 eslint-plugin-jest@22.3.2

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to extend classes in Kotlin without using inheritance
In this tutorial, we compare and contrast inheritance and Kotlin extensions to understand the pros and cons of each.
Read more >
extends - JavaScript - MDN Web Docs - Mozilla
The extends keyword is used in class declarations or class expressions to create a class that is a child of another class.
Read more >
Extending - Manual - PHP
Example #1 Extending the built-in classes. <?php /** * My Reflection_Method class */ class My_Reflection_Method extends ReflectionMethod
Read more >
Does extending class need another 'use' to call namespace?
No, you need the "use" statement in both files. Use is a file-level keyword and isn't affected by inheritance.
Read more >
Extending Classes | Think Java | Trinket
In Java, classes may extend only one superclass. Classes that do not specify a superclass with extends automatically inherit from java.lang.Object .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found