eslint 5.8.0 → 5.9.0

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 (269) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/lib/cli-engine.js +128 -31
  3. package/lib/cli.js +6 -1
  4. package/lib/options.js +5 -0
  5. package/lib/rules/accessor-pairs.js +4 -0
  6. package/lib/rules/array-bracket-newline.js +5 -0
  7. package/lib/rules/array-bracket-spacing.js +5 -0
  8. package/lib/rules/array-callback-return.js +2 -0
  9. package/lib/rules/array-element-newline.js +4 -0
  10. package/lib/rules/arrow-body-style.js +2 -0
  11. package/lib/rules/arrow-parens.js +2 -0
  12. package/lib/rules/arrow-spacing.js +2 -0
  13. package/lib/rules/block-scoped-var.js +2 -0
  14. package/lib/rules/block-spacing.js +2 -0
  15. package/lib/rules/brace-style.js +2 -0
  16. package/lib/rules/callback-return.js +2 -0
  17. package/lib/rules/camelcase.js +2 -0
  18. package/lib/rules/capitalized-comments.js +4 -0
  19. package/lib/rules/class-methods-use-this.js +3 -0
  20. package/lib/rules/comma-dangle.js +4 -0
  21. package/lib/rules/comma-spacing.js +2 -0
  22. package/lib/rules/comma-style.js +5 -0
  23. package/lib/rules/complexity.js +2 -0
  24. package/lib/rules/computed-property-spacing.js +2 -0
  25. package/lib/rules/consistent-return.js +2 -0
  26. package/lib/rules/consistent-this.js +2 -0
  27. package/lib/rules/constructor-super.js +2 -0
  28. package/lib/rules/curly.js +2 -0
  29. package/lib/rules/default-case.js +2 -0
  30. package/lib/rules/dot-location.js +2 -0
  31. package/lib/rules/dot-notation.js +2 -0
  32. package/lib/rules/eol-last.js +5 -0
  33. package/lib/rules/eqeqeq.js +2 -0
  34. package/lib/rules/for-direction.js +4 -0
  35. package/lib/rules/func-call-spacing.js +4 -0
  36. package/lib/rules/func-name-matching.js +3 -0
  37. package/lib/rules/func-names.js +3 -0
  38. package/lib/rules/func-style.js +3 -0
  39. package/lib/rules/function-paren-newline.js +5 -0
  40. package/lib/rules/generator-star-spacing.js +3 -0
  41. package/lib/rules/getter-return.js +5 -0
  42. package/lib/rules/global-require.js +2 -0
  43. package/lib/rules/guard-for-in.js +2 -0
  44. package/lib/rules/handle-callback-err.js +2 -0
  45. package/lib/rules/id-blacklist.js +2 -0
  46. package/lib/rules/id-length.js +2 -0
  47. package/lib/rules/id-match.js +101 -27
  48. package/lib/rules/implicit-arrow-linebreak.js +4 -0
  49. package/lib/rules/indent-legacy.js +4 -1
  50. package/lib/rules/indent.js +2 -0
  51. package/lib/rules/init-declarations.js +2 -0
  52. package/lib/rules/jsx-quotes.js +2 -0
  53. package/lib/rules/key-spacing.js +4 -3
  54. package/lib/rules/keyword-spacing.js +2 -0
  55. package/lib/rules/line-comment-position.js +2 -0
  56. package/lib/rules/linebreak-style.js +2 -0
  57. package/lib/rules/lines-around-comment.js +2 -0
  58. package/lib/rules/lines-around-directive.js +6 -2
  59. package/lib/rules/lines-between-class-members.js +2 -0
  60. package/lib/rules/max-classes-per-file.js +4 -0
  61. package/lib/rules/max-depth.js +2 -0
  62. package/lib/rules/max-len.js +2 -0
  63. package/lib/rules/max-lines-per-function.js +2 -0
  64. package/lib/rules/max-lines.js +2 -0
  65. package/lib/rules/max-nested-callbacks.js +2 -0
  66. package/lib/rules/max-params.js +2 -0
  67. package/lib/rules/max-statements-per-line.js +2 -0
  68. package/lib/rules/max-statements.js +2 -0
  69. package/lib/rules/multiline-comment-style.js +3 -0
  70. package/lib/rules/multiline-ternary.js +3 -0
  71. package/lib/rules/new-cap.js +2 -0
  72. package/lib/rules/new-parens.js +2 -1
  73. package/lib/rules/newline-after-var.js +5 -2
  74. package/lib/rules/newline-before-return.js +5 -2
  75. package/lib/rules/newline-per-chained-call.js +4 -0
  76. package/lib/rules/no-alert.js +2 -0
  77. package/lib/rules/no-array-constructor.js +2 -0
  78. package/lib/rules/no-async-promise-executor.js +3 -0
  79. package/lib/rules/no-await-in-loop.js +4 -0
  80. package/lib/rules/no-bitwise.js +2 -0
  81. package/lib/rules/no-buffer-constructor.js +4 -0
  82. package/lib/rules/no-caller.js +2 -0
  83. package/lib/rules/no-case-declarations.js +2 -0
  84. package/lib/rules/no-catch-shadow.js +6 -3
  85. package/lib/rules/no-class-assign.js +2 -0
  86. package/lib/rules/no-compare-neg-zero.js +4 -0
  87. package/lib/rules/no-cond-assign.js +2 -0
  88. package/lib/rules/no-confusing-arrow.js +2 -0
  89. package/lib/rules/no-console.js +2 -0
  90. package/lib/rules/no-const-assign.js +2 -0
  91. package/lib/rules/no-constant-condition.js +2 -0
  92. package/lib/rules/no-continue.js +2 -0
  93. package/lib/rules/no-control-regex.js +4 -2
  94. package/lib/rules/no-debugger.js +4 -0
  95. package/lib/rules/no-delete-var.js +2 -0
  96. package/lib/rules/no-div-regex.js +2 -0
  97. package/lib/rules/no-dupe-args.js +2 -0
  98. package/lib/rules/no-dupe-class-members.js +2 -0
  99. package/lib/rules/no-dupe-keys.js +2 -0
  100. package/lib/rules/no-duplicate-case.js +2 -0
  101. package/lib/rules/no-duplicate-imports.js +2 -0
  102. package/lib/rules/no-else-return.js +2 -0
  103. package/lib/rules/no-empty-character-class.js +2 -0
  104. package/lib/rules/no-empty-function.js +2 -0
  105. package/lib/rules/no-empty-pattern.js +2 -0
  106. package/lib/rules/no-empty.js +2 -0
  107. package/lib/rules/no-eq-null.js +2 -0
  108. package/lib/rules/no-eval.js +2 -0
  109. package/lib/rules/no-ex-assign.js +2 -0
  110. package/lib/rules/no-extend-native.js +2 -0
  111. package/lib/rules/no-extra-bind.js +2 -1
  112. package/lib/rules/no-extra-boolean-cast.js +2 -1
  113. package/lib/rules/no-extra-label.js +2 -1
  114. package/lib/rules/no-extra-parens.js +5 -6
  115. package/lib/rules/no-extra-semi.js +2 -0
  116. package/lib/rules/no-fallthrough.js +2 -0
  117. package/lib/rules/no-floating-decimal.js +2 -1
  118. package/lib/rules/no-func-assign.js +2 -0
  119. package/lib/rules/no-global-assign.js +2 -0
  120. package/lib/rules/no-implicit-coercion.js +3 -0
  121. package/lib/rules/no-implicit-globals.js +2 -0
  122. package/lib/rules/no-implied-eval.js +2 -0
  123. package/lib/rules/no-inline-comments.js +2 -0
  124. package/lib/rules/no-inner-declarations.js +2 -0
  125. package/lib/rules/no-invalid-regexp.js +2 -0
  126. package/lib/rules/no-invalid-this.js +2 -0
  127. package/lib/rules/no-irregular-whitespace.js +2 -0
  128. package/lib/rules/no-iterator.js +2 -0
  129. package/lib/rules/no-label-var.js +2 -0
  130. package/lib/rules/no-labels.js +2 -0
  131. package/lib/rules/no-lone-blocks.js +2 -0
  132. package/lib/rules/no-lonely-if.js +2 -1
  133. package/lib/rules/no-loop-func.js +2 -0
  134. package/lib/rules/no-magic-numbers.js +3 -0
  135. package/lib/rules/no-misleading-character-class.js +4 -0
  136. package/lib/rules/no-mixed-operators.js +3 -0
  137. package/lib/rules/no-mixed-requires.js +2 -0
  138. package/lib/rules/no-mixed-spaces-and-tabs.js +2 -0
  139. package/lib/rules/no-multi-assign.js +3 -0
  140. package/lib/rules/no-multi-spaces.js +2 -0
  141. package/lib/rules/no-multi-str.js +2 -0
  142. package/lib/rules/no-multiple-empty-lines.js +2 -0
  143. package/lib/rules/no-native-reassign.js +4 -1
  144. package/lib/rules/no-negated-condition.js +2 -0
  145. package/lib/rules/no-negated-in-lhs.js +5 -2
  146. package/lib/rules/no-nested-ternary.js +2 -0
  147. package/lib/rules/no-new-func.js +2 -0
  148. package/lib/rules/no-new-object.js +2 -0
  149. package/lib/rules/no-new-require.js +2 -0
  150. package/lib/rules/no-new-symbol.js +2 -0
  151. package/lib/rules/no-new-wrappers.js +2 -0
  152. package/lib/rules/no-new.js +2 -0
  153. package/lib/rules/no-obj-calls.js +2 -0
  154. package/lib/rules/no-octal-escape.js +2 -0
  155. package/lib/rules/no-octal.js +2 -0
  156. package/lib/rules/no-param-reassign.js +2 -0
  157. package/lib/rules/no-path-concat.js +2 -0
  158. package/lib/rules/no-plusplus.js +2 -0
  159. package/lib/rules/no-process-env.js +2 -0
  160. package/lib/rules/no-process-exit.js +2 -0
  161. package/lib/rules/no-proto.js +2 -0
  162. package/lib/rules/no-prototype-builtins.js +2 -0
  163. package/lib/rules/no-redeclare.js +2 -0
  164. package/lib/rules/no-regex-spaces.js +2 -1
  165. package/lib/rules/no-restricted-globals.js +2 -0
  166. package/lib/rules/no-restricted-imports.js +40 -22
  167. package/lib/rules/no-restricted-modules.js +2 -0
  168. package/lib/rules/no-restricted-properties.js +2 -0
  169. package/lib/rules/no-restricted-syntax.js +2 -0
  170. package/lib/rules/no-return-assign.js +2 -0
  171. package/lib/rules/no-return-await.js +4 -0
  172. package/lib/rules/no-script-url.js +2 -0
  173. package/lib/rules/no-self-assign.js +2 -0
  174. package/lib/rules/no-self-compare.js +2 -0
  175. package/lib/rules/no-sequences.js +2 -0
  176. package/lib/rules/no-shadow-restricted-names.js +2 -0
  177. package/lib/rules/no-shadow.js +2 -0
  178. package/lib/rules/no-spaced-func.js +4 -1
  179. package/lib/rules/no-sparse-arrays.js +2 -0
  180. package/lib/rules/no-sync.js +2 -0
  181. package/lib/rules/no-tabs.js +2 -0
  182. package/lib/rules/no-template-curly-in-string.js +2 -0
  183. package/lib/rules/no-ternary.js +2 -0
  184. package/lib/rules/no-this-before-super.js +2 -0
  185. package/lib/rules/no-throw-literal.js +2 -0
  186. package/lib/rules/no-trailing-spaces.js +2 -0
  187. package/lib/rules/no-undef-init.js +2 -1
  188. package/lib/rules/no-undef.js +2 -0
  189. package/lib/rules/no-undefined.js +2 -0
  190. package/lib/rules/no-underscore-dangle.js +2 -0
  191. package/lib/rules/no-unexpected-multiline.js +2 -0
  192. package/lib/rules/no-unmodified-loop-condition.js +2 -0
  193. package/lib/rules/no-unneeded-ternary.js +2 -0
  194. package/lib/rules/no-unreachable.js +2 -1
  195. package/lib/rules/no-unsafe-finally.js +2 -0
  196. package/lib/rules/no-unsafe-negation.js +3 -0
  197. package/lib/rules/no-unused-expressions.js +2 -0
  198. package/lib/rules/no-unused-labels.js +2 -1
  199. package/lib/rules/no-unused-vars.js +36 -12
  200. package/lib/rules/no-use-before-define.js +2 -0
  201. package/lib/rules/no-useless-call.js +2 -0
  202. package/lib/rules/no-useless-computed-key.js +2 -1
  203. package/lib/rules/no-useless-concat.js +2 -0
  204. package/lib/rules/no-useless-constructor.js +2 -0
  205. package/lib/rules/no-useless-escape.js +2 -0
  206. package/lib/rules/no-useless-rename.js +4 -0
  207. package/lib/rules/no-useless-return.js +3 -0
  208. package/lib/rules/no-var.js +2 -0
  209. package/lib/rules/no-void.js +2 -0
  210. package/lib/rules/no-warning-comments.js +2 -0
  211. package/lib/rules/no-whitespace-before-property.js +2 -0
  212. package/lib/rules/no-with.js +2 -0
  213. package/lib/rules/nonblock-statement-body-position.js +4 -0
  214. package/lib/rules/object-curly-newline.js +4 -0
  215. package/lib/rules/object-curly-spacing.js +2 -0
  216. package/lib/rules/object-property-newline.js +3 -2
  217. package/lib/rules/object-shorthand.js +2 -0
  218. package/lib/rules/one-var-declaration-per-line.js +2 -0
  219. package/lib/rules/one-var.js +2 -0
  220. package/lib/rules/operator-assignment.js +2 -0
  221. package/lib/rules/operator-linebreak.js +2 -0
  222. package/lib/rules/padded-blocks.js +2 -0
  223. package/lib/rules/padding-line-between-statements.js +4 -0
  224. package/lib/rules/prefer-arrow-callback.js +2 -0
  225. package/lib/rules/prefer-const.js +53 -7
  226. package/lib/rules/prefer-destructuring.js +3 -0
  227. package/lib/rules/prefer-numeric-literals.js +2 -1
  228. package/lib/rules/prefer-object-spread.js +4 -0
  229. package/lib/rules/prefer-promise-reject-errors.js +4 -0
  230. package/lib/rules/prefer-reflect.js +4 -1
  231. package/lib/rules/prefer-rest-params.js +2 -0
  232. package/lib/rules/prefer-spread.js +2 -1
  233. package/lib/rules/prefer-template.js +2 -1
  234. package/lib/rules/quote-props.js +2 -0
  235. package/lib/rules/quotes.js +2 -0
  236. package/lib/rules/radix.js +2 -0
  237. package/lib/rules/require-atomic-updates.js +4 -0
  238. package/lib/rules/require-await.js +3 -0
  239. package/lib/rules/require-jsdoc.js +2 -0
  240. package/lib/rules/require-unicode-regexp.js +4 -0
  241. package/lib/rules/require-yield.js +2 -0
  242. package/lib/rules/rest-spread-spacing.js +4 -0
  243. package/lib/rules/semi-spacing.js +2 -0
  244. package/lib/rules/semi-style.js +3 -0
  245. package/lib/rules/semi.js +2 -0
  246. package/lib/rules/sort-imports.js +2 -0
  247. package/lib/rules/sort-keys.js +3 -0
  248. package/lib/rules/sort-vars.js +2 -0
  249. package/lib/rules/space-before-blocks.js +46 -35
  250. package/lib/rules/space-before-function-paren.js +2 -0
  251. package/lib/rules/space-in-parens.js +2 -0
  252. package/lib/rules/space-infix-ops.js +2 -0
  253. package/lib/rules/space-unary-ops.js +2 -0
  254. package/lib/rules/spaced-comment.js +2 -0
  255. package/lib/rules/strict.js +2 -0
  256. package/lib/rules/switch-colon-spacing.js +4 -0
  257. package/lib/rules/symbol-description.js +2 -0
  258. package/lib/rules/template-curly-spacing.js +2 -0
  259. package/lib/rules/template-tag-spacing.js +2 -0
  260. package/lib/rules/unicode-bom.js +2 -0
  261. package/lib/rules/use-isnan.js +2 -0
  262. package/lib/rules/valid-jsdoc.js +2 -0
  263. package/lib/rules/valid-typeof.js +2 -0
  264. package/lib/rules/vars-on-top.js +2 -0
  265. package/lib/rules/wrap-iife.js +2 -0
  266. package/lib/rules/wrap-regex.js +3 -1
  267. package/lib/rules/yield-star-spacing.js +2 -0
  268. package/lib/rules/yoda.js +2 -0
  269. package/package.json +3 -3
