eslint 5.13.0 → 5.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +68 -156
  3. package/lib/built-in-rules-index.js +1 -0
  4. package/lib/cli-engine.js +5 -2
  5. package/lib/config/config-file.js +27 -4
  6. package/lib/config/config-initializer.js +151 -144
  7. package/lib/config/config-ops.js +2 -0
  8. package/lib/config/config-validator.js +1 -1
  9. package/lib/config/plugins.js +1 -1
  10. package/lib/formatters/codeframe.js +1 -1
  11. package/lib/formatters/stylish.js +2 -2
  12. package/lib/linter.js +7 -4
  13. package/lib/rules/accessor-pairs.js +4 -2
  14. package/lib/rules/array-callback-return.js +4 -3
  15. package/lib/rules/arrow-body-style.js +1 -1
  16. package/lib/rules/arrow-parens.js +2 -1
  17. package/lib/rules/arrow-spacing.js +7 -6
  18. package/lib/rules/brace-style.js +2 -1
  19. package/lib/rules/camelcase.js +5 -4
  20. package/lib/rules/capitalized-comments.js +10 -14
  21. package/lib/rules/class-methods-use-this.js +1 -1
  22. package/lib/rules/comma-spacing.js +10 -4
  23. package/lib/rules/complexity.js +6 -7
  24. package/lib/rules/consistent-return.js +2 -1
  25. package/lib/rules/curly.js +1 -1
  26. package/lib/rules/default-case.js +2 -2
  27. package/lib/rules/dot-notation.js +7 -5
  28. package/lib/rules/eol-last.js +1 -1
  29. package/lib/rules/func-call-spacing.js +2 -2
  30. package/lib/rules/func-style.js +3 -2
  31. package/lib/rules/getter-return.js +3 -2
  32. package/lib/rules/handle-callback-err.js +1 -1
  33. package/lib/rules/id-length.js +3 -2
  34. package/lib/rules/id-match.js +7 -4
  35. package/lib/rules/indent-legacy.js +1 -1
  36. package/lib/rules/indent.js +9 -6
  37. package/lib/rules/jsx-quotes.js +2 -2
  38. package/lib/rules/key-spacing.js +1 -1
  39. package/lib/rules/keyword-spacing.js +14 -14
  40. package/lib/rules/line-comment-position.js +5 -4
  41. package/lib/rules/lines-around-comment.js +14 -14
  42. package/lib/rules/lines-between-class-members.js +2 -1
  43. package/lib/rules/max-depth.js +5 -5
  44. package/lib/rules/max-len.js +21 -14
  45. package/lib/rules/max-lines-per-function.js +13 -17
  46. package/lib/rules/max-lines.js +3 -5
  47. package/lib/rules/max-nested-callbacks.js +6 -7
  48. package/lib/rules/max-params.js +5 -5
  49. package/lib/rules/max-statements-per-line.js +3 -2
  50. package/lib/rules/max-statements.js +6 -7
  51. package/lib/rules/multiline-comment-style.js +9 -9
  52. package/lib/rules/new-cap.js +9 -6
  53. package/lib/rules/newline-per-chained-call.js +2 -1
  54. package/lib/rules/no-alert.js +1 -1
  55. package/lib/rules/no-bitwise.js +2 -1
  56. package/lib/rules/no-caller.js +1 -1
  57. package/lib/rules/no-confusing-arrow.js +1 -1
  58. package/lib/rules/no-constant-condition.js +2 -1
  59. package/lib/rules/no-dupe-keys.js +2 -2
  60. package/lib/rules/no-duplicate-imports.js +2 -1
  61. package/lib/rules/no-else-return.js +4 -3
  62. package/lib/rules/no-empty-character-class.js +1 -1
  63. package/lib/rules/no-empty.js +2 -1
  64. package/lib/rules/no-eval.js +1 -1
  65. package/lib/rules/no-extra-parens.js +7 -1
  66. package/lib/rules/no-fallthrough.js +4 -3
  67. package/lib/rules/no-implicit-coercion.js +10 -7
  68. package/lib/rules/no-implied-eval.js +1 -1
  69. package/lib/rules/no-invalid-regexp.js +2 -2
  70. package/lib/rules/no-irregular-whitespace.js +11 -7
  71. package/lib/rules/no-labels.js +6 -4
  72. package/lib/rules/no-lonely-if.js +1 -1
  73. package/lib/rules/no-magic-numbers.js +6 -3
  74. package/lib/rules/no-mixed-operators.js +6 -5
  75. package/lib/rules/no-mixed-requires.js +1 -1
  76. package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
  77. package/lib/rules/no-multi-spaces.js +2 -1
  78. package/lib/rules/no-octal-escape.js +1 -1
  79. package/lib/rules/no-octal.js +1 -1
  80. package/lib/rules/no-param-reassign.js +2 -2
  81. package/lib/rules/no-path-concat.js +1 -1
  82. package/lib/rules/no-plusplus.js +2 -1
  83. package/lib/rules/no-redeclare.js +2 -2
  84. package/lib/rules/no-regex-spaces.js +1 -1
  85. package/lib/rules/no-return-assign.js +1 -1
  86. package/lib/rules/no-self-assign.js +3 -2
  87. package/lib/rules/no-shadow-restricted-names.js +16 -2
  88. package/lib/rules/no-shadow.js +3 -3
  89. package/lib/rules/no-sync.js +2 -1
  90. package/lib/rules/no-tabs.js +4 -3
  91. package/lib/rules/no-template-curly-in-string.js +1 -1
  92. package/lib/rules/no-trailing-spaces.js +7 -5
  93. package/lib/rules/no-undef.js +2 -1
  94. package/lib/rules/no-underscore-dangle.js +6 -3
  95. package/lib/rules/no-unexpected-multiline.js +1 -1
  96. package/lib/rules/no-unmodified-loop-condition.js +5 -5
  97. package/lib/rules/no-unneeded-ternary.js +2 -1
  98. package/lib/rules/no-unsafe-finally.js +3 -3
  99. package/lib/rules/no-unused-expressions.js +8 -5
  100. package/lib/rules/no-unused-vars.js +6 -6
  101. package/lib/rules/no-use-before-define.js +2 -2
  102. package/lib/rules/no-useless-escape.js +1 -1
  103. package/lib/rules/no-useless-rename.js +3 -3
  104. package/lib/rules/no-var.js +1 -1
  105. package/lib/rules/no-warning-comments.js +6 -6
  106. package/lib/rules/object-property-newline.js +5 -3
  107. package/lib/rules/one-var.js +18 -35
  108. package/lib/rules/padded-blocks.js +32 -9
  109. package/lib/rules/padding-line-between-statements.js +4 -3
  110. package/lib/rules/prefer-arrow-callback.js +4 -2
  111. package/lib/rules/prefer-const.js +5 -5
  112. package/lib/rules/prefer-destructuring.js +56 -5
  113. package/lib/rules/prefer-named-capture-group.js +123 -0
  114. package/lib/rules/prefer-object-spread.js +1 -1
  115. package/lib/rules/prefer-promise-reject-errors.js +1 -1
  116. package/lib/rules/prefer-spread.js +2 -13
  117. package/lib/rules/prefer-template.js +3 -3
  118. package/lib/rules/quotes.js +2 -2
  119. package/lib/rules/require-jsdoc.js +13 -7
  120. package/lib/rules/semi-spacing.js +6 -8
  121. package/lib/rules/semi.js +4 -4
  122. package/lib/rules/sort-imports.js +6 -3
  123. package/lib/rules/sort-keys.js +13 -5
  124. package/lib/rules/sort-vars.js +2 -1
  125. package/lib/rules/space-infix-ops.js +2 -1
  126. package/lib/rules/space-unary-ops.js +5 -3
  127. package/lib/rules/spaced-comment.js +6 -5
  128. package/lib/rules/switch-colon-spacing.js +2 -2
  129. package/lib/rules/template-curly-spacing.js +2 -2
  130. package/lib/rules/use-isnan.js +1 -1
  131. package/lib/rules/valid-jsdoc.js +12 -7
  132. package/lib/rules/valid-typeof.js +2 -1
  133. package/lib/rules/vars-on-top.js +1 -1
  134. package/lib/rules/wrap-iife.js +3 -2
  135. package/lib/rules/yoda.js +6 -4
  136. package/lib/util/ajv.js +1 -0
  137. package/lib/util/ast-utils.js +12 -12
  138. package/lib/util/config-comment-parser.js +4 -4
  139. package/lib/util/glob-utils.js +3 -3
  140. package/lib/util/ignored-paths.js +4 -4
  141. package/lib/util/interpolate.js +1 -1
  142. package/lib/util/naming.js +6 -6
  143. package/lib/util/node-event-generator.js +1 -1
  144. package/lib/util/path-utils.js +2 -2
  145. package/lib/util/patterns/letters.js +1 -1
  146. package/lib/util/source-code.js +2 -2
  147. package/lib/util/xml-escape.js +1 -1
  148. package/package.json +25 -23
