eslint 5.7.0 → 5.11.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 (284) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +2 -2
  3. package/conf/eslint-recommended.js +1 -0
  4. package/lib/cli-engine.js +129 -32
  5. package/lib/cli.js +6 -1
  6. package/lib/config/autoconfig.js +0 -1
  7. package/lib/config/config-rule.js +4 -4
  8. package/lib/config/config-validator.js +2 -2
  9. package/lib/config.js +15 -2
  10. package/lib/linter.js +17 -120
  11. package/lib/options.js +5 -0
  12. package/lib/rules/accessor-pairs.js +4 -0
  13. package/lib/rules/array-bracket-newline.js +5 -0
  14. package/lib/rules/array-bracket-spacing.js +5 -0
  15. package/lib/rules/array-callback-return.js +2 -0
  16. package/lib/rules/array-element-newline.js +4 -1
  17. package/lib/rules/arrow-body-style.js +2 -0
  18. package/lib/rules/arrow-parens.js +2 -0
  19. package/lib/rules/arrow-spacing.js +2 -0
  20. package/lib/rules/block-scoped-var.js +2 -0
  21. package/lib/rules/block-spacing.js +2 -0
  22. package/lib/rules/brace-style.js +2 -0
  23. package/lib/rules/callback-return.js +2 -0
  24. package/lib/rules/camelcase.js +26 -14
  25. package/lib/rules/capitalized-comments.js +4 -0
  26. package/lib/rules/class-methods-use-this.js +3 -0
  27. package/lib/rules/comma-dangle.js +4 -0
  28. package/lib/rules/comma-spacing.js +2 -0
  29. package/lib/rules/comma-style.js +12 -2
  30. package/lib/rules/complexity.js +2 -0
  31. package/lib/rules/computed-property-spacing.js +2 -0
  32. package/lib/rules/consistent-return.js +2 -0
  33. package/lib/rules/consistent-this.js +2 -0
  34. package/lib/rules/constructor-super.js +2 -0
  35. package/lib/rules/curly.js +2 -0
  36. package/lib/rules/default-case.js +2 -0
  37. package/lib/rules/dot-location.js +2 -0
  38. package/lib/rules/dot-notation.js +2 -0
  39. package/lib/rules/eol-last.js +5 -0
  40. package/lib/rules/eqeqeq.js +2 -1
  41. package/lib/rules/for-direction.js +4 -0
  42. package/lib/rules/func-call-spacing.js +4 -0
  43. package/lib/rules/func-name-matching.js +3 -0
  44. package/lib/rules/func-names.js +3 -0
  45. package/lib/rules/func-style.js +3 -0
  46. package/lib/rules/function-paren-newline.js +5 -0
  47. package/lib/rules/generator-star-spacing.js +3 -0
  48. package/lib/rules/getter-return.js +5 -0
  49. package/lib/rules/global-require.js +2 -0
  50. package/lib/rules/guard-for-in.js +2 -0
  51. package/lib/rules/handle-callback-err.js +3 -1
  52. package/lib/rules/id-blacklist.js +2 -0
  53. package/lib/rules/id-length.js +2 -0
  54. package/lib/rules/id-match.js +101 -27
  55. package/lib/rules/implicit-arrow-linebreak.js +147 -2
  56. package/lib/rules/indent-legacy.js +4 -4
  57. package/lib/rules/indent.js +31 -23
  58. package/lib/rules/init-declarations.js +2 -0
  59. package/lib/rules/jsx-quotes.js +2 -0
  60. package/lib/rules/key-spacing.js +4 -3
  61. package/lib/rules/keyword-spacing.js +7 -1
  62. package/lib/rules/line-comment-position.js +2 -0
  63. package/lib/rules/linebreak-style.js +2 -0
  64. package/lib/rules/lines-around-comment.js +2 -0
  65. package/lib/rules/lines-around-directive.js +6 -2
  66. package/lib/rules/lines-between-class-members.js +2 -0
  67. package/lib/rules/max-classes-per-file.js +4 -0
  68. package/lib/rules/max-depth.js +2 -0
  69. package/lib/rules/max-len.js +2 -0
  70. package/lib/rules/max-lines-per-function.js +2 -0
  71. package/lib/rules/max-lines.js +2 -0
  72. package/lib/rules/max-nested-callbacks.js +2 -0
  73. package/lib/rules/max-params.js +2 -0
  74. package/lib/rules/max-statements-per-line.js +2 -0
  75. package/lib/rules/max-statements.js +2 -0
  76. package/lib/rules/multiline-comment-style.js +3 -0
  77. package/lib/rules/multiline-ternary.js +3 -0
  78. package/lib/rules/new-cap.js +2 -0
  79. package/lib/rules/new-parens.js +2 -1
  80. package/lib/rules/newline-after-var.js +5 -2
  81. package/lib/rules/newline-before-return.js +6 -3
  82. package/lib/rules/newline-per-chained-call.js +4 -0
  83. package/lib/rules/no-alert.js +2 -0
  84. package/lib/rules/no-array-constructor.js +2 -0
  85. package/lib/rules/no-async-promise-executor.js +3 -0
  86. package/lib/rules/no-await-in-loop.js +4 -0
  87. package/lib/rules/no-bitwise.js +2 -0
  88. package/lib/rules/no-buffer-constructor.js +4 -0
  89. package/lib/rules/no-caller.js +2 -0
  90. package/lib/rules/no-case-declarations.js +2 -0
  91. package/lib/rules/no-catch-shadow.js +6 -3
  92. package/lib/rules/no-class-assign.js +2 -0
  93. package/lib/rules/no-compare-neg-zero.js +4 -0
  94. package/lib/rules/no-cond-assign.js +2 -0
  95. package/lib/rules/no-confusing-arrow.js +2 -0
  96. package/lib/rules/no-console.js +2 -0
  97. package/lib/rules/no-const-assign.js +2 -0
  98. package/lib/rules/no-constant-condition.js +2 -1
  99. package/lib/rules/no-continue.js +2 -0
  100. package/lib/rules/no-control-regex.js +4 -2
  101. package/lib/rules/no-debugger.js +4 -0
  102. package/lib/rules/no-delete-var.js +2 -0
  103. package/lib/rules/no-div-regex.js +2 -0
  104. package/lib/rules/no-dupe-args.js +2 -0
  105. package/lib/rules/no-dupe-class-members.js +2 -0
  106. package/lib/rules/no-dupe-keys.js +2 -0
  107. package/lib/rules/no-duplicate-case.js +2 -0
  108. package/lib/rules/no-duplicate-imports.js +2 -0
  109. package/lib/rules/no-else-return.js +2 -1
  110. package/lib/rules/no-empty-character-class.js +2 -0
  111. package/lib/rules/no-empty-function.js +2 -0
  112. package/lib/rules/no-empty-pattern.js +2 -0
  113. package/lib/rules/no-empty.js +2 -0
  114. package/lib/rules/no-eq-null.js +2 -0
  115. package/lib/rules/no-eval.js +2 -0
  116. package/lib/rules/no-ex-assign.js +2 -0
  117. package/lib/rules/no-extend-native.js +2 -0
  118. package/lib/rules/no-extra-bind.js +2 -1
  119. package/lib/rules/no-extra-boolean-cast.js +2 -1
  120. package/lib/rules/no-extra-label.js +2 -1
  121. package/lib/rules/no-extra-parens.js +5 -6
  122. package/lib/rules/no-extra-semi.js +2 -0
  123. package/lib/rules/no-fallthrough.js +2 -0
  124. package/lib/rules/no-floating-decimal.js +2 -1
  125. package/lib/rules/no-func-assign.js +2 -0
  126. package/lib/rules/no-global-assign.js +2 -0
  127. package/lib/rules/no-implicit-coercion.js +3 -0
  128. package/lib/rules/no-implicit-globals.js +2 -0
  129. package/lib/rules/no-implied-eval.js +3 -1
  130. package/lib/rules/no-inline-comments.js +2 -0
  131. package/lib/rules/no-inner-declarations.js +2 -0
  132. package/lib/rules/no-invalid-regexp.js +2 -0
  133. package/lib/rules/no-invalid-this.js +2 -0
  134. package/lib/rules/no-irregular-whitespace.js +7 -9
  135. package/lib/rules/no-iterator.js +2 -0
  136. package/lib/rules/no-label-var.js +2 -0
  137. package/lib/rules/no-labels.js +2 -0
  138. package/lib/rules/no-lone-blocks.js +2 -0
  139. package/lib/rules/no-lonely-if.js +2 -1
  140. package/lib/rules/no-loop-func.js +2 -0
  141. package/lib/rules/no-magic-numbers.js +3 -0
  142. package/lib/rules/no-misleading-character-class.js +4 -0
  143. package/lib/rules/no-mixed-operators.js +3 -0
  144. package/lib/rules/no-mixed-requires.js +2 -0
  145. package/lib/rules/no-mixed-spaces-and-tabs.js +2 -0
  146. package/lib/rules/no-multi-assign.js +3 -0
  147. package/lib/rules/no-multi-spaces.js +2 -0
  148. package/lib/rules/no-multi-str.js +2 -0
  149. package/lib/rules/no-multiple-empty-lines.js +2 -0
  150. package/lib/rules/no-native-reassign.js +4 -1
  151. package/lib/rules/no-negated-condition.js +2 -0
  152. package/lib/rules/no-negated-in-lhs.js +5 -2
  153. package/lib/rules/no-nested-ternary.js +2 -0
  154. package/lib/rules/no-new-func.js +2 -0
  155. package/lib/rules/no-new-object.js +2 -0
  156. package/lib/rules/no-new-require.js +2 -0
  157. package/lib/rules/no-new-symbol.js +2 -0
  158. package/lib/rules/no-new-wrappers.js +2 -0
  159. package/lib/rules/no-new.js +2 -0
  160. package/lib/rules/no-obj-calls.js +2 -0
  161. package/lib/rules/no-octal-escape.js +2 -0
  162. package/lib/rules/no-octal.js +2 -0
  163. package/lib/rules/no-param-reassign.js +2 -0
  164. package/lib/rules/no-path-concat.js +2 -0
  165. package/lib/rules/no-plusplus.js +2 -0
  166. package/lib/rules/no-process-env.js +2 -0
  167. package/lib/rules/no-process-exit.js +2 -0
  168. package/lib/rules/no-proto.js +2 -0
  169. package/lib/rules/no-prototype-builtins.js +2 -0
  170. package/lib/rules/no-redeclare.js +2 -0
  171. package/lib/rules/no-regex-spaces.js +2 -1
  172. package/lib/rules/no-restricted-globals.js +2 -0
  173. package/lib/rules/no-restricted-imports.js +41 -23
  174. package/lib/rules/no-restricted-modules.js +2 -0
  175. package/lib/rules/no-restricted-properties.js +2 -0
  176. package/lib/rules/no-restricted-syntax.js +2 -0
  177. package/lib/rules/no-return-assign.js +2 -0
  178. package/lib/rules/no-return-await.js +4 -0
  179. package/lib/rules/no-script-url.js +2 -0
  180. package/lib/rules/no-self-assign.js +2 -0
  181. package/lib/rules/no-self-compare.js +2 -0
  182. package/lib/rules/no-sequences.js +2 -0
  183. package/lib/rules/no-shadow-restricted-names.js +2 -0
  184. package/lib/rules/no-shadow.js +2 -0
  185. package/lib/rules/no-spaced-func.js +4 -1
  186. package/lib/rules/no-sparse-arrays.js +2 -0
  187. package/lib/rules/no-sync.js +2 -0
  188. package/lib/rules/no-tabs.js +2 -0
  189. package/lib/rules/no-template-curly-in-string.js +2 -0
  190. package/lib/rules/no-ternary.js +2 -0
  191. package/lib/rules/no-this-before-super.js +2 -1
  192. package/lib/rules/no-throw-literal.js +2 -0
  193. package/lib/rules/no-trailing-spaces.js +2 -0
  194. package/lib/rules/no-undef-init.js +2 -1
  195. package/lib/rules/no-undef.js +2 -0
  196. package/lib/rules/no-undefined.js +2 -0
  197. package/lib/rules/no-underscore-dangle.js +2 -0
  198. package/lib/rules/no-unexpected-multiline.js +2 -0
  199. package/lib/rules/no-unmodified-loop-condition.js +2 -0
  200. package/lib/rules/no-unneeded-ternary.js +2 -0
  201. package/lib/rules/no-unreachable.js +2 -1
  202. package/lib/rules/no-unsafe-finally.js +2 -0
  203. package/lib/rules/no-unsafe-negation.js +3 -0
  204. package/lib/rules/no-unused-expressions.js +2 -0
  205. package/lib/rules/no-unused-labels.js +2 -1
  206. package/lib/rules/no-unused-vars.js +36 -12
  207. package/lib/rules/no-use-before-define.js +2 -0
  208. package/lib/rules/no-useless-call.js +2 -0
  209. package/lib/rules/no-useless-catch.js +51 -0
  210. package/lib/rules/no-useless-computed-key.js +2 -1
  211. package/lib/rules/no-useless-concat.js +2 -0
  212. package/lib/rules/no-useless-constructor.js +2 -0
  213. package/lib/rules/no-useless-escape.js +2 -0
  214. package/lib/rules/no-useless-rename.js +4 -0
  215. package/lib/rules/no-useless-return.js +3 -0
  216. package/lib/rules/no-var.js +2 -0
  217. package/lib/rules/no-void.js +2 -0
  218. package/lib/rules/no-warning-comments.js +2 -0
  219. package/lib/rules/no-whitespace-before-property.js +2 -0
  220. package/lib/rules/no-with.js +2 -0
  221. package/lib/rules/nonblock-statement-body-position.js +4 -0
  222. package/lib/rules/object-curly-newline.js +4 -1
  223. package/lib/rules/object-curly-spacing.js +2 -0
  224. package/lib/rules/object-property-newline.js +3 -2
  225. package/lib/rules/object-shorthand.js +2 -0
  226. package/lib/rules/one-var-declaration-per-line.js +2 -0
  227. package/lib/rules/one-var.js +2 -1
  228. package/lib/rules/operator-assignment.js +2 -0
  229. package/lib/rules/operator-linebreak.js +2 -0
  230. package/lib/rules/padded-blocks.js +2 -0
  231. package/lib/rules/padding-line-between-statements.js +41 -0
  232. package/lib/rules/prefer-arrow-callback.js +2 -0
  233. package/lib/rules/prefer-const.js +116 -11
  234. package/lib/rules/prefer-destructuring.js +3 -0
  235. package/lib/rules/prefer-numeric-literals.js +2 -1
  236. package/lib/rules/prefer-object-spread.js +4 -0
  237. package/lib/rules/prefer-promise-reject-errors.js +4 -0
  238. package/lib/rules/prefer-reflect.js +4 -1
  239. package/lib/rules/prefer-rest-params.js +2 -0
  240. package/lib/rules/prefer-spread.js +2 -1
  241. package/lib/rules/prefer-template.js +2 -1
  242. package/lib/rules/quote-props.js +2 -0
  243. package/lib/rules/quotes.js +50 -25
  244. package/lib/rules/radix.js +2 -0
  245. package/lib/rules/require-atomic-updates.js +4 -0
  246. package/lib/rules/require-await.js +3 -0
  247. package/lib/rules/require-jsdoc.js +6 -1
  248. package/lib/rules/require-unicode-regexp.js +4 -0
  249. package/lib/rules/require-yield.js +2 -0
  250. package/lib/rules/rest-spread-spacing.js +4 -0
  251. package/lib/rules/semi-spacing.js +2 -0
  252. package/lib/rules/semi-style.js +3 -0
  253. package/lib/rules/semi.js +2 -0
  254. package/lib/rules/sort-imports.js +2 -0
  255. package/lib/rules/sort-keys.js +3 -0
  256. package/lib/rules/sort-vars.js +2 -0
  257. package/lib/rules/space-before-blocks.js +46 -35
  258. package/lib/rules/space-before-function-paren.js +2 -0
  259. package/lib/rules/space-in-parens.js +2 -1
  260. package/lib/rules/space-infix-ops.js +6 -1
  261. package/lib/rules/space-unary-ops.js +2 -0
  262. package/lib/rules/spaced-comment.js +2 -0
  263. package/lib/rules/strict.js +2 -0
  264. package/lib/rules/switch-colon-spacing.js +4 -0
  265. package/lib/rules/symbol-description.js +2 -0
  266. package/lib/rules/template-curly-spacing.js +2 -0
  267. package/lib/rules/template-tag-spacing.js +2 -0
  268. package/lib/rules/unicode-bom.js +2 -0
  269. package/lib/rules/use-isnan.js +2 -0
  270. package/lib/rules/valid-jsdoc.js +6 -1
  271. package/lib/rules/valid-typeof.js +2 -0
  272. package/lib/rules/vars-on-top.js +2 -0
  273. package/lib/rules/wrap-iife.js +2 -0
  274. package/lib/rules/wrap-regex.js +3 -1
  275. package/lib/rules/yield-star-spacing.js +2 -0
  276. package/lib/rules/yoda.js +2 -0
  277. package/lib/testers/rule-tester.js +2 -2
  278. package/lib/util/config-comment-parser.js +144 -0
  279. package/lib/util/glob-utils.js +1 -1
  280. package/lib/{ignored-paths.js → util/ignored-paths.js} +4 -4
  281. package/lib/{report-translator.js → util/report-translator.js} +2 -2
  282. package/lib/util/source-code.js +2 -1
  283. package/messages/all-files-ignored.txt +1 -1
  284. package/package.json +10 -11
