eslint 6.5.1 → 6.7.2

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 (197) hide show
  1. package/CHANGELOG.md +118 -0
  2. package/README.md +10 -9
  3. package/conf/config-schema.js +1 -0
  4. package/conf/default-cli-options.js +1 -1
  5. package/lib/cli-engine/cascading-config-array-factory.js +40 -14
  6. package/lib/cli-engine/cli-engine.js +49 -21
  7. package/lib/cli-engine/config-array/config-array.js +13 -4
  8. package/lib/cli-engine/config-array/config-dependency.js +2 -0
  9. package/lib/cli-engine/config-array/extracted-config.js +27 -0
  10. package/lib/cli-engine/config-array/ignore-pattern.js +231 -0
  11. package/lib/cli-engine/config-array/index.js +2 -0
  12. package/lib/cli-engine/config-array/override-tester.js +2 -0
  13. package/lib/cli-engine/config-array-factory.js +120 -2
  14. package/lib/cli-engine/file-enumerator.js +65 -34
  15. package/lib/cli-engine/formatters/html.js +1 -0
  16. package/lib/init/autoconfig.js +1 -11
  17. package/lib/init/config-file.js +0 -1
  18. package/lib/init/config-initializer.js +4 -4
  19. package/lib/init/config-rule.js +1 -5
  20. package/lib/init/npm-utils.js +0 -5
  21. package/lib/linter/code-path-analysis/code-path-analyzer.js +24 -38
  22. package/lib/linter/code-path-analysis/code-path-segment.js +17 -25
  23. package/lib/linter/code-path-analysis/code-path-state.js +40 -81
  24. package/lib/linter/code-path-analysis/code-path.js +10 -11
  25. package/lib/linter/code-path-analysis/debug-helpers.js +8 -12
  26. package/lib/linter/code-path-analysis/fork-context.js +23 -34
  27. package/lib/linter/code-path-analysis/id-generator.js +2 -2
  28. package/lib/linter/linter.js +121 -95
  29. package/lib/linter/node-event-generator.js +3 -2
  30. package/lib/linter/report-translator.js +73 -7
  31. package/lib/rule-tester/rule-tester.js +46 -14
  32. package/lib/rules/accessor-pairs.js +8 -8
  33. package/lib/rules/array-bracket-newline.js +12 -15
  34. package/lib/rules/array-bracket-spacing.js +12 -12
  35. package/lib/rules/array-callback-return.js +6 -11
  36. package/lib/rules/array-element-newline.js +5 -8
  37. package/lib/rules/arrow-parens.js +0 -1
  38. package/lib/rules/block-scoped-var.js +3 -3
  39. package/lib/rules/block-spacing.js +4 -4
  40. package/lib/rules/camelcase.js +19 -6
  41. package/lib/rules/capitalized-comments.js +0 -7
  42. package/lib/rules/class-methods-use-this.js +3 -3
  43. package/lib/rules/comma-dangle.js +20 -25
  44. package/lib/rules/comma-spacing.js +1 -1
  45. package/lib/rules/computed-property-spacing.js +14 -14
  46. package/lib/rules/consistent-return.js +4 -5
  47. package/lib/rules/consistent-this.js +5 -5
  48. package/lib/rules/constructor-super.js +14 -16
  49. package/lib/rules/curly.js +12 -9
  50. package/lib/rules/default-param-last.js +1 -0
  51. package/lib/rules/dot-location.js +11 -12
  52. package/lib/rules/func-names.js +6 -6
  53. package/lib/rules/function-call-argument-newline.js +8 -6
  54. package/lib/rules/generator-star-spacing.js +4 -9
  55. package/lib/rules/getter-return.js +4 -7
  56. package/lib/rules/grouped-accessor-pairs.js +224 -0
  57. package/lib/rules/indent.js +13 -2
  58. package/lib/rules/index.js +5 -0
  59. package/lib/rules/init-declarations.js +2 -2
  60. package/lib/rules/jsx-quotes.js +1 -1
  61. package/lib/rules/keyword-spacing.js +32 -56
  62. package/lib/rules/lines-around-directive.js +1 -1
  63. package/lib/rules/max-len.js +0 -5
  64. package/lib/rules/max-statements-per-line.js +3 -7
  65. package/lib/rules/multiline-comment-style.js +237 -106
  66. package/lib/rules/multiline-ternary.js +3 -3
  67. package/lib/rules/newline-after-var.js +6 -7
  68. package/lib/rules/newline-before-return.js +8 -9
  69. package/lib/rules/newline-per-chained-call.js +2 -4
  70. package/lib/rules/no-class-assign.js +2 -2
  71. package/lib/rules/no-compare-neg-zero.js +1 -2
  72. package/lib/rules/no-cond-assign.js +14 -4
  73. package/lib/rules/no-confusing-arrow.js +2 -2
  74. package/lib/rules/no-console.js +4 -8
  75. package/lib/rules/no-const-assign.js +1 -1
  76. package/lib/rules/no-constructor-return.js +62 -0
  77. package/lib/rules/no-dupe-args.js +1 -1
  78. package/lib/rules/no-dupe-class-members.js +3 -4
  79. package/lib/rules/no-dupe-else-if.js +122 -0
  80. package/lib/rules/no-dupe-keys.js +6 -5
  81. package/lib/rules/no-duplicate-imports.js +14 -18
  82. package/lib/rules/no-else-return.js +0 -8
  83. package/lib/rules/no-empty-function.js +2 -4
  84. package/lib/rules/no-eval.js +10 -18
  85. package/lib/rules/no-ex-assign.js +1 -1
  86. package/lib/rules/no-extra-bind.js +5 -12
  87. package/lib/rules/no-extra-boolean-cast.js +0 -2
  88. package/lib/rules/no-extra-label.js +4 -9
  89. package/lib/rules/no-extra-parens.js +17 -15
  90. package/lib/rules/no-extra-semi.js +5 -6
  91. package/lib/rules/no-fallthrough.js +6 -6
  92. package/lib/rules/no-func-assign.js +3 -3
  93. package/lib/rules/no-global-assign.js +4 -4
  94. package/lib/rules/no-implicit-coercion.js +10 -10
  95. package/lib/rules/no-implicit-globals.js +90 -8
  96. package/lib/rules/no-implied-eval.js +0 -1
  97. package/lib/rules/no-inline-comments.js +25 -11
  98. package/lib/rules/no-invalid-this.js +17 -5
  99. package/lib/rules/no-labels.js +3 -6
  100. package/lib/rules/no-lone-blocks.js +1 -1
  101. package/lib/rules/no-loop-func.js +6 -11
  102. package/lib/rules/no-magic-numbers.js +6 -6
  103. package/lib/rules/no-misleading-character-class.js +14 -7
  104. package/lib/rules/no-mixed-operators.js +13 -22
  105. package/lib/rules/no-mixed-requires.js +0 -1
  106. package/lib/rules/no-multi-spaces.js +1 -1
  107. package/lib/rules/no-native-reassign.js +4 -4
  108. package/lib/rules/no-octal-escape.js +1 -1
  109. package/lib/rules/no-param-reassign.js +28 -7
  110. package/lib/rules/no-redeclare.js +1 -1
  111. package/lib/rules/no-regex-spaces.js +0 -1
  112. package/lib/rules/no-restricted-imports.js +11 -11
  113. package/lib/rules/no-self-assign.js +12 -13
  114. package/lib/rules/no-sequences.js +3 -3
  115. package/lib/rules/no-setter-return.js +227 -0
  116. package/lib/rules/no-shadow.js +1 -4
  117. package/lib/rules/no-tabs.js +8 -2
  118. package/lib/rules/no-this-before-super.js +12 -13
  119. package/lib/rules/no-trailing-spaces.js +19 -7
  120. package/lib/rules/no-underscore-dangle.js +23 -4
  121. package/lib/rules/no-unexpected-multiline.js +8 -0
  122. package/lib/rules/no-unmodified-loop-condition.js +16 -29
  123. package/lib/rules/no-unneeded-ternary.js +3 -3
  124. package/lib/rules/no-unreachable.js +7 -7
  125. package/lib/rules/no-unsafe-finally.js +4 -7
  126. package/lib/rules/no-unsafe-negation.js +32 -9
  127. package/lib/rules/no-unused-expressions.js +11 -7
  128. package/lib/rules/no-unused-labels.js +3 -6
  129. package/lib/rules/no-unused-vars.js +22 -29
  130. package/lib/rules/no-use-before-define.js +10 -15
  131. package/lib/rules/no-useless-call.js +4 -4
  132. package/lib/rules/no-useless-computed-key.js +60 -33
  133. package/lib/rules/no-useless-concat.js +4 -4
  134. package/lib/rules/no-useless-constructor.js +14 -22
  135. package/lib/rules/no-useless-escape.js +29 -8
  136. package/lib/rules/no-useless-rename.js +7 -7
  137. package/lib/rules/no-useless-return.js +8 -15
  138. package/lib/rules/no-var.js +12 -25
  139. package/lib/rules/no-warning-comments.js +0 -1
  140. package/lib/rules/no-whitespace-before-property.js +3 -3
  141. package/lib/rules/object-curly-newline.js +7 -10
  142. package/lib/rules/object-curly-spacing.js +21 -22
  143. package/lib/rules/object-shorthand.js +1 -1
  144. package/lib/rules/one-var-declaration-per-line.js +2 -2
  145. package/lib/rules/operator-assignment.js +33 -3
  146. package/lib/rules/padded-blocks.js +1 -1
  147. package/lib/rules/padding-line-between-statements.js +0 -16
  148. package/lib/rules/prefer-arrow-callback.js +6 -6
  149. package/lib/rules/prefer-const.js +27 -28
  150. package/lib/rules/prefer-destructuring.js +1 -7
  151. package/lib/rules/prefer-exponentiation-operator.js +189 -0
  152. package/lib/rules/prefer-named-capture-group.js +0 -1
  153. package/lib/rules/prefer-numeric-literals.js +32 -4
  154. package/lib/rules/prefer-object-spread.js +7 -7
  155. package/lib/rules/prefer-rest-params.js +3 -6
  156. package/lib/rules/prefer-spread.js +4 -4
  157. package/lib/rules/prefer-template.js +5 -6
  158. package/lib/rules/quote-props.js +1 -1
  159. package/lib/rules/quotes.js +5 -6
  160. package/lib/rules/radix.js +5 -10
  161. package/lib/rules/require-await.js +10 -5
  162. package/lib/rules/require-yield.js +2 -2
  163. package/lib/rules/rest-spread-spacing.js +1 -1
  164. package/lib/rules/semi.js +6 -3
  165. package/lib/rules/sort-imports.js +3 -4
  166. package/lib/rules/sort-keys.js +1 -3
  167. package/lib/rules/space-before-blocks.js +1 -2
  168. package/lib/rules/space-in-parens.js +4 -4
  169. package/lib/rules/space-infix-ops.js +6 -6
  170. package/lib/rules/spaced-comment.js +20 -22
  171. package/lib/rules/strict.js +2 -4
  172. package/lib/rules/symbol-description.js +1 -2
  173. package/lib/rules/template-curly-spacing.js +2 -2
  174. package/lib/rules/use-isnan.js +40 -3
  175. package/lib/rules/utils/ast-utils.js +84 -85
  176. package/lib/rules/utils/fix-tracker.js +0 -6
  177. package/lib/rules/utils/lazy-loading-rule-map.js +0 -1
  178. package/lib/rules/vars-on-top.js +11 -11
  179. package/lib/shared/config-ops.js +2 -2
  180. package/lib/shared/runtime-info.js +8 -8
  181. package/lib/shared/traverser.js +2 -0
  182. package/lib/shared/types.js +9 -0
  183. package/lib/source-code/source-code.js +94 -17
  184. package/lib/source-code/token-store/backward-token-comment-cursor.js +5 -5
  185. package/lib/source-code/token-store/backward-token-cursor.js +5 -5
  186. package/lib/source-code/token-store/cursors.js +17 -19
  187. package/lib/source-code/token-store/decorative-cursor.js +1 -1
  188. package/lib/source-code/token-store/filter-cursor.js +2 -2
  189. package/lib/source-code/token-store/forward-token-comment-cursor.js +5 -5
  190. package/lib/source-code/token-store/forward-token-cursor.js +5 -5
  191. package/lib/source-code/token-store/index.js +86 -92
  192. package/lib/source-code/token-store/limit-cursor.js +2 -2
  193. package/lib/source-code/token-store/padded-token-cursor.js +7 -7
  194. package/lib/source-code/token-store/skip-cursor.js +2 -2
  195. package/lib/source-code/token-store/utils.js +9 -13
  196. package/package.json +9 -7
  197. package/lib/cli-engine/ignored-paths.js +0 -362
