-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
How to prevent failing to compile on CRA when eslint errors? #10021
Comments
Add additional rules to your eslint configuration, it will overwrite error to warn. You have to specify it per rule.
|
Hmm thanks, this is a kind of workaround, but I don't see it as real solution... |
The issue with this workaround is that I extend multiple configs... I'd have to override a non-trivial number of rules. In my case, the ideal would be to apply something like the now-deprecated eslint-loader's Only when I run a husky hook or in a pre-build step do I want to run a strict check with an NPM script like: |
This is our exact issue as well. We updated from 3.4.3 and having the build fail for a stray unused import during development is almost hostile. There really should be an option to restore previous behavior. |
Couldn't agree more with this. Local development workflow now shot to pieces with this now |
Burned by this since upgrading today, odd default for a development env. |
This page has a comment which describes the desired behaviour from CRA < 4: // We use eslint-loader so even warnings are very visible. Was there a conscious decision to change this behaviour, or was it just left out of the new linting configuration during the migration away from |
This is a big stopper for me (and most likely for anyone else who extends CRA linting rules beyong it's default). Unless a solution is provied I'll have to revert to a pre 4.0 version. Even doing something as simple as extending eslint's react-app with airbnb will cause a compile error on things that were perviously harmless warnings. |
Team, we are blocked by this as well. Do we have any more insight into what is going on here? What is the rational for failing the build on warnings? It would be good to know the background before we come up with next steps. We have a large codebase that predates the introduction of eslint and a richer rule set. We keep warnings on to help with on-going clean up without failing builds. |
Local development went from smooth to painful. Litteraly have to wait 10 sec for every change made because I added an extra space in my code somewhere and it doesn't compile. Can't debug properly. Rollbacking |
Look at this issue : #9887 As they say, commenting out airbnb mentions in the extends array make things work again.... |
I don't even have airbnb in the extends array in my eslintrc config. I have only have:
|
@NicoAdrian If you look at the |
@chrisahardie Linting errors didn't block me from compiling before 4.0.0, I don't plan to override settings |
Having the same issue on my team - we want to enforce linting at commit/PR time, but not during active development. We would really like to ignore lint errors when running I noticed under advanced configuration there is an option to compile despite having Typescript errors - TSC_COMPILE_ON_ERROR. Having a similar option for lint would be tremendous - something like LINT_COMPILE_ON_ERROR that we could set when this behavior is desired. |
Used to work out the box, in the true style of CTA, now it doesn't. |
This is completely unreasonable in my opinion as well. I think our team also has no choice but to just roll back and wait for them to change this behavior. |
This issue is a duplicate of: #9887 |
@pascalstr's workaround is a decent option. If you're not using typescript, add something like the following in .eslintrc.json: {
"rules": {
"no-unused-vars": "warn",
"react/prop-types": "warn"
}
} In my case, it's only these two that are showstoppers. It's sub-optimal and I agree with the comments above that refusing to compile in the development environment over an unused variable is pretty hostile. But you'll at least be able to compile and it's simpler than holding back indefinitely. |
@webarnes but this will affect when you really want to lint your project, right? How can we configure a set of rules only for CRA that won't affect linting on CI for example? |
You can write eslintrc in Javascript and export a different object in different environments. So you would have different rules in development vs. production. Again, just a stopgap. I think the real solution would be saner defaults in CRA but I also want to keep working. |
Sorry you're running into this. It sounds like a duplicate of #9887. Let's consolidate the information over there if possible. Thanks! |
Sorry for being late but I think this can help others will have the same issue in the future |
@niyodusengaclement Thanks, this do the job indeed! |
I've done the same in my "scripts": {
"start": "ESLINT_NO_DEV_ERRORS='true' BROWSER=none PORT=8080 react-scripts start",
}, And now I can run the app with Looking at the EDIT In the package.json file, add these variables to your "scripts": {
"start": "ESLINT_NO_DEV_ERRORS='true' react-scripts start",
"build": "DISABLE_ESLINT_PLUGIN='true' react-scripts build",
}, The eslint will be completely disabled on your build. No warnings and errors. Use carefully. |
Thanks, Ive been using Vite for a while and went back to CRA just to build a starter skeleton for projects that Vite can't handle and forgot how annoying that problem was and how it seems it still hasn't got a satisfactory fix yet! Your solution did the trick for now though.... thanks.... |
@PaulHaze I also switched to Vite, can you share what is possible at CRA, that can not be made with Vite? Just out of curiosity... |
Gosh I am probably the wrong person to ask. I'm still very much a beginner when it comes to programming. Especially compared to most people on here. My experience so far with Vite has been great though. Super fast, and feels a less bloated than CRA. Saying that I was working on one project with tailwind in Vite and the refresh was very slow and flickering on every save. For that one I went back to CRA and it worked fine. However since that project the issue hasn't returned and so far its playing nice with every tailwind build I've made with it..... |
I create .env file and I am keep getting |
I fixed mine by adding |
Install
|
Failed to load plugin 'only-warn' declared in '.eslintrc.js': Cannot find module 'eslint-plugin-only-warn' |
I installed the new react/CRA version (4). Right now when I have eslint errors the whole page blows and CRA fails to compile.
Sometimes I make some small test or debug something in the flow, and don't want CRA to fail the running only because of 1-2 intentional eslint errors.
Is there a possibility only to display the errors in the console, but not to fail to compile?
If it fails the npm run build it is okay.
Thanks and best regards
The text was updated successfully, but these errors were encountered: