Turning Off Eslint Rule for a Specific Line

Turning off eslint rule for a specific line

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

Turning off eslint rule for a specific file

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

eslint: How to disable certain eslint-disable- syntax?

Plugin eslint-plugin-eslint-comments is what you want.

ESlint: Turning off a specific rule across a project

In you .eslintrc you have two rules keys. The second will overwrite the first. Here's the file with the rules merged together:

{
"rules": {
"wrap-iife": [
2,
"inside"
],
"max-len": [
2,
120
],
"indent": [
2,
2
],
"no-with": 2,
"no-implicit-coercion": [
2, {
"string": true
}
],
"camelcase": [
2, {
"properties": "never"
}
],
"quotes": [
2,
"single"
],
"linebreak-style": [
2,
"unix"
],
"semi": [
2,
"always"
],
"angular/controller-as-vm": "off",
"angular/document-service": "off",
"angular/window-service": "off"
},
"env": {
"es6": true,
"browser": true,
"node": true
},
"ecmaFeatures": {
"modules": true
},
"globals": {
"angular": true
},
"extends": "angular"
}

ESLint disable specific rule for line break

This triggers the "object-curly-spacing" lint, so ignore it:

"rules": {
"object-curly-spacing": "off",
}


Related Topics



Leave a reply



Submit