@@ -2,10 +2,21 @@
2
2
  * @fileoverview Rule to flag assignment in a conditional statement's test expression
3
3
  * @author Stephen Murray <spmurrayzzz>
4
4
  */
5
+
5
6
  "use strict";
6
7
 
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
7
12
  const astUtils = require("./utils/ast-utils");
8
13
 
14
+ //------------------------------------------------------------------------------
15
+ // Helpers
16
+ //------------------------------------------------------------------------------
17
+
18
+ const TEST_CONDITION_PARENT_TYPES = new Set(["IfStatement", "WhileStatement", "DoWhileStatement", "ForStatement", "ConditionalExpression"]);
19
+
9
20
  const NODE_DESCRIPTIONS = {
10
21
  DoWhileStatement: "a 'do...while' statement",
11
22
  ForStatement: "a 'for' statement",
@@ -55,7 +66,7 @@ module.exports = {
55
66
  */
56
67
  function isConditionalTestExpression(node) {
57
68
  return node.parent &&
58
- node.parent.test &&
69
+ TEST_CONDITION_PARENT_TYPES.has(node.parent.type) &&
59
70
  node === node.parent.test;
60
71
  }
61
72
 
@@ -105,8 +116,7 @@ module.exports = {
105
116
  ) {
106
117
 
107
118
  context.report({
108
- node,
109
- loc: node.test.loc.start,
119
+ node: node.test,
110
120
  messageId: "missing"
111
121
  });
112
122
  }
@@ -122,7 +132,7 @@ module.exports = {
122
132
 
123
133
  if (ancestor) {
124
134
  context.report({
125
- node: ancestor,
135
+ node,
126
136
  messageId: "unexpected",
127
137
  data: {
128
138
  type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type
@@ -14,7 +14,7 @@ const astUtils = require("./utils/ast-utils.js");
14
14
 
15
15
  /**
16
16
  * Checks whether or not a node is a conditional expression.
17
- * @param {ASTNode} node - node to test
17
+ * @param {ASTNode} node node to test
18
18
  * @returns {boolean} `true` if the node is a conditional expression.
19
19
  */
20
20
  function isConditional(node) {
@@ -59,7 +59,7 @@ module.exports = {
59
59
 
60
60
  /**
61
61
  * Reports if an arrow function contains an ambiguous conditional.
62
- * @param {ASTNode} node - A node to check and report.
62
+ * @param {ASTNode} node A node to check and report.
63
63
  * @returns {void}
64
64
  */
65
65
  function checkArrowFunc(node) {
@@ -54,8 +54,7 @@ module.exports = {
54
54
 
55
55
  /**
56
56
  * Checks whether the given reference is 'console' or not.
57
- *
58
- * @param {eslint-scope.Reference} reference - The reference to check.
57
+ * @param {eslint-scope.Reference} reference The reference to check.
59
58
  * @returns {boolean} `true` if the reference is 'console'.
60
59
  */
61
60
  function isConsole(reference) {
@@ -67,8 +66,7 @@ module.exports = {
67
66
  /**
68
67
  * Checks whether the property name of the given MemberExpression node
69
68
  * is allowed by options or not.
70
- *
71
- * @param {ASTNode} node - The MemberExpression node to check.
69
+ * @param {ASTNode} node The MemberExpression node to check.
72
70
  * @returns {boolean} `true` if the property name of the node is allowed.
73
71
  */
74
72
  function isAllowed(node) {
@@ -80,8 +78,7 @@ module.exports = {
80
78
  /**
81
79
  * Checks whether the given reference is a member access which is not
82
80
  * allowed by options or not.
83
- *
84
- * @param {eslint-scope.Reference} reference - The reference to check.
81
+ * @param {eslint-scope.Reference} reference The reference to check.
85
82
  * @returns {boolean} `true` if the reference is a member access which
86
83
  * is not allowed by options.
87
84
  */
@@ -98,8 +95,7 @@ module.exports = {
98
95
 
99
96
  /**
100
97
  * Reports the given reference as a violation.
101
- *
102
- * @param {eslint-scope.Reference} reference - The reference to report.
98
+ * @param {eslint-scope.Reference} reference The reference to report.
103
99
  * @returns {void}
104
100
  */
105
101
  function report(reference) {
@@ -33,7 +33,7 @@ module.exports = {
33
33
 
34
34
  /**
35
35
  * Finds and reports references that are non initializer and writable.
36
- * @param {Variable} variable - A variable to check.
36
+ * @param {Variable} variable A variable to check.
37
37
  * @returns {void}
38
38
  */
39
39
  function checkVariable(variable) {
@@ -0,0 +1,62 @@
1
+ /**
2
+ * @fileoverview Rule to disallow returning value from constructor.
3
+ * @author Pig Fang <https://github.com/g-plane>
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Rule Definition
10
+ //------------------------------------------------------------------------------
11
+
12
+ module.exports = {
13
+ meta: {
14
+ type: "problem",
15
+
16
+ docs: {
17
+ description: "disallow returning value from constructor",
18
+ category: "Best Practices",
19
+ recommended: false,
20
+ url: "https://eslint.org/docs/rules/no-constructor-return"
21
+ },
22
+
23
+ schema: {},
24
+
25
+ fixable: null,
26
+
27
+ messages: {
28
+ unexpected: "Unexpected return statement in constructor."
29
+ }
30
+ },
31
+
32
+ create(context) {
33
+ const stack = [];
34
+
35
+ return {
36
+ onCodePathStart(_, node) {
37
+ stack.push(node);
38
+ },
39
+ onCodePathEnd() {
40
+ stack.pop();
41
+ },
42
+ ReturnStatement(node) {
43
+ const last = stack[stack.length - 1];
44
+
45
+ if (!last.parent) {
46
+ return;
47
+ }
48
+
49
+ if (
50
+ last.parent.type === "MethodDefinition" &&
51
+ last.parent.kind === "constructor" &&
52
+ (node.parent.parent === last || node.argument)
53
+ ) {
54
+ context.report({
55
+ node,
56
+ messageId: "unexpected"
57
+ });
58
+ }
59
+ }
60
+ };
61
+ }
62
+ };
@@ -35,7 +35,7 @@ module.exports = {
35
35
 
36
36
  /**
37
37
  * Checks whether or not a given definition is a parameter's.
38
- * @param {eslint-scope.DefEntry} def - A definition to check.
38
+ * @param {eslint-scope.DefEntry} def A definition to check.
39
39
  * @returns {boolean} `true` if the definition is a parameter's.
40
40
  */
41
41
  function isParameter(def) {
@@ -32,8 +32,8 @@ module.exports = {
32
32
 
33
33
  /**
34
34
  * Gets state of a given member name.
35
- * @param {string} name - A name of a member.
36
- * @param {boolean} isStatic - A flag which specifies that is a static member.
35
+ * @param {string} name A name of a member.
36
+ * @param {boolean} isStatic A flag which specifies that is a static member.
37
37
  * @returns {Object} A state of a given member name.
38
38
  * - retv.init {boolean} A flag which shows the name is declared as normal member.
39
39
  * - retv.get {boolean} A flag which shows the name is declared as getter.
@@ -55,8 +55,7 @@ module.exports = {
55
55
 
56
56
  /**
57
57
  * Gets the name text of a given node.
58
- *
59
- * @param {ASTNode} node - A node to get the name.
58
+ * @param {ASTNode} node A node to get the name.
60
59
  * @returns {string} The name text of the node.
61
60
  */
62
61
  function getName(node) {
@@ -0,0 +1,122 @@
1
+ /**
2
+ * @fileoverview Rule to disallow duplicate conditions in if-else-if chains
3
+ * @author Milos Djermanovic
4
+ */
5
+
6
+ "use strict";
7
+
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const astUtils = require("./utils/ast-utils");
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Helpers
16
+ //------------------------------------------------------------------------------
17
+
18
+ /**
19
+ * Determines whether the first given array is a subset of the second given array.
20
+ * @param {Function} comparator A function to compare two elements, should return `true` if they are equal.
21
+ * @param {Array} arrA The array to compare from.
22
+ * @param {Array} arrB The array to compare against.
23
+ * @returns {boolean} `true` if the array `arrA` is a subset of the array `arrB`.
24
+ */
25
+ function isSubsetByComparator(comparator, arrA, arrB) {
26
+ return arrA.every(a => arrB.some(b => comparator(a, b)));
27
+ }
28
+
29
+ /**
30
+ * Splits the given node by the given logical operator.
31
+ * @param {string} operator Logical operator `||` or `&&`.
32
+ * @param {ASTNode} node The node to split.
33
+ * @returns {ASTNode[]} Array of conditions that makes the node when joined by the operator.
34
+ */
35
+ function splitByLogicalOperator(operator, node) {
36
+ if (node.type === "LogicalExpression" && node.operator === operator) {
37
+ return [...splitByLogicalOperator(operator, node.left), ...splitByLogicalOperator(operator, node.right)];
38
+ }
39
+ return [node];
40
+ }
41
+
42
+ const splitByOr = splitByLogicalOperator.bind(null, "||");
43
+ const splitByAnd = splitByLogicalOperator.bind(null, "&&");
44
+
45
+ //------------------------------------------------------------------------------
46
+ // Rule Definition
47
+ //------------------------------------------------------------------------------
48
+
49
+ module.exports = {
50
+ meta: {
51
+ type: "problem",
52
+
53
+ docs: {
54
+ description: "disallow duplicate conditions in if-else-if chains",
55
+ category: "Possible Errors",
56
+ recommended: false,
57
+ url: "https://eslint.org/docs/rules/no-dupe-else-if"
58
+ },
59
+
60
+ schema: [],
61
+
62
+ messages: {
63
+ unexpected: "This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain."
64
+ }
65
+ },
66
+
67
+ create(context) {
68
+ const sourceCode = context.getSourceCode();
69
+
70
+ /**
71
+ * Determines whether the two given nodes are considered to be equal. In particular, given that the nodes
72
+ * represent expressions in a boolean context, `||` and `&&` can be considered as commutative operators.
73
+ * @param {ASTNode} a First node.
74
+ * @param {ASTNode} b Second node.
75
+ * @returns {boolean} `true` if the nodes are considered to be equal.
76
+ */
77
+ function equal(a, b) {
78
+ if (a.type !== b.type) {
79
+ return false;
80
+ }
81
+
82
+ if (
83
+ a.type === "LogicalExpression" &&
84
+ (a.operator === "||" || a.operator === "&&") &&
85
+ a.operator === b.operator
86
+ ) {
87
+ return equal(a.left, b.left) && equal(a.right, b.right) ||
88
+ equal(a.left, b.right) && equal(a.right, b.left);
89
+ }
90
+
91
+ return astUtils.equalTokens(a, b, sourceCode);
92
+ }
93
+
94
+ const isSubset = isSubsetByComparator.bind(null, equal);
95
+
96
+ return {
97
+ IfStatement(node) {
98
+ const test = node.test,
99
+ conditionsToCheck = test.type === "LogicalExpression" && test.operator === "&&"
100
+ ? [test, ...splitByAnd(test)]
101
+ : [test];
102
+ let current = node,
103
+ listToCheck = conditionsToCheck.map(c => splitByOr(c).map(splitByAnd));
104
+
105
+ while (current.parent && current.parent.type === "IfStatement" && current.parent.alternate === current) {
106
+ current = current.parent;
107
+
108
+ const currentOrOperands = splitByOr(current.test).map(splitByAnd);
109
+
110
+ listToCheck = listToCheck.map(orOperands => orOperands.filter(
111
+ orOperand => !currentOrOperands.some(currentOrOperand => isSubset(currentOrOperand, orOperand))
112
+ ));
113
+
114
+ if (listToCheck.some(orOperands => orOperands.length === 0)) {
115
+ context.report({ node: test, messageId: "unexpected" });
116
+ break;
117
+ }
118
+ }
119
+ }
120
+ };
121
+ }
122
+ };
@@ -23,9 +23,10 @@ const SET_KIND = /^(?:init|set)$/u;
23
23
  */
24
24
  class ObjectInfo {
25
25
 
26
+ // eslint-disable-next-line jsdoc/require-description
26
27
  /**
27
- * @param {ObjectInfo|null} upper - The information of the outer object.
28
- * @param {ASTNode} node - The ObjectExpression node of this information.
28
+ * @param {ObjectInfo|null} upper The information of the outer object.
29
+ * @param {ASTNode} node The ObjectExpression node of this information.
29
30
  */
30
31
  constructor(upper, node) {
31
32
  this.upper = upper;
@@ -35,7 +36,7 @@ class ObjectInfo {
35
36
 
36
37
  /**
37
38
  * Gets the information of the given Property node.
38
- * @param {ASTNode} node - The Property node to get.
39
+ * @param {ASTNode} node The Property node to get.
39
40
  * @returns {{get: boolean, set: boolean}} The information of the property.
40
41
  */
41
42
  getPropertyInfo(node) {
@@ -49,7 +50,7 @@ class ObjectInfo {
49
50
 
50
51
  /**
51
52
  * Checks whether the given property has been defined already or not.
52
- * @param {ASTNode} node - The Property node to check.
53
+ * @param {ASTNode} node The Property node to check.
53
54
  * @returns {boolean} `true` if the property has been defined.
54
55
  */
55
56
  isPropertyDefined(node) {
@@ -63,7 +64,7 @@ class ObjectInfo {
63
64
 
64
65
  /**
65
66
  * Defines the given property.
66
- * @param {ASTNode} node - The Property node to define.
67
+ * @param {ASTNode} node The Property node to define.
67
68
  * @returns {void}
68
69
  */
69
70
  defineProperty(node) {
@@ -10,8 +10,7 @@
10
10
 
11
11
  /**
12
12
  * Returns the name of the module imported or re-exported.
13
- *
14
- * @param {ASTNode} node - A node to get.
13
+ * @param {ASTNode} node A node to get.
15
14
  * @returns {string} the name of the module, or empty string if no name.
16
15
  */
17
16
  function getValue(node) {
@@ -24,12 +23,11 @@ function getValue(node) {
24
23
 
25
24
  /**
26
25
  * Checks if the name of the import or export exists in the given array, and reports if so.
27
- *
28
- * @param {RuleContext} context - The ESLint rule context object.
29
- * @param {ASTNode} node - A node to get.
30
- * @param {string} value - The name of the imported or exported module.
31
- * @param {string[]} array - The array containing other imports or exports in the file.
32
- * @param {string} messageId - A messageId to be reported after the name of the module
26
+ * @param {RuleContext} context The ESLint rule context object.
27
+ * @param {ASTNode} node A node to get.
28
+ * @param {string} value The name of the imported or exported module.
29
+ * @param {string[]} array The array containing other imports or exports in the file.
30
+ * @param {string} messageId A messageId to be reported after the name of the module
33
31
  *
34
32
  * @returns {void} No return value
35
33
  */
@@ -47,16 +45,15 @@ function checkAndReport(context, node, value, array, messageId) {
47
45
 
48
46
  /**
49
47
  * @callback nodeCallback
50
- * @param {ASTNode} node - A node to handle.
48
+ * @param {ASTNode} node A node to handle.
51
49
  */
52
50
 
53
51
  /**
54
52
  * Returns a function handling the imports of a given file
55
- *
56
- * @param {RuleContext} context - The ESLint rule context object.
57
- * @param {boolean} includeExports - Whether or not to check for exports in addition to imports.
58
- * @param {string[]} importsInFile - The array containing other imports in the file.
59
- * @param {string[]} exportsInFile - The array containing other exports in the file.
53
+ * @param {RuleContext} context The ESLint rule context object.
54
+ * @param {boolean} includeExports Whether or not to check for exports in addition to imports.
55
+ * @param {string[]} importsInFile The array containing other imports in the file.
56
+ * @param {string[]} exportsInFile The array containing other exports in the file.
60
57
  *
61
58
  * @returns {nodeCallback} A function passed to ESLint to handle the statement.
62
59
  */
@@ -78,10 +75,9 @@ function handleImports(context, includeExports, importsInFile, exportsInFile) {
78
75
 
79
76
  /**
80
77
  * Returns a function handling the exports of a given file
81
- *
82
- * @param {RuleContext} context - The ESLint rule context object.
83
- * @param {string[]} importsInFile - The array containing other imports in the file.
84
- * @param {string[]} exportsInFile - The array containing other exports in the file.
78
+ * @param {RuleContext} context The ESLint rule context object.
79
+ * @param {string[]} importsInFile The array containing other imports in the file.
80
+ * @param {string[]} exportsInFile The array containing other exports in the file.
85
81
  *
86
82
  * @returns {nodeCallback} A function passed to ESLint to handle the statement.
87
83
  */
@@ -58,7 +58,6 @@ module.exports = {
58
58
  *
59
59
  * This is not a generic function. In particular, it is assumed that the scope is a function scope or
60
60
  * a function's inner scope, and that the names can be valid identifiers in the given scope.
61
- *
62
61
  * @param {string[]} names Array of variable names.
63
62
  * @param {eslint-scope.Scope} scope Function scope or a function's inner scope.
64
63
  * @returns {boolean} True if all names can be safely declared, false otherwise.
@@ -134,7 +133,6 @@ module.exports = {
134
133
 
135
134
  /**
136
135
  * Checks whether the removal of `else` and its braces is safe from variable name collisions.
137
- *
138
136
  * @param {Node} node The 'else' node.
139
137
  * @param {eslint-scope.Scope} scope The scope in which the node and the whole 'if' statement is.
140
138
  * @returns {boolean} True if it is safe, false otherwise.
@@ -171,7 +169,6 @@ module.exports = {
171
169
 
172
170
  /**
173
171
  * Display the context report if rule is violated
174
- *
175
172
  * @param {Node} node The 'else' node
176
173
  * @returns {void}
177
174
  */
@@ -255,7 +252,6 @@ module.exports = {
255
252
 
256
253
  /**
257
254
  * Check to see if the node is a ReturnStatement
258
- *
259
255
  * @param {Node} node The node being evaluated
260
256
  * @returns {boolean} True if node is a return
261
257
  */
@@ -267,7 +263,6 @@ module.exports = {
267
263
  * Naive return checking, does not iterate through the whole
268
264
  * BlockStatement because we make the assumption that the ReturnStatement
269
265
  * will be the last node in the body of the BlockStatement.
270
- *
271
266
  * @param {Node} node The consequent/alternate node
272
267
  * @returns {boolean} True if it has a return
273
268
  */
@@ -284,7 +279,6 @@ module.exports = {
284
279
  /**
285
280
  * Check to see if the node is valid for evaluation,
286
281
  * meaning it has an else.
287
- *
288
282
  * @param {Node} node The node being evaluated
289
283
  * @returns {boolean} True if the node is valid
290
284
  */
@@ -296,7 +290,6 @@ module.exports = {
296
290
  * If the consequent is an IfStatement, check to see if it has an else
297
291
  * and both its consequent and alternate path return, meaning this is
298
292
  * a nested case of rule violation. If-Else not considered currently.
299
- *
300
293
  * @param {Node} node The consequent node
301
294
  * @returns {boolean} True if this is a nested rule violation
302
295
  */
@@ -309,7 +302,6 @@ module.exports = {
309
302
  * Check the consequent/body node to make sure it is not
310
303
  * a ReturnStatement or an IfStatement that returns on both
311
304
  * code paths.
312
- *
313
305
  * @param {Node} node The consequent or body node
314
306
  * @returns {boolean} `true` if it is a Return/If node that always returns.
315
307
  */
@@ -28,8 +28,7 @@ const ALLOW_OPTIONS = Object.freeze([
28
28
 
29
29
  /**
30
30
  * Gets the kind of a given function node.
31
- *
32
- * @param {ASTNode} node - A function node to get. This is one of
31
+ * @param {ASTNode} node A function node to get. This is one of
33
32
  * an ArrowFunctionExpression, a FunctionDeclaration, or a
34
33
  * FunctionExpression.
35
34
  * @returns {string} The kind of the function. This is one of "functions",
@@ -130,8 +129,7 @@ module.exports = {
130
129
  * - Not allowed by options.
131
130
  * - The body is empty.
132
131
  * - The body doesn't have any comments.
133
- *
134
- * @param {ASTNode} node - A function node to report. This is one of
132
+ * @param {ASTNode} node A function node to report. This is one of
135
133
  * an ArrowFunctionExpression, a FunctionDeclaration, or a
136
134
  * FunctionExpression.
137
135
  * @returns {void}
@@ -22,9 +22,8 @@ const candidatesOfGlobalObject = Object.freeze([
22
22
 
23
23
  /**
24
24
  * Checks a given node is a Identifier node of the specified name.
25
- *
26
- * @param {ASTNode} node - A node to check.
27
- * @param {string} name - A name to check.
25
+ * @param {ASTNode} node A node to check.
26
+ * @param {string} name A name to check.
28
27
  * @returns {boolean} `true` if the node is a Identifier node of the name.
29
28
  */
30
29
  function isIdentifier(node, name) {
@@ -33,9 +32,8 @@ function isIdentifier(node, name) {
33
32
 
34
33
  /**
35
34
  * Checks a given node is a Literal node of the specified string value.
36
- *
37
- * @param {ASTNode} node - A node to check.
38
- * @param {string} name - A name to check.
35
+ * @param {ASTNode} node A node to check.
36
+ * @param {string} name A name to check.
39
37
  * @returns {boolean} `true` if the node is a Literal node of the name.
40
38
  */
41
39
  function isConstant(node, name) {
@@ -57,9 +55,8 @@ function isConstant(node, name) {
57
55
  /**
58
56
  * Checks a given node is a MemberExpression node which has the specified name's
59
57
  * property.
60
- *
61
- * @param {ASTNode} node - A node to check.
62
- * @param {string} name - A name to check.
58
+ * @param {ASTNode} node A node to check.
59
+ * @param {string} name A name to check.
63
60
  * @returns {boolean} `true` if the node is a MemberExpression node which has
64
61
  * the specified name's property
65
62
  */
@@ -113,8 +110,7 @@ module.exports = {
113
110
  *
114
111
  * This is used in order to check whether or not `this` binding is a
115
112
  * reference to the global object.
116
- *
117
- * @param {ASTNode} node - A node of the scope. This is one of Program,
113
+ * @param {ASTNode} node A node of the scope. This is one of Program,
118
114
  * FunctionDeclaration, FunctionExpression, and ArrowFunctionExpression.
119
115
  * @returns {void}
120
116
  */
@@ -132,7 +128,6 @@ module.exports = {
132
128
 
133
129
  /**
134
130
  * Pops a variable scope from the stack.
135
- *
136
131
  * @returns {void}
137
132
  */
138
133
  function exitVarScope() {
@@ -148,8 +143,7 @@ module.exports = {
148
143
  * The location of the report is always `eval` `Identifier` (or possibly
149
144
  * `Literal`). The type of the report is `CallExpression` if the parent is
150
145
  * `CallExpression`. Otherwise, it's the given node type.
151
- *
152
- * @param {ASTNode} node - A node to report.
146
+ * @param {ASTNode} node A node to report.
153
147
  * @returns {void}
154
148
  */
155
149
  function report(node) {
@@ -171,8 +165,7 @@ module.exports = {
171
165
 
172
166
  /**
173
167
  * Reports accesses of `eval` via the global object.
174
- *
175
- * @param {eslint-scope.Scope} globalScope - The global scope.
168
+ * @param {eslint-scope.Scope} globalScope The global scope.
176
169
  * @returns {void}
177
170
  */
178
171
  function reportAccessingEvalViaGlobalObject(globalScope) {
@@ -205,8 +198,7 @@ module.exports = {
205
198
 
206
199
  /**
207
200
  * Reports all accesses of `eval` (excludes direct calls to eval).
208
- *
209
- * @param {eslint-scope.Scope} globalScope - The global scope.
201
+ * @param {eslint-scope.Scope} globalScope The global scope.
210
202
  * @returns {void}
211
203
  */
212
204
  function reportAccessingEval(globalScope) {
@@ -33,7 +33,7 @@ module.exports = {
33
33
 
34
34
  /**
35
35
  * Finds and reports references that are non initializer and writable.
36
- * @param {Variable} variable - A variable to check.
36
+ * @param {Variable} variable A variable to check.
37
37
  * @returns {void}
38
38
  */
39
39
  function checkVariable(variable) {