You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Option to disable ESLint in specific contexts (but not everywhere) #9929
On my project, ESLint's feedback is most valuable from 1) our editors, and 2) CI. It's not very useful when lint errors appear in the browser when connected to the dev server. (in fact, it slows me down!)
Describe the solution you'd like
I'd like to disable ESLint in the dev server, without affecting how ESLint behaves in other contexts. (e.g., eslint on the command line and in VS Code should be unafffected).
This could be via an environment var, e.g. DISABLE_LINT=1 react-scripts start.
changed the title [-]Option to disable eslint in specific contexts (but not everywhere)[/-][+]Option to disable ESLint in specific contexts (but not everywhere)[/+]on Oct 27, 2020
I have a terrible, no good, really bad workaround: use an executable .eslintrc.js file and emit config conditionally.
It's not a true disable, but you can make it do very nearly nothing:
constrealConfig={/* ... */};constnopConfig={/* This config is meant to do nothing. It exists because there's no good way to disable ESLint in Create React App: https://github.com/facebook/create-react-app/issues/9929 So the workaround here is to craft a config that does as little as possible, and then conditionally use it. */ignorePatterns: ["**/*.ts","**/*.tsx","./*.js","config/*.js"],};module.exports=process.env.DISABLE_ESLINT ? nopConfig : realConfig;
Note that you can't ignore all files lest ESLint get upset, with an error like All files matched by '/foo/bar/src/.' are ignored., but you can drop in an empty dummy file to placate it.
Reacted by Richard Beattie, David Rice, David Vogeleer, Trafiz, Ihor Yemets, Neil Bryson, Santiago Pernigotti, Alexander Sumiński, Utkarsh Gupta, Yiheng and 2 more
Reacted by Ihor Yemets, Alexander Sumiński, Rodrigo Maia, Utkarsh Gupta, Inácio Schweller and Raul Rene Lepșa
FYI there is already #9887 that tracks a similar concern. Disabling ESLint altogether (and losing useful notifications about problems) might not be necessary if we figure out a way to show errors in console only, like they used to be pre-v4.0.
@unframework Interesting, thanks for the reference. Fixing #9887 would certainly make dev server lint errors less annoying, but It'd still want to disable them for a couple reasons:
So I don't get spammed with warnings and errors for my WIP code. I address lint issues during a different part of my workflow, not during the rapid iteration cycle I use the dev server for.
Performance. Especially with some of typescript-eslint's slower rules, linting is a performance cost I'd prefer to pay less frequently. (A full eslint on my project currently takes 20s!)
Agreed re: performance, and it is funny that before CRA 4.0 that was actually the default (just a predefined bare-bones check in dev server, but allowing broader project-specific config for editor/CI/pre-commit).
Your solution with conditional config seems like a pretty flexible approach for that...
Hey there @sahilrajput03, @jrr is referring about how to conditionally apply eslint rules. Not removing all of the eslint checks from the whole project.
Activity
[-]Option to disable eslint in specific contexts (but not everywhere)[/-][+]Option to disable ESLint in specific contexts (but not everywhere)[/+]msbarry commentedon Oct 29, 2020
An alternative here might be to have eslint checking happen asynchronously after the initial and incremental compiles, like typescript type checking.
jrr commentedon Oct 30, 2020
I have a terrible, no good, really bad workaround: use an executable
.eslintrc.jsfile and emit config conditionally.It's not a true disable, but you can make it do very nearly nothing:
Note that you can't ignore all files lest ESLint get upset, with an error like
All files matched by '/foo/bar/src/.' are ignored., but you can drop in an empty dummy file to placate it.krailler commentedon Oct 30, 2020
+1 I'd like to disable eslint on the dev server
sahilrajput03 commentedon Oct 30, 2020
+1 I'd like to disable eslint on the dev server
unframework commentedon Nov 3, 2020
FYI there is already #9887 that tracks a similar concern. Disabling ESLint altogether (and losing useful notifications about problems) might not be necessary if we figure out a way to show errors in console only, like they used to be pre-v4.0.
jrr commentedon Nov 3, 2020
@unframework Interesting, thanks for the reference. Fixing #9887 would certainly make dev server lint errors less annoying, but It'd still want to disable them for a couple reasons:
eslinton my project currently takes 20s!)unframework commentedon Nov 3, 2020
Agreed re: performance, and it is funny that before CRA 4.0 that was actually the default (just a predefined bare-bones check in dev server, but allowing broader project-specific config for editor/CI/pre-commit).
Your solution with conditional config seems like a pretty flexible approach for that...
sahilrajput03 commentedon Nov 6, 2020
Hey its there's a simple solution to fix this in cra4, check out my guide on this topic(for cra4 only).
https://gist.github.com/sahilrajput03/bdd1f1d686da2e919eac647c89d87310
ashfaqnisar commentedon Nov 23, 2020
Hey there @sahilrajput03, @jrr is referring about how to conditionally apply eslint rules. Not removing all of the eslint checks from the whole project.
Workaround for CRA issue
Workaround for CRA issue
mrmckeb commentedon Jan 6, 2021
Hi @jrr, we've created a discussion around this. Feel free to vote or add thoughts!
#10344
Workaround for CRA issue
Workaround for CRA issue
jrr commentedon Feb 3, 2021
Fixed via #10170 in 4.0.2. Thanks @mrmckeb !