Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable ESLint that create-react-app provides

create-react-app v3.0.0 is out. It supports TypeScript linting internally. (That's nice!) I think I understand the situation where TSLint is on, and am planning to replace it with ESLint, but it is not right now.

How to disable that linting step in react-scripts start?

/* eslint-disable */ and others are not the ones I'm looking for.

like image 501
Ginpei Avatar asked Apr 24 '19 00:04

Ginpei


People also ask

How do I disable ESLint in Create react app?

As of react-scripts v4. 0.2, you can now opt out of ESLint with an environment variable. You can do this by adding it to your . env file, or by prefixing your scripts in your package.

Is ESLint included in Create react app?

Because Create React App comes with ESLint already integrated. They use their own sharable ESLint configuration and this can be found under the eslintConfig object in package.

What does ESLint-disable do?

The // eslint-disable-line comment disables the no-eval rule for just that line. You can also disable the no-eval rule for an entire function block by using /* eslint-disable */ .


Video Answer


2 Answers

As of react-scripts v4.0.2, you can now opt out of ESLint with an environment variable. You can do this by adding it to your .env file, or by prefixing your scripts in your package.json file.

For example in .env:

DISABLE_ESLINT_PLUGIN=true 

Or in your package.json:

{   "scripts": {     "start": "DISABLE_ESLINT_PLUGIN=true react-scripts start",     "build": "DISABLE_ESLINT_PLUGIN=true react-scripts build",     "test": "DISABLE_ESLINT_PLUGIN=true react-scripts test"   } } 

https://github.com/facebook/create-react-app/pull/10170

like image 81
sargunv Avatar answered Oct 02 '22 16:10

sargunv


You could set EXTEND_ESLINT environment variable to true, for example in .env file:

EXTEND_ESLINT=true 

Now you can extend eslint configuration in your package.json file:

... "eslintConfig": {     "extends": "react-app",     "rules": {       "jsx-a11y/anchor-is-valid": "off"     }   }, ... 

To disable eslint you could add a file .eslintignore with the content:

* 

See documentation for details: https://create-react-app.dev/docs/setting-up-your-editor/#experimental-extending-the-eslint-config

like image 31
kodemi Avatar answered Oct 02 '22 16:10

kodemi