I'm always frustrated when the build command is linting my code and there is no way for me to skip the linting step. My pipeline is lint > test > build. I want to lint before testing because my test files are also linted. With the current setup, linting happens twice.
I would like to be able to opt out of linting: "build" : "react-scripts built --no-lint"
Or (even better) have linting separated from the build command so I can remove it. It would appear this way in the default setup:
"build": "react-scripts lint && react-scripts build"
The README never mentions that linting will happen within the build step, so this makes the actual process much more visible.
Somehow disabling linting by configuration before the build step happens.
A related issue was auto-staled without solution:
https://github.com/facebook/create-react-app/issues/7078
Do you have any stats on how long it takes (as a percentage of total build time) to do the linting in your case? I'm wondering if it's worth adding something like this.
This is part of the problem, I have no visibility into the cost of this because the only indication of linting is when it fails. I could give it a try if there were a way, but it is safe to assume that there is a cost to the extra linting and that it increases with the scale of the codebase.
Is there a way to collect those stats?
The specific lint configuration is also not being respected:
$ react-scripts build
Creating an optimized production build...
Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.
Failed to compile.
Not really, but you could run a lint with the same linting rules as CRA and see how long it takes, that would give you an indication.
Another potentially undocumented "feature" is noop gzipping during production build which definitely slows down the build.
I would suggest to have both lint/gzip being optional. We have custom react scripts where we got rid of eslint & gzip and the build time went from ~4:40 to ~2:40
I think it makes sense in certain scenarios like CI/CD environments. As long as they stay opt out I don鈥檛 think it harms to add this.
There is another scenario that happens to our team quite a lot.
We have a git hook to ensure that all files committed are fine, running prettier and linters.
When we are bugfixing in the browser, sometimes we comment out pieces of code, just to have the browser throw us an error of "you are importing stuff and then not using it". It makes quick checks way less trivial.
I'd rather have the option to avoid linting on dev build, since we know that we're not committing offending code, plus we have the linters in our editors.
Most helpful comment
There is another scenario that happens to our team quite a lot.
We have a git hook to ensure that all files committed are fine, running prettier and linters.
When we are bugfixing in the browser, sometimes we comment out pieces of code, just to have the browser throw us an error of "you are importing stuff and then not using it". It makes quick checks way less trivial.
I'd rather have the option to avoid linting on dev build, since we know that we're not committing offending code, plus we have the linters in our editors.