@@ -23,22 +23,28 @@ module.exports = {
23
23
  type: "object",
24
24
  properties: {
25
25
  ClassDeclaration: {
26
- type: "boolean"
26
+ type: "boolean",
27
+ default: false
27
28
  },
28
29
  MethodDefinition: {
29
- type: "boolean"
30
+ type: "boolean",
31
+ default: false
30
32
  },
31
33
  FunctionDeclaration: {
32
- type: "boolean"
34
+ type: "boolean",
35
+ default: true
33
36
  },
34
37
  ArrowFunctionExpression: {
35
- type: "boolean"
38
+ type: "boolean",
39
+ default: false
36
40
  },
37
41
  FunctionExpression: {
38
- type: "boolean"
42
+ type: "boolean",
43
+ default: false
39
44
  }
40
45
  },
41
- additionalProperties: false
46
+ additionalProperties: false,
47
+ default: {}
42
48
  }
43
49
  },
44
50
  additionalProperties: false
@@ -58,7 +64,7 @@ module.exports = {
58
64
  ArrowFunctionExpression: false,
59
65
  FunctionExpression: false
60
66
  };
61
- const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require || {});
67
+ const options = Object.assign(DEFAULT_OPTIONS, context.options[0] && context.options[0].require);
62
68
 
63
69
  /**
64
70
  * Report the error message
@@ -29,10 +29,12 @@ module.exports = {
29
29
  type: "object",
30
30
  properties: {
31
31
  before: {
32
- type: "boolean"
32
+ type: "boolean",
33
+ default: false
33
34
  },
34
35
  after: {
35
- type: "boolean"
36
+ type: "boolean",
37
+ default: true
36
38
  }
37
39
  },
38
40
  additionalProperties: false
@@ -48,12 +50,8 @@ module.exports = {
48
50
  requireSpaceAfter = true;
49
51
 
50
52
  if (typeof config === "object") {
51
- if (Object.prototype.hasOwnProperty.call(config, "before")) {
52
- requireSpaceBefore = config.before;
53
- }
54
- if (Object.prototype.hasOwnProperty.call(config, "after")) {
55
- requireSpaceAfter = config.after;
56
- }
53
+ requireSpaceBefore = config.before;
54
+ requireSpaceAfter = config.after;
57
55
  }
58
56
 
59
57
  /**
package/lib/rules/semi.js CHANGED
@@ -72,11 +72,11 @@ module.exports = {
72
72
 
73
73
  create(context) {
74
74
 
75
- const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-`
75
+ const OPT_OUT_PATTERN = /^[-[(/+`]/u; // One of [(/+-`
76
76
  const options = context.options[1];
77
77
  const never = context.options[0] === "never";
78
78
  const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock);
79
- const beforeStatementContinuationChars = (options && options.beforeStatementContinuationChars) || "any";
79
+ const beforeStatementContinuationChars = options && options.beforeStatementContinuationChars || "any";
80
80
  const sourceCode = context.getSourceCode();
81
81
 
82
82
  //--------------------------------------------------------------------------
@@ -291,7 +291,7 @@ module.exports = {
291
291
  const parent = node.parent;
292
292
 
293
293
  if ((parent.type !== "ForStatement" || parent.init !== node) &&
294
- (!/^For(?:In|Of)Statement/.test(parent.type) || parent.left !== node)
294
+ (!/^For(?:In|Of)Statement/u.test(parent.type) || parent.left !== node)
295
295
  ) {
296
296
  checkForSemicolon(node);
297
297
  }
@@ -318,7 +318,7 @@ module.exports = {
318
318
  }
319
319
  },
320
320
  ExportDefaultDeclaration(node) {
321
- if (!/(?:Class|Function)Declaration/.test(node.declaration.type)) {
321
+ if (!/(?:Class|Function)Declaration/u.test(node.declaration.type)) {
322
322
  checkForSemicolon(node);
323
323
  }
324
324
  }
@@ -25,7 +25,8 @@ module.exports = {
25
25
  type: "object",
26
26
  properties: {
27
27
  ignoreCase: {
28
- type: "boolean"
28
+ type: "boolean",
29
+ default: false
29
30
  },
30
31
  memberSyntaxSortOrder: {
31
32
  type: "array",
@@ -37,10 +38,12 @@ module.exports = {
37
38
  maxItems: 4
38
39
  },
39
40
  ignoreDeclarationSort: {
40
- type: "boolean"
41
+ type: "boolean",
42
+ default: false
41
43
  },
42
44
  ignoreMemberSort: {
43
- type: "boolean"
45
+ type: "boolean",
46
+ default: false
44
47
  }
45
48
  },
46
49
  additionalProperties: false
@@ -90,10 +90,12 @@ module.exports = {
90
90
  type: "object",
91
91
  properties: {
92
92
  caseSensitive: {
93
- type: "boolean"
93
+ type: "boolean",
94
+ default: true
94
95
  },
95
96
  natural: {
96
- type: "boolean"
97
+ type: "boolean",
98
+ default: false
97
99
  }
98
100
  },
99
101
  additionalProperties: false
@@ -106,8 +108,8 @@ module.exports = {
106
108
  // Parse options.
107
109
  const order = context.options[0] || "asc";
108
110
  const options = context.options[1];
109
- const insensitive = (options && options.caseSensitive) === false;
110
- const natual = Boolean(options && options.natural);
111
+ const insensitive = options && options.caseSensitive === false;
112
+ const natual = options && options.natural;
111
113
  const isValidOrder = isValidOrders[
112
114
  order + (insensitive ? "I" : "") + (natual ? "N" : "")
113
115
  ];
@@ -127,8 +129,14 @@ module.exports = {
127
129
  stack = stack.upper;
128
130
  },
129
131
 
132
+ SpreadElement(node) {
133
+ if (node.parent.type === "ObjectExpression") {
134
+ stack.prevName = null;
135
+ }
136
+ },
137
+
130
138
  Property(node) {
131
- if (node.parent.type === "ObjectPattern" || node.parent.properties.some(n => n.type === "SpreadElement")) {
139
+ if (node.parent.type === "ObjectPattern") {
132
140
  return;
133
141
  }
134
142
 
@@ -25,7 +25,8 @@ module.exports = {
25
25
  type: "object",
26
26
  properties: {
27
27
  ignoreCase: {
28
- type: "boolean"
28
+ type: "boolean",
29
+ default: false
29
30
  }
30
31
  },
31
32
  additionalProperties: false
@@ -26,7 +26,8 @@ module.exports = {
26
26
  type: "object",
27
27
  properties: {
28
28
  int32Hint: {
29
- type: "boolean"
29
+ type: "boolean",
30
+ default: false
30
31
  }
31
32
  },
32
33
  additionalProperties: false
@@ -32,10 +32,12 @@ module.exports = {
32
32
  type: "object",
33
33
  properties: {
34
34
  words: {
35
- type: "boolean"
35
+ type: "boolean",
36
+ default: true
36
37
  },
37
38
  nonwords: {
38
- type: "boolean"
39
+ type: "boolean",
40
+ default: false
39
41
  },
40
42
  overrides: {
41
43
  type: "object",
@@ -58,7 +60,7 @@ module.exports = {
58
60
  },
59
61
 
60
62
  create(context) {
61
- const options = context.options && Array.isArray(context.options) && context.options[0] || { words: true, nonwords: false };
63
+ const options = context.options[0] || { words: true, nonwords: false };
62
64
 
63
65
  const sourceCode = context.getSourceCode();
64
66
 
@@ -126,7 +126,7 @@ function createAlwaysStylePattern(markers, exceptions) {
126
126
  pattern += "?"; // or nothing.
127
127
  pattern += createExceptionsPattern(exceptions);
128
128
 
129
- return new RegExp(pattern);
129
+ return new RegExp(pattern); // eslint-disable-line require-unicode-regexp
130
130
  }
131
131
 
132
132
  /**
@@ -142,7 +142,7 @@ function createAlwaysStylePattern(markers, exceptions) {
142
142
  function createNeverStylePattern(markers) {
143
143
  const pattern = `^(${markers.map(escape).join("|")})?[ \t]+`;
144
144
 
145
- return new RegExp(pattern);
145
+ return new RegExp(pattern); // eslint-disable-line require-unicode-regexp
146
146
  }
147
147
 
148
148
  //------------------------------------------------------------------------------
@@ -215,7 +215,8 @@ module.exports = {
215
215
  }
216
216
  },
217
217
  balanced: {
218
- type: "boolean"
218
+ type: "boolean",
219
+ default: false
219
220
  }
220
221
  },
221
222
  additionalProperties: false
@@ -249,9 +250,9 @@ module.exports = {
249
250
  // Create RegExp object for valid patterns.
250
251
  rule[type] = {
251
252
  beginRegex: requireSpace ? createAlwaysStylePattern(markers, exceptions) : createNeverStylePattern(markers),
252
- endRegex: balanced && requireSpace ? new RegExp(`${createExceptionsPattern(exceptions)}$`) : new RegExp(endNeverPattern),
253
+ endRegex: balanced && requireSpace ? new RegExp(`${createExceptionsPattern(exceptions)}$`) : new RegExp(endNeverPattern), // eslint-disable-line require-unicode-regexp
253
254
  hasExceptions: exceptions.length > 0,
254
- markers: new RegExp(`^(${markers.map(escape).join("|")})`)
255
+ markers: new RegExp(`^(${markers.map(escape).join("|")})`) // eslint-disable-line require-unicode-regexp
255
256
  };
256
257
 
257
258
  return rule;
@@ -30,8 +30,8 @@ module.exports = {
30
30
  {
31
31
  type: "object",
32
32
  properties: {
33
- before: { type: "boolean" },
34
- after: { type: "boolean" }
33
+ before: { type: "boolean", default: false },
34
+ after: { type: "boolean", default: true }
35
35
  },
36
36
  additionalProperties: false
37
37
  }
@@ -15,8 +15,8 @@ const astUtils = require("../util/ast-utils");
15
15
  // Helpers
16
16
  //------------------------------------------------------------------------------
17
17
 
18
- const OPEN_PAREN = /\$\{$/;
19
- const CLOSE_PAREN = /^\}/;
18
+ const OPEN_PAREN = /\$\{$/u;
19
+ const CLOSE_PAREN = /^\}/u;
20
20
 
21
21
  //------------------------------------------------------------------------------
22
22
  // Rule Definition
@@ -30,7 +30,7 @@ module.exports = {
30
30
 
31
31
  return {
32
32
  BinaryExpression(node) {
33
- if (/^(?:[<>]|[!=]=)=?$/.test(node.operator) && (node.left.name === "NaN" || node.right.name === "NaN")) {
33
+ if (/^(?:[<>]|[!=]=)=?$/u.test(node.operator) && (node.left.name === "NaN" || node.right.name === "NaN")) {
34
34
  context.report({ node, messageId: "useIsNaN" });
35
35
  }
36
36
  }
@@ -42,22 +42,27 @@ module.exports = {
42
42
  }
43
43
  },
44
44
  requireReturn: {
45
- type: "boolean"
45
+ type: "boolean",
46
+ default: true
46
47
  },
47
48
  requireParamDescription: {
48
- type: "boolean"
49
+ type: "boolean",
50
+ default: true
49
51
  },
50
52
  requireReturnDescription: {
51
- type: "boolean"
53
+ type: "boolean",
54
+ default: true
52
55
  },
53
56
  matchDescription: {
54
57
  type: "string"
55
58
  },
56
59
  requireReturnType: {
57
- type: "boolean"
60
+ type: "boolean",
61
+ default: true
58
62
  },
59
63
  requireParamType: {
60
- type: "boolean"
64
+ type: "boolean",
65
+ default: true
61
66
  }
62
67
  },
63
68
  additionalProperties: false
@@ -295,7 +300,7 @@ module.exports = {
295
300
  });
296
301
  } catch (ex) {
297
302
 
298
- if (/braces/i.test(ex.message)) {
303
+ if (/braces/iu.test(ex.message)) {
299
304
  context.report({ node: jsdocNode, messageId: "missingBrace" });
300
305
  } else {
301
306
  context.report({ node: jsdocNode, messageId: "syntaxError" });
@@ -477,7 +482,7 @@ module.exports = {
477
482
  }
478
483
 
479
484
  if (options.matchDescription) {
480
- const regex = new RegExp(options.matchDescription);
485
+ const regex = new RegExp(options.matchDescription); // eslint-disable-line require-unicode-regexp
481
486
 
482
487
  if (!regex.test(jsdoc.description)) {
483
488
  context.report({ node: jsdocNode, messageId: "unsatisfiedDesc" });
@@ -24,7 +24,8 @@ module.exports = {
24
24
  type: "object",
25
25
  properties: {
26
26
  requireStringLiterals: {
27
- type: "boolean"
27
+ type: "boolean",
28
+ default: false
28
29
  }
29
30
  },
30
31
  additionalProperties: false
@@ -117,7 +117,7 @@ module.exports = {
117
117
  * @returns {void}
118
118
  */
