简体   繁体   中英

Allow create-react-app to compile with ESLint errors

I recently added ESLint and prettier with a bunch of configurations to create-react-app.

Here are the packages:

"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.1.4",
"prettier": "^2.1.2",

Now, the problem is that the development server fails to compile, because there are loads of ESLint errors in the project. It says:

Failed to compile

*list of errors*

This error occurred during the build time and cannot be dismissed.

This is highly intrusive. I need it to still be able to compile as I don't see a reason for it to refuse to do so because or some styling issues.

How can I prevent this from happening without doing some hack like setting all ESLint errors to warning level. I also do not want to eject.

I also wish not to put everything into .eslintigore during development as this would be very annoying for my team to have to change that file over and over during development.

Any help is appreciated.

I was having exactly the same problem after using a Vite for a while and then returning to CRA and installing my usual Airbnb linting tools. I found THIS solution on Github which basically says to add these lines to your package.json starting scripts

"start": "ESLINT_NO_DEV_ERRORS='true'  react-scripts start",  
"build": "DISABLE_ESLINT_PLUGIN='true' react-scripts build",

This did the trick for me. It kept the linting errors showing in the code but unless they were breaking the code it compiled and ran no problem.

I don't think this is a long term solution, but it will do for a workaround...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM