summaryrefslogtreecommitdiff
path: root/lib/.eslintrc.yaml
blob: 2823b7aa0d1deffc4104499b88c0832edc185683 (plain)
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
env:
  es6: true

rules:
  prefer-object-spread: error
  no-buffer-constructor: error
  no-mixed-operators:
    - error
    - groups: [[ "&&", "||" ]]
  no-restricted-globals:
    - error
    - name: Array
      message: "Use `const { Array } = primordials;` instead of the global."
    - name: Boolean
      message: "Use `const { Boolean } = primordials;` instead of the global."
    - name: JSON
      message: "Use `const { JSON } = primordials;` instead of the global."
    - name: Math
      message: "Use `const { Math } = primordials;` instead of the global."
    - name: Number
      message: "Use `const { Number } = primordials;` instead of the global."
    - name: Object
      message: "Use `const { Object } = primordials;` instead of the global."
    - name: Reflect
      message: "Use `const { Reflect } = primordials;` instead of the global."
  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)$/])"
      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'."
  # Custom rules in tools/eslint-rules
  node-core/lowercase-name-for-primitive: error
  node-core/non-ascii-character: error
globals:
  Intl: false
  # Assertions
  CHECK: false
  CHECK_EQ: false
  CHECK_GE: false
  CHECK_GT: false
  CHECK_LE: false
  CHECK_LT: false
  CHECK_NE: false
  DCHECK: false
  DCHECK_EQ: false
  DCHECK_GE: false
  DCHECK_GT: false
  DCHECK_LE: false
  DCHECK_LT: false
  DCHECK_NE: false
  # Parameters passed to internal modules
  global: false
  require: false
  process: false
  exports: false
  module: false
  internalBinding: false
  primordials: false