package/CHANGELOG.md CHANGED
@@ -1,3 +1,79 @@
1
+ v5.11.0 - December 22, 2018
2
+
3
+ * [`b4395f6`](https://github.com/eslint/eslint/commit/b4395f671442a7e0be956382c24cce38025a6df6) New: add option `first` for VariableDeclarator in indent (fixes #8976) (#11193) (Pig Fang)
4
+ * [`2b5a602`](https://github.com/eslint/eslint/commit/2b5a60284670a3ab1281b206941ed38faf2ea10c) New: no-useless-catch rule (fixes #11174) (#11198) (Alexander Grasley)
5
+ * [`06b3b5b`](https://github.com/eslint/eslint/commit/06b3b5bfcf0429c5078d4f4af3c03bb777e4f022) Fix: Account for comments in implicit-arrow-linebreak (#10545) (Mark de Dios)
6
+ * [`4242314`](https://github.com/eslint/eslint/commit/4242314215a6f35e432860433906f47af1a29724) Update: handle computed properties in camelcase (fixes #11084) (#11113) (Bence Dányi)
7
+ * [`1009304`](https://github.com/eslint/eslint/commit/100930493d9ab802a94dac5c761515b12241ddd2) Docs: add a note for no-unused-expressions (fixes #11169) (#11192) (Pig Fang)
8
+ * [`88f99d3`](https://github.com/eslint/eslint/commit/88f99d31b88a4cde4563bc4a6f4c41f0cc557885) Docs: clarify how to use configs in plugins (#11199) (Kai Cataldo)
9
+ * [`bcf558b`](https://github.com/eslint/eslint/commit/bcf558b2f7036f487af2bdb2b2d34b6cdf7fc174) Docs: Clarify the no-unused-vars docs (#11195) (Jed Fox)
10
+ * [`a470eb7`](https://github.com/eslint/eslint/commit/a470eb73d52fae0f0bc48de5a487e23cf78fcfa9) Docs: Fix no-irregular-whitespace description (#11196) (Jed Fox)
11
+ * [`8abc8af`](https://github.com/eslint/eslint/commit/8abc8afe71691b747cbd1819a13d896e8aa5b92a) Docs: Remove a misleading example (#11204) (Bogdan Gradinariu)
12
+ * [`733d936`](https://github.com/eslint/eslint/commit/733d93618a99758a05453ab94505a9f1330950e0) Docs: link to JSDoc EOL blogpost in valid-jsdoc and require-jsdoc (#11191) (Nathan Diddle)
13
+ * [`d5eb108`](https://github.com/eslint/eslint/commit/d5eb108e17f676d0e4fcddeb1211b4bdfac760c1) Docs: Ensure `triage` label is added to new issues (#11182) (Teddy Katz)
14
+ * [`617a287`](https://github.com/eslint/eslint/commit/617a2874ed085bca36ca289aac55e3b7f7ce937e) Docs: add missing deprecation notices for jsdoc rules (#11171) (Teddy Katz)
15
+
16
+ v5.10.0 - December 8, 2018
17
+
18
+ * [`4b0f517`](https://github.com/eslint/eslint/commit/4b0f517cd317e5f1b99a1e8a0392332bd8a2e231) Upgrade: single- and multiline const, let, var statements (fixes #10721) (#10919) (Tom Panier)
19
+ * [`9666aba`](https://github.com/eslint/eslint/commit/9666abaf46c841fba7b5d4e53c6998cd25b9bc33) Update: space-infix-ops reports violating operator (#10934) (Bence Dányi)
20
+ * [`c14f717`](https://github.com/eslint/eslint/commit/c14f717f4c32860766185da47f64f8eb0c2d2998) Fix: Update all-files-ignored.txt message to be less confusing (#11075) (z.ky)
21
+ * [`9f3573d`](https://github.com/eslint/eslint/commit/9f3573dda3dc35bc220e945686cc835eaad0ac2c) Docs: Clarify the CLIEngine options (#10995) (Ed Morley)
22
+ * [`dd7b0cb`](https://github.com/eslint/eslint/commit/dd7b0cb019d94964930d30fec36f7b22ef072822) Chore: refactor template literal feature detection in 'quotes' rule (#11125) (Bryan)
23
+ * [`3bf0332`](https://github.com/eslint/eslint/commit/3bf0332508b921cb660c2e8a1ab7ddf46a2013b6) Fix: fix the fixer of lone comma with comments (fixes #10632) (#11154) (Pig Fang)
24
+ * [`f850726`](https://github.com/eslint/eslint/commit/f8507260c2091d18488fde20e466639d1a7f913c) Upgrade: Espree v5.0.0 (#11161) (Kai Cataldo)
25
+ * [`4490d7a`](https://github.com/eslint/eslint/commit/4490d7af529d4ecc18b6874f1d838869656da58a) Update: deprecate valid-jsdoc and require-jsdoc (#11145) (Teddy Katz)
26
+ * [`60dfb6c`](https://github.com/eslint/eslint/commit/60dfb6c623dfe829e5350dabe507e7850c1beacf) Docs: Update issue templates (#11163) (Teddy Katz)
27
+ * [`958987a`](https://github.com/eslint/eslint/commit/958987aa6f5630faa051d8f822f0200faff41924) Docs: Fix link to rule no-useless-rename (#11165) (Brian)
28
+ * [`62fd2b9`](https://github.com/eslint/eslint/commit/62fd2b93448966331db3eb2dfbe4e1273eb032b2) Update: Amend keyword-spacing to validate `default` keywords (#11097) (Bin Ury)
29
+ * [`4bcdfd0`](https://github.com/eslint/eslint/commit/4bcdfd07d514fd7a6b8672d33703d0b6c606f214) Chore: fix some jsdoc-related issues (#11148) (薛定谔的猫)
30
+ * [`c6471ed`](https://github.com/eslint/eslint/commit/c6471ed6feb3e71e239379a7042deb9b8ab3cf39) Docs: fix typo in issue-templates/new-rule (#11149) (薛定谔的猫)
31
+ * [`5d451c5`](https://github.com/eslint/eslint/commit/5d451c510c15abc41b5bb14b4955a7db96aeb100) Chore: Remove dependency on is-resolvable (#11128) (Matt Grande)
32
+ * [`bc50dc7`](https://github.com/eslint/eslint/commit/bc50dc7737496712463220e662946eb516e36ae1) Chore: Move ignored-paths, report-translator to lib/util (refs #10559) (#11116) (Kevin Partington)
33
+ * [`c0a80d0`](https://github.com/eslint/eslint/commit/c0a80d0ca3c80ca27694fc8aedcf84b72bfd9465) Fix: Do not strip underscores in camelcase allow (fixes #11000) (#11001) (Luke Page)
34
+ * [`a675c89`](https://github.com/eslint/eslint/commit/a675c89573836adaf108a932696b061946abf1e6) Docs: (Grammar) "the setup" -> "to set up" (#11117) (MarvinJWendt)
35
+ * [`54dfa60`](https://github.com/eslint/eslint/commit/54dfa602f62e6d183d57d60d5fdd417a263f479e) Fix: Typo in function comment parameters (#11111) (Pierre Maoui)
36
+ * [`cf296bd`](https://github.com/eslint/eslint/commit/cf296bdabf0dbbfbae491419e38aee4ecd63ec71) Docs: switch incorrect example with correct one (#11107) (Romain Le Quellec)
37
+ * [`d2d500c`](https://github.com/eslint/eslint/commit/d2d500ca5dff307189b9d4161a5e7b8282557dd6) Docs: no-console#When-Not-To-Use provides incorrect rule snippet (#11093) (Lawrence Chou)
38
+ * [`f394a1d`](https://github.com/eslint/eslint/commit/f394a1dfc5eb4874f899b7bc19685896893af7b8) Chore: Extract config comment parsing (#11091) (Nicholas C. Zakas)
39
+ * [`709190f`](https://github.com/eslint/eslint/commit/709190f8c5d7559b1e0915e25af60b50a94ba1c7) Build: fix test failure on Node 11 (#11100) (Teddy Katz)
40
+ * [`3025cdd`](https://github.com/eslint/eslint/commit/3025cddf0a2ea8461ce05575098a5714fcf6278d) Update: don't indent leading semi in line after import (fixes #11082) (#11085) (Pig Fang)
41
+ * [`e18c827`](https://github.com/eslint/eslint/commit/e18c827cc12cb1c52e5d0aa993f572cb56238704) Chore: refactor linter#parseBooleanConfig to improve readability (#11074) (薛定谔的猫)
42
+ * [`5da378a`](https://github.com/eslint/eslint/commit/5da378ac922d732ca1765f08edee0face1b1b924) Upgrade: eslint-release@1.2.0 (#11073) (Teddy Katz)
43
+
44
+ v5.9.0 - November 9, 2018
45
+
46
+ * 9436712 Fix: Unused recursive function expressions (fixes #10982) (#11032) (Sergei Startsev)
47
+ * c832cd5 Update: add `ignoreDestructuring` option to `id-match` rule (#10554) (一名宅。)
48
+ * 54687a8 Fix: prefer-const autofix multiline assignment (fixes #10582) (#10987) (Scott Stern)
49
+ * ae2b61d Update: "off" options for "space-before-blocks" (refs #10906) (#10907) (Sophie Kirschner)
50
+ * 57f357e Docs: Update require-await docs with exception (fixes #9540) (#11063) (Nicholas C. Zakas)
51
+ * 79a2797 Update: no-restricted-imports to check re-export (fixes #9678) (#11064) (Nicholas C. Zakas)
52
+ * 3dd7493 Docs: update ecmaVersion to include 2019/10 values (#11059) (Vse Mozhet Byt)
53
+ * 607635d Upgrade: eslint-plugin-node & eslint-plugin (#11067) (薛定谔的猫)
54
+ * dcc6233 Fix: Ignore empty statements in no-unreachable (fixes #9081) (#11058) (Nicholas C. Zakas)
55
+ * 7ad86de New: Add --fix-type option to CLI (fixes #10855) (#10912) (Nicholas C. Zakas)
56
+ * 0800b20 Chore: fix invalid super() calls in tests (#11054) (Teddy Katz)
57
+ * 4fe3287 Docs: Cross-reference two rules (refs #11041) (#11042) (Paul Melnikow)
58
+ * 5525eb6 Fix: rule deprecation warnings did not consider all rules (#11044) (Teddy Katz)
59
+ * 44d37ca Docs: Update steps for adding new TSC member (#11038) (Nicholas C. Zakas)
60
+ * 802e926 Update: Warn for deprecation in Node output (fixes #7443) (#10953) (Colin Chang)
61
+
62
+ v5.8.0 - October 26, 2018
63
+
64
+ * 9152417 Fix: deprecation warning in RuleTester using Node v11 (#11009) (Teddy Katz)
65
+ * e349a03 Docs: Update issue templates to ask for PRs (#11012) (Nicholas C. Zakas)
66
+ * 3d88b38 Chore: avoid using legacy report API in no-irregular-whitespace (#11013) (Teddy Katz)
67
+ * 5a31a92 Build: compile espree's deps to ES5 when generating site (fixes #11014) (#11015) (Teddy Katz)
68
+ * 3943635 Update: Create Linter.version API (fixes #9271) (#11010) (Nicholas C. Zakas)
69
+ * a940cf4 Docs: Mention version for config glob patterns (fixes #8793) (Nicholas C. Zakas)
70
+ * 6e1c530 Build: run tests on Node 11 (#11008) (Teddy Katz)
71
+ * 58ff359 Docs: add instructions for npm 2FA (refs #10631) (#10992) (Teddy Katz)
72
+ * 2f87bb3 Upgrade: eslint-release@1.0.0 (refs #10631) (#10991) (Teddy Katz)
73
+ * 57ef0fd Fix: prefer-const when using destructuring assign (fixes #8308) (#10924) (Nicholas C. Zakas)
74
+ * 577cbf1 Chore: Add typescript-specific edge case tests to space-infix-ops (#10986) (Bence Dányi)
75
+ * d45b184 Chore: Using deconstruction assignment for shelljs (#10974) (ZYSzys)
76
+
1
77
  v5.7.0 - October 12, 2018
2
78
 
3
79
  * 6cb63fd Update: Add iife to padding-line-between-statements (fixes #10853) (#10916) (Kevin Partington)
package/README.md CHANGED
@@ -38,7 +38,7 @@ If you want to include ESLint as part of your project's build system, we recomme
38
38
  $ npm install eslint --save-dev
39
39
  ```
40
40
 
41
- You should then setup a configuration file:
41
+ You should then set up a configuration file:
42
42
 
43
43
  ```
44
44
  $ ./node_modules/.bin/eslint --init
@@ -60,7 +60,7 @@ If you want to make ESLint available to tools that run across all of your projec
60
60
  $ npm install -g eslint
61
61
  ```
62
62
 
63
- You should then setup a configuration file:
63
+ You should then set up a configuration file:
64
64
 
65
65
  ```
66
66
  $ eslint --init
@@ -207,6 +207,7 @@ module.exports = {
207
207
  "no-unused-vars": "error",
208
208
  "no-use-before-define": "off",
209
209
  "no-useless-call": "off",
210
+ "no-useless-catch": "off",
210
211
  "no-useless-computed-key": "off",
211
212
  "no-useless-concat": "off",
212
213
  "no-useless-constructor": "off",
package/lib/cli-engine.js CHANGED
@@ -19,8 +19,10 @@ const fs = require("fs"),
19
19
  path = require("path"),
20
20
  defaultOptions = require("../conf/default-cli-options"),
21
21
  Linter = require("./linter"),
22
- IgnoredPaths = require("./ignored-paths"),
22
+ lodash = require("lodash"),
23
+ IgnoredPaths = require("./util/ignored-paths"),
23
24
  Config = require("./config"),
25
+ ConfigOps = require("./config/config-ops"),
24
26
  LintResultCache = require("./util/lint-result-cache"),
25
27
  globUtils = require("./util/glob-utils"),
26
28
  validator = require("./config/config-validator"),
@@ -31,6 +33,7 @@ const fs = require("fs"),
31
33
 
32
34
  const debug = require("debug")("eslint:cli-engine");
33
35
  const resolver = new ModuleResolver();
36
+ const validFixTypes = new Set(["problem", "suggestion", "layout"]);
34
37
 
35
38
  //------------------------------------------------------------------------------
36
39
  // Typedefs
@@ -48,6 +51,7 @@ const resolver = new ModuleResolver();
48
51
  * @property {string[]} envs An array of environments to load.
49
52
  * @property {string[]} extensions An array of file extensions to check.
50
53
  * @property {boolean|Function} fix Execute in autofix mode. If a function, should return a boolean.
54
+ * @property {string[]} fixTypes Array of rule types to apply fixes for.
51
55
  * @property {string[]} globals An array of global variables to declare.
52
56
  * @property {boolean} ignore False disables use of .eslintignore.
53
57
  * @property {string} ignorePath The ignore file to use instead of .eslintignore.
@@ -84,6 +88,21 @@ const resolver = new ModuleResolver();
84
88
  // Helpers
85
89
  //------------------------------------------------------------------------------
86
90
 
91
+ /**
92
+ * Determines if each fix type in an array is supported by ESLint and throws
93
+ * an error if not.
94
+ * @param {string[]} fixTypes An array of fix types to check.
95
+ * @returns {void}
96
+ * @throws {Error} If an invalid fix type is found.
97
+ */
98
+ function validateFixTypes(fixTypes) {
99
+ for (const fixType of fixTypes) {
100
+ if (!validFixTypes.has(fixType)) {
101
+ throw new Error(`Invalid fix type "${fixType}" found.`);
102
+ }
103
+ }
104
+ }
105
+
87
106
  /**
88
107
  * It will calculate the error and warning count for collection of messages per file
89
108
  * @param {Object[]} messages - Collection of messages
@@ -142,7 +161,7 @@ function calculateStatsPerRun(results) {
142
161
  * @param {boolean} allowInlineConfig Allow/ignore comments that change config.
143
162
  * @param {boolean} reportUnusedDisableDirectives Allow/ignore comments that change config.
144
163
  * @param {Linter} linter Linter context
145
- * @returns {LintResult} The results for linting on this text.
164
+ * @returns {{rules: LintResult, config: Object}} The results for linting on this text and the fully-resolved config for it.
146
165
  * @private
147
166
  */
148
167
  function processText(text, configHelper, filename, fix, allowInlineConfig, reportUnusedDisableDirectives, linter) {
@@ -174,7 +193,6 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
174
193
  }
175
194
 
176
195
  const autofixingEnabled = typeof fix !== "undefined" && (!processor || processor.supportsAutofix);
177
-
178
196
  const fixedResult = linter.verifyAndFix(text, config, {
179
197
  filename: effectiveFilename,
180
198
  allowInlineConfig,
@@ -183,7 +201,6 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
183
201
  preprocess: processor && (rawText => processor.preprocess(rawText, effectiveFilename)),
184
202
  postprocess: processor && (problemLists => processor.postprocess(problemLists, effectiveFilename))
185
203
  });
186
-
187
204
  const stats = calculateStatsPerFile(fixedResult.messages);
188
205
 
189
206
  const result = {
@@ -203,7 +220,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
203
220
  result.source = text;
204
221
  }
205
222
 
206
- return result;
223
+ return { result, config };
207
224
  }
208
225
 
209
226
  /**
@@ -213,24 +230,22 @@ function processText(text, configHelper, filename, fix, allowInlineConfig, repor
213
230
  * @param {Object} configHelper The configuration options for ESLint.
214
231
  * @param {Object} options The CLIEngine options object.
215
232
  * @param {Linter} linter Linter context
216
- * @returns {LintResult} The results for linting on this file.
233
+ * @returns {{rules: LintResult, config: Object}} The results for linting on this text and the fully-resolved config for it.
217
234
  * @private
218
235
  */
219
236
  function processFile(filename, configHelper, options, linter) {
220
237
 
221
- const text = fs.readFileSync(path.resolve(filename), "utf8"),
222
- result = processText(
223
- text,
224
- configHelper,
225
- filename,
226
- options.fix,
227
- options.allowInlineConfig,
228
- options.reportUnusedDisableDirectives,
229
- linter
230
- );
231
-
232
- return result;
233
-
238
+ const text = fs.readFileSync(path.resolve(filename), "utf8");
239
+
240
+ return processText(
241
+ text,
242
+ configHelper,
243
+ filename,
244
+ options.fix,
245
+ options.allowInlineConfig,
246
+ options.reportUnusedDisableDirectives,
247
+ linter
248
+ );
234
249
  }
235
250
 
236
251
  /**
@@ -272,6 +287,33 @@ function createIgnoreResult(filePath, baseDir) {
272
287
  };
273
288
  }
274
289
 
290
+ /**
291
+ * Produces rule warnings (i.e. deprecation) from configured rules
292
+ * @param {(Array<string>|Set<string>)} usedRules - Rules configured
293
+ * @param {Map} loadedRules - Map of loaded rules
294
+ * @returns {Array<Object>} Contains rule warnings
295
+ * @private
296
+ */
297
+ function createRuleDeprecationWarnings(usedRules, loadedRules) {
298
+ const usedDeprecatedRules = [];
299
+
300
+ usedRules.forEach(name => {
301
+ const loadedRule = loadedRules.get(name);
302
+
303
+ if (loadedRule && loadedRule.meta && loadedRule.meta.deprecated) {
304
+ const deprecatedRule = { ruleId: name };
305
+ const replacedBy = lodash.get(loadedRule, "meta.replacedBy", []);
306
+
307
+ if (replacedBy.every(newRule => lodash.isString(newRule))) {
308
+ deprecatedRule.replacedBy = replacedBy;
309
+ }
310
+
311
+ usedDeprecatedRules.push(deprecatedRule);
312
+ }
313
+ });
314
+
315
+ return usedDeprecatedRules;
316
+ }
275
317
 
276
318
  /**
277
319
  * Checks if the given message is an error message.
@@ -429,6 +471,33 @@ class CLIEngine {
429
471
  */
430
472
  this._lintResultCache = new LintResultCache(cacheFile, this.config);
431
473
  }
474
+
475
+ // setup special filter for fixes
476
+ if (this.options.fix && this.options.fixTypes && this.options.fixTypes.length > 0) {
477
+
478
+ debug(`Using fix types ${this.options.fixTypes}`);
479
+
480
+ // throw an error if any invalid fix types are found
481
+ validateFixTypes(this.options.fixTypes);
482
+
483
+ // convert to Set for faster lookup
484
+ const fixTypes = new Set(this.options.fixTypes);
485
+
486
+ // save original value of options.fix in case it's a function
487
+ const originalFix = (typeof this.options.fix === "function")
488
+ ? this.options.fix : () => this.options.fix;
489
+
490
+ // create a cache of rules (but don't populate until needed)
491
+ this._rulesCache = null;
492
+
493
+ this.options.fix = lintResult => {
494
+ const rule = this._rulesCache.get(lintResult.ruleId);
495
+ const matches = rule.meta && fixTypes.has(rule.meta.type);
496
+
497
+ return matches && originalFix(lintResult);
498
+ };
499
+ }
500
+
432
501
  }
433
502
 
434
503
  getRules() {
@@ -511,6 +580,7 @@ class CLIEngine {
511
580
 
512
581
  const startTime = Date.now();
513
582
  const fileList = globUtils.listFilesToProcess(patterns, options);
583
+ const allUsedRules = new Set();
514
584
  const results = fileList.map(fileInfo => {
515
585
  if (fileInfo.ignored) {
516
586
  return createIgnoreResult(fileInfo.filename, options.cwd);
@@ -532,9 +602,20 @@ class CLIEngine {
532
602
  }
533
603
  }
534
604
 
605
+ // if there's a cache, populate it
606
+ if ("_rulesCache" in this) {
607
+ this._rulesCache = this.getRules();
608
+ }
609
+
535
610
  debug(`Processing ${fileInfo.filename}`);
536
611
 
537
- return processFile(fileInfo.filename, configHelper, options, this.linter);
612
+ const { result, config } = processFile(fileInfo.filename, configHelper, options, this.linter);
613
+
614
+ Object.keys(config.rules)
615
+ .filter(ruleId => ConfigOps.getRuleSeverity(config.rules[ruleId]))
616
+ .forEach(ruleId => allUsedRules.add(ruleId));
617
+
618
+ return result;
538
619
  });
539
620
 
540
621
  if (options.cache) {
@@ -555,6 +636,8 @@ class CLIEngine {
555
636
 
556
637
  const stats = calculateStatsPerRun(results);
557
638
 
639
+ const usedDeprecatedRules = createRuleDeprecationWarnings(allUsedRules, this.getRules());
640
+
558
641
  debug(`Linting complete in: ${Date.now() - startTime}ms`);
559
642
 
560
643
  return {
@@ -562,7 +645,8 @@ class CLIEngine {
562
645
  errorCount: stats.errorCount,
563
646
  warningCount: stats.warningCount,
564
647
  fixableErrorCount: stats.fixableErrorCount,
565
- fixableWarningCount: stats.fixableWarningCount
648
+ fixableWarningCount: stats.fixableWarningCount,
649
+ usedDeprecatedRules
566
650
  };
567
651
  }
568
652
 
@@ -585,22 +669,34 @@ class CLIEngine {
585
669
  const resolvedFilename = filename && !path.isAbsolute(filename)
586
670
  ? path.resolve(options.cwd, filename)
587
671
  : filename;
672
+ let usedDeprecatedRules;
588
673
 
589
674
  if (resolvedFilename && ignoredPaths.contains(resolvedFilename)) {
590
675
  if (warnIgnored) {
591
676
  results.push(createIgnoreResult(resolvedFilename, options.cwd));
592
677
  }
678
+ usedDeprecatedRules = [];
593
679
  } else {
594
- results.push(
595
- processText(
596
- text,
597
- configHelper,
598
- resolvedFilename,
599
- options.fix,
600
- options.allowInlineConfig,
601
- options.reportUnusedDisableDirectives,
602
- this.linter
603
- )
680
+
681
+ // if there's a cache, populate it
682
+ if ("_rulesCache" in this) {
683
+ this._rulesCache = this.getRules();
684
+ }
685
+
686
+ const { result, config } = processText(
687
+ text,
688
+ configHelper,
689
+ resolvedFilename,
690
+ options.fix,
691
+ options.allowInlineConfig,
692
+ options.reportUnusedDisableDirectives,
693
+ this.linter
694
+ );
695
+
696
+ results.push(result);
697
+ usedDeprecatedRules = createRuleDeprecationWarnings(
698
+ Object.keys(config.rules).filter(rule => ConfigOps.getRuleSeverity(config.rules[rule])),
699
+ this.getRules()
604
700
  );
605
701
  }
606
702
 
@@ -611,7 +707,8 @@ class CLIEngine {
611
707
  errorCount: stats.errorCount,
612
708
  warningCount: stats.warningCount,
613
709
  fixableErrorCount: stats.fixableErrorCount,
614
- fixableWarningCount: stats.fixableWarningCount
710
+ fixableWarningCount: stats.fixableWarningCount,
711
+ usedDeprecatedRules
615
712
  };
616
713
  }
617
714
 
package/lib/cli.js CHANGED
@@ -64,6 +64,7 @@ function translateOptions(cliOptions) {
64
64
  cacheFile: cliOptions.cacheFile,
65
65
  cacheLocation: cliOptions.cacheLocation,
66
66
  fix: (cliOptions.fix || cliOptions.fixDryRun) && (cliOptions.quiet ? quietFixPredicate : true),
67
+ fixTypes: cliOptions.fixType,
67
68
  allowInlineConfig: cliOptions.inlineConfig,
68
69
  reportUnusedDisableDirectives: cliOptions.reportUnusedDisableDirectives
69
70
  };
@@ -187,8 +188,12 @@ const cli = {
187
188
  return 2;
188
189
  }
189
190
 
190
- const engine = new CLIEngine(translateOptions(currentOptions));
191
+ if (currentOptions.fixType && !currentOptions.fix && !currentOptions.fixDryRun) {
192
+ log.error("The --fix-type option requires either --fix or --fix-dry-run.");
193
+ return 2;
194
+ }
191
195
 
196
+ const engine = new CLIEngine(translateOptions(currentOptions));
192
197
  const report = useStdin ? engine.executeOnText(text, currentOptions.stdinFilename, true) : engine.executeOnFiles(files);
193
198
 
194
199
  if (currentOptions.fix) {
@@ -102,7 +102,6 @@ class Registry {
102
102
  *
103
103
  * The length of the returned array will be <= MAX_CONFIG_COMBINATIONS.
104
104
  *
105
- * @param {Object} registry The autoconfig registry
106
105
  * @returns {Object[]} "rules" configurations to use for linting
107
106
  */
108
107
  buildRuleSets() {
@@ -37,9 +37,9 @@ function explodeArray(xs) {
37
37
  * For example:
38
38
  * combineArrays([a, [b, c]], [x, y]); // -> [[a, x], [a, y], [b, c, x], [b, c, y]]
39
39
  *
40
- * @param {array} arr1 The first array to combine.
41
- * @param {array} arr2 The second array to combine.
42
- * @returns {array} A mixture of the elements of the first and second arrays.
40
+ * @param {Array} arr1 The first array to combine.
41
+ * @param {Array} arr2 The second array to combine.
42
+ * @returns {Array} A mixture of the elements of the first and second arrays.
43
43
  */
44
44
  function combineArrays(arr1, arr2) {
45
45
  const res = [];
@@ -268,7 +268,7 @@ class RuleConfigSet {
268
268
  /**
269
269
  * Generate valid rule configurations based on a schema object
270
270
  * @param {Object} schema A rule's schema object
271
- * @returns {array[]} Valid rule configurations
271
+ * @returns {Array[]} Valid rule configurations
272
272
  */
273
273
  function generateConfigsFromSchema(schema) {
274
274
  const configSet = new RuleConfigSet();
@@ -83,7 +83,7 @@ function validateRuleSeverity(options) {
83
83
  /**
84
84
  * Validates the non-severity options passed to a rule, based on its schema.
85
85
  * @param {{create: Function}} rule The rule to validate
86
- * @param {array} localOptions The options for the rule, excluding severity
86
+ * @param {Array} localOptions The options for the rule, excluding severity
87
87
  * @returns {void}
88
88
  */
89
89
  function validateRuleSchema(rule, localOptions) {
@@ -111,7 +111,7 @@ function validateRuleSchema(rule, localOptions) {
111
111
  * Validates a rule's options against its schema.
112
112
  * @param {{create: Function}|null} rule The rule that the config is being validated for
113
113
  * @param {string} ruleId The rule's unique name.
114
- * @param {array|number} options The given options for the rule.
114
+ * @param {Array|number} options The given options for the rule.
115
115
  * @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
116
116
  * no source is prepended to the message.
117
117
  * @returns {void}
package/lib/config.js CHANGED
@@ -15,8 +15,7 @@ const path = require("path"),
15
15
  ConfigFile = require("./config/config-file"),
16
16
  ConfigCache = require("./config/config-cache"),
17
17
  Plugins = require("./config/plugins"),
18
- FileFinder = require("./util/file-finder"),
19
- isResolvable = require("is-resolvable");
18
+ FileFinder = require("./util/file-finder");
20
19
 
21
20
  const debug = require("debug")("eslint:config");
22
21
 
@@ -41,6 +40,20 @@ function hasRules(options) {
41
40
  return options.rules && Object.keys(options.rules).length > 0;
42
41
  }
43
42
 
43
+ /**
44
+ * Determines if a module is can be resolved.
45
+ * @param {string} moduleId The ID (name) of the module
46
+ * @returns {boolean} True if it is resolvable; False otherwise.
47
+ */
48
+ function isResolvable(moduleId) {
49
+ try {
50
+ require.resolve(moduleId);
51
+ return true;
52
+ } catch (err) {
53
+ return false;
54
+ }
55
+ }
56
+
44
57
  //------------------------------------------------------------------------------
45
58
  // API
46
59
  //------------------------------------------------------------------------------