I’m having trouble with eslint scripts in VSC.
I followed this tutorial to configure ESLint with Prettier and Husky in a create-react-app
project. When I execute npm run lint
the Terminal doesn’t show me any error, it doesn’t show me anything, like it didn’t run
fer@desktop... (main)
$ npm run lint
> [email protected] lint
> eslint .
fer@desktop... (main)
The script was working fine, but it stopped working and I couldn’t make it work again.
- Problems doesn’t show me any error until I open a file with an error, in that case Problems only shows me the errors found on that file, and when I close the file, the errors disappear.
- When I push to
main
a file with eslint errors, Vercel doesn’t deploy the project, and it shows me all the eslint errors, so there is working the eslint config. - Sometimes when I run the app the browser shows me all the errors, but sometimes not, I don’t understand why.
- When I run
npm run build
the console shows me all the errors and doesn’t build.
Here my eslint config and package.json
.eslintrc.json
{
"env": {
"browser": true,
"es2021": true,
"jest": true
},
"extends": [
"react-app",
"react-app/jest",
"airbnb-base",
"plugin:prettier/recommended"
],
"overrides": [],
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"plugins": ["react", "prettier"],
"root": true,
"rules": {
"react/jsx-uses-react": ["off"],
"react/prop-types": ["off"],
"react/react-in-jsx-scope": ["off"],
"react/jsx-props-no-spreading": ["warn"],
"no-shadow": "off",
"no-nested-ternary": "off",
"prefer-template": "off"
}
}
package.json
{
"name": "portfolio",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emailjs/browser": "^3.7.0",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.38.0",
"react-router-dom": "^6.4.2",
"react-scripts": "5.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"prepare": "husky install"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"eslint": "^8.28.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jsx-a11y": "^6.6.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"prettier": "^2.8.0",
"husky": "^8.0.0"
}
}
Thanks in advance.