-
-
Notifications
You must be signed in to change notification settings - Fork 27k
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
Create React App - linting & CI/CD #3315
Comments
I'll go through this issue more in a bit, but setting |
@Timer you're right! Perfect. So that takes care of a bunch of my confusion. I just misunderstood part of the docs. I edited my original comment accordingly. |
Great! & like I said I will go through this issue a bit more later tonight. If you found the documentation confusing around |
Yeah no rush m8, this isn't a blocker.
Absolutely. At the very minimum I'll adjust the wording per our discussion. |
So we only use the error level for things we are 100% confident are errors. For example, we set The Originally, we may have never had errors. I think it'd be better to update this comment and say we error for things which are actual errors or unsupported functionality which would result in an error / unpredictable behavior.
That is true currently, but there's a pull request to add a
How did you come to this conclusion?
A few are! And we generally take pull requests to remove them. Very few however are style-esque because they almost always are a mistake. |
I may be wrong, but there looks to be a number of discrepancies between the User Guide and CRA's actual behaviour with regard to linting.
In the Continuous Integration section it says:
But if I run
CI=false npm run build
it still shows linter warnings. And, maybe I missed it, but there doesn't seem to be any checks for theCI
environment variable in webpack.config.prod.js or webpack.config.prod.js. The linter seems to run by default on every build.Towards the end of the section it also says:The build command does check for linter warnings. But it won't fail on a linter warning. Should this read. "The build command will check for linter errors and fail if any are found."?This brings me to something else that's giving me trouble. In eslint-config-react-app/index.js there is a comment at the top that says:
Okay....but if you scroll down to the eslint rules there are a number of rules that are defined at the error level. Namely,
no-undef
,no-restricted-globals
,no-restricted-properties
,import/first
,import/no-amd
,import/no-webpack-loader-syntax
...and more.Looking deeper into eslint-config-react-app/index.js made me even more confused. For context, I had just read through issue #2157. And particularly @gaearon's comment, where it states:
and
But there are a number of rules in there that are pretty style-specific. To prove it you can even do an intersect between the rules defined here and those found in eslint-config-prettier:
Some Thoughts
I think I understand the sentiment behind the comment in eslint-config-react-app/index.js where it says that usingeslint-loader
should make linter warnings visible enough that there doesn't need to be linter errors. This is great for beginners that might otherwise get discouraged by the inability to build their new React app because of a linter errors. The linter is there for them as a learning aid, but it doesn't act as a blocker.But, CRA is too useful a tool to be used solely by beginners on their weekend project. And there is a real need in a professional setting to turn those linter "warnings" into "errors", and have them fail in CI. What do y'all think about adding a flag or something to turn those warnings into errors? I can volunteer some of my time to do this myself if there is interest.Also, It seems like the only way to run these lint rules is by building the app. Is there a reason behind this? Many enterprises are starting to use CRA, and many pay by build minutes. So this isn't just an issue of having to wait for a build in order to have some lint checks, this decision is costing businesses money. What if there were a separate "lint" react script that we could provide "--warn" (default) or "--error" flags to run in CI?
To Summarize
the docs say the build will fail on linter warnings, but it doesn't.(it does if CI=true)eslint-config-react-app
says there shouldn't be any rules set at an "error" level, but there are.The text was updated successfully, but these errors were encountered: