-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Option to disable ESLint in specific contexts (but not everywhere) #9929
Comments
An alternative here might be to have eslint checking happen asynchronously after the initial and incremental compiles, like typescript type checking. |
I have a terrible, no good, really bad workaround: use an executable It's not a true disable, but you can make it do very nearly nothing: const realConfig = {/* ... */};
const nopConfig = {
/*
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 |
+1 I'd like to disable eslint on the dev server |
1 similar comment
+1 I'd like to disable eslint on the dev server |
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:
|
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 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 |
Hey there @sahilrajput03, @jrr is referring about how to conditionally apply eslint rules. Not removing all of the eslint checks from the whole project. |
- Add workaround for facebook/create-react-app#9929
- Add workaround for facebook/create-react-app#9929
- Add workaround for facebook/create-react-app#9929
- Add workaround for facebook/create-react-app#9929
Is your proposal related to a problem?
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
.Describe alternatives you've considered
I've looked through react-script's webpack config to check if there was already a way to do this, but couldn't find one:
create-react-app/packages/react-scripts/config/webpack.config.js
Lines 749 to 767 in 027b03b
I've also looked into whether there was already a global disable available from ESLint or its webpack plugin, and couldn't find anything.
Additional context
I know CRA aims to limit the available configuration options, but it seems reasonable for this one to go in Advanced Configuration.
The text was updated successfully, but these errors were encountered: