ES Lint

字数 370 · 2021-11-29

disable

1
/* eslint-disable @typescript-eslint/no-var-requires */

rc

1
2
3
4
5
6
module.exports = {
  // ...
  rules: {
    'prettier/prettier': ['error', { singleQuote: true }],
  }
}

rules

  • 0 - "off"
  • 1 - "warn"
  • 2 - "error" (exit code is 1 when triggered)

additional options

using array literal syntax

1
quotes: ["error", "double"]

Disabling Rules

1
2
3
4
5
/* eslint-disable */

alert('foo');

/* eslint-enable */
1
2
3
4
5
6
7
8
9
alert('foo'); // eslint-disable-line

// eslint-disable-next-line
alert('foo');

/* eslint-disable-next-line */
alert('foo');

alert('foo'); /* eslint-disable-line */

extend

1
2
3
4
5
module.exports = {
  extends: [
    ''
  ]
}

eslint-config- prefix can be omitted. For example:

1
2
// resolves as eslint-config-airbnb
'airbnb'

Using a configuration from a plugin

package name prefix eslint-plugin- can be omitted. For example:

1
2
// plugin:<package-name>/<configuration-name>
'plugin:react/recommended'

Using a configuration file

ESLint resolves a relative path

1
'./node_modules/coding-standard/eslintDefaults.js'

parser

Developer guide

https://eslint.org/docs/latest/developer-guide/architecture/