eslint 4.12.1 → 4.15.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 +49 -0
  2. package/README.md +3 -3
  3. package/lib/cli-engine.js +4 -0
  4. package/lib/linter.js +78 -35
  5. package/lib/options.js +47 -41
  6. package/lib/report-translator.js +34 -13
  7. package/lib/rules/.eslintrc.yml +1 -0
  8. package/lib/rules/accessor-pairs.js +2 -1
  9. package/lib/rules/array-bracket-newline.js +2 -1
  10. package/lib/rules/array-bracket-spacing.js +2 -1
  11. package/lib/rules/array-callback-return.js +18 -3
  12. package/lib/rules/array-element-newline.js +2 -1
  13. package/lib/rules/arrow-body-style.js +15 -2
  14. package/lib/rules/arrow-parens.js +2 -1
  15. package/lib/rules/arrow-spacing.js +2 -1
  16. package/lib/rules/block-scoped-var.js +2 -1
  17. package/lib/rules/block-spacing.js +2 -1
  18. package/lib/rules/brace-style.js +2 -1
  19. package/lib/rules/callback-return.js +2 -1
  20. package/lib/rules/camelcase.js +29 -17
  21. package/lib/rules/capitalized-comments.js +2 -1
  22. package/lib/rules/class-methods-use-this.js +2 -1
  23. package/lib/rules/comma-dangle.js +2 -1
  24. package/lib/rules/comma-spacing.js +2 -1
  25. package/lib/rules/comma-style.js +2 -1
  26. package/lib/rules/complexity.js +3 -16
  27. package/lib/rules/computed-property-spacing.js +2 -1
  28. package/lib/rules/consistent-return.js +2 -1
  29. package/lib/rules/consistent-this.js +2 -1
  30. package/lib/rules/constructor-super.js +2 -1
  31. package/lib/rules/curly.js +2 -1
  32. package/lib/rules/default-case.js +2 -1
  33. package/lib/rules/dot-location.js +2 -1
  34. package/lib/rules/dot-notation.js +2 -1
  35. package/lib/rules/eol-last.js +10 -1
  36. package/lib/rules/eqeqeq.js +2 -1
  37. package/lib/rules/for-direction.js +2 -1
  38. package/lib/rules/func-call-spacing.js +2 -1
  39. package/lib/rules/func-name-matching.js +2 -1
  40. package/lib/rules/func-names.js +2 -1
  41. package/lib/rules/func-style.js +2 -1
  42. package/lib/rules/function-paren-newline.js +2 -1
  43. package/lib/rules/generator-star-spacing.js +2 -1
  44. package/lib/rules/getter-return.js +2 -1
  45. package/lib/rules/global-require.js +2 -1
  46. package/lib/rules/guard-for-in.js +2 -1
  47. package/lib/rules/handle-callback-err.js +2 -1
  48. package/lib/rules/id-blacklist.js +2 -1
  49. package/lib/rules/id-length.js +2 -1
  50. package/lib/rules/id-match.js +2 -1
  51. package/lib/rules/implicit-arrow-linebreak.js +2 -1
  52. package/lib/rules/indent-legacy.js +2 -1
  53. package/lib/rules/indent.js +13 -2
  54. package/lib/rules/init-declarations.js +2 -1
  55. package/lib/rules/jsx-quotes.js +2 -1
  56. package/lib/rules/key-spacing.js +2 -1
  57. package/lib/rules/keyword-spacing.js +2 -1
  58. package/lib/rules/line-comment-position.js +2 -1
  59. package/lib/rules/linebreak-style.js +2 -1
  60. package/lib/rules/lines-around-comment.js +2 -1
  61. package/lib/rules/lines-around-directive.js +2 -1
  62. package/lib/rules/lines-between-class-members.js +53 -4
  63. package/lib/rules/max-depth.js +2 -1
  64. package/lib/rules/max-len.js +2 -1
  65. package/lib/rules/max-lines.js +2 -1
  66. package/lib/rules/max-nested-callbacks.js +2 -1
  67. package/lib/rules/max-params.js +2 -1
  68. package/lib/rules/max-statements-per-line.js +2 -1
  69. package/lib/rules/max-statements.js +2 -1
  70. package/lib/rules/multiline-comment-style.js +2 -1
  71. package/lib/rules/multiline-ternary.js +2 -1
  72. package/lib/rules/new-cap.js +2 -1
  73. package/lib/rules/new-parens.js +2 -1
  74. package/lib/rules/newline-after-var.js +2 -1
  75. package/lib/rules/newline-before-return.js +2 -1
  76. package/lib/rules/newline-per-chained-call.js +2 -1
  77. package/lib/rules/no-alert.js +2 -1
  78. package/lib/rules/no-array-constructor.js +2 -1
  79. package/lib/rules/no-await-in-loop.js +2 -1
  80. package/lib/rules/no-bitwise.js +2 -1
  81. package/lib/rules/no-buffer-constructor.js +2 -1
  82. package/lib/rules/no-caller.js +2 -1
  83. package/lib/rules/no-case-declarations.js +2 -1
  84. package/lib/rules/no-catch-shadow.js +2 -1
  85. package/lib/rules/no-class-assign.js +2 -1
  86. package/lib/rules/no-compare-neg-zero.js +2 -1
  87. package/lib/rules/no-cond-assign.js +2 -1
  88. package/lib/rules/no-confusing-arrow.js +2 -1
  89. package/lib/rules/no-console.js +2 -1
  90. package/lib/rules/no-const-assign.js +2 -1
  91. package/lib/rules/no-constant-condition.js +2 -1
  92. package/lib/rules/no-continue.js +2 -1
  93. package/lib/rules/no-control-regex.js +2 -1
  94. package/lib/rules/no-debugger.js +2 -1
  95. package/lib/rules/no-delete-var.js +2 -1
  96. package/lib/rules/no-div-regex.js +2 -1
  97. package/lib/rules/no-dupe-args.js +2 -1
  98. package/lib/rules/no-dupe-class-members.js +2 -1
  99. package/lib/rules/no-dupe-keys.js +2 -1
  100. package/lib/rules/no-duplicate-case.js +2 -1
  101. package/lib/rules/no-duplicate-imports.js +2 -1
  102. package/lib/rules/no-else-return.js +2 -1
  103. package/lib/rules/no-empty-character-class.js +2 -1
  104. package/lib/rules/no-empty-function.js +2 -1
  105. package/lib/rules/no-empty-pattern.js +2 -1
  106. package/lib/rules/no-empty.js +2 -1
  107. package/lib/rules/no-eq-null.js +2 -1
  108. package/lib/rules/no-eval.js +2 -1
  109. package/lib/rules/no-ex-assign.js +2 -1
  110. package/lib/rules/no-extend-native.js +2 -1
  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 +3 -2
  115. package/lib/rules/no-extra-semi.js +2 -1
  116. package/lib/rules/no-fallthrough.js +2 -1
  117. package/lib/rules/no-floating-decimal.js +2 -1
  118. package/lib/rules/no-func-assign.js +2 -1
  119. package/lib/rules/no-global-assign.js +2 -1
  120. package/lib/rules/no-implicit-coercion.js +2 -1
  121. package/lib/rules/no-implicit-globals.js +2 -1
  122. package/lib/rules/no-implied-eval.js +2 -1
  123. package/lib/rules/no-inline-comments.js +2 -1
  124. package/lib/rules/no-inner-declarations.js +2 -1
  125. package/lib/rules/no-invalid-regexp.js +2 -1
  126. package/lib/rules/no-invalid-this.js +2 -1
  127. package/lib/rules/no-irregular-whitespace.js +2 -1
  128. package/lib/rules/no-iterator.js +2 -1
  129. package/lib/rules/no-label-var.js +2 -1
  130. package/lib/rules/no-labels.js +2 -1
  131. package/lib/rules/no-lone-blocks.js +2 -1
  132. package/lib/rules/no-lonely-if.js +2 -1
  133. package/lib/rules/no-loop-func.js +2 -1
  134. package/lib/rules/no-magic-numbers.js +2 -1
  135. package/lib/rules/no-mixed-operators.js +2 -1
  136. package/lib/rules/no-mixed-requires.js +2 -1
  137. package/lib/rules/no-mixed-spaces-and-tabs.js +2 -1
  138. package/lib/rules/no-multi-assign.js +2 -1
  139. package/lib/rules/no-multi-spaces.js +2 -1
  140. package/lib/rules/no-multi-str.js +2 -1
  141. package/lib/rules/no-multiple-empty-lines.js +2 -1
  142. package/lib/rules/no-native-reassign.js +2 -1
  143. package/lib/rules/no-negated-condition.js +2 -1
  144. package/lib/rules/no-negated-in-lhs.js +2 -1
  145. package/lib/rules/no-nested-ternary.js +2 -1
  146. package/lib/rules/no-new-func.js +2 -1
  147. package/lib/rules/no-new-object.js +2 -1
  148. package/lib/rules/no-new-require.js +2 -1
  149. package/lib/rules/no-new-symbol.js +2 -1
  150. package/lib/rules/no-new-wrappers.js +2 -1
  151. package/lib/rules/no-new.js +2 -1
  152. package/lib/rules/no-obj-calls.js +2 -1
  153. package/lib/rules/no-octal-escape.js +2 -1
  154. package/lib/rules/no-octal.js +2 -1
  155. package/lib/rules/no-param-reassign.js +2 -1
  156. package/lib/rules/no-path-concat.js +2 -1
  157. package/lib/rules/no-plusplus.js +2 -1
  158. package/lib/rules/no-process-env.js +2 -1
  159. package/lib/rules/no-process-exit.js +2 -1
  160. package/lib/rules/no-proto.js +2 -1
  161. package/lib/rules/no-prototype-builtins.js +2 -1
  162. package/lib/rules/no-redeclare.js +2 -1
  163. package/lib/rules/no-regex-spaces.js +2 -1
  164. package/lib/rules/no-restricted-globals.js +2 -1
  165. package/lib/rules/no-restricted-imports.js +2 -1
  166. package/lib/rules/no-restricted-modules.js +2 -1
  167. package/lib/rules/no-restricted-properties.js +2 -1
  168. package/lib/rules/no-restricted-syntax.js +2 -1
  169. package/lib/rules/no-return-assign.js +2 -1
  170. package/lib/rules/no-return-await.js +5 -1
  171. package/lib/rules/no-script-url.js +2 -1
  172. package/lib/rules/no-self-assign.js +2 -1
  173. package/lib/rules/no-self-compare.js +2 -1
  174. package/lib/rules/no-sequences.js +2 -1
  175. package/lib/rules/no-shadow-restricted-names.js +2 -1
  176. package/lib/rules/no-shadow.js +2 -1
  177. package/lib/rules/no-spaced-func.js +2 -1
  178. package/lib/rules/no-sparse-arrays.js +2 -1
  179. package/lib/rules/no-sync.js +2 -1
  180. package/lib/rules/no-tabs.js +2 -1
  181. package/lib/rules/no-template-curly-in-string.js +2 -1
  182. package/lib/rules/no-ternary.js +2 -1
  183. package/lib/rules/no-this-before-super.js +2 -1
  184. package/lib/rules/no-throw-literal.js +2 -1
  185. package/lib/rules/no-trailing-spaces.js +2 -1
  186. package/lib/rules/no-undef-init.js +2 -1
  187. package/lib/rules/no-undef.js +2 -1
  188. package/lib/rules/no-undefined.js +2 -1
  189. package/lib/rules/no-underscore-dangle.js +2 -1
  190. package/lib/rules/no-unexpected-multiline.js +2 -1
  191. package/lib/rules/no-unmodified-loop-condition.js +81 -79
  192. package/lib/rules/no-unneeded-ternary.js +2 -1
  193. package/lib/rules/no-unreachable.js +2 -1
  194. package/lib/rules/no-unsafe-finally.js +2 -1
  195. package/lib/rules/no-unsafe-negation.js +2 -1
  196. package/lib/rules/no-unused-expressions.js +2 -1
  197. package/lib/rules/no-unused-labels.js +2 -1
  198. package/lib/rules/no-unused-vars.js +10 -14
  199. package/lib/rules/no-use-before-define.js +2 -1
  200. package/lib/rules/no-useless-call.js +2 -1
  201. package/lib/rules/no-useless-computed-key.js +2 -1
  202. package/lib/rules/no-useless-concat.js +2 -1
  203. package/lib/rules/no-useless-constructor.js +2 -1
  204. package/lib/rules/no-useless-escape.js +2 -1
  205. package/lib/rules/no-useless-rename.js +2 -1
  206. package/lib/rules/no-useless-return.js +2 -1
  207. package/lib/rules/no-var.js +2 -1
  208. package/lib/rules/no-void.js +2 -1
  209. package/lib/rules/no-warning-comments.js +2 -1
  210. package/lib/rules/no-whitespace-before-property.js +2 -1
  211. package/lib/rules/no-with.js +2 -1
  212. package/lib/rules/nonblock-statement-body-position.js +2 -1
  213. package/lib/rules/object-curly-newline.js +2 -1
  214. package/lib/rules/object-curly-spacing.js +2 -1
  215. package/lib/rules/object-property-newline.js +2 -1
  216. package/lib/rules/object-shorthand.js +2 -1
  217. package/lib/rules/one-var-declaration-per-line.js +2 -1
  218. package/lib/rules/one-var.js +42 -8
  219. package/lib/rules/operator-assignment.js +2 -1
  220. package/lib/rules/operator-linebreak.js +2 -1
  221. package/lib/rules/padded-blocks.js +2 -1
  222. package/lib/rules/padding-line-between-statements.js +2 -1
  223. package/lib/rules/prefer-arrow-callback.js +2 -1
  224. package/lib/rules/prefer-const.js +2 -1
  225. package/lib/rules/prefer-destructuring.js +2 -1
  226. package/lib/rules/prefer-numeric-literals.js +2 -1
  227. package/lib/rules/prefer-promise-reject-errors.js +2 -1
  228. package/lib/rules/prefer-reflect.js +2 -1
  229. package/lib/rules/prefer-rest-params.js +2 -1
  230. package/lib/rules/prefer-spread.js +2 -1
  231. package/lib/rules/prefer-template.js +2 -1
  232. package/lib/rules/quote-props.js +2 -1
  233. package/lib/rules/quotes.js +2 -1
  234. package/lib/rules/radix.js +2 -1
  235. package/lib/rules/require-await.js +2 -1
  236. package/lib/rules/require-jsdoc.js +2 -1
  237. package/lib/rules/require-yield.js +2 -1
  238. package/lib/rules/rest-spread-spacing.js +2 -1
  239. package/lib/rules/semi-spacing.js +2 -1
  240. package/lib/rules/semi-style.js +2 -1
  241. package/lib/rules/semi.js +2 -1
  242. package/lib/rules/sort-imports.js +2 -1
  243. package/lib/rules/sort-keys.js +2 -1
  244. package/lib/rules/sort-vars.js +2 -1
  245. package/lib/rules/space-before-blocks.js +2 -1
  246. package/lib/rules/space-before-function-paren.js +2 -1
  247. package/lib/rules/space-in-parens.js +2 -1
  248. package/lib/rules/space-infix-ops.js +2 -1
  249. package/lib/rules/space-unary-ops.js +2 -1
  250. package/lib/rules/spaced-comment.js +2 -1
  251. package/lib/rules/strict.js +2 -1
  252. package/lib/rules/switch-colon-spacing.js +2 -1
  253. package/lib/rules/symbol-description.js +2 -1
  254. package/lib/rules/template-curly-spacing.js +2 -1
  255. package/lib/rules/template-tag-spacing.js +2 -1
  256. package/lib/rules/unicode-bom.js +2 -1
  257. package/lib/rules/use-isnan.js +2 -1
  258. package/lib/rules/valid-jsdoc.js +2 -1
  259. package/lib/rules/valid-typeof.js +2 -1
  260. package/lib/rules/vars-on-top.js +2 -1
  261. package/lib/rules/wrap-iife.js +2 -1
  262. package/lib/rules/wrap-regex.js +2 -1
  263. package/lib/rules/yield-star-spacing.js +2 -1
  264. package/lib/rules/yoda.js +2 -1
  265. package/lib/testers/rule-tester.js +63 -30
  266. package/lib/util/interpolate.js +24 -0
  267. package/lib/util/source-code.js +41 -6
  268. package/lib/util/traverser.js +163 -15
  269. package/package.json +3 -3