@@ -11,13 +11,17 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "suggestion",
15
+
14
16
  docs: {
15
17
  description: "disallow renaming import, export, and destructured assignments to the same name",
16
18
  category: "ECMAScript 6",
17
19
  recommended: false,
18
20
  url: "https://eslint.org/docs/rules/no-useless-rename"
19
21
  },
22
+
20
23
  fixable: "code",
24
+
21
25
  schema: [
22
26
  {
23
27
  type: "object",
@@ -66,12 +66,15 @@ function isInFinally(node) {
66
66
 
67
67
  module.exports = {
68
68
  meta: {
69
+ type: "suggestion",
70
+
69
71
  docs: {
70
72
  description: "disallow redundant return statements",
71
73
  category: "Best Practices",
72
74
  recommended: false,
73
75
  url: "https://eslint.org/docs/rules/no-useless-return"
74
76
  },
77
+
75
78
  fixable: "code",
76
79
  schema: []
77
80
  },
@@ -180,6 +180,8 @@ function hasReferenceInTDZ(node) {
180
180
 
181
181
  module.exports = {
182
182
  meta: {
183
+ type: "suggestion",
184
+
183
185
  docs: {
184
186
  description: "require `let` or `const` instead of `var`",
185
187
  category: "ECMAScript 6",
@@ -10,6 +10,8 @@
10
10
 
11
11
  module.exports = {
12
12
  meta: {
13
+ type: "suggestion",
14
+
13
15
  docs: {
14
16
  description: "disallow `void` operators",
15
17
  category: "Best Practices",
@@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils");
13
13
 
14
14
  module.exports = {
15
15
  meta: {
16
+ type: "suggestion",
17
+
16
18
  docs: {
17
19
  description: "disallow specified warning terms in comments",
18
20
  category: "Best Practices",
@@ -16,6 +16,8 @@ const astUtils = require("../util/ast-utils");
16
16
 
17
17
  module.exports = {
18
18
  meta: {
19
+ type: "layout",
20
+
19
21
  docs: {
20
22
  description: "disallow whitespace before properties",
21
23
  category: "Stylistic Issues",
@@ -11,6 +11,8 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "suggestion",
15
+
14
16
  docs: {
15
17
  description: "disallow `with` statements",
16
18
  category: "Best Practices",
@@ -12,13 +12,17 @@ const POSITION_SCHEMA = { enum: ["beside", "below", "any"] };
12
12
 
13
13
  module.exports = {
14
14
  meta: {
15
+ type: "layout",
16
+
15
17
  docs: {
16
18
  description: "enforce the location of single-line statements",
17
19
  category: "Stylistic Issues",
18
20
  recommended: false,
19
21
  url: "https://eslint.org/docs/rules/nonblock-statement-body-position"
20
22
  },
23
+
21
24
  fixable: "whitespace",
25
+
22
26
  schema: [
23
27
  POSITION_SCHEMA,
24
28
  {
@@ -134,13 +134,17 @@ function areLineBreaksRequired(node, options, first, last) {
134
134
 
135
135
  module.exports = {
136
136
  meta: {
137
+ type: "layout",
138
+
137
139
  docs: {
138
140
  description: "enforce consistent line breaks inside braces",
139
141
  category: "Stylistic Issues",
140
142
  recommended: false,
141
143
  url: "https://eslint.org/docs/rules/object-curly-newline"
142
144
  },
145
+
143
146
  fixable: "whitespace",
147
+
144
148
  schema: [
145
149
  {
146
150
  oneOf: [
@@ -12,6 +12,8 @@ const astUtils = require("../util/ast-utils");
12
12
 
13
13
  module.exports = {
14
14
  meta: {
15
+ type: "layout",
16
+
15
17
  docs: {
16
18
  description: "enforce consistent spacing inside braces",
17
19
  category: "Stylistic Issues",
@@ -11,6 +11,8 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "layout",
15
+
14
16
  docs: {
15
17
  description: "enforce placing object properties on separate lines",
16
18
  category: "Stylistic Issues",
@@ -38,8 +40,7 @@ module.exports = {
38
40
 
39
41
  create(context) {
40
42
  const allowSameLine = context.options[0] && (
41
- Boolean(context.options[0].allowAllPropertiesOnSameLine) ||
42
- Boolean(context.options[0].allowMultiplePropertiesPerLine) // Deprecated
43
+ (Boolean(context.options[0].allowAllPropertiesOnSameLine) || Boolean(context.options[0].allowMultiplePropertiesPerLine)) // Deprecated
43
44
  );
44
45
  const errorMessage = allowSameLine
45
46
  ? "Object properties must go on a new line if they aren't all on the same line."
@@ -24,6 +24,8 @@ const astUtils = require("../util/ast-utils");
24
24
  //------------------------------------------------------------------------------
25
25
  module.exports = {
26
26
  meta: {
27
+ type: "suggestion",
28
+
27
29
  docs: {
28
30
  description: "require or disallow method and property shorthand syntax for object literals",
29
31
  category: "ECMAScript 6",
@@ -10,6 +10,8 @@
10
10
 
11
11
  module.exports = {
12
12
  meta: {
13
+ type: "suggestion",
14
+
13
15
  docs: {
14
16
  description: "require or disallow newlines around variable declarations",
15
17
  category: "Stylistic Issues",
@@ -11,6 +11,8 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "suggestion",
15
+
14
16
  docs: {
15
17
  description: "enforce variables to be declared either together or separately in functions",
16
18
  category: "Stylistic Issues",
@@ -89,6 +89,8 @@ function canBeFixed(node) {
89
89
 
90
90
  module.exports = {
91
91
  meta: {
92
+ type: "suggestion",
93
+
92
94
  docs: {
93
95
  description: "require or disallow assignment operator shorthand where possible",
94
96
  category: "Stylistic Issues",
@@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils");
17
17
 
18
18
  module.exports = {
19
19
  meta: {
20
+ type: "layout",
21
+
20
22
  docs: {
21
23
  description: "enforce consistent linebreak style for operators",
22
24
  category: "Stylistic Issues",
@@ -11,6 +11,8 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "layout",
15
+
14
16
  docs: {
15
17
  description: "require or disallow padding within blocks",
16
18
  category: "Stylistic Issues",
@@ -400,13 +400,17 @@ const StatementTypes = {
400
400
 
401
401
  module.exports = {
402
402
  meta: {
403
+ type: "layout",
404
+
403
405
  docs: {
404
406
  description: "require or disallow padding lines between statements",
405
407
  category: "Stylistic Issues",
406
408
  recommended: false,
407
409
  url: "https://eslint.org/docs/rules/padding-line-between-statements"
408
410
  },
411
+
409
412
  fixable: "whitespace",
413
+
410
414
  schema: {
411
415
  definitions: {
412
416
  paddingType: {
@@ -132,6 +132,8 @@ function hasDuplicateParams(paramsList) {
132
132
 
133
133
  module.exports = {
134
134
  meta: {
135
+ type: "suggestion",
136
+
135
137
  docs: {
136
138
  description: "require using arrow functions for callbacks",
137
139
  category: "ECMAScript 6",
@@ -330,6 +330,8 @@ function findUp(node, type, shouldStop) {
330
330
 
331
331
  module.exports = {
332
332
  meta: {
333
+ type: "suggestion",
334
+
333
335
  docs: {
334
336
  description: "require `const` declarations for variables that are never reassigned after declared",
335
337
  category: "ECMAScript 6",
@@ -357,6 +359,8 @@ module.exports = {
357
359
  const shouldMatchAnyDestructuredVariable = options.destructuring !== "all";
358
360
  const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true;
359
361
  const variables = [];
362
+ let reportCount = 0;
363
+ let name = "";
360
364
 
361
365
  /**
362
366
  * Reports given identifier nodes if all of the nodes should be declared
@@ -377,14 +381,41 @@ module.exports = {
377
381
 
378
382
  if (nodes.length && (shouldMatchAnyDestructuredVariable || nodesToReport.length === nodes.length)) {
379
383
  const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("Statement"));
380
- const shouldFix = varDeclParent &&
384
+ const isVarDecParentNull = varDeclParent === null;
385
+
386
+ if (!isVarDecParentNull && varDeclParent.declarations.length > 0) {
387
+ const firstDeclaration = varDeclParent.declarations[0];
388
+
389
+ if (firstDeclaration.init) {
390
+ const firstDecParent = firstDeclaration.init.parent;
391
+
392
+ /*
393
+ * First we check the declaration type and then depending on
394
+ * if the type is a "VariableDeclarator" or its an "ObjectPattern"
395
+ * we compare the name from the first identifier, if the names are different
396
+ * we assign the new name and reset the count of reportCount and nodeCount in
397
+ * order to check each block for the number of reported errors and base our fix
398
+ * based on comparing nodes.length and nodesToReport.length.
399
+ */
400
+
401
+ if (firstDecParent.type === "VariableDeclarator") {
402
+
403
+ if (firstDecParent.id.name !== name) {
404
+ name = firstDecParent.id.name;
405
+ reportCount = 0;
406
+ }
407
+
408
+ if (firstDecParent.id.type === "ObjectPattern") {
409
+ if (firstDecParent.init.name !== name) {
410
+ name = firstDecParent.init.name;
411
+ reportCount = 0;
412
+ }
413
+ }
414
+ }
415
+ }
416
+ }
381
417
 
382
- /*
383
- * If there are multiple variable declarations, like {let a = 1, b = 2}, then
384
- * do not attempt to fix if one of the declarations should be `const`. It's
385
- * too hard to know how the developer would want to automatically resolve the issue.
386
- */
387
- varDeclParent.declarations.length === 1 &&
418
+ let shouldFix = varDeclParent &&
388
419
 
389
420
  // Don't do a fix unless the variable is initialized (or it's in a for-in or for-of loop)
390
421
  (varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" || varDeclParent.declarations[0].init) &&
@@ -396,6 +427,21 @@ module.exports = {
396
427
  */
397
428
  nodesToReport.length === nodes.length;
398
429
 
430
+ if (!isVarDecParentNull && varDeclParent.declarations && varDeclParent.declarations.length !== 1) {
431
+
432
+ if (varDeclParent && varDeclParent.declarations && varDeclParent.declarations.length >= 1) {
433
+
434
+ /*
435
+ * Add nodesToReport.length to a count, then comparing the count to the length
436
+ * of the declarations in the current block.
437
+ */
438
+
439
+ reportCount += nodesToReport.length;
440
+
441
+ shouldFix = shouldFix && (reportCount === varDeclParent.declarations.length);
442
+ }
443
+ }
444
+
399
445
  nodesToReport.forEach(node => {
400
446
  context.report({
401
447
  node,
@@ -10,12 +10,15 @@
10
10
 
11
11
  module.exports = {
12
12
  meta: {
13
+ type: "suggestion",
14
+
13
15
  docs: {
14
16
  description: "require destructuring from arrays and/or objects",
15
17
  category: "ECMAScript 6",
16
18
  recommended: false,
17
19
  url: "https://eslint.org/docs/rules/prefer-destructuring"
18
20
  },
21
+
19
22
  schema: [
20
23
  {
21
24
 
@@ -38,6 +38,8 @@ function isParseInt(calleeNode) {
38
38
 
39
39
  module.exports = {
40
40
  meta: {
41
+ type: "suggestion",
42
+
41
43
  docs: {
42
44
  description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals",
43
45
  category: "ECMAScript 6",
@@ -46,7 +48,6 @@ module.exports = {
46
48
  },
47
49
 
48
50
  schema: [],
49
-
50
51
  fixable: "code"
51
52
  },
52
53
 
@@ -212,6 +212,8 @@ function defineFixer(node, sourceCode) {
212
212
 
213
213
  module.exports = {
214
214
  meta: {
215
+ type: "suggestion",
216
+
215
217
  docs: {
216
218
  description:
217
219
  "disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.",
@@ -219,8 +221,10 @@ module.exports = {
219
221
  recommended: false,
220
222
  url: "https://eslint.org/docs/rules/prefer-object-spread"
221
223
  },
224
+
222
225
  schema: [],
223
226
  fixable: "code",
227
+
224
228
  messages: {
225
229
  useSpreadMessage: "Use an object spread instead of `Object.assign` eg: `{ ...foo }`",
226
230
  useLiteralMessage: "Use an object literal instead of `Object.assign`. eg: `{ foo: bar }`"
@@ -12,13 +12,17 @@ const astUtils = require("../util/ast-utils");
12
12
 
13
13
  module.exports = {
14
14
  meta: {
15
+ type: "suggestion",
16
+
15
17
  docs: {
16
18
  description: "require using Error objects as Promise rejection reasons",
17
19
  category: "Best Practices",
18
20
  recommended: false,
19
21
  url: "https://eslint.org/docs/rules/prefer-promise-reject-errors"
20
22
  },
23
+
21
24
  fixable: null,
25
+
22
26
  schema: [
23
27
  {
24
28
  type: "object",
@@ -11,16 +11,19 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "suggestion",
15
+
14
16
  docs: {
15
17
  description: "require `Reflect` methods where applicable",
16
18
  category: "ECMAScript 6",
17
19
  recommended: false,
18
- replacedBy: [],
19
20
  url: "https://eslint.org/docs/rules/prefer-reflect"
20
21
  },
21
22
 
22
23
  deprecated: true,
23
24
 
25
+ replacedBy: [],
26
+
24
27
  schema: [
25
28
  {
26
29
  type: "object",
@@ -62,6 +62,8 @@ function isNotNormalMemberAccess(reference) {
62
62
 
63
63
  module.exports = {
64
64
  meta: {
65
+ type: "suggestion",
66
+
65
67
  docs: {
66
68
  description: "require rest parameters instead of `arguments`",
67
69
  category: "ECMAScript 6",
@@ -49,6 +49,8 @@ function isValidThisArg(expectedThis, thisArg, context) {
49
49
 
50
50
  module.exports = {
51
51
  meta: {
52
+ type: "suggestion",
53
+
52
54
  docs: {
53
55
  description: "require spread operators instead of `.apply()`",
54
56
  category: "ECMAScript 6",
@@ -57,7 +59,6 @@ module.exports = {
57
59
  },
58
60
 
59
61
  schema: [],
60
-
61
62
  fixable: "code"
62
63
  },
63
64
 
@@ -141,6 +141,8 @@ function endsWithTemplateCurly(node) {
141
141
 
142
142
  module.exports = {
143
143
  meta: {
144
+ type: "suggestion",
145
+
144
146
  docs: {
145
147
  description: "require template literals instead of string concatenation",
146
148
  category: "ECMAScript 6",
@@ -149,7 +151,6 @@ module.exports = {
149
151
  },
150
152
 
151
153
  schema: [],
152
-
153
154
  fixable: "code"
154
155
  },
155
156
 
@@ -17,6 +17,8 @@ const espree = require("espree"),
17
17
 
18
18
  module.exports = {
19
19
  meta: {
20
+ type: "suggestion",
21
+
20
22
  docs: {
21
23
  description: "require quotes around object literal property names",
22
24
  category: "Stylistic Issues",
@@ -76,6 +76,8 @@ const AVOID_ESCAPE = "avoid-escape";
76
76
 
77
77
  module.exports = {
78
78
  meta: {
79
+ type: "layout",
80
+
79
81
  docs: {
80
82
  description: "enforce the consistent use of either backticks, double, or single quotes",
81
83
  category: "Stylistic Issues",
@@ -78,6 +78,8 @@ function isDefaultRadix(radix) {
78
78
 
79
79
  module.exports = {
80
80
  meta: {
81
+ type: "suggestion",
82
+
81
83
  docs: {
82
84
  description: "enforce the consistent use of the radix argument when using `parseInt()`",
83
85
  category: "Best Practices",
@@ -12,14 +12,18 @@ const astUtils = require("../util/ast-utils");
12
12
 
13
13
  module.exports = {
14
14
  meta: {
15
+ type: "problem",
16
+
15
17
  docs: {
16
18
  description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
17
19
  category: "Possible Errors",
18
20
  recommended: false,
19
21
  url: "https://eslint.org/docs/rules/require-atomic-updates"
20
22
  },
23
+
21
24
  fixable: null,
22
25
  schema: [],
26
+
23
27
  messages: {
24
28
  nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`."
25
29
  }
@@ -31,12 +31,15 @@ function capitalizeFirstLetter(text) {
31
31
 
32
32
  module.exports = {
33
33
  meta: {
34
+ type: "suggestion",
35
+
34
36
  docs: {
35
37
  description: "disallow async functions which have no `await` expression",
36
38
  category: "Best Practices",
37
39
  recommended: false,
38
40
  url: "https://eslint.org/docs/rules/require-await"
39
41
  },
42
+
40
43
  schema: []
41
44
  },
42
45
 
@@ -6,6 +6,8 @@
6
6
 
7
7
  module.exports = {
8
8
  meta: {
9
+ type: "suggestion",
10
+
9
11
  docs: {
10
12
  description: "require JSDoc comments",
11
13
  category: "Stylistic Issues",
@@ -22,15 +22,19 @@ const {
22
22
 
23
23
  module.exports = {
24
24
  meta: {
25
+ type: "suggestion",
26
+
25
27
  docs: {
26
28
  description: "enforce the use of `u` flag on RegExp",
27
29
  category: "Best Practices",
28
30
  recommended: false,
29
31
  url: "https://eslint.org/docs/rules/require-unicode-regexp"
30
32
  },
33
+
31
34
  messages: {
32
35
  requireUFlag: "Use the 'u' flag."
33
36
  },
37
+
34
38
  schema: []
35
39
  },
36
40
 
@@ -11,6 +11,8 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "suggestion",
15
+
14
16
  docs: {
15
17
  description: "require generator functions to contain `yield`",
16
18
  category: "ECMAScript 6",
@@ -11,13 +11,17 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "layout",
15
+
14
16
  docs: {
15
17
  description: "enforce spacing between rest and spread operators and their expressions",
16
18
  category: "ECMAScript 6",
17
19
  recommended: false,
18
20
  url: "https://eslint.org/docs/rules/rest-spread-spacing"
19
21
  },
22
+
20
23
  fixable: "whitespace",
24
+
21
25
  schema: [
22
26
  {
23
27
  enum: ["always", "never"]
@@ -13,6 +13,8 @@ const astUtils = require("../util/ast-utils");
13
13
 
14
14
  module.exports = {
15
15
  meta: {
16
+ type: "layout",
17
+
16
18
  docs: {
17
19
  description: "enforce consistent spacing before and after semicolons",
18
20
  category: "Stylistic Issues",
@@ -65,12 +65,15 @@ function isLastChild(node) {
65
65
 
66
66
  module.exports = {
67
67
  meta: {
68
+ type: "layout",
69
+
68
70
  docs: {
69
71
  description: "enforce location of semicolons",
70
72
  category: "Stylistic Issues",
71
73
  recommended: false,
72
74
  url: "https://eslint.org/docs/rules/semi-style"
73
75
  },
76
+
74
77
  schema: [{ enum: ["last", "first"] }],
75
78
  fixable: "whitespace"
76
79
  },
package/lib/rules/semi.js CHANGED
@@ -17,6 +17,8 @@ const astUtils = require("../util/ast-utils");
17
17
 
18
18
  module.exports = {
19
19
  meta: {
20
+ type: "layout",
21
+
20
22
  docs: {
21
23
  description: "require or disallow semicolons instead of ASI",
22
24
  category: "Stylistic Issues",
@@ -11,6 +11,8 @@
11
11
 
12
12
  module.exports = {
13
13
  meta: {
14
+ type: "suggestion",
15
+
14
16
  docs: {
15
17
  description: "enforce sorted import declarations within modules",
16
18
  category: "ECMAScript 6",