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

Upgrading from 22.13.0 -> 22.13.1 fails on with jest/globals set in env #338

Closed
tmorehouse opened this issue Jul 22, 2019 · 6 comments
Closed

Comments

@tmorehouse
Copy link

Upgrading from 22.13.0 to 22.13.1 is now causing the following error for us:

$ eslint --ext .js,.md,.vue ./
Error: .eslintrc.js:
	Environment key "jest/globals" is unknown

    at /home/circleci/project/node_modules/eslint/lib/shared/config-validator.js:169:19
    at Array.forEach (<anonymous>)
    at validateEnvironment (/home/circleci/project/node_modules/eslint/lib/shared/config-validator.js:163:30)
    at validateConfigArray (/home/circleci/project/node_modules/eslint/lib/shared/config-validator.js:334:9)
    at CascadingConfigArrayFactory._finalizeConfigArray (/home/circleci/project/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:392:13)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/home/circleci/project/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:248:21)
    at FileEnumerator._iterateFilesRecursive (/home/circleci/project/node_modules/eslint/lib/cli-engine/file-enumerator.js:400:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/home/circleci/project/node_modules/eslint/lib/cli-engine/file-enumerator.js:254:49)
    at iterateFiles.next (<anonymous>)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Exited with code 2

Our .eslintrc.js file:

module.exports = {
  extends: ['standard', 'plugin:vue/recommended', 'plugin:prettier/recommended'],
  plugins: ['jest', 'markdown', 'node', 'promise'],
  parserOptions: {
    parser: 'babel-eslint',
    sourceType: 'module'
  },
  env: {
    browser: true,
    es6: true,
    'jest/globals': true
  },
  globals: {
    Vue: true
  },
  rules: {
    'spaced-comment': 'off', // needed to ignore `/*#__PURE__*/` comments
    'vue/html-self-closing': [
      'error',
      {
        html: {
          void: 'never',
          normal: 'never',
          component: 'never'
        }
      }
    ],
    'vue/max-attributes-per-line': ['error', { singleline: 4 }],
    'vue/no-template-shadow': 'off',
    'vue/no-use-v-if-with-v-for': 'off',
    'vue/no-v-html': 'off',
    'vue/require-default-prop': 'off',
    'vue/require-prop-types': 'off',
    'vue/singleline-html-element-content-newline': 'off'
  }
}
@aknorw
Copy link

aknorw commented Jul 22, 2019

That's not the only issue with 22.13.1:

Error: Failed to load plugin 'jest' declared in '.eslintrc.json': Cannot find module 'typescript'
Referenced from: /home/antoine/Work/back/report-consumer-worker/.eslintrc.json
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (/home/antoine/Work/back/report-consumer-worker/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/home/antoine/Work/back/report-consumer-worker/node_modules/@typescript-eslint/typescript-estree/dist/parser.js:17:25)
    at Module._compile (/home/antoine/Work/back/report-consumer-worker/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

My eslintrc.json file:

{
  "env": {
    "node": true,
    "jest": true
  },
  "parserOptions": {
    "ecmaFeatures": {
      "impliedStrict": true
    }
  },
  "extends": [
    "airbnb-base",
    "prettier",
    "plugin:node/recommended",
    "plugin:security/recommended",
    "plugin:jest/recommended"
  ],
  "plugins": ["security", "jest"],
  "rules": {
    "semi": [2, "never"],
    "no-unexpected-multiline": 2,
    "max-len": [
      1,
      {
        "code": 120,
        "comments": 200
      }
    ],
    "security/detect-object-injection": 0,
    "camelcase": 0,
    "node/shebang": 0
  }
}

@tmorehouse
Copy link
Author

Upgrading to the new 22.13.2 appears to fix the issue

@SimenB
Copy link
Member

SimenB commented Jul 22, 2019

@aknorw your issue should be solved with 22.13.3 (22.13.2 had a hacky fix). (EDIT: Note that at the time of writing, a new version hasn't been published. ETA 5 min)

@tmorehouse that's interesting (and good to hear!). I was just to post that I was unable to reproduce, what an odd error... We have changed nothing except for rule's implementations, which shouldn't affect the global thing...

EDIT: Nah, it probably failed to load the entire plugin and the error was just bad. At least, that's my guess...

@scarcoco
Copy link

i use npx react-native int Demo create a new project with the same issue, and i see the version of eslint-plugin-jest, it's 22.4.1.

@react-native-community/eslint-config had locked it version.

@scarcoco
Copy link

react-info

System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
    Memory: 3.31 GB / 16.00 GB
    Shell: 5.3 - /bin/zsh
  Binaries:
    Node: 12.7.0 - ~/.nvm/versions/node/v12.7.0/bin/node
    Yarn: 1.17.3 - ~/.nvm/versions/node/v12.7.0/bin/yarn
    npm: 6.10.0 - ~/.nvm/versions/node/v12.7.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  SDKs:
    iOS SDK:
      Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
    Android SDK:
      API Levels: 25, 26, 27, 28
      Build Tools: 25.0.2, 26.0.2, 27.0.3, 28.0.1, 28.0.3
      System Images: android-19 | ARM EABI v7a, android-19 | Intel x86 Atom, android-19 | Google APIs Intel x86 Atom, android-22 | Google APIs Intel x86 Atom, android-23 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom
      Android NDK: 19.2.5345600
  IDEs:
    Android Studio: 3.4 AI-183.6156.11.34.5522156
    Xcode: 10.1/10B61 - /usr/bin/xcodebuild
  npmPackages:
    react: 16.8.6 => 16.8.6
    react-native: 0.60.4 => 0.60.4
  npmGlobalPackages:
    react-native-cli: 2.0.1

@scarcoco
Copy link

i get why

because i open from parent directory of project, not project directory

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

4 participants