@@ -19,7 +19,8 @@ module.exports = {
19
19
  docs: {
20
20
  description: "require parentheses around arrow function arguments",
21
21
  category: "ECMAScript 6",
22
- recommended: false
22
+ recommended: false,
23
+ url: "https://eslint.org/docs/rules/arrow-parens"
23
24
  },
24
25
 
25
26
  fixable: "code",
@@ -19,7 +19,8 @@ module.exports = {
19
19
  docs: {
20
20
  description: "enforce consistent spacing before and after the arrow in arrow functions",
21
21
  category: "ECMAScript 6",
22
- recommended: false
22
+ recommended: false,
23
+ url: "https://eslint.org/docs/rules/arrow-spacing"
23
24
  },
24
25
 
25
26
  fixable: "whitespace",
@@ -13,7 +13,8 @@ module.exports = {
13
13
  docs: {
14
14
  description: "enforce the use of variables within the scope they are defined",
15
15
  category: "Best Practices",
16
- recommended: false
16
+ recommended: false,
17
+ url: "https://eslint.org/docs/rules/block-scoped-var"
17
18
  },
18
19
 
19
20
  schema: []
@@ -16,7 +16,8 @@ module.exports = {
16
16
  docs: {
17
17
  description: "disallow or enforce spaces inside of blocks after opening block and before closing block",
18
18
  category: "Stylistic Issues",
19
- recommended: false
19
+ recommended: false,
20
+ url: "https://eslint.org/docs/rules/block-spacing"
20
21
  },
21
22
 
22
23
  fixable: "whitespace",
@@ -16,7 +16,8 @@ module.exports = {
16
16
  docs: {
17
17
  description: "enforce consistent brace style for blocks",
18
18
  category: "Stylistic Issues",
19
- recommended: false
19
+ recommended: false,
20
+ url: "https://eslint.org/docs/rules/brace-style"
20
21
  },
21
22
 
22
23
  schema: [
@@ -13,7 +13,8 @@ module.exports = {
13
13
  docs: {
14
14
  description: "require `return` statements after callbacks",
15
15
  category: "Node.js and CommonJS",
16
- recommended: false
16
+ recommended: false,
17
+ url: "https://eslint.org/docs/rules/callback-return"
17
18
  },
18
19
 
19
20
  schema: [{
@@ -14,7 +14,8 @@ module.exports = {
14
14
  docs: {
15
15
  description: "enforce camelcase naming convention",
16
16
  category: "Stylistic Issues",
17
- recommended: false
17
+ recommended: false,
18
+ url: "https://eslint.org/docs/rules/camelcase"
18
19
  },
19
20
 
20
21
  schema: [
@@ -92,34 +93,45 @@ module.exports = {
92
93
  }
93
94
 
94
95
  // Always report underscored object names
95
- if (node.parent.object.type === "Identifier" &&
96
- node.parent.object.name === node.name &&
97
- isUnderscored(name)) {
96
+ if (node.parent.object.type === "Identifier" && node.parent.object.name === node.name && isUnderscored(name)) {
98
97
  report(node);
99
98
 
100
99
  // Report AssignmentExpressions only if they are the left side of the assignment
101
- } else if (effectiveParent.type === "AssignmentExpression" &&
102
- isUnderscored(name) &&
103
- (effectiveParent.right.type !== "MemberExpression" ||
104
- effectiveParent.left.type === "MemberExpression" &&
105
- effectiveParent.left.property.name === node.name)) {
100
+ } else if (effectiveParent.type === "AssignmentExpression" && isUnderscored(name) && (effectiveParent.right.type !== "MemberExpression" || effectiveParent.left.type === "MemberExpression" && effectiveParent.left.property.name === node.name)) {
106
101
  report(node);
107
102
  }
108
103
 
109
- // Properties have their own rules
110
- } else if (node.parent.type === "Property") {
104
+ /*
105
+ * Properties have their own rules, and
106
+ * AssignmentPattern nodes can be treated like Properties:
107
+ * e.g.: const { no_camelcased = false } = bar;
108
+ */
109
+ } else if (node.parent.type === "Property" || node.parent.type === "AssignmentPattern") {
111
110
 
112
- // "never" check properties
113
- if (properties === "never") {
114
- return;
111
+ if (node.parent.parent && node.parent.parent.type === "ObjectPattern") {
112
+
113
+ if (node.parent.shorthand && node.parent.value.left && isUnderscored(name)) {
114
+
115
+ report(node);
116
+ }
117
+
118
+ // prevent checking righthand side of destructured object
119
+ if (node.parent.key === node && node.parent.value !== node) {
120
+ return;
121
+ }
122
+
123
+ if (node.parent.value.name && isUnderscored(name)) {
124
+ report(node);
125
+ }
115
126
  }
116
127
 
117
- if (node.parent.parent && node.parent.parent.type === "ObjectPattern" &&
118
- node.parent.key === node && node.parent.value !== node) {
128
+ // "never" check properties
129
+ if (properties === "never") {
119
130
  return;
120
131
  }
121
132
 
122
- if (isUnderscored(name) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type)) {
133
+ // don't check right hand side of AssignmentExpression to prevent duplicate warnings
134
+ if (isUnderscored(name) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type) && !(node.parent.right === node)) {
123
135
  report(node);
124
136
  }
125
137
 
@@ -113,7 +113,8 @@ module.exports = {
113
113
  docs: {
114
114
  description: "enforce or disallow capitalization of the first letter of a comment",
115
115
  category: "Stylistic Issues",
116
- recommended: false
116
+ recommended: false,
117
+ url: "https://eslint.org/docs/rules/capitalized-comments"
117
118
  },
118
119
  fixable: "code",
119
120
  schema: [
@@ -14,7 +14,8 @@ module.exports = {
14
14
  docs: {
15
15
  description: "enforce that class methods utilize `this`",
16
16
  category: "Best Practices",
17
- recommended: false
17
+ recommended: false,
18
+ url: "https://eslint.org/docs/rules/class-methods-use-this"
18
19
  },
19
20
  schema: [{
20
21
  type: "object",
@@ -79,7 +79,8 @@ module.exports = {
79
79
  docs: {
80
80
  description: "require or disallow trailing commas",
81
81
  category: "Stylistic Issues",
82
- recommended: false
82
+ recommended: false,
83
+ url: "https://eslint.org/docs/rules/comma-dangle"
83
84
  },
84
85
  fixable: "code",
85
86
  schema: {
@@ -15,7 +15,8 @@ module.exports = {
15
15
  docs: {
16
16
  description: "enforce consistent spacing before and after commas",
17
17
  category: "Stylistic Issues",
18
- recommended: false
18
+ recommended: false,
19
+ url: "https://eslint.org/docs/rules/comma-spacing"
19
20
  },
20
21
 
21
22
  fixable: "whitespace",
@@ -16,7 +16,8 @@ module.exports = {
16
16
  docs: {
17
17
  description: "enforce consistent comma style",
18
18
  category: "Stylistic Issues",
19
- recommended: false
19
+ recommended: false,
20
+ url: "https://eslint.org/docs/rules/comma-style"
20
21
  },
21
22
  fixable: "code",
22
23
  schema: [
@@ -23,7 +23,8 @@ module.exports = {
23
23
  docs: {
24
24
  description: "enforce a maximum cyclomatic complexity allowed in a program",
25
25
  category: "Best Practices",
26
- recommended: false
26
+ recommended: false,
27
+ url: "https://eslint.org/docs/rules/complexity"
27
28
  },
28
29
 
29
30
  schema: [
@@ -126,20 +127,6 @@ module.exports = {
126
127
  }
127
128
  }
128
129
 
129
- /**
130
- * Increase the logical path complexity in context
131
- * @param {ASTNode} node node to evaluate
132
- * @returns {void}
133
- * @private
134
- */
135
- function increaseLogicalComplexity(node) {
136
-
137
- // Avoiding &&
138
- if (node.operator === "||") {
139
- increaseComplexity();
140
- }
141
- }
142
-
143
130
  //--------------------------------------------------------------------------
144
131
  // Public API
145
132
  //--------------------------------------------------------------------------
@@ -154,7 +141,7 @@ module.exports = {
154
141
 
155
142
  CatchClause: increaseComplexity,
156
143
  ConditionalExpression: increaseComplexity,
157
- LogicalExpression: increaseLogicalComplexity,
144
+ LogicalExpression: increaseComplexity,
158
145
  ForStatement: increaseComplexity,
159
146
  ForInStatement: increaseComplexity,
160
147
  ForOfStatement: increaseComplexity,
@@ -15,7 +15,8 @@ module.exports = {
15
15
  docs: {
16
16
  description: "enforce consistent spacing inside computed property brackets",
17
17
  category: "Stylistic Issues",
18
- recommended: false
18
+ recommended: false,
19
+ url: "https://eslint.org/docs/rules/computed-property-spacing"
19
20
  },
20
21
 
21
22
  fixable: "whitespace",
@@ -56,7 +56,8 @@ module.exports = {
56
56
  docs: {
57
57
  description: "require `return` statements to either always or never specify values",
58
58
  category: "Best Practices",
59
- recommended: false
59
+ recommended: false,
60
+ url: "https://eslint.org/docs/rules/consistent-return"
60
61
  },
61
62
 
62
63
  schema: [{
@@ -13,7 +13,8 @@ module.exports = {
13
13
  docs: {
14
14
  description: "enforce consistent naming when capturing the current execution context",
15
15
  category: "Stylistic Issues",
16
- recommended: false
16
+ recommended: false,
17
+ url: "https://eslint.org/docs/rules/consistent-this"
17
18
  },
18
19
 
19
20
  schema: {
@@ -95,7 +95,8 @@ module.exports = {
95
95
  docs: {
96
96
  description: "require `super()` calls in constructors",
97
97
  category: "ECMAScript 6",
98
- recommended: true
98
+ recommended: true,
99
+ url: "https://eslint.org/docs/rules/constructor-super"
99
100
  },
100
101
 
101
102
  schema: []
@@ -19,7 +19,8 @@ module.exports = {
19
19
  docs: {
20
20
  description: "enforce consistent brace style for all control statements",
21
21
  category: "Best Practices",
22
- recommended: false
22
+ recommended: false,
23
+ url: "https://eslint.org/docs/rules/curly"
23
24
  },
24
25
 
25
26
  schema: {
@@ -15,7 +15,8 @@ module.exports = {
15
15
  docs: {
16
16
  description: "require `default` cases in `switch` statements",
17
17
  category: "Best Practices",
18
- recommended: false
18
+ recommended: false,
19
+ url: "https://eslint.org/docs/rules/default-case"
19
20
  },
20
21
 
21
22
  schema: [{
@@ -16,7 +16,8 @@ module.exports = {
16
16
  docs: {
17
17
  description: "enforce consistent newlines before and after dots",
18
18
  category: "Best Practices",
19
- recommended: false
19
+ recommended: false,
20
+ url: "https://eslint.org/docs/rules/dot-location"
20
21
  },
21
22
 
22
23
  schema: [
@@ -22,7 +22,8 @@ module.exports = {
22
22
  docs: {
23
23
  description: "enforce dot notation whenever possible",
24
24
  category: "Best Practices",
25
- recommended: false
25
+ recommended: false,
26
+ url: "https://eslint.org/docs/rules/dot-notation"
26
27
  },
27
28
 
28
29
  schema: [
@@ -19,7 +19,8 @@ module.exports = {
19
19
  docs: {
20
20
  description: "require or disallow newline at the end of files",
21
21
  category: "Stylistic Issues",
22
- recommended: false
22
+ recommended: false,
23
+ url: "https://eslint.org/docs/rules/eol-last"
23
24
  },
24
25
  fixable: "whitespace",
25
26
  schema: [
@@ -46,6 +47,14 @@ module.exports = {
46
47
  CRLF = `\r${LF}`,
47
48
  endsWithNewline = lodash.endsWith(src, LF);
48
49
 
50
+ /*
51
+ * Empty source is always valid: No content in file so we don't
52
+ * need to lint for a newline on the last line of content.
53
+ */
54
+ if (!src.length) {
55
+ return;
56
+ }
57
+
49
58
  let mode = context.options[0] || "always",
50
59
  appendCRLF = false;
51
60
 
@@ -20,7 +20,8 @@ module.exports = {
20
20
  docs: {
21
21
  description: "require the use of `===` and `!==`",
22
22
  category: "Best Practices",
23
- recommended: false
23
+ recommended: false,
24
+ url: "https://eslint.org/docs/rules/eqeqeq"
24
25
  },
25
26
 
26
27
  schema: {
@@ -14,7 +14,8 @@ module.exports = {
14
14
  docs: {
15
15
  description: "enforce \"for\" loop update clause moving the counter in the right direction.",
16
16
  category: "Possible Errors",
17
- recommended: false
17
+ recommended: false,
18
+ url: "https://eslint.org/docs/rules/for-direction"
18
19
  },
19
20
  fixable: null,
20
21
  schema: []
@@ -20,7 +20,8 @@ module.exports = {
20
20
  docs: {
21
21
  description: "require or disallow spacing between function identifiers and their invocations",
22
22
  category: "Stylistic Issues",
23
- recommended: false
23
+ recommended: false,
24
+ url: "https://eslint.org/docs/rules/func-call-spacing"
24
25
  },
25
26
 
26
27
  fixable: "whitespace",
@@ -70,7 +70,8 @@ module.exports = {
70
70
  docs: {
71
71
  description: "require function names to match the name of the variable or property to which they are assigned",
72
72
  category: "Stylistic Issues",
73
- recommended: false
73
+ recommended: false,
74
+ url: "https://eslint.org/docs/rules/func-name-matching"
74
75
  },
75
76
 
76
77
  schema: {
@@ -29,7 +29,8 @@ module.exports = {
29
29
  docs: {
30
30
  description: "require or disallow named `function` expressions",
31
31
  category: "Stylistic Issues",
32
- recommended: false
32
+ recommended: false,
33
+ url: "https://eslint.org/docs/rules/func-names"
33
34
  },
34
35
 
35
36
  schema: [
@@ -13,7 +13,8 @@ module.exports = {
13
13
  docs: {
14
14
  description: "enforce the consistent use of either `function` declarations or expressions",
15
15
  category: "Stylistic Issues",
16
- recommended: false
16
+ recommended: false,
17
+ url: "https://eslint.org/docs/rules/func-style"
17
18
  },
18
19
 
19
20
  schema: [
@@ -19,7 +19,8 @@ module.exports = {
19
19
  docs: {
20
20
  description: "enforce consistent line breaks inside function parentheses",
21
21
  category: "Stylistic Issues",
22
- recommended: false
22
+ recommended: false,
23
+ url: "https://eslint.org/docs/rules/function-paren-newline"
23
24
  },
24
25
  fixable: "whitespace",
25
26
  schema: [
@@ -30,7 +30,8 @@ module.exports = {
30
30
  docs: {
31
31
  description: "enforce consistent spacing around `*` operators in generator functions",
32
32
  category: "ECMAScript 6",
33
- recommended: false
33
+ recommended: false,
34
+ url: "https://eslint.org/docs/rules/generator-star-spacing"
34
35
  },
35
36
 
36
37
  fixable: "whitespace",
@@ -47,7 +47,8 @@ module.exports = {
47
47
  docs: {
48
48
  description: "enforce `return` statements in getters",
49
49
  category: "Possible Errors",
50
- recommended: false
50
+ recommended: false,
51
+ url: "https://eslint.org/docs/rules/getter-return"
51
52
  },
52
53
  fixable: null,
53
54
  schema: [
@@ -51,7 +51,8 @@ module.exports = {
51
51
  docs: {
52
52
  description: "require `require()` calls to be placed at top-level module scope",
53
53
  category: "Node.js and CommonJS",
54
- recommended: false
54
+ recommended: false,
55
+ url: "https://eslint.org/docs/rules/global-require"
55
56
  },
56
57
 
57
58
  schema: []
@@ -14,7 +14,8 @@ module.exports = {
14
14
  docs: {
15
15
  description: "require `for-in` loops to include an `if` statement",
16
16
  category: "Best Practices",
17
- recommended: false
17
+ recommended: false,
18
+ url: "https://eslint.org/docs/rules/guard-for-in"
18
19
  },
19
20
 
20
21
  schema: []
@@ -14,7 +14,8 @@ module.exports = {
14
14
  docs: {
15
15
  description: "require error handling in callbacks",
16
16
  category: "Node.js and CommonJS",
17
- recommended: false
17
+ recommended: false,
18
+ url: "https://eslint.org/docs/rules/handle-callback-err"
18
19
  },
19
20
 
20
21
  schema: [
@@ -15,7 +15,8 @@ module.exports = {
15
15
  docs: {
16
16
  description: "disallow specified identifiers",
17
17
  category: "Stylistic Issues",
18
- recommended: false
18
+ recommended: false,
19
+ url: "https://eslint.org/docs/rules/id-blacklist"
19
20
  },
20
21
 
21
22
  schema: {
@@ -15,7 +15,8 @@ module.exports = {
15
15
  docs: {
16
16
  description: "enforce minimum and maximum identifier lengths",
17
17
  category: "Stylistic Issues",
18
- recommended: false
18
+ recommended: false,
19
+ url: "https://eslint.org/docs/rules/id-length"
19
20
  },
20
21
 
21
22
  schema: [
@@ -14,7 +14,8 @@ module.exports = {
14
14
  docs: {
15
15
  description: "require identifiers to match a specified regular expression",
16
16
  category: "Stylistic Issues",
17
- recommended: false
17
+ recommended: false,
18
+ url: "https://eslint.org/docs/rules/id-match"
18
19
  },
19
20
 
20
21
  schema: [
@@ -12,7 +12,8 @@ module.exports = {
12
12
  docs: {
13
13
  description: "enforce the location of arrow function bodies",
14
14
  category: "Stylistic Issues",
15
- recommended: false
15
+ recommended: false,
16
+ url: "https://eslint.org/docs/rules/implicit-arrow-linebreak"
16
17
  },
17
18
  fixable: "whitespace",
18
19
  schema: [
@@ -25,7 +25,8 @@ module.exports = {
25
25
  description: "enforce consistent indentation",
26
26
  category: "Stylistic Issues",
27
27
  recommended: false,
28
- replacedBy: ["indent"]
28
+ replacedBy: ["indent"],
29
+ url: "https://eslint.org/docs/rules/indent-legacy"
29
30
  },
30
31
 
31
32
  deprecated: true,
@@ -492,7 +492,8 @@ module.exports = {
492
492
  docs: {
493
493
  description: "enforce consistent indentation",
494
494
  category: "Stylistic Issues",
495
- recommended: false
495
+ recommended: false,
496
+ url: "https://eslint.org/docs/rules/indent"
496
497
  },
497
498
 
498
499
  fixable: "whitespace",
@@ -600,6 +601,9 @@ module.exports = {
600
601
  pattern: ":exit$"
601
602
  }
602
603
  }
604
+ },
605
+ ignoreComments: {
606
+ type: "boolean"
603
607
  }
604
608
  },
605
609
  additionalProperties: false
@@ -638,7 +642,8 @@ module.exports = {
638
642
  ObjectExpression: 1,
639
643
  ImportDeclaration: 1,
640
644
  flatTernaryExpressions: false,
641
- ignoredNodes: []
645
+ ignoredNodes: [],
646
+ ignoreComments: false
642
647
  };
643
648
 
644
649
  if (context.options.length) {
@@ -1457,6 +1462,12 @@ module.exports = {
1457
1462
  },
1458
1463
  "Program:exit"() {
1459
1464
 
1465
+ // If ignoreComments option is enabled, ignore all comment tokens.
1466
+ if (options.ignoreComments) {
1467
+ sourceCode.getAllComments()
1468
+ .forEach(comment => offsets.ignoreToken(comment));
1469
+ }
1470
+
1460
1471
  // Invoke the queued offset listeners for the nodes that aren't ignored.
1461
1472
  listenerCallQueue
1462
1473
  .filter(nodeInfo => !ignoredNodes.has(nodeInfo.node))
@@ -47,7 +47,8 @@ module.exports = {
47
47
  docs: {
48
48
  description: "require or disallow initialization in variable declarations",
49
49
  category: "Variables",
50
- recommended: false
50
+ recommended: false,
51
+ url: "https://eslint.org/docs/rules/init-declarations"
51
52
  },
52
53
 
53
54
  schema: {
@@ -41,7 +41,8 @@ module.exports = {
41
41
  docs: {
42
42
  description: "enforce the consistent use of either double or single quotes in JSX attributes",
43
43
  category: "Stylistic Issues",
44
- recommended: false
44
+ recommended: false,
45
+ url: "https://eslint.org/docs/rules/jsx-quotes"
45
46
  },
46
47
 
47
48
  fixable: "whitespace",
@@ -131,7 +131,8 @@ module.exports = {
131
131
  docs: {
132
132
  description: "enforce consistent spacing between keys and values in object literal properties",
133
133
  category: "Stylistic Issues",
134
- recommended: false
134
+ recommended: false,
135
+ url: "https://eslint.org/docs/rules/key-spacing"
135
136
  },
136
137
 
137
138
  fixable: "whitespace",
@@ -68,7 +68,8 @@ module.exports = {
68
68
  docs: {
69
69
  description: "enforce consistent spacing before and after keywords",
70
70
  category: "Stylistic Issues",
71
- recommended: false
71
+ recommended: false,
72
+ url: "https://eslint.org/docs/rules/keyword-spacing"
72
73
  },
73
74
 
74
75
  fixable: "whitespace",
@@ -15,7 +15,8 @@ module.exports = {
15
15
  docs: {
16
16
  description: "enforce position of line comments",
17
17
  category: "Stylistic Issues",
18
- recommended: false
18
+ recommended: false,
19
+ url: "https://eslint.org/docs/rules/line-comment-position"
19
20
  },
20
21
 
21
22
  schema: [