-
Notifications
You must be signed in to change notification settings - Fork 29.6k
/
.eslintrc.yaml
90 lines (84 loc) Β· 5.83 KB
/
.eslintrc.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
## Test-specific linter rules
env:
node: true
es6: true
rules:
multiline-comment-style: [error, separate-lines]
prefer-const: error
symbol-description: off
comma-dangle: [error, always-multiline]
no-restricted-syntax:
# Config copied from .eslintrc.js
- error
- selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])
message: Use strictEqual instead of deepStrictEqual for literals or undefined.
- selector: CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual']):matches([arguments.1.type='Literal']:not([arguments.1.regex]), [arguments.1.type='Identifier'][arguments.1.name='undefined'])
message: Use notStrictEqual instead of notDeepStrictEqual for literals or undefined.
- selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.2.type='Literal']
message: Do not use a literal for the third argument of assert.deepStrictEqual()
- selector: CallExpression:matches([callee.name='doesNotThrow'], [callee.property.name='doesNotThrow'])
message: Do not use `assert.doesNotThrow()`. Write the code without the wrapper and add a comment instead.
- selector: CallExpression:matches([callee.name='doesNotReject'], [callee.property.name='doesNotReject'])
message: Do not use `assert.doesNotReject()`. Write the code without the wrapper and add a comment instead.
- selector: CallExpression:matches([callee.name='rejects'], [callee.property.name='rejects'])[arguments.length<2]
message: '`assert.rejects()` must be invoked with at least two arguments.'
- selector: CallExpression[callee.property.name='strictEqual'][arguments.2.type='Literal']
message: Do not use a literal for the third argument of assert.strictEqual()
- selector: CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.1.type='Literal']:not([arguments.1.regex])
message: Use an object as second argument of `assert.throws()`.
- selector: CallExpression:matches([callee.name='throws'], [callee.property.name='throws'])[arguments.length<2]
message: '`assert.throws()` must be invoked with at least two arguments.'
- selector: CallExpression[callee.name='setInterval'][arguments.length<2]
message: '`setInterval()` must be invoked with at least two arguments.'
- selector: ThrowStatement > CallExpression[callee.name=/Error$/]
message: Use `new` keyword when throwing an `Error`.
- selector: CallExpression:matches([callee.name='notDeepStrictEqual'], [callee.property.name='notDeepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression:matches([callee.name='notStrictEqual'], [callee.property.name='notStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression:matches([callee.name='deepStrictEqual'], [callee.property.name='deepStrictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression:matches([callee.name='strictEqual'], [callee.property.name='strictEqual'])[arguments.0.type='Literal']:not([arguments.1.type='Literal']):not([arguments.1.type='ObjectExpression']):not([arguments.1.type='ArrayExpression']):not([arguments.1.type='UnaryExpression'])
message: The first argument should be the `actual`, not the `expected` value.
- selector: CallExpression[callee.name='isNaN']
message: Use Number.isNaN() instead of the global isNaN() function.
- selector: VariableDeclarator > CallExpression:matches([callee.name='debuglog'], [callee.property.name='debuglog']):not([arguments.0.value='test'])
message: Use 'test' as debuglog value in tests.
- selector: CallExpression:matches([callee.object.name="common"][callee.property.name=/^mustCall/],[callee.name="mustCall"],[callee.name="mustCallAtLeast"])>:first-child[type=/FunctionExpression$/][body.body.length=0]
message: Do not use an empty function, omit the parameter altogether.
- selector: Identifier[name='webcrypto']
message: Use `globalThis.crypto`.
# Custom rules in tools/eslint-rules
node-core/prefer-assert-iferror: error
node-core/prefer-assert-methods: error
node-core/prefer-common-mustnotcall: error
node-core/prefer-common-mustsucceed: error
node-core/crypto-check: error
node-core/eslint-check: error
node-core/async-iife-no-unused-result: error
node-core/inspector-check: error
## common module is mandatory in tests
node-core/required-modules:
- error
- common: common(/index\.(m)?js)?$
node-core/require-common-first: error
node-core/no-duplicate-requires: off
# Global scoped methods and vars
globals:
WebAssembly: false
overrides:
- files:
- es-module/*.js
- es-module/*.mjs
- parallel/*.js
- parallel/*.mjs
- sequential/*.js
- sequential/*.mjs
rules:
comma-dangle: [error, {
arrays: always-multiline,
exports: always-multiline,
functions: only-multiline,
imports: always-multiline,
objects: only-multiline,
}]