Repository navigation
Closed
Labels
Description
Description
I use @react-native-community/eslint-config with TypeScript. After update "@typescript-eslint/eslint-plugin", "@typescript-eslint/parser", and "@typescript-eslint/typescript-estree" from "5.24.0" to "5.25.0" I have error
Oops! Something went wrong! :(
ESLint: 8.16.0
Error: .eslintrc.js » @react-native-community/eslint-config#overrides[2]:
Environment key "jest/globals" is unknown
at /Users/bardiamist/Documents/my-proj/my-proj-mobile/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2058:23
at Array.forEach (<anonymous>)
at ConfigValidator.validateEnvironment (/Users/bardiamist/Documents/my-proj/my-proj-mobile/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2052:34)
at ConfigValidator.validateConfigArray (/Users/bardiamist/Documents/my-proj/my-proj-mobile/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2202:18)
at CascadingConfigArrayFactory._finalizeConfigArray (/Users/bardiamist/Documents/my-proj/my-proj-mobile/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3947:23)
at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/bardiamist/Documents/my-proj/my-proj-mobile/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3753:21)
at FileEnumerator._iterateFilesRecursive (/Users/bardiamist/Documents/my-proj/my-proj-mobile/node_modules/eslint/lib/cli-engine/file-enumerator.js:446:49)
at _iterateFilesRecursive.next (<anonymous>)
at FileEnumerator.iterateFiles (/Users/bardiamist/Documents/my-proj/my-proj-mobile/node_modules/eslint/lib/cli-engine/file-enumerator.js:297:49)
at iterateFiles.next (<anonymous>)
error Command failed with exit code 2.
Version
3.0.2
Output of npx react-native info
System:
OS: macOS 12.4
CPU: (10) arm64 Apple M1 Max
Memory: 8.97 GB / 64.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 18.2.0 - /opt/homebrew/bin/node
Yarn: 1.22.15 - /opt/homebrew/bin/yarn
npm: 8.9.0 - /opt/homebrew/bin/npm
Watchman: 2022.05.30.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 15.5, macOS 12.3, tvOS 15.4, watchOS 8.5
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8512546
Xcode: 13.4/13F17a - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
@react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.68.2 => 0.68.2
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
Steps to reproduce
Use @react-native-community
Run yarn eslint .
Snack, code example, screenshot, or link to a repository
module.exports = {
parser: "@typescript-eslint/parser",
extends: [
'plugin:@typescript-eslint/recommended',
'@react-native-community',
'airbnb',
],
...
};Reacted by Alex Rififi, Cem Üstün, Deniss, hossein-rashno and Hugo van de Vliert
Activity
Bardiamist commentedon Jun 2, 2022
Related issue typescript-eslint/typescript-eslint#5132
Bardiamist commentedon Jun 7, 2022
Looks fixed in typescript-eslint 5.27.1
sacru2red commentedon Jun 30, 2022
@Bardiamist
I don't understand.
I think @react-native-community/eslint-config project should upgrade @typescript-eslint packages,
@react-native-community/eslint-config package have dependencies
And you can say "just upgrade your project dependencies only"
But, there's another problem
React import React 'React' was used before it was defined
I wonder, here is managing package "@react-native-community/eslint-config"
https://github.com/facebook/react-native/tree/HEAD/packages/eslint-config-react-native-community#readme
I tried edit my project yarn.loack file, to @typescript-eslint/ libs to ^5.27.1
and it works
sacru2red commentedon Jun 30, 2022
I don't know what's the better,
I decide to upgrade "@typescript-eslint/eslint-plugin", "@typescript-eslint/parser" in my project
and I should add eslint config to
megacherry commentedon Jul 20, 2022
I had the same error and what worked was yarn-deduplicate, see also this comment: #32181 (comment)
I think it's related.
JDMathew commentedon Nov 16, 2022
Updating
jestinpackage.jsonfixed this for meBardiamist commentedon Nov 16, 2022
Problem appears often after some depencencies update
I fixing by next steps:
package.jsonversion of@react-native-community/eslint-configto2.0.0(3.1.0don't work)yarn3.2.0yarnPrgrmmrOleg commentedon Feb 24, 2023
Here is what helped me
npm i eslint-plugin-jest -DMore details here
tonsnoei commentedon Mar 24, 2023
In my case I was missing the file:
jest.config.jsin the root of my project. I added it with the following contents:This solves the issue.
martinezguillaume commentedon Aug 21, 2023
For me this command fix it...
yarn upgrade @typescript-eslint/eslint-plugin @typescript-eslint/parser(with a
rm -rf node_modules && yarnafter)It's a real pain these dependencies, you think you have the last version, but in your
yarn.lock, you still have old subdependencies...Remove
yarn.lockcan be a solution, but it's more a workaround than a real solution.Update part5b.md
murashki commentedon Jun 25, 2024
nvm use 16 helped me
fdobre commentedon Sep 25, 2024
For me this error showed up at upgrading from RN 0.73.9 to 0.74.5,
I fixed it with updating in package.json the following 2 modules vrom v5 to v7:
Fixes lint issue (see react/react-native#33955)
Chore: Upgrade sample and E2E tests to RN 0.75 (#4155)
jose920405 commentedon Jan 16, 2025
This combination worked for me
devDependencies
that
eslint-configversion requires alsoThis is an example of my
.eslintrc.jsfile.friederbluemle commentedon Jul 18, 2025
Yes, this error can happen when upgrading React Native and certain TS/ESLint related dependencies are still incorrectly held back by explicit entries in package.json and/or yarn.lock.
An existing project might still have have
@typescript-eslintdependencies in its package.json, possibly because it was originally based on the (now deprecated) react-native-template-typescript.Newer versions of
@react-native/eslint-configalready have direct dependencies on the correct@typescript-eslintpackages. If lower versions are declared in package.json, it might accidentally override it and lead to the errors above.In many cases the simplest solution is the following: