eslint 8.0.0-beta.0 → 8.0.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.
- package/README.md +4 -4
- package/bin/eslint.js +1 -1
- package/conf/eslint-recommended.js +1 -1
- package/conf/{category-list.json → rule-type-list.json} +4 -7
- package/lib/cli-engine/cli-engine.js +11 -3
- package/lib/cli-engine/file-enumerator.js +4 -3
- package/lib/cli-engine/formatters/html.js +1 -1
- package/lib/cli-engine/hash.js +2 -2
- package/lib/cli-engine/xml-escape.js +1 -1
- package/lib/config/flat-config-array.js +2 -2
- package/lib/config/flat-config-schema.js +1 -1
- package/lib/config/rule-validator.js +25 -8
- package/lib/eslint/eslint.js +4 -0
- package/lib/init/autoconfig.js +17 -18
- package/lib/init/config-file.js +3 -3
- package/lib/init/config-initializer.js +11 -10
- package/lib/init/config-rule.js +15 -16
- package/lib/init/npm-utils.js +16 -15
- package/lib/init/source-code-utils.js +6 -5
- package/lib/linter/apply-disable-directives.js +80 -11
- package/lib/linter/code-path-analysis/code-path-analyzer.js +115 -36
- package/lib/linter/code-path-analysis/code-path-segment.js +0 -1
- package/lib/linter/code-path-analysis/code-path-state.js +4 -1
- package/lib/linter/code-path-analysis/code-path.js +14 -5
- package/lib/linter/code-path-analysis/debug-helpers.js +2 -2
- package/lib/linter/code-path-analysis/fork-context.js +0 -1
- package/lib/linter/code-path-analysis/id-generator.js +0 -1
- package/lib/linter/config-comment-parser.js +1 -1
- package/lib/linter/linter.js +51 -22
- package/lib/linter/node-event-generator.js +0 -1
- package/lib/linter/report-translator.js +12 -12
- package/lib/linter/rules.js +3 -0
- package/lib/linter/safe-emitter.js +2 -2
- package/lib/linter/source-code-fixer.js +2 -2
- package/lib/linter/timing.js +2 -2
- package/lib/rule-tester/rule-tester.js +12 -2
- package/lib/rules/accessor-pairs.js +0 -1
- package/lib/rules/array-bracket-newline.js +0 -1
- package/lib/rules/array-bracket-spacing.js +0 -1
- package/lib/rules/array-callback-return.js +0 -1
- package/lib/rules/array-element-newline.js +0 -1
- package/lib/rules/arrow-body-style.js +0 -1
- package/lib/rules/arrow-parens.js +0 -1
- package/lib/rules/arrow-spacing.js +0 -1
- package/lib/rules/block-scoped-var.js +0 -1
- package/lib/rules/block-spacing.js +0 -1
- package/lib/rules/brace-style.js +0 -1
- package/lib/rules/callback-return.js +1 -1
- package/lib/rules/camelcase.js +17 -19
- package/lib/rules/capitalized-comments.js +0 -1
- package/lib/rules/class-methods-use-this.js +51 -9
- package/lib/rules/comma-dangle.js +0 -1
- package/lib/rules/comma-spacing.js +0 -1
- package/lib/rules/comma-style.js +0 -1
- package/lib/rules/complexity.js +47 -56
- package/lib/rules/computed-property-spacing.js +0 -1
- package/lib/rules/consistent-return.js +0 -1
- package/lib/rules/consistent-this.js +1 -2
- package/lib/rules/constructor-super.js +0 -1
- package/lib/rules/curly.js +0 -1
- package/lib/rules/default-case-last.js +0 -1
- package/lib/rules/default-case.js +2 -3
- package/lib/rules/default-param-last.js +1 -2
- package/lib/rules/dot-location.js +0 -1
- package/lib/rules/dot-notation.js +0 -1
- package/lib/rules/eol-last.js +6 -2
- package/lib/rules/eqeqeq.js +1 -2
- package/lib/rules/for-direction.js +0 -1
- package/lib/rules/func-call-spacing.js +0 -1
- package/lib/rules/func-name-matching.js +9 -6
- package/lib/rules/func-names.js +0 -1
- package/lib/rules/func-style.js +0 -1
- package/lib/rules/function-call-argument-newline.js +0 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/generator-star-spacing.js +0 -1
- package/lib/rules/getter-return.js +0 -1
- package/lib/rules/global-require.js +1 -1
- package/lib/rules/grouped-accessor-pairs.js +0 -1
- package/lib/rules/guard-for-in.js +0 -1
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-blacklist.js +1 -1
- package/lib/rules/id-denylist.js +0 -1
- package/lib/rules/id-length.js +0 -1
- package/lib/rules/id-match.js +0 -1
- package/lib/rules/implicit-arrow-linebreak.js +0 -1
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +7 -10
- package/lib/rules/index.js +1 -1
- package/lib/rules/init-declarations.js +0 -1
- package/lib/rules/jsx-quotes.js +0 -1
- package/lib/rules/key-spacing.js +4 -5
- package/lib/rules/keyword-spacing.js +19 -3
- package/lib/rules/line-comment-position.js +0 -1
- package/lib/rules/linebreak-style.js +0 -1
- package/lib/rules/lines-around-comment.js +0 -1
- package/lib/rules/lines-around-directive.js +1 -2
- package/lib/rules/lines-between-class-members.js +50 -3
- package/lib/rules/max-classes-per-file.js +31 -8
- package/lib/rules/max-depth.js +0 -1
- package/lib/rules/max-len.js +1 -2
- package/lib/rules/max-lines-per-function.js +1 -2
- package/lib/rules/max-lines.js +0 -1
- package/lib/rules/max-nested-callbacks.js +0 -1
- package/lib/rules/max-params.js +0 -1
- package/lib/rules/max-statements-per-line.js +0 -1
- package/lib/rules/max-statements.js +0 -1
- package/lib/rules/multiline-comment-style.js +0 -1
- package/lib/rules/multiline-ternary.js +0 -1
- package/lib/rules/new-cap.js +2 -2
- package/lib/rules/new-parens.js +0 -1
- package/lib/rules/newline-after-var.js +4 -5
- package/lib/rules/newline-before-return.js +2 -3
- package/lib/rules/newline-per-chained-call.js +1 -2
- package/lib/rules/no-alert.js +0 -1
- package/lib/rules/no-array-constructor.js +0 -1
- package/lib/rules/no-async-promise-executor.js +0 -1
- package/lib/rules/no-await-in-loop.js +0 -1
- package/lib/rules/no-bitwise.js +5 -6
- package/lib/rules/no-buffer-constructor.js +1 -1
- package/lib/rules/no-caller.js +0 -1
- package/lib/rules/no-case-declarations.js +0 -1
- package/lib/rules/no-catch-shadow.js +0 -1
- package/lib/rules/no-class-assign.js +0 -1
- package/lib/rules/no-compare-neg-zero.js +0 -1
- package/lib/rules/no-cond-assign.js +0 -1
- package/lib/rules/no-confusing-arrow.js +0 -1
- package/lib/rules/no-console.js +0 -1
- package/lib/rules/no-const-assign.js +0 -1
- package/lib/rules/no-constant-condition.js +0 -1
- package/lib/rules/no-constructor-return.js +0 -1
- package/lib/rules/no-continue.js +0 -1
- package/lib/rules/no-control-regex.js +0 -1
- package/lib/rules/no-debugger.js +0 -1
- package/lib/rules/no-delete-var.js +0 -1
- package/lib/rules/no-div-regex.js +0 -1
- package/lib/rules/no-dupe-args.js +0 -1
- package/lib/rules/no-dupe-class-members.js +0 -1
- package/lib/rules/no-dupe-else-if.js +0 -1
- package/lib/rules/no-dupe-keys.js +0 -2
- package/lib/rules/no-duplicate-case.js +0 -1
- package/lib/rules/no-duplicate-imports.js +0 -1
- package/lib/rules/no-else-return.js +0 -1
- package/lib/rules/no-empty-character-class.js +0 -1
- package/lib/rules/no-empty-function.js +0 -1
- package/lib/rules/no-empty-pattern.js +0 -1
- package/lib/rules/no-empty.js +0 -1
- package/lib/rules/no-eq-null.js +0 -1
- package/lib/rules/no-eval.js +0 -1
- package/lib/rules/no-ex-assign.js +0 -1
- package/lib/rules/no-extend-native.js +0 -1
- package/lib/rules/no-extra-bind.js +0 -1
- package/lib/rules/no-extra-boolean-cast.js +1 -1
- package/lib/rules/no-extra-label.js +0 -1
- package/lib/rules/no-extra-parens.js +0 -1
- package/lib/rules/no-extra-semi.js +0 -1
- package/lib/rules/no-fallthrough.js +0 -1
- package/lib/rules/no-floating-decimal.js +0 -1
- package/lib/rules/no-func-assign.js +0 -1
- package/lib/rules/no-global-assign.js +0 -1
- package/lib/rules/no-implicit-coercion.js +0 -1
- package/lib/rules/no-implicit-globals.js +0 -1
- package/lib/rules/no-implied-eval.js +0 -1
- package/lib/rules/no-import-assign.js +0 -1
- package/lib/rules/no-inline-comments.js +0 -1
- package/lib/rules/no-inner-declarations.js +0 -1
- package/lib/rules/no-invalid-regexp.js +0 -1
- package/lib/rules/no-invalid-this.js +0 -1
- package/lib/rules/no-irregular-whitespace.js +0 -1
- package/lib/rules/no-iterator.js +0 -1
- package/lib/rules/no-label-var.js +0 -1
- package/lib/rules/no-labels.js +0 -1
- package/lib/rules/no-lone-blocks.js +0 -1
- package/lib/rules/no-lonely-if.js +0 -1
- package/lib/rules/no-loop-func.js +1 -2
- package/lib/rules/no-loss-of-precision.js +0 -1
- package/lib/rules/no-magic-numbers.js +0 -1
- package/lib/rules/no-misleading-character-class.js +0 -1
- package/lib/rules/no-mixed-operators.js +1 -2
- package/lib/rules/no-mixed-requires.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +0 -1
- package/lib/rules/no-multi-assign.js +0 -1
- package/lib/rules/no-multi-spaces.js +0 -1
- package/lib/rules/no-multi-str.js +0 -1
- package/lib/rules/no-multiple-empty-lines.js +0 -1
- package/lib/rules/no-native-reassign.js +0 -1
- package/lib/rules/no-negated-condition.js +0 -1
- package/lib/rules/no-negated-in-lhs.js +0 -1
- package/lib/rules/no-nested-ternary.js +0 -1
- package/lib/rules/no-new-func.js +34 -7
- package/lib/rules/no-new-object.js +0 -1
- package/lib/rules/no-new-require.js +1 -1
- package/lib/rules/no-new-symbol.js +0 -1
- package/lib/rules/no-new-wrappers.js +0 -1
- package/lib/rules/no-new.js +0 -1
- package/lib/rules/no-nonoctal-decimal-escape.js +0 -1
- package/lib/rules/no-obj-calls.js +0 -1
- package/lib/rules/no-octal-escape.js +0 -1
- package/lib/rules/no-octal.js +0 -1
- package/lib/rules/no-param-reassign.js +0 -1
- package/lib/rules/no-path-concat.js +1 -1
- package/lib/rules/no-plusplus.js +0 -1
- package/lib/rules/no-process-env.js +1 -1
- package/lib/rules/no-process-exit.js +1 -1
- package/lib/rules/no-promise-executor-return.js +0 -1
- package/lib/rules/no-proto.js +0 -1
- package/lib/rules/no-prototype-builtins.js +0 -1
- package/lib/rules/no-redeclare.js +0 -1
- package/lib/rules/no-regex-spaces.js +0 -1
- package/lib/rules/no-restricted-exports.js +0 -1
- package/lib/rules/no-restricted-globals.js +1 -2
- package/lib/rules/no-restricted-imports.js +5 -6
- package/lib/rules/no-restricted-modules.js +3 -3
- package/lib/rules/no-restricted-properties.js +2 -3
- package/lib/rules/no-restricted-syntax.js +1 -2
- package/lib/rules/no-return-assign.js +0 -1
- package/lib/rules/no-return-await.js +0 -1
- package/lib/rules/no-script-url.js +1 -3
- package/lib/rules/no-self-assign.js +0 -1
- package/lib/rules/no-self-compare.js +0 -1
- package/lib/rules/no-sequences.js +0 -1
- package/lib/rules/no-setter-return.js +0 -1
- package/lib/rules/no-shadow-restricted-names.js +0 -1
- package/lib/rules/no-shadow.js +1 -2
- package/lib/rules/no-spaced-func.js +0 -1
- package/lib/rules/no-sparse-arrays.js +0 -1
- package/lib/rules/no-sync.js +1 -3
- package/lib/rules/no-tabs.js +0 -1
- package/lib/rules/no-template-curly-in-string.js +0 -1
- package/lib/rules/no-ternary.js +0 -1
- package/lib/rules/no-this-before-super.js +0 -1
- package/lib/rules/no-throw-literal.js +0 -1
- package/lib/rules/no-trailing-spaces.js +0 -1
- package/lib/rules/no-undef-init.js +9 -61
- package/lib/rules/no-undef.js +0 -1
- package/lib/rules/no-undefined.js +0 -1
- package/lib/rules/no-underscore-dangle.js +0 -1
- package/lib/rules/no-unexpected-multiline.js +0 -1
- package/lib/rules/no-unmodified-loop-condition.js +0 -1
- package/lib/rules/no-unneeded-ternary.js +0 -1
- package/lib/rules/no-unreachable-loop.js +0 -1
- package/lib/rules/no-unreachable.js +26 -25
- package/lib/rules/no-unsafe-finally.js +0 -1
- package/lib/rules/no-unsafe-negation.js +0 -1
- package/lib/rules/no-unsafe-optional-chaining.js +0 -1
- package/lib/rules/no-unused-expressions.js +4 -5
- package/lib/rules/no-unused-labels.js +0 -1
- package/lib/rules/no-unused-vars.js +26 -28
- package/lib/rules/no-use-before-define.js +0 -1
- package/lib/rules/no-useless-backreference.js +0 -1
- package/lib/rules/no-useless-call.js +0 -1
- package/lib/rules/no-useless-catch.js +0 -1
- package/lib/rules/no-useless-computed-key.js +1 -1
- package/lib/rules/no-useless-concat.js +0 -1
- package/lib/rules/no-useless-constructor.js +0 -1
- package/lib/rules/no-useless-escape.js +9 -9
- package/lib/rules/no-useless-rename.js +0 -1
- package/lib/rules/no-useless-return.js +0 -1
- package/lib/rules/no-var.js +0 -1
- package/lib/rules/no-void.js +0 -1
- package/lib/rules/no-warning-comments.js +0 -1
- package/lib/rules/no-whitespace-before-property.js +0 -1
- package/lib/rules/no-with.js +0 -1
- package/lib/rules/nonblock-statement-body-position.js +0 -1
- package/lib/rules/object-curly-newline.js +0 -1
- package/lib/rules/object-curly-spacing.js +0 -1
- package/lib/rules/object-property-newline.js +0 -1
- package/lib/rules/object-shorthand.js +3 -8
- package/lib/rules/one-var-declaration-per-line.js +0 -1
- package/lib/rules/one-var.js +1 -2
- package/lib/rules/operator-assignment.js +6 -7
- package/lib/rules/operator-linebreak.js +0 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +0 -1
- package/lib/rules/prefer-arrow-callback.js +1 -1
- package/lib/rules/prefer-const.js +0 -1
- package/lib/rules/prefer-destructuring.js +1 -2
- package/lib/rules/prefer-exponentiation-operator.js +0 -1
- package/lib/rules/prefer-named-capture-group.js +0 -1
- package/lib/rules/prefer-numeric-literals.js +0 -1
- package/lib/rules/prefer-object-spread.js +0 -1
- package/lib/rules/prefer-promise-reject-errors.js +0 -1
- package/lib/rules/prefer-reflect.js +0 -1
- package/lib/rules/prefer-regex-literals.js +0 -1
- package/lib/rules/prefer-rest-params.js +0 -1
- package/lib/rules/prefer-spread.js +0 -1
- package/lib/rules/prefer-template.js +0 -1
- package/lib/rules/quote-props.js +8 -9
- package/lib/rules/quotes.js +0 -1
- package/lib/rules/radix.js +0 -1
- package/lib/rules/require-atomic-updates.js +24 -9
- package/lib/rules/require-await.js +0 -1
- package/lib/rules/require-jsdoc.js +1 -1
- package/lib/rules/require-unicode-regexp.js +0 -1
- package/lib/rules/require-yield.js +0 -1
- package/lib/rules/rest-spread-spacing.js +0 -1
- package/lib/rules/semi-spacing.js +0 -1
- package/lib/rules/semi-style.js +0 -1
- package/lib/rules/semi.js +66 -6
- package/lib/rules/sort-imports.js +0 -1
- package/lib/rules/sort-keys.js +0 -1
- package/lib/rules/sort-vars.js +0 -1
- package/lib/rules/space-before-blocks.js +14 -3
- package/lib/rules/space-before-function-paren.js +0 -1
- package/lib/rules/space-in-parens.js +0 -1
- package/lib/rules/space-infix-ops.js +0 -1
- package/lib/rules/space-unary-ops.js +0 -1
- package/lib/rules/spaced-comment.js +0 -1
- package/lib/rules/strict.js +0 -1
- package/lib/rules/switch-colon-spacing.js +1 -14
- package/lib/rules/symbol-description.js +0 -1
- package/lib/rules/template-curly-spacing.js +0 -1
- package/lib/rules/template-tag-spacing.js +0 -1
- package/lib/rules/unicode-bom.js +0 -1
- package/lib/rules/use-isnan.js +0 -1
- package/lib/rules/utils/ast-utils.js +29 -7
- package/lib/rules/utils/lazy-loading-rule-map.js +3 -3
- package/lib/rules/valid-jsdoc.js +1 -1
- package/lib/rules/valid-typeof.js +0 -1
- package/lib/rules/vars-on-top.js +1 -2
- package/lib/rules/wrap-iife.js +0 -1
- package/lib/rules/wrap-regex.js +0 -1
- package/lib/rules/yield-star-spacing.js +0 -1
- package/lib/rules/yoda.js +0 -1
- package/lib/shared/ajv.js +1 -1
- package/lib/shared/config-validator.js +10 -5
- package/lib/shared/logging.js +1 -1
- package/lib/shared/relative-module-resolver.js +1 -0
- package/lib/shared/runtime-info.js +3 -0
- package/lib/shared/traverser.js +2 -2
- package/lib/shared/types.js +2 -2
- package/lib/source-code/source-code.js +11 -5
- package/lib/source-code/token-store/cursor.js +1 -1
- package/package.json +5 -5
@@ -28,7 +28,6 @@ module.exports = {
|
|
28
28
|
|
29
29
|
docs: {
|
30
30
|
description: "require or disallow method and property shorthand syntax for object literals",
|
31
|
-
category: "ECMAScript 6",
|
32
31
|
recommended: false,
|
33
32
|
url: "https://eslint.org/docs/rules/object-shorthand"
|
34
33
|
},
|
@@ -149,7 +148,6 @@ module.exports = {
|
|
149
148
|
* @param {ASTNode} property Property AST node
|
150
149
|
* @returns {boolean} True if the property can have a shorthand form
|
151
150
|
* @private
|
152
|
-
*
|
153
151
|
*/
|
154
152
|
function canHaveShorthand(property) {
|
155
153
|
return (property.kind !== "set" && property.kind !== "get" && property.type !== "SpreadElement" && property.type !== "SpreadProperty" && property.type !== "ExperimentalSpreadProperty");
|
@@ -157,7 +155,7 @@ module.exports = {
|
|
157
155
|
|
158
156
|
/**
|
159
157
|
* Checks whether a node is a string literal.
|
160
|
-
* @param
|
158
|
+
* @param {ASTNode} node Any AST node.
|
161
159
|
* @returns {boolean} `true` if it is a string literal.
|
162
160
|
*/
|
163
161
|
function isStringLiteral(node) {
|
@@ -169,7 +167,6 @@ module.exports = {
|
|
169
167
|
* @param {ASTNode} property Property AST node
|
170
168
|
* @returns {boolean} True if the property is considered shorthand, false if not.
|
171
169
|
* @private
|
172
|
-
*
|
173
170
|
*/
|
174
171
|
function isShorthand(property) {
|
175
172
|
|
@@ -182,7 +179,6 @@ module.exports = {
|
|
182
179
|
* @param {ASTNode} property Property AST node
|
183
180
|
* @returns {boolean} True if the key and value are named equally, false if not.
|
184
181
|
* @private
|
185
|
-
*
|
186
182
|
*/
|
187
183
|
function isRedundant(property) {
|
188
184
|
const value = property.value;
|
@@ -199,10 +195,9 @@ module.exports = {
|
|
199
195
|
|
200
196
|
/**
|
201
197
|
* Ensures that an object's properties are consistently shorthand, or not shorthand at all.
|
202
|
-
* @param
|
203
|
-
* @param
|
198
|
+
* @param {ASTNode} node Property AST node
|
199
|
+
* @param {boolean} checkRedundancy Whether to check longform redundancy
|
204
200
|
* @returns {void}
|
205
|
-
*
|
206
201
|
*/
|
207
202
|
function checkConsistency(node, checkRedundancy) {
|
208
203
|
|
package/lib/rules/one-var.js
CHANGED
@@ -34,7 +34,6 @@ module.exports = {
|
|
34
34
|
|
35
35
|
docs: {
|
36
36
|
description: "enforce variables to be declared either together or separately in functions",
|
37
|
-
category: "Stylistic Issues",
|
38
37
|
recommended: false,
|
39
38
|
url: "https://eslint.org/docs/rules/one-var"
|
40
39
|
},
|
@@ -209,7 +208,7 @@ module.exports = {
|
|
209
208
|
|
210
209
|
/**
|
211
210
|
* Determines the current scope (function or block)
|
212
|
-
* @param
|
211
|
+
* @param {string} statementType node.kind, one of: "var", "let", or "const"
|
213
212
|
* @returns {Object} The scope associated with statementType
|
214
213
|
*/
|
215
214
|
function getCurrentScope(statementType) {
|
@@ -17,8 +17,8 @@ const astUtils = require("./utils/ast-utils");
|
|
17
17
|
/**
|
18
18
|
* Checks whether an operator is commutative and has an operator assignment
|
19
19
|
* shorthand form.
|
20
|
-
* @param
|
21
|
-
* @returns {boolean}
|
20
|
+
* @param {string} operator Operator to check.
|
21
|
+
* @returns {boolean} True if the operator is commutative and has a
|
22
22
|
* shorthand form.
|
23
23
|
*/
|
24
24
|
function isCommutativeOperatorWithShorthand(operator) {
|
@@ -28,8 +28,8 @@ function isCommutativeOperatorWithShorthand(operator) {
|
|
28
28
|
/**
|
29
29
|
* Checks whether an operator is not commutative and has an operator assignment
|
30
30
|
* shorthand form.
|
31
|
-
* @param
|
32
|
-
* @returns {boolean}
|
31
|
+
* @param {string} operator Operator to check.
|
32
|
+
* @returns {boolean} True if the operator is not commutative and has
|
33
33
|
* a shorthand form.
|
34
34
|
*/
|
35
35
|
function isNonCommutativeOperatorWithShorthand(operator) {
|
@@ -63,7 +63,6 @@ module.exports = {
|
|
63
63
|
|
64
64
|
docs: {
|
65
65
|
description: "require or disallow assignment operator shorthand where possible",
|
66
|
-
category: "Stylistic Issues",
|
67
66
|
recommended: false,
|
68
67
|
url: "https://eslint.org/docs/rules/operator-assignment"
|
69
68
|
},
|
@@ -96,7 +95,7 @@ module.exports = {
|
|
96
95
|
|
97
96
|
/**
|
98
97
|
* Ensures that an assignment uses the shorthand form where possible.
|
99
|
-
* @param
|
98
|
+
* @param {ASTNode} node An AssignmentExpression node.
|
100
99
|
* @returns {void}
|
101
100
|
*/
|
102
101
|
function verify(node) {
|
@@ -149,7 +148,7 @@ module.exports = {
|
|
149
148
|
|
150
149
|
/**
|
151
150
|
* Warns if an assignment expression uses operator assignment shorthand.
|
152
|
-
* @param
|
151
|
+
* @param {ASTNode} node An AssignmentExpression node.
|
153
152
|
* @returns {void}
|
154
153
|
*/
|
155
154
|
function prohibit(node) {
|
@@ -21,7 +21,6 @@ module.exports = {
|
|
21
21
|
|
22
22
|
docs: {
|
23
23
|
description: "require or disallow padding within blocks",
|
24
|
-
category: "Stylistic Issues",
|
25
24
|
recommended: false,
|
26
25
|
url: "https://eslint.org/docs/rules/padded-blocks"
|
27
26
|
},
|
@@ -167,6 +166,7 @@ module.exports = {
|
|
167
166
|
/**
|
168
167
|
* Checks if a node should be padded, according to the rule config.
|
169
168
|
* @param {ASTNode} node The AST node to check.
|
169
|
+
* @throws {Error} (Unreachable)
|
170
170
|
* @returns {boolean} True if the node should be padded, false otherwise.
|
171
171
|
*/
|
172
172
|
function requirePaddingFor(node) {
|
@@ -60,6 +60,7 @@ function getVariableOfArguments(scope) {
|
|
60
60
|
/**
|
61
61
|
* Checks whether or not a given node is a callback.
|
62
62
|
* @param {ASTNode} node A node to check.
|
63
|
+
* @throws {Error} (Unreachable.)
|
63
64
|
* @returns {Object}
|
64
65
|
* {boolean} retv.isCallback - `true` if the node is a callback.
|
65
66
|
* {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`.
|
@@ -150,7 +151,6 @@ module.exports = {
|
|
150
151
|
|
151
152
|
docs: {
|
152
153
|
description: "require using arrow functions for callbacks",
|
153
|
-
category: "ECMAScript 6",
|
154
154
|
recommended: false,
|
155
155
|
url: "https://eslint.org/docs/rules/prefer-arrow-callback"
|
156
156
|
},
|
@@ -26,7 +26,6 @@ module.exports = {
|
|
26
26
|
|
27
27
|
docs: {
|
28
28
|
description: "require destructuring from arrays and/or objects",
|
29
|
-
category: "ECMAScript 6",
|
30
29
|
recommended: false,
|
31
30
|
url: "https://eslint.org/docs/rules/prefer-destructuring"
|
32
31
|
},
|
@@ -119,8 +118,8 @@ module.exports = {
|
|
119
118
|
// Helpers
|
120
119
|
//--------------------------------------------------------------------------
|
121
120
|
|
122
|
-
// eslint-disable-next-line jsdoc/require-description
|
123
121
|
/**
|
122
|
+
* Checks if destructuring type should be checked.
|
124
123
|
* @param {string} nodeType "AssignmentExpression" or "VariableDeclarator"
|
125
124
|
* @param {string} destructuringType "array" or "object"
|
126
125
|
* @returns {boolean} `true` if the destructuring type should be checked for the given node
|
@@ -45,7 +45,6 @@ module.exports = {
|
|
45
45
|
|
46
46
|
docs: {
|
47
47
|
description: "disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals",
|
48
|
-
category: "ECMAScript 6",
|
49
48
|
recommended: false,
|
50
49
|
url: "https://eslint.org/docs/rules/prefer-numeric-literals"
|
51
50
|
},
|
@@ -247,7 +247,6 @@ module.exports = {
|
|
247
247
|
docs: {
|
248
248
|
description:
|
249
249
|
"disallow using Object.assign with an object literal as the first argument and prefer the use of object spread instead.",
|
250
|
-
category: "Stylistic Issues",
|
251
250
|
recommended: false,
|
252
251
|
url: "https://eslint.org/docs/rules/prefer-object-spread"
|
253
252
|
},
|
package/lib/rules/quote-props.js
CHANGED
@@ -22,7 +22,6 @@ module.exports = {
|
|
22
22
|
|
23
23
|
docs: {
|
24
24
|
description: "require quotes around object literal property names",
|
25
|
-
category: "Stylistic Issues",
|
26
25
|
recommended: false,
|
27
26
|
url: "https://eslint.org/docs/rules/quote-props"
|
28
27
|
},
|
@@ -91,7 +90,7 @@ module.exports = {
|
|
91
90
|
|
92
91
|
/**
|
93
92
|
* Checks whether a certain string constitutes an ES3 token
|
94
|
-
* @param
|
93
|
+
* @param {string} tokenStr The string to be checked.
|
95
94
|
* @returns {boolean} `true` if it is an ES3 token.
|
96
95
|
*/
|
97
96
|
function isKeyword(tokenStr) {
|
@@ -100,9 +99,9 @@ module.exports = {
|
|
100
99
|
|
101
100
|
/**
|
102
101
|
* Checks if an espree-tokenized key has redundant quotes (i.e. whether quotes are unnecessary)
|
103
|
-
* @param
|
104
|
-
* @param
|
105
|
-
* @param
|
102
|
+
* @param {string} rawKey The raw key value from the source
|
103
|
+
* @param {espreeTokens} tokens The espree-tokenized node key
|
104
|
+
* @param {boolean} [skipNumberLiterals=false] Indicates whether number literals should be checked
|
106
105
|
* @returns {boolean} Whether or not a key has redundant quotes.
|
107
106
|
* @private
|
108
107
|
*/
|
@@ -139,7 +138,7 @@ module.exports = {
|
|
139
138
|
|
140
139
|
/**
|
141
140
|
* Ensures that a property's key is quoted only when necessary
|
142
|
-
* @param
|
141
|
+
* @param {ASTNode} node Property AST node
|
143
142
|
* @returns {void}
|
144
143
|
*/
|
145
144
|
function checkUnnecessaryQuotes(node) {
|
@@ -195,7 +194,7 @@ module.exports = {
|
|
195
194
|
|
196
195
|
/**
|
197
196
|
* Ensures that a property's key is quoted
|
198
|
-
* @param
|
197
|
+
* @param {ASTNode} node Property AST node
|
199
198
|
* @returns {void}
|
200
199
|
*/
|
201
200
|
function checkOmittedQuotes(node) {
|
@@ -213,8 +212,8 @@ module.exports = {
|
|
213
212
|
|
214
213
|
/**
|
215
214
|
* Ensures that an object's keys are consistently quoted, optionally checks for redundancy of quotes
|
216
|
-
* @param
|
217
|
-
* @param
|
215
|
+
* @param {ASTNode} node Property AST node
|
216
|
+
* @param {boolean} checkQuotesRedundancy Whether to check quotes' redundancy
|
218
217
|
* @returns {void}
|
219
218
|
*/
|
220
219
|
function checkConsistency(node, checkQuotesRedundancy) {
|
package/lib/rules/quotes.js
CHANGED
package/lib/rules/radix.js
CHANGED
@@ -79,6 +79,9 @@ function isLocalVariableWithoutEscape(variable, isMemberAccess) {
|
|
79
79
|
reference.from.variableScope === functionScope);
|
80
80
|
}
|
81
81
|
|
82
|
+
/**
|
83
|
+
* Represents segment information.
|
84
|
+
*/
|
82
85
|
class SegmentInfo {
|
83
86
|
constructor() {
|
84
87
|
this.info = new WeakMap();
|
@@ -168,7 +171,6 @@ module.exports = {
|
|
168
171
|
|
169
172
|
docs: {
|
170
173
|
description: "disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
|
171
|
-
category: "Possible Errors",
|
172
174
|
recommended: false,
|
173
175
|
url: "https://eslint.org/docs/rules/require-atomic-updates"
|
174
176
|
},
|
@@ -177,7 +179,8 @@ module.exports = {
|
|
177
179
|
schema: [],
|
178
180
|
|
179
181
|
messages: {
|
180
|
-
nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`."
|
182
|
+
nonAtomicUpdate: "Possible race condition: `{{value}}` might be reassigned based on an outdated value of `{{value}}`.",
|
183
|
+
nonAtomicObjectUpdate: "Possible race condition: `{{value}}` might be assigned based on an outdated state of `{{object}}`."
|
181
184
|
}
|
182
185
|
},
|
183
186
|
|
@@ -273,13 +276,25 @@ module.exports = {
|
|
273
276
|
const variable = reference.resolved;
|
274
277
|
|
275
278
|
if (segmentInfo.isOutdated(codePath.currentSegments, variable)) {
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
279
|
+
if (node.parent.left === reference.identifier) {
|
280
|
+
context.report({
|
281
|
+
node: node.parent,
|
282
|
+
messageId: "nonAtomicUpdate",
|
283
|
+
data: {
|
284
|
+
value: variable.name
|
285
|
+
}
|
286
|
+
});
|
287
|
+
} else {
|
288
|
+
context.report({
|
289
|
+
node: node.parent,
|
290
|
+
messageId: "nonAtomicObjectUpdate",
|
291
|
+
data: {
|
292
|
+
value: sourceCode.getText(node.parent.left),
|
293
|
+
object: variable.name
|
294
|
+
}
|
295
|
+
});
|
296
|
+
}
|
297
|
+
|
283
298
|
}
|
284
299
|
}
|
285
300
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @fileoverview Rule to check for jsdoc presence.
|
3
3
|
* @author Gyandeep Singh
|
4
|
+
* @deprecated in ESLint v5.10.0
|
4
5
|
*/
|
5
6
|
"use strict";
|
6
7
|
|
@@ -10,7 +11,6 @@ module.exports = {
|
|
10
11
|
|
11
12
|
docs: {
|
12
13
|
description: "require JSDoc comments",
|
13
|
-
category: "Stylistic Issues",
|
14
14
|
recommended: false,
|
15
15
|
url: "https://eslint.org/docs/rules/require-jsdoc"
|
16
16
|
},
|
package/lib/rules/semi-style.js
CHANGED
package/lib/rules/semi.js
CHANGED
@@ -21,7 +21,6 @@ module.exports = {
|
|
21
21
|
|
22
22
|
docs: {
|
23
23
|
description: "require or disallow semicolons instead of ASI",
|
24
|
-
category: "Stylistic Issues",
|
25
24
|
recommended: false,
|
26
25
|
url: "https://eslint.org/docs/rules/semi"
|
27
26
|
},
|
@@ -78,6 +77,8 @@ module.exports = {
|
|
78
77
|
create(context) {
|
79
78
|
|
80
79
|
const OPT_OUT_PATTERN = /^[-[(/+`]/u; // One of [(/+-`
|
80
|
+
const unsafeClassFieldNames = new Set(["get", "set", "static"]);
|
81
|
+
const unsafeClassFieldFollowers = new Set(["*", "in", "instanceof"]);
|
81
82
|
const options = context.options[1];
|
82
83
|
const never = context.options[0] === "never";
|
83
84
|
const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock);
|
@@ -166,6 +167,55 @@ module.exports = {
|
|
166
167
|
);
|
167
168
|
}
|
168
169
|
|
170
|
+
/**
|
171
|
+
* Checks if a given PropertyDefinition node followed by a semicolon
|
172
|
+
* can safely remove that semicolon. It is not to safe to remove if
|
173
|
+
* the class field name is "get", "set", or "static", or if
|
174
|
+
* followed by a generator method.
|
175
|
+
* @param {ASTNode} node The node to check.
|
176
|
+
* @returns {boolean} `true` if the node cannot have the semicolon
|
177
|
+
* removed.
|
178
|
+
*/
|
179
|
+
function maybeClassFieldAsiHazard(node) {
|
180
|
+
|
181
|
+
if (node.type !== "PropertyDefinition") {
|
182
|
+
return false;
|
183
|
+
}
|
184
|
+
|
185
|
+
/*
|
186
|
+
* Computed property names and non-identifiers are always safe
|
187
|
+
* as they can be distinguished from keywords easily.
|
188
|
+
*/
|
189
|
+
const needsNameCheck = !node.computed && node.key.type === "Identifier";
|
190
|
+
|
191
|
+
/*
|
192
|
+
* Certain names are problematic unless they also have a
|
193
|
+
* a way to distinguish between keywords and property
|
194
|
+
* names.
|
195
|
+
*/
|
196
|
+
if (needsNameCheck && unsafeClassFieldNames.has(node.key.name)) {
|
197
|
+
|
198
|
+
/*
|
199
|
+
* Special case: If the field name is `static`,
|
200
|
+
* it is only valid if the field is marked as static,
|
201
|
+
* so "static static" is okay but "static" is not.
|
202
|
+
*/
|
203
|
+
const isStaticStatic = node.static && node.key.name === "static";
|
204
|
+
|
205
|
+
/*
|
206
|
+
* For other unsafe names, we only care if there is no
|
207
|
+
* initializer. No initializer = hazard.
|
208
|
+
*/
|
209
|
+
if (!isStaticStatic && !node.value) {
|
210
|
+
return true;
|
211
|
+
}
|
212
|
+
}
|
213
|
+
|
214
|
+
const followingToken = sourceCode.getTokenAfter(node);
|
215
|
+
|
216
|
+
return unsafeClassFieldFollowers.has(followingToken.value);
|
217
|
+
}
|
218
|
+
|
169
219
|
/**
|
170
220
|
* Check whether a given node is on the same line with the next token.
|
171
221
|
* @param {Node} node A statement node to check.
|
@@ -204,9 +254,6 @@ module.exports = {
|
|
204
254
|
if (isEndOfArrowBlock(sourceCode.getLastToken(node, 1))) {
|
205
255
|
return false;
|
206
256
|
}
|
207
|
-
if (t === "PropertyDefinition") {
|
208
|
-
return Boolean(t.value);
|
209
|
-
}
|
210
257
|
|
211
258
|
return true;
|
212
259
|
}
|
@@ -236,10 +283,19 @@ module.exports = {
|
|
236
283
|
if (isRedundantSemi(sourceCode.getLastToken(node))) {
|
237
284
|
return true; // `;;` or `;}`
|
238
285
|
}
|
286
|
+
if (maybeClassFieldAsiHazard(node)) {
|
287
|
+
return false;
|
288
|
+
}
|
239
289
|
if (isOnSameLineWithNextToken(node)) {
|
240
290
|
return false; // One liner.
|
241
291
|
}
|
242
|
-
|
292
|
+
|
293
|
+
// continuation characters should not apply to class fields
|
294
|
+
if (
|
295
|
+
node.type !== "PropertyDefinition" &&
|
296
|
+
beforeStatementContinuationChars === "never" &&
|
297
|
+
!maybeAsiHazardAfter(node)
|
298
|
+
) {
|
243
299
|
return true; // ASI works. This statement doesn't connect to the next.
|
244
300
|
}
|
245
301
|
if (!maybeAsiHazardBefore(sourceCode.getTokenAfter(node))) {
|
@@ -279,7 +335,11 @@ module.exports = {
|
|
279
335
|
if (never) {
|
280
336
|
if (isSemi && canRemoveSemicolon(node)) {
|
281
337
|
report(node, true);
|
282
|
-
} else if (
|
338
|
+
} else if (
|
339
|
+
!isSemi && beforeStatementContinuationChars === "always" &&
|
340
|
+
node.type !== "PropertyDefinition" &&
|
341
|
+
maybeAsiHazardBefore(sourceCode.getTokenAfter(node))
|
342
|
+
) {
|
283
343
|
report(node);
|
284
344
|
}
|
285
345
|
} else {
|
package/lib/rules/sort-keys.js
CHANGED
package/lib/rules/sort-vars.js
CHANGED