node/lib/.eslintrc.yaml

161 lines
6.2 KiB
YAML

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'."
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: Buffer
message: "Use `const { Buffer } = require('buffer');` 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."
# 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."
# 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: TextEncoder
message: "Use `const { TextEncoder } = require('internal/encoding');` 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: atob
message: "Use `const { atob } = require('buffer');` instead of the global."
- name: btoa
message: "Use `const { btoa } = require('buffer');` 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."
# 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: 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: URIError
- name: WeakMap
into: Safe
- name: WeakRef
into: Safe
- name: WeakSet
into: Safe
globals:
Intl: false
# Parameters passed to internal modules
global: false
require: false
process: false
exports: false
module: false
internalBinding: false
primordials: false