-
-
Notifications
You must be signed in to change notification settings - Fork 26.8k
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
Crash the build during CI whenever linter warnings are encountered #944
Conversation
…ings are encountered.
Thanks! Maybe add a paragraph to https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#continuous-integration? Can you post a screenshot of what the log looks like with warnings? |
I have updated the docs, let me know what you think! |
|
||
If you find yourself doing this often in development, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows. | ||
The build command will check for linter warning and fail if any are found. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "linter warnings".
@@ -142,6 +142,11 @@ function build(previousSizeMap) { | |||
process.exit(1); | |||
} | |||
|
|||
if (process.env.CI && stats.compilation.warnings.length) { | |||
printErrors('Failed to compile. Note, the build has crashed because it is being run with the environment variable CI set to true. In this mode the build crashes when any warnings are encountered.', stats.compilation.warnings); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note, the build has crashed because it is being run with the environment variable CI set to true.
I think this wording makes it sound like having the CI
env variable set to true is the problem, not the warnings themself. I hope people won't "fix" this by trying to set the env variable to false...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good comment! We wouldn't want this message to cause any confusion. I will rephrase it:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to remove the description! People can refer to the updated README for more information about running builds in CI:) Do you agree?
👍 |
This patch triggers build errors even when webpack emits a warning, e.g.:
Since I have no access to I also tried to Is there a proper way to fix this besides ejecting? |
I think we might have to change the way we catch the ESLint errors here – failing for any Webpack warning is not good, because mostly harmless warnings are sometimes also triggered by UglifyJS etc. Is there a way we can only catch ESLint errors? |
@scholtzm Can you open a new issue about this problem so we can keep track of it? A merged pull request can't be reopened. |
Yep, was going to suggest it as well. |
That is a side affect I did not take into account:( I hope this gets fixed soon! Thanks a lot for finding this bug @scholtzm! |
FWIW I didn't see this addition to the docs (totally my fault), and the error was not clear that this was because of |
@jayphelps 👍 Wanna send a PR? |
Great feedback! This error message was included in the original PR but I removed it because I thought that just having it in the docs was enough, but I guess I was wrong ;) |
Yeah. I think @jayphelps’s wording is more clear than originally was in the PR so I’d be glad to get that in. |
Yep, I agree:) |
…acebook#944) * Added functionality to crash the build during CI whenever linter warnings are encountered. * Updated the docs with a description on how to use the build in CI * Fixed small typo * Fixed description of build error.
Any thought on reconsidering this? I've received flak when trying to add similar functionality to linters, with their reasoning being the rules can be configured to be an error or a warning. Turning a warning into an error doesn't make a whole lot of sense. And that logic still applies here: eslint lets you configure things to be errors or warnings. It's great that you consider unused vars to be an error. Then make it an error in the first place. |
We intentionally show lint errors very obtrusively (e.g. undefined variable doesn't let you see the app at all—it's treated as a built crash). So making making more minor issues errors would be too disruptive. |
…acebook#944) * Added functionality to crash the build during CI whenever linter warnings are encountered. * Updated the docs with a description on how to use the build in CI * Fixed small typo * Fixed description of build error.
Okay, how to make the build NOT to crash during build with CI set to true? |
Fixes issue #906.
Whenever someone runs the build script with the environmental variable
CI
set to true then it will crash when any linter warnings are encountered.I have tested this locally by generating an app using
create-react-app
and the updatedreact-scripts
. Is this enough or should there be an automated way of testing this functionality? If so, can anyone give some advice on how to go about testing this?I am also struggling to find the best location to document this feature. I considered updating the
npm run build
section of the README with this information however, I am afraid that explaining this feature in that location will only detract from the clarity to the reader. Perhaps I should create a new section in the user guide where this is explained, any thoughts?