In order to turn off linting rule for a particular line in JSHint we use the following rule:
/* jshint ignore:start*/ $scope.someVar = ConstructorFunction(); /* jshint ignore:end */
I have been trying to locate the equivalent of the above for eslint.
For those converting eslint-disable-next-line to eslint-disable (for multiple lines), remember two things. 1. /* */ instead of // 2. It's eslint-disable and not eslint-disable-next-line . Just reiterating coz I did the same and had to search many more things due to the 2nd point.
To ignore some folder from eslint rules we could create the file . eslintignore in root directory and add there the path to the folder we want omit (the same way as for . gitignore ). Excerpt from the ESLint documentation "In addition to any patterns in a .
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.
To disable next line:
// eslint-disable-next-line no-use-before-define var thing = new Thing();
Or use the single line syntax:
var thing = new Thing(); // eslint-disable-line no-use-before-define
See the eslint docs
ESlint has now been updated with a better way disable a single line, see @goofballLogic's excellent answer.
You can use the following
/*eslint-disable */ //suppress all warnings between comments alert('foo'); /*eslint-enable */
Which is slightly buried in the "configuring rules" section of the docs;
To disable a warning for an entire file, you can include a comment at the top of the file e.g.
/*eslint eqeqeq:0*/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With