Demand
When we actually develop, we often need to introduce third-party developed programs. Some cannot be installed through NPM, only manually put files into the project. The actual development of these projects did not follow the strict ESLint
syntax. This time we need to manually configure ESLint
.
Use
ESLint
is designed to be fully configurable, you can switch each rule, or you can customize the rules. The configuration of each rule is not explained in detail here, only a simple and practical way to not use grammar checking for a specified file ESLint
.
Suppress rule warnings throughout file scope
will be /* eslint-disable */
placed at the top of the file
/* eslint-disable */alert(‘foo‘);
Temporary suppression rule warning in file
Wrap blocks of code that need to be ignored in comments
/* eslint-disable */alert(‘foo‘);/* eslint-enable */
Enable or disable warnings for a specified rule
Wrap blocks of code that need to be ignored in comments
/* eslint-disable no-alert, no-console */alert(‘foo‘);console.log(‘bar‘);/* eslint-enable no-alert, no-console */
Disable rule warnings for a specified row
There are two forms of this method, see below.
alert(‘foo‘); // eslint-disable-line// eslint-disable-next-linealert(‘foo‘);
Disables a specified rule on a specified line
alert(‘foo‘); // eslint-disable-line no-alert// eslint-disable-next-line no-alertalert(‘foo‘);
To disable multiple rules on a particular line
alert(‘foo‘); // eslint-disable-line no-alert, quotes, semi// eslint-disable-next-line no-alert, quotes, semialert(‘foo‘);
Specifies that the JS file does not use the ESLint syntax check