@alexlit/lint-kit 176.0.1 → 177.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/package.json +1 -1
- package/packages/config-stylelint/package.json +5 -5
- package/packages/config-stylelint/plugins/color-format.js +1 -5
- package/packages/config-stylelint/plugins/logical-css.js +1 -4
- package/packages/config-eslint/node_modules/@eslint/core/LICENSE +0 -201
- package/packages/config-eslint/node_modules/@eslint/core/README.md +0 -29
- package/packages/config-eslint/node_modules/@eslint/core/dist/cjs/types.d.cts +0 -1179
- package/packages/config-eslint/node_modules/@eslint/core/dist/esm/types.d.ts +0 -1179
- package/packages/config-eslint/node_modules/@eslint/core/package.json +0 -49
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/LICENSE +0 -201
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/README.md +0 -273
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/cjs/index.cjs +0 -884
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts +0 -328
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/cjs/types.cts +0 -7
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/index.d.ts +0 -328
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/index.js +0 -879
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/types.d.ts +0 -6
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/types.ts +0 -7
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/package.json +0 -61
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/configs/flat-config-base.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/index.d.ts +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/index.js +0 -91
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/license +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/globals.json +0 -3345
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/index.d.ts +0 -3452
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/index.js +0 -2
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/license +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/package.json +0 -117
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/readme.md +0 -42
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/package.json +0 -128
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/readme.md +0 -261
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/call-or-new-expression.js +0 -120
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/function-types.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/index.js +0 -30
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-arrow-function-body.js +0 -3
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-directive.js +0 -4
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-empty-array-expression.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-empty-node.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-expression-statement.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-function.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-member-expression.js +0 -98
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-method-call.js +0 -62
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-negative-one.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-reference-identifier.js +0 -159
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-static-require.js +0 -10
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-tagged-template-literal.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-undefined.js +0 -3
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/literal.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/better-regex.js +0 -146
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/catch-error-name.js +0 -138
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-assert.js +0 -98
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-date-clone.js +0 -54
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-destructuring.js +0 -168
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-empty-array-spread.js +0 -127
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-existence-index-check.js +0 -137
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-function-scoping.js +0 -265
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/custom-error-definition.js +0 -218
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/empty-brace-spaces.js +0 -62
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/error-message.js +0 -98
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/escape-case.js +0 -86
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/expiring-todo-comments.js +0 -584
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/explicit-length-check.js +0 -236
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/filename-case.js +0 -276
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/add-parenthesizes-to-return-or-throw-expression.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/append-argument.js +0 -30
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/extend-fix-range.js +0 -11
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/fix-space-around-keywords.js +0 -43
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/index.js +0 -23
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-argument.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-expression-statement.js +0 -34
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-method-call.js +0 -28
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-object-property.js +0 -21
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-parentheses.js +0 -19
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-spaces-after.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-specifier.js +0 -59
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/rename-variable.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-argument.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-member-expression-property.js +0 -25
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-node-or-token-and-spaces-before.js +0 -31
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-reference-identifier.js +0 -32
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-string-raw.js +0 -12
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-template-element.js +0 -10
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/switch-call-expression-to-new-expression.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/switch-new-expression-to-call-expression.js +0 -42
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/import-style.js +0 -375
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/index.js +0 -143
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/new-for-builtins.js +0 -112
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-abusive-eslint-disable.js +0 -63
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-accessor-recursion.js +0 -160
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-anonymous-default-export.js +0 -210
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-callback-reference.js +0 -285
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-for-each.js +0 -496
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-method-this-argument.js +0 -223
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-reduce.js +0 -128
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-reverse.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-sort.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-await-expression-member.js +0 -85
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-await-in-promise-methods.js +0 -69
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-console-spaces.js +0 -89
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-document-cookie.js +0 -27
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-empty-file.js +0 -58
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-for-loop.js +0 -419
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-hex-escape.js +0 -54
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-immediate-mutation.js +0 -778
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-instanceof-builtins.js +0 -216
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-invalid-fetch-options.js +0 -112
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-invalid-remove-event-listener.js +0 -61
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-keyword-prefix.js +0 -202
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-lonely-if.js +0 -155
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-magic-array-flat-depth.js +0 -55
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-named-default.js +0 -101
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-negated-condition.js +0 -145
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-negation-in-equality-check.js +0 -99
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-nested-ternary.js +0 -60
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-new-array.js +0 -106
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-new-buffer.js +0 -100
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-null.js +0 -153
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-object-as-default-parameter.js +0 -52
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-process-exit.js +0 -106
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-single-promise-in-promise-methods.js +0 -179
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-static-only-class.js +0 -226
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-thenable.js +0 -194
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-this-assignment.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-typeof-undefined.js +0 -146
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-array-flat-depth.js +0 -49
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-array-splice-count.js +0 -23
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-await.js +0 -110
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-polyfills.js +0 -174
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-slice-end.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unreadable-array-destructuring.js +0 -85
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unreadable-iife.js +0 -43
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unused-properties.js +0 -240
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-collection-argument.js +0 -101
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-error-capture-stack-trace.js +0 -146
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-fallback-in-spread.js +0 -66
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-length-check.js +0 -150
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-promise-resolve-reject.js +0 -210
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-spread.js +0 -389
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-switch-case.js +0 -59
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-undefined.js +0 -275
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-zero-fractions.js +0 -81
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/number-literal-case.js +0 -82
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/numeric-separators-style.js +0 -189
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-add-event-listener.js +0 -191
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-find.js +0 -458
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-flat-map.js +0 -86
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-flat.js +0 -279
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-index-of.js +0 -34
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-some.js +0 -219
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-at.js +0 -380
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-bigint-literals.js +0 -129
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-blob-reading-methods.js +0 -47
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-class-fields.js +0 -158
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-classlist-toggle.js +0 -255
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-code-point.js +0 -56
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-date-now.js +0 -133
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-default-parameters.js +0 -218
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-append.js +0 -50
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-dataset.js +0 -135
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-remove.js +0 -124
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-text-content.js +0 -77
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-event-target.js +0 -119
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-export-from.js +0 -367
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-global-this.js +0 -222
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-import-meta-properties.js +0 -320
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-includes.js +0 -111
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-json-parse-buffer.js +0 -161
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-keyboard-event-key.js +0 -188
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-logical-operator-over-ternary.js +0 -162
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-math-min-max.js +0 -205
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-math-trunc.js +0 -111
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-modern-dom-apis.js +0 -145
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-modern-math-apis.js +0 -210
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-module.js +0 -377
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-native-coercion-functions.js +0 -187
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-negative-index.js +0 -211
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-node-protocol.js +0 -86
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-number-properties.js +0 -142
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-object-from-entries.js +0 -256
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-optional-catch-binding.js +0 -77
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-prototype-methods.js +0 -162
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-query-selector.js +0 -170
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-reflect-apply.js +0 -99
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-regexp-test.js +0 -155
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-response-static-json.js +0 -85
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-set-has.js +0 -181
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-set-size.js +0 -106
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-single-call.js +0 -188
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-spread.js +0 -521
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-raw.js +0 -149
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-replace-all.js +0 -180
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-slice.js +0 -180
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-starts-ends-with.js +0 -201
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-trim-start-end.js +0 -46
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-structured-clone.js +0 -149
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-switch.js +0 -357
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-ternary.js +0 -288
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-top-level-await.js +0 -154
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-type-error.js +0 -169
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prevent-abbreviations.js +0 -655
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/relative-url-style.js +0 -171
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-array-join-separator.js +0 -65
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-module-attributes.js +0 -120
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-module-specifiers.js +0 -158
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-number-to-fixed-digits-argument.js +0 -55
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-post-message-target-origin.js +0 -74
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/get-documentation-url.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/index.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-create.js +0 -51
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-listener.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-problem.js +0 -38
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-rule-fixer.js +0 -49
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-rule.js +0 -38
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-rules.js +0 -13
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/unicorn-context.js +0 -36
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/unicorn-listeners.js +0 -65
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/utilities.js +0 -27
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/abbreviations.js +0 -270
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/builtin-errors.js +0 -14
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/dom-events.js +0 -275
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/event-keys.js +0 -54
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/negative-index.js +0 -52
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/no-array-mutate-rule.js +0 -139
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/no-unnecessary-length-or-infinity-rule.js +0 -80
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/package-json.js +0 -42
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/simple-array-search-rule.js +0 -126
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/typed-array.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/string-content.js +0 -192
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/switch-case-braces.js +0 -114
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/template-indent.js +0 -219
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/text-encoding-identifier-case.js +0 -130
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/throw-new-error.js +0 -60
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/array-or-object-prototype-property.js +0 -57
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/assert-token.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/boolean.js +0 -88
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/builtins.js +0 -30
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/cartesian-product-samples.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/create-deprecated-rules.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/escape-string.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/escape-template-element-raw.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-ancestor.js +0 -15
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-available-variable-name.js +0 -147
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-builtin-rule.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-call-expression-arguments-text.js +0 -36
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-call-or-new-expression-tokens.js +0 -67
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-class-head-location.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-documentation-url.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-indent-string.js +0 -18
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-references.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-scopes.js +0 -12
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-sibling-node.js +0 -38
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-switch-case-head-location.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-token-store.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-variable-identifiers.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/global-reference-tracker.js +0 -68
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/has-optional-chain-element.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/has-same-range.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/index.js +0 -59
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-function-self-used-inside.js +0 -39
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-left-hand-side.js +0 -20
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-logical-expression.js +0 -14
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-method-named.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-new-expression-with-parentheses.js +0 -28
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-node-matches.js +0 -58
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-node-value-not-dom-node.js +0 -20
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-node-value-not-function.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-number.js +0 -224
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-object-method.js +0 -10
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-on-same-line.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-same-identifier.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-same-reference.js +0 -170
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-export-local.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-import-local.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-property-assignment-pattern-left.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-property-value.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-unresolved-variable.js +0 -14
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-value-not-usable.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/needs-semicolon.js +0 -118
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/numeric.js +0 -49
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/parentheses.js +0 -71
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/resolve-variable-name.js +0 -18
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/rule.js +0 -27
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-await-expression-argument.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-call-expression-callee.js +0 -18
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-conditional-expression-child.js +0 -13
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-expression-statement-expression.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-logical-expression-child.js +0 -43
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-member-expression-object.js +0 -47
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-new-expression-callee.js +0 -28
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-unary-expression.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/singular.js +0 -16
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/string-cases.js +0 -2
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/to-location.js +0 -25
package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-immediate-mutation.js
DELETED
|
@@ -1,778 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hasSideEffect,
|
|
3
|
-
isCommaToken,
|
|
4
|
-
isSemicolonToken,
|
|
5
|
-
findVariable,
|
|
6
|
-
} from '@eslint-community/eslint-utils';
|
|
7
|
-
import {
|
|
8
|
-
isMethodCall,
|
|
9
|
-
isMemberExpression,
|
|
10
|
-
isNewExpression,
|
|
11
|
-
} from './ast/index.js';
|
|
12
|
-
import {
|
|
13
|
-
removeExpressionStatement,
|
|
14
|
-
removeArgument,
|
|
15
|
-
} from './fix/index.js';
|
|
16
|
-
import {
|
|
17
|
-
getNextNode,
|
|
18
|
-
getCallExpressionArgumentsText,
|
|
19
|
-
getParenthesizedText,
|
|
20
|
-
getVariableIdentifiers,
|
|
21
|
-
getNewExpressionTokens,
|
|
22
|
-
isNewExpressionWithParentheses,
|
|
23
|
-
} from './utils/index.js';
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
@import {TSESTree as ESTree} from '@typescript-eslint/types';
|
|
27
|
-
@import * as ESLint from 'eslint';
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
const MESSAGE_ID_ERROR = 'error';
|
|
31
|
-
const MESSAGE_ID_SUGGESTION_ARRAY = 'suggestion/array';
|
|
32
|
-
const MESSAGE_ID_SUGGESTION_OBJECT = 'suggestion/object';
|
|
33
|
-
const MESSAGE_ID_SUGGESTION_OBJECT_ASSIGN = 'suggestion/object-assign';
|
|
34
|
-
const MESSAGE_ID_SUGGESTION_SET = 'suggestion/set';
|
|
35
|
-
const MESSAGE_ID_SUGGESTION_MAP = 'suggestion/map';
|
|
36
|
-
const messages = {
|
|
37
|
-
[MESSAGE_ID_ERROR]: 'Immediate mutation on {{objectType}} is not allowed.',
|
|
38
|
-
[MESSAGE_ID_SUGGESTION_ARRAY]: '{{operation}} the elements to the {{assignType}}.',
|
|
39
|
-
[MESSAGE_ID_SUGGESTION_OBJECT]: 'Move this property to the {{assignType}}.',
|
|
40
|
-
[MESSAGE_ID_SUGGESTION_OBJECT_ASSIGN]: '{{description}} the {{assignType}}.',
|
|
41
|
-
[MESSAGE_ID_SUGGESTION_SET]: 'Move the element to the {{assignType}}.',
|
|
42
|
-
[MESSAGE_ID_SUGGESTION_MAP]: 'Move the entry to the {{assignType}}.',
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const hasVariableInNodes = (variable, nodes, context) => {
|
|
46
|
-
const {sourceCode} = context;
|
|
47
|
-
const identifiers = getVariableIdentifiers(variable);
|
|
48
|
-
return nodes.some(node => {
|
|
49
|
-
const range = sourceCode.getRange(node);
|
|
50
|
-
return identifiers.some(identifier => {
|
|
51
|
-
const [start, end] = sourceCode.getRange(identifier);
|
|
52
|
-
return start >= range[0] && end <= range[1];
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
function isCallExpressionWithOptionalArrayExpression(newExpression, names) {
|
|
58
|
-
if (!isNewExpression(
|
|
59
|
-
newExpression,
|
|
60
|
-
{names, maximumArguments: 1},
|
|
61
|
-
)) {
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// `new Set();` and `new Set([]);`
|
|
66
|
-
const [iterable] = newExpression.arguments;
|
|
67
|
-
return (!iterable || iterable.type === 'ArrayExpression');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function * removeExpressionStatementAfterAssign(expressionStatement, context, fixer) {
|
|
71
|
-
const tokenBefore = context.sourceCode.getTokenBefore(expressionStatement);
|
|
72
|
-
const shouldPreserveSemiColon = !isSemicolonToken(tokenBefore);
|
|
73
|
-
yield removeExpressionStatement(expressionStatement, context, fixer, shouldPreserveSemiColon);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function appendListTextToArrayExpressionOrObjectExpression(
|
|
77
|
-
context,
|
|
78
|
-
fixer,
|
|
79
|
-
arrayOrObjectExpression,
|
|
80
|
-
listText,
|
|
81
|
-
) {
|
|
82
|
-
const {sourceCode} = context;
|
|
83
|
-
const [
|
|
84
|
-
penultimateToken,
|
|
85
|
-
closingBracketToken,
|
|
86
|
-
] = sourceCode.getLastTokens(arrayOrObjectExpression, 2);
|
|
87
|
-
const list = arrayOrObjectExpression.type === 'ArrayExpression'
|
|
88
|
-
? arrayOrObjectExpression.elements
|
|
89
|
-
: arrayOrObjectExpression.properties;
|
|
90
|
-
const shouldInsertComma = list.length > 0 && !isCommaToken(penultimateToken);
|
|
91
|
-
|
|
92
|
-
return fixer.insertTextBefore(
|
|
93
|
-
closingBracketToken,
|
|
94
|
-
`${shouldInsertComma ? ',' : ''} ${listText}`,
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function * appendElementsTextToSetConstructor({
|
|
99
|
-
context,
|
|
100
|
-
fixer,
|
|
101
|
-
newExpression,
|
|
102
|
-
elementsText,
|
|
103
|
-
nextExpressionStatement,
|
|
104
|
-
}) {
|
|
105
|
-
if (isNewExpressionWithParentheses(newExpression, context)) {
|
|
106
|
-
const [setInitialValue] = newExpression.arguments;
|
|
107
|
-
if (setInitialValue) {
|
|
108
|
-
yield appendListTextToArrayExpressionOrObjectExpression(context, fixer, setInitialValue, elementsText);
|
|
109
|
-
} else {
|
|
110
|
-
const {
|
|
111
|
-
openingParenthesisToken,
|
|
112
|
-
} = getNewExpressionTokens(newExpression, context);
|
|
113
|
-
yield fixer.insertTextAfter(openingParenthesisToken, `[${elementsText}]`);
|
|
114
|
-
}
|
|
115
|
-
} else {
|
|
116
|
-
/*
|
|
117
|
-
The new expression doesn't have parentheses
|
|
118
|
-
```
|
|
119
|
-
const set = (( new (( Set )) ));
|
|
120
|
-
set.add(1);
|
|
121
|
-
```
|
|
122
|
-
*/
|
|
123
|
-
yield fixer.insertTextAfter(newExpression, `([${elementsText}])`);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
yield * removeExpressionStatementAfterAssign(nextExpressionStatement, context, fixer);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function getObjectExpressionPropertiesText(objectExpression, context) {
|
|
130
|
-
const {sourceCode} = context;
|
|
131
|
-
const openingBraceToken = sourceCode.getFirstToken(objectExpression);
|
|
132
|
-
const [penultimateToken, closingBraceToken] = sourceCode.getLastTokens(objectExpression, 2);
|
|
133
|
-
const [, start] = sourceCode.getRange(openingBraceToken);
|
|
134
|
-
const [end] = sourceCode.getRange(isCommaToken(penultimateToken) ? penultimateToken : closingBraceToken);
|
|
135
|
-
return sourceCode.text.slice(start, end);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
@typedef {ESTree.VariableDeclarator['init'] | ESTree.AssignmentExpression['right']} ValueNode
|
|
140
|
-
@typedef {(information: ViolationCaseInformation, arguments: any)} GetFix
|
|
141
|
-
@typedef {Parameters<ESLint.Rule.RuleContext['report']>[0]} Problem
|
|
142
|
-
@typedef {(information: ViolationCaseInformation) => ESTree.Node} GetProblematicNode
|
|
143
|
-
@typedef {{
|
|
144
|
-
context: ESLint.Rule.RuleContext,
|
|
145
|
-
variable: ESLint.Scope.Variable,
|
|
146
|
-
variableNode: ESTree.Identifier,
|
|
147
|
-
valueNode: ValueNode,
|
|
148
|
-
statement: ESTree.VariableDeclaration | ESTree.ExpressionStatement,
|
|
149
|
-
nextExpressionStatement: ESTree.ExpressionStatement,
|
|
150
|
-
assignType: 'assignment' | 'declaration',
|
|
151
|
-
getFix: GetFix,
|
|
152
|
-
}} ViolationCaseInformation
|
|
153
|
-
@typedef {{
|
|
154
|
-
testValue: (value: ValueNode) => boolean,
|
|
155
|
-
getProblematicNode: GetProblematicNode,
|
|
156
|
-
getProblem: (node: ReturnType<GetProblematicNode>, information: ViolationCaseInformation) => Problem,
|
|
157
|
-
getFix: GetFix,
|
|
158
|
-
}} ViolationCase
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
// `Array`
|
|
162
|
-
/** @type {ViolationCase} */
|
|
163
|
-
const arrayMutationSettings = {
|
|
164
|
-
testValue: value => value?.type === 'ArrayExpression',
|
|
165
|
-
getProblematicNode({
|
|
166
|
-
context,
|
|
167
|
-
variable,
|
|
168
|
-
nextExpressionStatement,
|
|
169
|
-
}) {
|
|
170
|
-
const callExpression = nextExpressionStatement.expression;
|
|
171
|
-
|
|
172
|
-
if (!(
|
|
173
|
-
isMethodCall(callExpression, {
|
|
174
|
-
object: variable.name,
|
|
175
|
-
methods: ['push', 'unshift'],
|
|
176
|
-
optionalMember: false,
|
|
177
|
-
optionalCall: false,
|
|
178
|
-
})
|
|
179
|
-
&& callExpression.arguments.length > 0
|
|
180
|
-
)) {
|
|
181
|
-
return;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (hasVariableInNodes(variable, callExpression.arguments, context)) {
|
|
185
|
-
return;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return callExpression;
|
|
189
|
-
},
|
|
190
|
-
getProblem(callExpression, information) {
|
|
191
|
-
const {
|
|
192
|
-
context,
|
|
193
|
-
assignType,
|
|
194
|
-
getFix,
|
|
195
|
-
} = information;
|
|
196
|
-
const {sourceCode} = context;
|
|
197
|
-
const memberExpression = callExpression.callee;
|
|
198
|
-
const method = memberExpression.property;
|
|
199
|
-
const problem = {
|
|
200
|
-
node: memberExpression,
|
|
201
|
-
messageId: MESSAGE_ID_ERROR,
|
|
202
|
-
data: {objectType: 'array'},
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
const isPrepend = method.name === 'unshift';
|
|
206
|
-
const fix = getFix(information, {
|
|
207
|
-
callExpression,
|
|
208
|
-
isPrepend,
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
if (callExpression.arguments.some(element => hasSideEffect(element, sourceCode))) {
|
|
212
|
-
problem.suggest = [
|
|
213
|
-
{
|
|
214
|
-
messageId: MESSAGE_ID_SUGGESTION_ARRAY,
|
|
215
|
-
fix,
|
|
216
|
-
data: {operation: isPrepend ? 'Prepend' : 'Append', assignType},
|
|
217
|
-
},
|
|
218
|
-
];
|
|
219
|
-
} else {
|
|
220
|
-
problem.fix = fix;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
return problem;
|
|
224
|
-
},
|
|
225
|
-
getFix: (
|
|
226
|
-
{
|
|
227
|
-
context,
|
|
228
|
-
valueNode: arrayExpression,
|
|
229
|
-
nextExpressionStatement,
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
callExpression,
|
|
233
|
-
isPrepend,
|
|
234
|
-
},
|
|
235
|
-
) => function * (fixer) {
|
|
236
|
-
const text = getCallExpressionArgumentsText(context, callExpression, /* includeTrailingComma */ false);
|
|
237
|
-
|
|
238
|
-
yield (
|
|
239
|
-
isPrepend
|
|
240
|
-
? fixer.insertTextAfter(
|
|
241
|
-
context.sourceCode.getFirstToken(arrayExpression),
|
|
242
|
-
`${text}, `,
|
|
243
|
-
)
|
|
244
|
-
: appendListTextToArrayExpressionOrObjectExpression(context, fixer, arrayExpression, text)
|
|
245
|
-
);
|
|
246
|
-
|
|
247
|
-
yield * removeExpressionStatementAfterAssign(
|
|
248
|
-
nextExpressionStatement,
|
|
249
|
-
context,
|
|
250
|
-
fixer,
|
|
251
|
-
);
|
|
252
|
-
},
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
// `Object` + `AssignmentExpression`
|
|
256
|
-
/** @type {ViolationCase} */
|
|
257
|
-
const objectWithAssignmentExpressionSettings = {
|
|
258
|
-
testValue: value => value?.type === 'ObjectExpression',
|
|
259
|
-
getProblematicNode({
|
|
260
|
-
context,
|
|
261
|
-
variable,
|
|
262
|
-
nextExpressionStatement,
|
|
263
|
-
}) {
|
|
264
|
-
const assignmentExpression = nextExpressionStatement.expression;
|
|
265
|
-
if (!(
|
|
266
|
-
assignmentExpression.type === 'AssignmentExpression'
|
|
267
|
-
&& assignmentExpression.operator === '='
|
|
268
|
-
&& isMemberExpression(assignmentExpression.left, {object: variable.name, optional: false})
|
|
269
|
-
)) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
const value = assignmentExpression.right;
|
|
274
|
-
const memberExpression = assignmentExpression.left;
|
|
275
|
-
const {property} = memberExpression;
|
|
276
|
-
|
|
277
|
-
if (
|
|
278
|
-
hasVariableInNodes(
|
|
279
|
-
variable,
|
|
280
|
-
memberExpression.computed ? [property, value] : [value],
|
|
281
|
-
context,
|
|
282
|
-
)
|
|
283
|
-
) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
return assignmentExpression;
|
|
288
|
-
},
|
|
289
|
-
getProblem(assignmentExpression, information) {
|
|
290
|
-
const {
|
|
291
|
-
context,
|
|
292
|
-
assignType,
|
|
293
|
-
getFix,
|
|
294
|
-
} = information;
|
|
295
|
-
const {sourceCode} = context;
|
|
296
|
-
const {
|
|
297
|
-
left: memberExpression,
|
|
298
|
-
right: value,
|
|
299
|
-
} = assignmentExpression;
|
|
300
|
-
|
|
301
|
-
const {property} = memberExpression;
|
|
302
|
-
const operatorToken = sourceCode.getTokenAfter(memberExpression, token => token.type === 'Punctuator' && token.value === assignmentExpression.operator);
|
|
303
|
-
|
|
304
|
-
const problem = {
|
|
305
|
-
node: assignmentExpression,
|
|
306
|
-
loc: {
|
|
307
|
-
start: sourceCode.getLoc(assignmentExpression).start,
|
|
308
|
-
end: sourceCode.getLoc(operatorToken).end,
|
|
309
|
-
},
|
|
310
|
-
messageId: MESSAGE_ID_ERROR,
|
|
311
|
-
data: {objectType: 'object'},
|
|
312
|
-
};
|
|
313
|
-
const fix = getFix(information, {
|
|
314
|
-
assignmentExpression,
|
|
315
|
-
memberExpression,
|
|
316
|
-
property,
|
|
317
|
-
value,
|
|
318
|
-
});
|
|
319
|
-
|
|
320
|
-
if (
|
|
321
|
-
(memberExpression.computed && hasSideEffect(property, sourceCode))
|
|
322
|
-
|| hasSideEffect(value, sourceCode)
|
|
323
|
-
) {
|
|
324
|
-
problem.suggest = [
|
|
325
|
-
{
|
|
326
|
-
messageId: MESSAGE_ID_SUGGESTION_OBJECT,
|
|
327
|
-
data: {assignType},
|
|
328
|
-
fix,
|
|
329
|
-
},
|
|
330
|
-
];
|
|
331
|
-
} else {
|
|
332
|
-
problem.fix = fix;
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
return problem;
|
|
336
|
-
},
|
|
337
|
-
getFix: (
|
|
338
|
-
{
|
|
339
|
-
context,
|
|
340
|
-
valueNode: objectExpression,
|
|
341
|
-
nextExpressionStatement,
|
|
342
|
-
},
|
|
343
|
-
{
|
|
344
|
-
memberExpression,
|
|
345
|
-
property,
|
|
346
|
-
value,
|
|
347
|
-
},
|
|
348
|
-
) => function * (fixer) {
|
|
349
|
-
let propertyText = getParenthesizedText(property, context);
|
|
350
|
-
if (memberExpression.computed) {
|
|
351
|
-
propertyText = `[${propertyText}]`;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
const valueText = getParenthesizedText(value, context);
|
|
355
|
-
|
|
356
|
-
const text = `${propertyText}: ${valueText},`;
|
|
357
|
-
const [
|
|
358
|
-
penultimateToken,
|
|
359
|
-
closingBraceToken,
|
|
360
|
-
] = context.sourceCode.getLastTokens(objectExpression, 2);
|
|
361
|
-
const shouldInsertComma = objectExpression.properties.length > 0 && !isCommaToken(penultimateToken);
|
|
362
|
-
|
|
363
|
-
yield fixer.insertTextBefore(
|
|
364
|
-
closingBraceToken,
|
|
365
|
-
`${shouldInsertComma ? ',' : ''} ${text}`,
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
yield * removeExpressionStatementAfterAssign(
|
|
369
|
-
nextExpressionStatement,
|
|
370
|
-
context,
|
|
371
|
-
fixer,
|
|
372
|
-
);
|
|
373
|
-
},
|
|
374
|
-
};
|
|
375
|
-
|
|
376
|
-
// `Object` + `Object.assign()`
|
|
377
|
-
/** @type {ViolationCase} */
|
|
378
|
-
const objectWithObjectAssignSettings = {
|
|
379
|
-
testValue: value => value?.type === 'ObjectExpression',
|
|
380
|
-
getProblematicNode({
|
|
381
|
-
context,
|
|
382
|
-
variable,
|
|
383
|
-
nextExpressionStatement,
|
|
384
|
-
}) {
|
|
385
|
-
const callExpression = nextExpressionStatement.expression;
|
|
386
|
-
|
|
387
|
-
if (!isMethodCall(callExpression, {
|
|
388
|
-
object: 'Object',
|
|
389
|
-
method: 'assign',
|
|
390
|
-
minimumArguments: 2,
|
|
391
|
-
optionalMember: false,
|
|
392
|
-
optionalCall: false,
|
|
393
|
-
})) {
|
|
394
|
-
return;
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
const [object, firstValue] = callExpression.arguments;
|
|
398
|
-
|
|
399
|
-
if (
|
|
400
|
-
!(object.type === 'Identifier' && object.name === variable.name)
|
|
401
|
-
|| firstValue.type === 'SpreadElement'
|
|
402
|
-
|| hasVariableInNodes(variable, [firstValue], context)
|
|
403
|
-
) {
|
|
404
|
-
return;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
return callExpression;
|
|
408
|
-
},
|
|
409
|
-
getProblem(callExpression, information) {
|
|
410
|
-
const {
|
|
411
|
-
context,
|
|
412
|
-
assignType,
|
|
413
|
-
getFix,
|
|
414
|
-
} = information;
|
|
415
|
-
const {sourceCode} = context;
|
|
416
|
-
const [, firstValue] = callExpression.arguments;
|
|
417
|
-
|
|
418
|
-
const problem = {
|
|
419
|
-
node: callExpression.callee,
|
|
420
|
-
messageId: MESSAGE_ID_ERROR,
|
|
421
|
-
data: {objectType: 'object'},
|
|
422
|
-
};
|
|
423
|
-
const fix = getFix(information, {
|
|
424
|
-
callExpression,
|
|
425
|
-
firstValue,
|
|
426
|
-
});
|
|
427
|
-
|
|
428
|
-
if (hasSideEffect(firstValue, sourceCode)) {
|
|
429
|
-
const description = firstValue.type === 'ObjectExpression'
|
|
430
|
-
? 'Move properties to'
|
|
431
|
-
: 'Spread properties in';
|
|
432
|
-
|
|
433
|
-
problem.suggest = [
|
|
434
|
-
{
|
|
435
|
-
messageId: MESSAGE_ID_SUGGESTION_OBJECT_ASSIGN,
|
|
436
|
-
data: {description, assignType},
|
|
437
|
-
fix,
|
|
438
|
-
},
|
|
439
|
-
];
|
|
440
|
-
} else {
|
|
441
|
-
problem.fix = fix;
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
return problem;
|
|
445
|
-
},
|
|
446
|
-
getFix: (
|
|
447
|
-
{
|
|
448
|
-
context,
|
|
449
|
-
valueNode: objectExpression,
|
|
450
|
-
nextExpressionStatement,
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
callExpression,
|
|
454
|
-
firstValue,
|
|
455
|
-
},
|
|
456
|
-
) => function * (fixer) {
|
|
457
|
-
let text;
|
|
458
|
-
if (firstValue.type === 'ObjectExpression') {
|
|
459
|
-
if (firstValue.properties.length > 0) {
|
|
460
|
-
text = getObjectExpressionPropertiesText(firstValue, context);
|
|
461
|
-
}
|
|
462
|
-
} else {
|
|
463
|
-
text = `...${getParenthesizedText(firstValue, context)}`;
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
if (text) {
|
|
467
|
-
yield appendListTextToArrayExpressionOrObjectExpression(context, fixer, objectExpression, text);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
if (callExpression.arguments.length !== 2) {
|
|
471
|
-
yield removeArgument(fixer, firstValue, context);
|
|
472
|
-
|
|
473
|
-
return;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
yield * removeExpressionStatementAfterAssign(
|
|
477
|
-
nextExpressionStatement,
|
|
478
|
-
context,
|
|
479
|
-
fixer,
|
|
480
|
-
);
|
|
481
|
-
},
|
|
482
|
-
};
|
|
483
|
-
|
|
484
|
-
// `Set` and `WeakSet`
|
|
485
|
-
/** @type {ViolationCase} */
|
|
486
|
-
const setMutationSettings = {
|
|
487
|
-
testValue: value => isCallExpressionWithOptionalArrayExpression(value, ['Set', 'WeakSet']),
|
|
488
|
-
getProblematicNode({
|
|
489
|
-
context,
|
|
490
|
-
variable,
|
|
491
|
-
nextExpressionStatement,
|
|
492
|
-
}) {
|
|
493
|
-
let callExpression = nextExpressionStatement.expression;
|
|
494
|
-
if (callExpression.type === 'ChainExpression') {
|
|
495
|
-
callExpression = callExpression.expression;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
if (!isMethodCall(callExpression, {
|
|
499
|
-
object: variable.name,
|
|
500
|
-
method: 'add',
|
|
501
|
-
argumentsLength: 1,
|
|
502
|
-
optionalMember: false,
|
|
503
|
-
optionalCall: false,
|
|
504
|
-
})) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if (hasVariableInNodes(variable, callExpression.arguments, context)) {
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
return callExpression;
|
|
513
|
-
},
|
|
514
|
-
getProblem(callExpression, information) {
|
|
515
|
-
const {
|
|
516
|
-
context,
|
|
517
|
-
assignType,
|
|
518
|
-
valueNode: newExpression,
|
|
519
|
-
getFix,
|
|
520
|
-
} = information;
|
|
521
|
-
const {sourceCode} = context;
|
|
522
|
-
const memberExpression = callExpression.callee;
|
|
523
|
-
const problem = {
|
|
524
|
-
node: memberExpression,
|
|
525
|
-
messageId: MESSAGE_ID_ERROR,
|
|
526
|
-
data: {objectType: `\`${newExpression.callee.name}\``},
|
|
527
|
-
};
|
|
528
|
-
|
|
529
|
-
const fix = getFix(information, {
|
|
530
|
-
callExpression,
|
|
531
|
-
newExpression,
|
|
532
|
-
});
|
|
533
|
-
|
|
534
|
-
if (callExpression.arguments.some(element => hasSideEffect(element, sourceCode))) {
|
|
535
|
-
problem.suggest = [
|
|
536
|
-
{
|
|
537
|
-
messageId: MESSAGE_ID_SUGGESTION_SET,
|
|
538
|
-
data: {assignType},
|
|
539
|
-
fix,
|
|
540
|
-
},
|
|
541
|
-
];
|
|
542
|
-
} else {
|
|
543
|
-
problem.fix = fix;
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
return problem;
|
|
547
|
-
},
|
|
548
|
-
getFix: (
|
|
549
|
-
{
|
|
550
|
-
context,
|
|
551
|
-
nextExpressionStatement,
|
|
552
|
-
},
|
|
553
|
-
{
|
|
554
|
-
callExpression,
|
|
555
|
-
newExpression,
|
|
556
|
-
},
|
|
557
|
-
) => fixer => {
|
|
558
|
-
const elementsText = getCallExpressionArgumentsText(
|
|
559
|
-
context,
|
|
560
|
-
callExpression,
|
|
561
|
-
/* IncludeTrailingComma */ false,
|
|
562
|
-
);
|
|
563
|
-
return appendElementsTextToSetConstructor({
|
|
564
|
-
context,
|
|
565
|
-
fixer,
|
|
566
|
-
newExpression,
|
|
567
|
-
elementsText,
|
|
568
|
-
nextExpressionStatement,
|
|
569
|
-
});
|
|
570
|
-
},
|
|
571
|
-
};
|
|
572
|
-
|
|
573
|
-
// `Map` and `WeakMap`
|
|
574
|
-
/** @type {ViolationCase} */
|
|
575
|
-
const mapMutationSettings = {
|
|
576
|
-
testValue: value => isCallExpressionWithOptionalArrayExpression(value, ['Map', 'WeakMap']),
|
|
577
|
-
getProblematicNode({
|
|
578
|
-
context,
|
|
579
|
-
variable,
|
|
580
|
-
nextExpressionStatement,
|
|
581
|
-
}) {
|
|
582
|
-
const callExpression = nextExpressionStatement.expression;
|
|
583
|
-
|
|
584
|
-
if (!isMethodCall(callExpression, {
|
|
585
|
-
object: variable.name,
|
|
586
|
-
method: 'set',
|
|
587
|
-
argumentsLength: 2,
|
|
588
|
-
optionalCall: false,
|
|
589
|
-
})) {
|
|
590
|
-
return;
|
|
591
|
-
}
|
|
592
|
-
|
|
593
|
-
if (hasVariableInNodes(variable, callExpression.arguments, context)) {
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
return callExpression;
|
|
598
|
-
},
|
|
599
|
-
getProblem(callExpression, information) {
|
|
600
|
-
const {
|
|
601
|
-
context,
|
|
602
|
-
assignType,
|
|
603
|
-
valueNode: newExpression,
|
|
604
|
-
getFix,
|
|
605
|
-
} = information;
|
|
606
|
-
const {sourceCode} = context;
|
|
607
|
-
const memberExpression = callExpression.callee;
|
|
608
|
-
const problem = {
|
|
609
|
-
node: memberExpression,
|
|
610
|
-
messageId: MESSAGE_ID_ERROR,
|
|
611
|
-
data: {objectType: `\`${newExpression.callee.name}\``},
|
|
612
|
-
};
|
|
613
|
-
|
|
614
|
-
const fix = getFix(information, {
|
|
615
|
-
callExpression,
|
|
616
|
-
newExpression,
|
|
617
|
-
});
|
|
618
|
-
|
|
619
|
-
if (callExpression.arguments.some(element => hasSideEffect(element, sourceCode))) {
|
|
620
|
-
problem.suggest = [
|
|
621
|
-
{
|
|
622
|
-
messageId: MESSAGE_ID_SUGGESTION_MAP,
|
|
623
|
-
data: {assignType},
|
|
624
|
-
fix,
|
|
625
|
-
},
|
|
626
|
-
];
|
|
627
|
-
} else {
|
|
628
|
-
problem.fix = fix;
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
return problem;
|
|
632
|
-
},
|
|
633
|
-
getFix: (
|
|
634
|
-
{
|
|
635
|
-
context,
|
|
636
|
-
nextExpressionStatement,
|
|
637
|
-
},
|
|
638
|
-
{
|
|
639
|
-
callExpression,
|
|
640
|
-
newExpression,
|
|
641
|
-
},
|
|
642
|
-
) => fixer => {
|
|
643
|
-
const argumentsText = getCallExpressionArgumentsText(
|
|
644
|
-
context,
|
|
645
|
-
callExpression,
|
|
646
|
-
/* IncludeTrailingComma */ false,
|
|
647
|
-
);
|
|
648
|
-
const entryText = `[${argumentsText}]`;
|
|
649
|
-
return appendElementsTextToSetConstructor({
|
|
650
|
-
context,
|
|
651
|
-
fixer,
|
|
652
|
-
newExpression,
|
|
653
|
-
elementsText: entryText,
|
|
654
|
-
nextExpressionStatement,
|
|
655
|
-
});
|
|
656
|
-
},
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
const cases = [
|
|
660
|
-
arrayMutationSettings,
|
|
661
|
-
objectWithAssignmentExpressionSettings,
|
|
662
|
-
objectWithObjectAssignSettings,
|
|
663
|
-
setMutationSettings,
|
|
664
|
-
mapMutationSettings,
|
|
665
|
-
];
|
|
666
|
-
|
|
667
|
-
function isLastDeclarator(variableDeclarator) {
|
|
668
|
-
const variableDeclaration = variableDeclarator.parent;
|
|
669
|
-
return (
|
|
670
|
-
variableDeclaration.type === 'VariableDeclaration'
|
|
671
|
-
&& variableDeclaration.declarations.at(-1) === variableDeclarator
|
|
672
|
-
);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
const getVariable = (node, context) => {
|
|
676
|
-
if (node.type === 'VariableDeclarator') {
|
|
677
|
-
return context.sourceCode.getDeclaredVariables(node)
|
|
678
|
-
.find(variable => variable.defs.length === 1 && variable.defs[0].name === node.id);
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
return findVariable(context.sourceCode.getScope(node), node.left.name);
|
|
682
|
-
};
|
|
683
|
-
|
|
684
|
-
function getCaseProblem(
|
|
685
|
-
context,
|
|
686
|
-
assignNode,
|
|
687
|
-
{
|
|
688
|
-
testValue,
|
|
689
|
-
getProblematicNode,
|
|
690
|
-
getProblem,
|
|
691
|
-
getFix,
|
|
692
|
-
},
|
|
693
|
-
) {
|
|
694
|
-
const isAssignment = assignNode.type === 'AssignmentExpression';
|
|
695
|
-
const [variableNode, valueNode] = (isAssignment ? ['left', 'right'] : ['id', 'init'])
|
|
696
|
-
.map(property => assignNode[property]);
|
|
697
|
-
|
|
698
|
-
// eslint-disable-next-line no-warning-comments
|
|
699
|
-
// TODO[@fisker]: `AssignmentExpression` should not limit to `Identifier`
|
|
700
|
-
if (!(variableNode.type === 'Identifier' && testValue(valueNode))) {
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
|
|
704
|
-
const statement = assignNode.parent;
|
|
705
|
-
|
|
706
|
-
if (!(
|
|
707
|
-
// eslint-disable-next-line no-warning-comments
|
|
708
|
-
// TODO[@fisker]: `AssignmentExpression` should support `a = b = c` too
|
|
709
|
-
(
|
|
710
|
-
isAssignment
|
|
711
|
-
&& assignNode.operator === '='
|
|
712
|
-
&& statement.type === 'ExpressionStatement'
|
|
713
|
-
&& statement.expression === assignNode)
|
|
714
|
-
|| (!isAssignment && isLastDeclarator(assignNode))
|
|
715
|
-
)) {
|
|
716
|
-
return;
|
|
717
|
-
}
|
|
718
|
-
|
|
719
|
-
const nextExpressionStatement = getNextNode(statement, context);
|
|
720
|
-
if (nextExpressionStatement?.type !== 'ExpressionStatement') {
|
|
721
|
-
return;
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
const variable = getVariable(assignNode, context);
|
|
725
|
-
/* c8 ignore next */
|
|
726
|
-
if (!variable) {
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
const information = {
|
|
731
|
-
context,
|
|
732
|
-
variable,
|
|
733
|
-
variableNode,
|
|
734
|
-
valueNode,
|
|
735
|
-
statement,
|
|
736
|
-
nextExpressionStatement,
|
|
737
|
-
assignType: isAssignment ? 'assignment' : 'declaration',
|
|
738
|
-
getFix,
|
|
739
|
-
};
|
|
740
|
-
|
|
741
|
-
const problematicNode = getProblematicNode(information);
|
|
742
|
-
|
|
743
|
-
if (!problematicNode) {
|
|
744
|
-
return;
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
return getProblem(problematicNode, information);
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
751
|
-
const create = context => {
|
|
752
|
-
for (const caseSettings of cases) {
|
|
753
|
-
context.on(
|
|
754
|
-
[
|
|
755
|
-
'VariableDeclarator',
|
|
756
|
-
'AssignmentExpression',
|
|
757
|
-
],
|
|
758
|
-
assignNode => getCaseProblem(context, assignNode, caseSettings),
|
|
759
|
-
);
|
|
760
|
-
}
|
|
761
|
-
};
|
|
762
|
-
|
|
763
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
764
|
-
const config = {
|
|
765
|
-
create,
|
|
766
|
-
meta: {
|
|
767
|
-
type: 'suggestion',
|
|
768
|
-
docs: {
|
|
769
|
-
description: 'Disallow immediate mutation after variable assignment.',
|
|
770
|
-
recommended: true,
|
|
771
|
-
},
|
|
772
|
-
fixable: 'code',
|
|
773
|
-
hasSuggestions: true,
|
|
774
|
-
messages,
|
|
775
|
-
},
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
export default config;
|