-
Notifications
You must be signed in to change notification settings - Fork 29.8k
/
.eslintrc.yaml
237 lines (236 loc) Β· 11.5 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
env:
es6: true
rules:
prefer-object-spread: error
no-buffer-constructor: error
no-mixed-operators:
- error
- groups: [['&&', '||']]
no-restricted-syntax:
# Config copied from .eslintrc.js
- error
- selector: CallExpression[callee.object.name='assert']:not([callee.property.name='ok']):not([callee.property.name='fail']):not([callee.property.name='ifError'])
message: Please only use simple assertions in ./lib
- selector: CallExpression[callee.name='setTimeout'][arguments.length<2]
message: setTimeout() must be invoked with at least two arguments.
- selector: CallExpression[callee.name='setInterval'][arguments.length<2]
message: setInterval() must be invoked with at least 2 arguments.
- selector: ThrowStatement > CallExpression[callee.name=/Error$/]
message: Use new keyword when throwing an Error.
# Config specific to lib
- selector: NewExpression[callee.name=/Error$/]:not([callee.name=/^(AssertionError|NghttpError|AbortError)$/])
message: Use an error exported by the internal/errors module.
- selector: CallExpression[callee.object.name='Error'][callee.property.name='captureStackTrace']
message: Please use `require('internal/errors').hideStackFrames()` instead.
- selector: AssignmentExpression:matches([left.name='prepareStackTrace'], [left.property.name='prepareStackTrace'])
message: Use 'overrideStackTrace' from 'lib/internal/errors.js' instead of 'Error.prepareStackTrace'.
- selector: ThrowStatement > NewExpression[callee.name=/^ERR_[A-Z_]+$/] > ObjectExpression:first-child:not(:has([key.name='message']):has([key.name='code']):has([key.name='syscall']))
message: The context passed into SystemError constructor must have .code, .syscall and .message.
no-restricted-globals:
- error
- name: AbortController
message: Use `const { AbortController } = require('internal/abort_controller');` instead of the global.
- name: AbortSignal
message: Use `const { AbortSignal } = require('internal/abort_controller');` instead of the global.
# Atomics is not available in primordials because it can be
# disabled with --no-harmony-atomics CLI flag.
- name: Atomics
message: Use `const { Atomics } = globalThis;` instead of the global.
- name: Blob
message: Use `const { Blob } = require('buffer');` instead of the global.
- name: BroadcastChannel
message: Use `const { BroadcastChannel } = require('internal/worker/io');` instead of the global.
- name: Buffer
message: Use `const { Buffer } = require('buffer');` instead of the global.
- name: ByteLengthQueuingStrategy
message: Use `const { ByteLengthQueuingStrategy } = require('internal/webstreams/queuingstrategies')` instead of the global.
- name: CompressionStream
message: Use `const { CompressionStream } = require('internal/webstreams/compression')` instead of the global.
- name: CountQueuingStrategy
message: Use `const { CountQueuingStrategy } = require('internal/webstreams/queuingstrategies')` instead of the global.
- name: DecompressionStream
message: Use `const { DecompressionStream } = require('internal/webstreams/compression')` instead of the global.
- name: DOMException
message: Use lazy function `const { lazyDOMException } = require('internal/util');` instead of the global.
- name: Event
message: Use `const { Event } = require('internal/event_target');` instead of the global.
- name: EventTarget
message: Use `const { EventTarget } = require('internal/event_target');` instead of the global.
- name: FormData
message: Use `const { FormData } = require('internal/deps/undici/undici');` instead of the global.
- name: Headers
message: Use `const { Headers } = require('internal/deps/undici/undici');` instead of the global.
# Intl is not available in primordials because it can be
# disabled with --without-intl build flag.
- name: Intl
message: Use `const { Intl } = globalThis;` instead of the global.
- name: MessageChannel
message: Use `const { MessageChannel } = require('internal/worker/io');` instead of the global.
- name: MessageEvent
message: Use `const { MessageEvent } = require('internal/worker/io');` instead of the global.
- name: MessagePort
message: Use `const { MessagePort } = require('internal/worker/io');` instead of the global.
- name: ReadableStream
message: Use `const { ReadableStream } = require('internal/webstreams/readablestream')` instead of the global.
- name: ReadableStreamDefaultReader
message: Use `const { ReadableStreamDefaultReader } = require('internal/webstreams/readablestream')` instead of the global.
- name: ReadableStreamBYOBReader
message: Use `const { ReadableStreamBYOBReader } = require('internal/webstreams/readablestream')` instead of the global.
- name: ReadableStreamBYOBRequest
message: Use `const { ReadableStreamBYOBRequest } = require('internal/webstreams/readablestream')` instead of the global.
- name: ReadableByteStreamController
message: Use `const { ReadableByteStreamController } = require('internal/webstreams/readablestream')` instead of the global.
- name: ReadableStreamDefaultController
message: Use `const { ReadableStreamDefaultController } = require('internal/webstreams/readablestream')` instead of the global.
- name: Request
message: Use `const { Request } = require('internal/deps/undici/undici');` instead of the global.
- name: Response
message: Use `const { Response } = require('internal/deps/undici/undici');` instead of the global.
# SharedArrayBuffer is not available in primordials because it can be
# disabled with --no-harmony-sharedarraybuffer CLI flag.
- name: SharedArrayBuffer
message: Use `const { SharedArrayBuffer } = globalThis;` instead of the global.
- name: TextDecoder
message: Use `const { TextDecoder } = require('internal/encoding');` instead of the global.
- name: TextDecoderStream
message: Use `const { TextDecoderStream } = require('internal/webstreams/encoding')` instead of the global.
- name: TextEncoder
message: Use `const { TextEncoder } = require('internal/encoding');` instead of the global.
- name: TextEncoderStream
message: Use `const { TextEncoderStream } = require('internal/webstreams/encoding')` instead of the global.
- name: TransformStream
message: Use `const { TransformStream } = require('internal/webstreams/transformstream')` instead of the global.
- name: TransformStreamDefaultController
message: Use `const { TransformStreamDefaultController } = require('internal/webstreams/transformstream')` instead of the global.
- name: URL
message: Use `const { URL } = require('internal/url');` instead of the global.
- name: URLSearchParams
message: Use `const { URLSearchParams } = require('internal/url');` instead of the global.
# WebAssembly is not available in primordials because it can be
# disabled with --jitless CLI flag.
- name: WebAssembly
message: Use `const { WebAssembly } = globalThis;` instead of the global.
- name: WritableStream
message: Use `const { WritableStream } = require('internal/webstreams/writablestream')` instead of the global.
- name: WritableStreamDefaultWriter
message: Use `const { WritableStreamDefaultWriter } = require('internal/webstreams/writablestream')` instead of the global.
- name: WritableStreamDefaultController
message: Use `const { WritableStreamDefaultController } = require('internal/webstreams/writablestream')` instead of the global.
- name: atob
message: Use `const { atob } = require('buffer');` instead of the global.
- name: btoa
message: Use `const { btoa } = require('buffer');` instead of the global.
- name: clearImmediate
message: Use `const { clearImmediate } = require('timers');` instead of the global.
- name: clearInterval
message: Use `const { clearInterval } = require('timers');` instead of the global.
- name: clearTimeout
message: Use `const { clearTimeout } = require('timers');` instead of the global.
- name: console
message: Use `const { console } = require('internal/console/global');` instead of the global.
- name: crypto
message: Use `const { crypto } = require('internal/crypto/webcrypto');` instead of the global.
- name: Crypto
message: Use `const { Crypto } = require('internal/crypto/webcrypto');` instead of the global.
- name: CryptoKey
message: Use `const { CryptoKey } = require('internal/crypto/webcrypto');` instead of the global.
- name: fetch
message: Use `const { fetch } = require('internal/deps/undici/undici');` instead of the global.
- name: global
message: Use `const { globalThis } = primordials;` instead of `global`.
- name: globalThis
message: Use `const { globalThis } = primordials;` instead of the global.
- name: performance
message: Use `const { performance } = require('perf_hooks');` instead of the global.
- name: queueMicrotask
message: Use `const { queueMicrotask } = require('internal/process/task_queues');` instead of the global.
- name: setImmediate
message: Use `const { setImmediate } = require('timers');` instead of the global.
- name: setInterval
message: Use `const { setInterval } = require('timers');` instead of the global.
- name: setTimeout
message: Use `const { setTimeout } = require('timers');` instead of the global.
- name: structuredClone
message: Use `const { structuredClone } = require('internal/structured_clone');` instead of the global.
- name: SubtleCrypto
message: Use `const { SubtleCrypto } = require('internal/crypto/webcrypto');` instead of the global.
# Custom rules in tools/eslint-rules
node-core/lowercase-name-for-primitive: error
node-core/non-ascii-character: error
node-core/no-array-destructuring: error
node-core/prefer-primordials:
- error
- name: AggregateError
- name: Array
- name: ArrayBuffer
- name: BigInt
- name: BigInt64Array
- name: BigUint64Array
- name: Boolean
- name: DataView
- name: Date
- name: decodeURI
- name: decodeURIComponent
- name: encodeURI
- name: encodeURIComponent
- name: escape
- name: eval
- name: Error
ignore:
- prepareStackTrace
- stackTraceLimit
- name: EvalError
- name: FinalizationRegistry
into: Safe
- name: Float32Array
- name: Float64Array
- name: Function
- name: Int16Array
- name: Int32Array
- name: Int8Array
- name: isFinite
into: Number
- name: isNaN
into: Number
- name: JSON
- name: Map
into: Safe
- name: Math
- name: Number
- name: Object
- name: parseFloat
into: Number
- name: parseInt
into: Number
- name: Proxy
- name: Promise
- name: RangeError
- name: ReferenceError
- name: Reflect
- name: RegExp
- name: Set
into: Safe
- name: String
- name: Symbol
- name: SyntaxError
- name: TypeError
- name: Uint16Array
- name: Uint32Array
- name: Uint8Array
- name: Uint8ClampedArray
- name: unescape
- name: URIError
- name: WeakMap
into: Safe
- name: WeakRef
into: Safe
- name: WeakSet
into: Safe
globals:
# Parameters passed to internal modules
require: false
process: false
exports: false
module: false
internalBinding: false
primordials: false