How To Turn Off Learned Words
ESLint - is a very convenient tool to control code quality. Merely, sometimes it's necessary to disable it. In this tutorial, y'all'll learn how to turn off ESLint for certain directories and files.
Full general case
For demo purposes imagine you take a file with a couple of console.log()
statements that ESLint doesn't like.
To temporarily plow off ESLint, you should add a block comment /* eslint-disable */
before the lines that you're interested in:
/* eslint-disable */ panel.log('JavaScript debug log'); console.log('eslint is disabled at present');
One time ESLint sees the /* eslint-disable */
annotate information technology turns off the parsing.
To plow it back on yous should use the cake comment /* eslint-enable */
.
/* eslint-disable */ panel.log('JavaScript debug log'); console.log('eslint is disabled now'); /* eslint-enable */
At present ESLint is enabled once again and will parse the rest of the file normally.
Disabling specific ESLint rules
To disable not all, but only some specific ESLint rules, y'all should list them in the same comment. Split the rules with commas:
/* eslint-disable no-console, no-control-regex*/ console.log('JavaScript debug log'); console.log('eslint is disabled now');
The rules eslint-disable
and eslint-enable
should always be placed in the cake comments. This doesn't work:
// eslint-disable no-console, no-control-regex console.log('JavaScript debug log'); panel.log('eslint is disabled now');
Ignore a single line
To disable ESLint for a single line, there are 2 options.
To plow off linter for the current line, y'all add together a annotate after that line:
console.log('eslint is disabled for the current line'); // eslint-disable-line
To plough off the linter for the next line, you place the comment before the line that you want to ignore:
// eslint-disable-side by side-line console.log('eslint is disabled for the electric current line');
Ignore multiple files or folders
To turn off ESLint in the whole file, you can add /* eslint-disable */
in the first line of that file.
Alternatively, y'all tin can create a file .eslintignore
in the root itemize. The format of this file matches the format of .gitignore
and you can add together at that place not but files merely directories as well.
build/*.js config/*.js bower_components/foo/*.js
Read more JavaScript tutorials or Acquire Total-Stack JS from scratch!
Source: https://learn.coderslang.com/0023-eslint-disable-for-specific-lines-files-and-folders/
Posted by: bennettwasat1989.blogspot.com
0 Response to "How To Turn Off Learned Words"
Post a Comment