Suppose that I have an unused variable in my
src/App.js. With create-react-app you get a nice warning in the terminal about this when you start (
yarn start). But what if I don’t ever want to accept any warnings and would like to break pull requests if there are warnings. Is there any way to do that?
One possible way to do it is to use
CI=true yarn build. Example:
▶ CI=true yarn build && echo $?
yarn run v1.3.2
$ 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.
Line 7: 'variable' is assigned a value but never used no-unused-vars
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
That’s not bad but it does require a full
yarn build which will definitely add to the CI time.
Is there a way to get the warnings without having to do a build?
I.e. Ideally something like this: