Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turning off eslint rule for a specific file

Is it possible to turn off the eslint rule for the whole file? Something such as:

// eslint-disable-file no-use-before-define  

(Analogous to eslint-disable-line.) It happens to me quite often, that in a certain file, I'm breaking a specific rule on many places which is considered OK for that file, but I don't want to disable the rule for the whole project nor do I want to disable other rules for that specific file.

like image 259
Tomas Kulich Avatar asked Jan 13 '16 10:01

Tomas Kulich


People also ask

How do I turn off the lint rule?

In addition to global configuration, you may also enable/disable linting for a subset of lint rules within a file with the following comment rule flags: /* tslint:disable */ - Disable all rules for the rest of the file. /* tslint:enable */ - Enable all rules for the rest of the file.

How do I ignore a folder in ESLint?

You can tell ESLint to ignore specific files and directories using ignorePatterns in your config files. ignorePatterns patterns follow the same rules as . eslintignore .


1 Answers

You can turn off/change a particular rule for a file by putting the configurations at the top of the file.

/* eslint no-use-before-define: 0 */  // --> OFF  or  /* eslint no-use-before-define: 2 */  // --> ON 

More info

like image 160
Gyandeep Avatar answered Oct 05 '22 09:10

Gyandeep