119
119
  function blockScopeVarCheck(node, parent, grandParent) {
120
- if (!(/Function/.test(grandParent.type) &&
120
+ if (!(/Function/u.test(grandParent.type) &&
121
121
  parent.type === "BlockStatement" &&
122
122
  isVarOnTop(node, parent.body))) {
123
123
  context.report({ node, messageId: "top" });
@@ -34,7 +34,8 @@ module.exports = {
34
34
  type: "object",
35
35
  properties: {
36
36
  functionPrototypeMethods: {
37
- type: "boolean"
37
+ type: "boolean",
38
+ default: false
38
39
  }
39
40
  },
40
41
  additionalProperties: false
@@ -52,7 +53,7 @@ module.exports = {
52
53
  create(context) {
53
54
 
54
55
  const style = context.options[0] || "outside";
55
- const includeFunctionPrototypeMethods = (context.options[1] && context.options[1].functionPrototypeMethods) || false;
56
+ const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
56
57
 
57
58
  const sourceCode = context.getSourceCode();
58
59
 
package/lib/rules/yoda.js CHANGED
@@ -20,7 +20,7 @@ const astUtils = require("../util/ast-utils");
20
20
  * @returns {boolean} Whether or not it is a comparison operator.
21
21
  */
22
22
  function isComparisonOperator(operator) {
23
- return (/^(==|===|!=|!==|<|>|<=|>=)$/).test(operator);
23
+ return (/^(==|===|!=|!==|<|>|<=|>=)$/u).test(operator);
24
24
  }
25
25
 
26
26
  /**
@@ -29,7 +29,7 @@ function isComparisonOperator(operator) {
29
29
  * @returns {boolean} Whether or not it is an equality operator.
30
30
  */
31
31
  function isEqualityOperator(operator) {
32
- return (/^(==|===)$/).test(operator);
32
+ return (/^(==|===)$/u).test(operator);
33
33
  }
34
34
 
35
35
  /**
@@ -169,10 +169,12 @@ module.exports = {
169
169
  type: "object",
170
170
  properties: {
171
171
  exceptRange: {
172
- type: "boolean"
172
+ type: "boolean",
173
+ default: false
173
174
  },
174
175
  onlyEquality: {
175
- type: "boolean"
176
+ type: "boolean",
177
+ default: false
176
178
  }
177
179
  },
178
180
  additionalProperties: false
package/lib/util/ajv.js CHANGED
@@ -17,6 +17,7 @@ const Ajv = require("ajv"),
17
17
 
18
18
  const ajv = new Ajv({
19
19
  meta: false,
20
+ useDefaults: true,
20
21
  validateSchema: false,
21
22
  missingRefs: "ignore",
22
23
  verbose: true,
@@ -16,19 +16,19 @@ const espree = require("espree");
16
16
  // Helpers
17
17
  //------------------------------------------------------------------------------
18
18
 
19
- const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/;
20
- const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/;
21
- const arrayOrTypedArrayPattern = /Array$/;
22
- const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/;
23
- const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/;
24
- const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/;
25
- const thisTagPattern = /^[\s*]*@this/m;
19
+ const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
20
+ const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u;
21
+ const arrayOrTypedArrayPattern = /Array$/u;
22
+ const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/u;
23
+ const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u;
24
+ const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/u;
25
+ const thisTagPattern = /^[\s*]*@this/mu;
26
26
 
27
27
 
28
- const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/;
28
+ const COMMENTS_IGNORE_PATTERN = /^\s*(?:eslint|jshint\s+|jslint\s+|istanbul\s+|globals?\s+|exported\s+|jscs)/u;
29
29
  const LINEBREAKS = new Set(["\r\n", "\r", "\n", "\u2028", "\u2029"]);
30
- const LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/;
31
- const SHEBANG_MATCHER = /^#!([^\r\n]+)/;
30
+ const LINEBREAK_MATCHER = /\r\n|[\r\n\u2028\u2029]/u;
31
+ const SHEBANG_MATCHER = /^#!([^\r\n]+)/u;
32
32
 
33
33
  // A set of node types that can contain a list of statements
34
34
  const STATEMENT_LIST_PARENTS = new Set(["Program", "BlockStatement", "SwitchCase"]);
@@ -398,7 +398,7 @@ function getOpeningParenOfParams(node, sourceCode) {
398
398
  * @returns {RegExp} A global regular expression that matches line terminators
399
399
  */
400
400
  function createGlobalLinebreakMatcher() {
401
- return new RegExp(LINEBREAK_MATCHER.source, "g");
401
+ return new RegExp(LINEBREAK_MATCHER.source, "gu");
402
402
  }
403
403
 
404
404
  /**
@@ -1006,7 +1006,7 @@ module.exports = {
1006
1006
  * '5' // false
1007
1007
  */
1008
1008
  isDecimalInteger(node) {
1009
- return node.type === "Literal" && typeof node.value === "number" && /^(0|[1-9]\d*)$/.test(node.raw);
1009
+ return node.type === "Literal" && typeof node.value === "number" && /^(0|[1-9]\d*)$/u.test(node.raw);
1010
1010
  },
1011
1011
 
1012
1012
  /**
@@ -38,9 +38,9 @@ module.exports = class ConfigCommentParser {
38
38
  const items = {};
39
39
 
40
40
  // Collapse whitespace around `:` and `,` to make parsing easier
41
- const trimmedString = string.replace(/\s*([:,])\s*/g, "$1");
41
+ const trimmedString = string.replace(/\s*([:,])\s*/gu, "$1");
42
42
 
43
- trimmedString.split(/\s|,+/).forEach(name => {
43
+ trimmedString.split(/\s|,+/u).forEach(name => {
44
44
  if (!name) {
45
45
  return;
46
46
  }
@@ -90,7 +90,7 @@ module.exports = class ConfigCommentParser {
90
90
  * But we are supporting that. So this is a fallback for that.
91
91
  */
92
92
  items = {};
93
- const normalizedString = string.replace(/([a-zA-Z0-9\-/]+):/g, "\"$1\":").replace(/(]|[0-9])\s+(?=")/, "$1,");
93
+ const normalizedString = string.replace(/([a-zA-Z0-9\-/]+):/gu, "\"$1\":").replace(/(\]|[0-9])\s+(?=")/u, "$1,");
94
94
 
95
95
  try {
96
96
  items = JSON.parse(`{${normalizedString}}`);
@@ -128,7 +128,7 @@ module.exports = class ConfigCommentParser {
128
128
  const items = {};
129
129
 
130
130
  // Collapse whitespace around commas
131
- string.replace(/\s*,\s*/g, ",").split(/,+/).forEach(name => {
131
+ string.replace(/\s*,\s*/gu, ",").split(/,+/u).forEach(name => {
132
132
  const trimmedName = name.trim();
133
133
 
134
134
  if (trimmedName) {
@@ -52,7 +52,7 @@ function processPath(options) {
52
52
  const cwd = (options && options.cwd) || process.cwd();
53
53
  let extensions = (options && options.extensions) || [".js"];
54
54
 
55
- extensions = extensions.map(ext => ext.replace(/^\./, ""));
55
+ extensions = extensions.map(ext => ext.replace(/^\./u, ""));
56
56
 
57
57
  let suffix = "/**";
58
58
 
@@ -74,7 +74,7 @@ function processPath(options) {
74
74
  const resolvedPath = path.resolve(cwd, pathname);
75
75
 
76
76
  if (directoryExists(resolvedPath)) {
77
- newPath = pathname.replace(/[/\\]$/, "") + suffix;
77
+ newPath = pathname.replace(/[/\\]$/u, "") + suffix;
78
78
  }
79
79
 
80
80
  return pathUtils.convertPathToPosix(newPath);
@@ -169,7 +169,7 @@ function resolveFileGlobPatterns(patterns, options) {
169
169
  return patterns.map(processPathExtensions);
170
170
  }
171
171
 
172
- const dotfilesPattern = /(?:(?:^\.)|(?:[/\\]\.))[^/\\.].*/;
172
+ const dotfilesPattern = /(?:(?:^\.)|(?:[/\\]\.))[^/\\.].*/u;
173
173
 
174
174
  /**
175
175
  * Build a list of absolute filesnames on which ESLint will act.
@@ -89,7 +89,7 @@ function mergeDefaultOptions(options) {
89
89
  */
90
90
  const normalizePathSeps = path.sep === "/"
91
91
  ? (str => str)
92
- : ((seps, str) => str.replace(seps, "/")).bind(null, new RegExp(`\\${path.sep}`, "g"));
92
+ : ((seps, str) => str.replace(seps, "/")).bind(null, new RegExp(`\\${path.sep}`, "gu"));
93
93
  /* eslint-enable valid-jsdoc */
94
94
 
95
95
  /**
@@ -104,7 +104,7 @@ function relativize(globPattern, relativePathToOldBaseDir) {
104
104
  }
105
105
 
106
106
  const prefix = globPattern.startsWith("!") ? "!" : "";
107
- const globWithoutPrefix = globPattern.replace(/^!/, "");
107
+ const globWithoutPrefix = globPattern.replace(/^!/u, "");
108
108
 
109
109
  if (globWithoutPrefix.startsWith("/")) {
110
110
  return `${prefix}/${normalizePathSeps(relativePathToOldBaseDir)}${globWithoutPrefix}`;
@@ -284,7 +284,7 @@ class IgnoredPaths {
284
284
  }
285
285
 
286
286
  // If it's only Windows drive letter, it needs \
287
- if (/^[A-Z]:$/.test(this._baseDir)) {
287
+ if (/^[A-Z]:$/u.test(this._baseDir)) {
288
288
  this._baseDir += "\\";
289
289
  }
290
290
 
@@ -300,7 +300,7 @@ class IgnoredPaths {
300
300
  */
301
301
  readIgnoreFile(filePath) {
302
302
  if (typeof this.cache[filePath] === "undefined") {
303
- this.cache[filePath] = fs.readFileSync(filePath, "utf8").split(/\r?\n/g).filter(Boolean);
303
+ this.cache[filePath] = fs.readFileSync(filePath, "utf8").split(/\r?\n/gu).filter(Boolean);
304
304
  }
305
305
  return this.cache[filePath];
306
306
  }
@@ -15,7 +15,7 @@ module.exports = (text, data) => {
15
15
  }
16
16
 
17
17
  // Substitution content for any {{ }} markers.
18
- return text.replace(/\{\{([^{}]+?)\}\}/g, (fullMatch, termWithWhitespace) => {
18
+ return text.replace(/\{\{([^{}]+?)\}\}/gu, (fullMatch, termWithWhitespace) => {
19
19
  const term = termWithWhitespace.trim();
20
20
 
21
21
  if (term in data) {
@@ -13,7 +13,7 @@ const pathUtils = require("../util/path-utils");
13
13
  // Private
14
14
  //------------------------------------------------------------------------------
15
15
 
16
- const NAMESPACE_REGEX = /^@.*\//i;
16
+ const NAMESPACE_REGEX = /^@.*\//iu;
17
17
 
18
18
  /**
19
19
  * Brings package name to correct format based on prefix
@@ -40,8 +40,8 @@ function normalizePackageName(name, prefix) {
40
40
  * it's a scoped package
41
41
  * package name is the prefix, or just a username
42
42
  */
43
- const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`),
44
- scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`);
43
+ const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`, "u"),
44
+ scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`, "u");
45
45
 
46
46
  if (scopedPackageShortcutRegex.test(normalizedName)) {
47
47
  normalizedName = normalizedName.replace(scopedPackageShortcutRegex, `$1/${prefix}`);
@@ -51,7 +51,7 @@ function normalizePackageName(name, prefix) {
51
51
  * for scoped packages, insert the prefix after the first / unless
52
52
  * the path is already @scope/eslint or @scope/eslint-xxx-yyy
53
53
  */
54
- normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/, `@$1/${prefix}-$2`);
54
+ normalizedName = normalizedName.replace(/^@([^/]+)\/(.*)$/u, `@$1/${prefix}-$2`);
55
55
  }
56
56
  } else if (normalizedName.indexOf(`${prefix}-`) !== 0) {
57
57
  normalizedName = `${prefix}-${normalizedName}`;
@@ -68,13 +68,13 @@ function normalizePackageName(name, prefix) {
68
68
  */
69
69
  function getShorthandName(fullname, prefix) {
70
70
  if (fullname[0] === "@") {
71
- let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`).exec(fullname);
71
+ let matchResult = new RegExp(`^(@[^/]+)/${prefix}$`, "u").exec(fullname);
72
72
 
73
73
  if (matchResult) {
74
74
  return matchResult[1];
75
75
  }
76
76
 
77
- matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`).exec(fullname);
77
+ matchResult = new RegExp(`^(@[^/]+)/${prefix}-(.+)$`, "u").exec(fullname);
78
78
  if (matchResult) {
79
79
  return `${matchResult[1]}/${matchResult[2]}`;
80
80
  }
@@ -157,7 +157,7 @@ function compareSpecificity(selectorA, selectorB) {
157
157
  */
158
158
  function tryParseSelector(rawSelector) {
159
159
  try {
160
- return esquery.parse(rawSelector.replace(/:exit$/, ""));
160
+ return esquery.parse(rawSelector.replace(/:exit$/u, ""));
161
161
  } catch (err) {
162
162
  if (typeof err.offset === "number") {
163
163
  throw new SyntaxError(`Syntax error in selector "${rawSelector}" at position ${err.offset}: ${err.message}`);