I use create-react-app to make a react app.
the linter works in create-react-app but now i want make it work in my sublimetext.
yarn global add eslint
(eslint v4.1.1 but also tried v3.19.0 because react app uses that one) eslint --init
and configured it.eslintrc
{ "extends": "react-app" }
eslint src/App.js
get error in terminal :
Referenced from: /mnt/storage/Dev/newapp/.eslintrc Error: Cannot find module 'eslint-config-react-app'
Referenced from: /mnt/storage/Dev/newapp/.eslintrc at ModuleResolver.resolve (/home/user/.config/yarn/global/node_modules/eslint/lib/util/module-resolver.js:74:19) at resolve (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:515:25) at load (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:584:26) at configExtends.reduceRight (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:421:36) at Array.reduceRight (native) at applyExtends (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:405:28) at loadFromDisk (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:556:22) at Object.load (/home/user/.config/yarn/global/node_modules/eslint/lib/config/config-file.js:592:20) at Config.getLocalConfigHierarchy (/home/user/.config/yarn/global/node_modules/eslint/lib/config.js:228:44) at Config.getConfigHierarchy (/home/user/.config/yarn/global/node_modules/eslint/lib/config.js:182:43)
I did add yarn global add babel-eslint eslint-plugin-react eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-flowtype
. but i think this is not necessary anymore!
Linting a React App In our terminal again, we need to npm install -g eslint-plugin-react . Alternatively if you're running ESLint locally, we run npm install eslint-plugin-react --save-dev . This will install the plugin we need, but we need to tell ESLint that we want this plugin to help us out.
Because Create React App comes with ESLint already integrated. They use their own sharable ESLint configuration and this can be found under the eslintConfig object in package. json .
Basically, just delete . eslintrc and any other eslint config files(if any) from the project. Also, check your package. json and delete all eslint packages and do npm install on your project.
I think if you add the module mentioned in the error message (eslint-config-react-app
) it should work? eg. yarn add --dev eslint-config-react-app
There's probably a misconfiguration in your package-lock.json
file, where ESLint was removed. I've encountered the exact same issue and solved it via:
cd <your-project-directory>
rm package-lock.json
rm -rf node_modules
npm install
You can run npm ls eslint --depth=99
to verify the eslint
package is installed. I've stumbled upon this via a comment from feross on GitHub.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With