Skip to content
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

Proposal: Option to build without linting #7828

Open
jsphstls opened this issue Oct 15, 2019 · 10 comments
Open

Proposal: Option to build without linting #7828

jsphstls opened this issue Oct 15, 2019 · 10 comments

Comments

@jsphstls
Copy link

Is your proposal related to a problem?

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.

Describe the solution you'd like

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.

Describe alternatives you've considered

Somehow disabling linting by configuration before the build step happens.

Additional context

A related issue was auto-staled without solution:
#7078

@rovansteen
Copy link
Contributor

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.

@jsphstls
Copy link
Author

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?

@jsphstls
Copy link
Author

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.

@rovansteen
Copy link
Contributor

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.

@miraage
Copy link

miraage commented Oct 18, 2019

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

@rovansteen
Copy link
Contributor

I think it makes sense in certain scenarios like CI/CD environments. As long as they stay opt out I don’t think it harms to add this.

@eturino
Copy link

eturino commented Nov 6, 2019

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.

@Primajin
Copy link
Contributor

Primajin commented Dec 9, 2021

Exhuming this - it seems like this was never pursued?
We have the same issue that linting is done twice and also I would like to be able to force the build step even if CRA thinks I wrote not so clean code - for example in a hotfix scenario I don't need CRA to tell me that e.g. a semicolon is missing when it wouldn't affect the built code in any way.

@giuband
Copy link

giuband commented Dec 9, 2021

@Primajin Opting out of eslint has been added here: #10170 (added in v4.0.2)

@Primajin
Copy link
Contributor

Perfect that actually solves it for me!

export DISABLE_ESLINT_PLUGIN=true

In my CI build job (that comes after lint) does not run it again but compiles directly 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants