@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-array-for-each.js
DELETED
|
@@ -1,496 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isParenthesized,
|
|
3
|
-
isCommaToken,
|
|
4
|
-
isSemicolonToken,
|
|
5
|
-
isClosingParenToken,
|
|
6
|
-
findVariable,
|
|
7
|
-
hasSideEffect,
|
|
8
|
-
} from '@eslint-community/eslint-utils';
|
|
9
|
-
import {
|
|
10
|
-
extendFixRange,
|
|
11
|
-
fixSpaceAroundKeyword,
|
|
12
|
-
removeParentheses,
|
|
13
|
-
} from './fix/index.js';
|
|
14
|
-
import needsSemicolon from './utils/needs-semicolon.js';
|
|
15
|
-
import shouldAddParenthesesToExpressionStatementExpression from './utils/should-add-parentheses-to-expression-statement-expression.js';
|
|
16
|
-
import shouldAddParenthesesToMemberExpressionObject from './utils/should-add-parentheses-to-member-expression-object.js';
|
|
17
|
-
import {getParentheses, getParenthesizedRange} from './utils/parentheses.js';
|
|
18
|
-
import isFunctionSelfUsedInside from './utils/is-function-self-used-inside.js';
|
|
19
|
-
import {isNodeMatches} from './utils/is-node-matches.js';
|
|
20
|
-
import assertToken from './utils/assert-token.js';
|
|
21
|
-
import {
|
|
22
|
-
isArrowFunctionBody,
|
|
23
|
-
isMethodCall,
|
|
24
|
-
isReferenceIdentifier,
|
|
25
|
-
functionTypes,
|
|
26
|
-
} from './ast/index.js';
|
|
27
|
-
|
|
28
|
-
const MESSAGE_ID_ERROR = 'no-array-for-each/error';
|
|
29
|
-
const MESSAGE_ID_SUGGESTION = 'no-array-for-each/suggestion';
|
|
30
|
-
const messages = {
|
|
31
|
-
[MESSAGE_ID_ERROR]: 'Use `for…of` instead of `.forEach(…)`.',
|
|
32
|
-
[MESSAGE_ID_SUGGESTION]: 'Switch to `for…of`.',
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const continueAbleNodeTypes = new Set([
|
|
36
|
-
'WhileStatement',
|
|
37
|
-
'DoWhileStatement',
|
|
38
|
-
'ForStatement',
|
|
39
|
-
'ForOfStatement',
|
|
40
|
-
'ForInStatement',
|
|
41
|
-
]);
|
|
42
|
-
|
|
43
|
-
const stripChainExpression = node =>
|
|
44
|
-
(node.parent.type === 'ChainExpression' && node.parent.expression === node)
|
|
45
|
-
? node.parent
|
|
46
|
-
: node;
|
|
47
|
-
|
|
48
|
-
function isReturnStatementInContinueAbleNodes(returnStatement, callbackFunction) {
|
|
49
|
-
for (let node = returnStatement; node && node !== callbackFunction; node = node.parent) {
|
|
50
|
-
if (continueAbleNodeTypes.has(node.type)) {
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function shouldSwitchReturnStatementToBlockStatement(returnStatement) {
|
|
59
|
-
const {parent} = returnStatement;
|
|
60
|
-
|
|
61
|
-
switch (parent.type) {
|
|
62
|
-
case 'IfStatement': {
|
|
63
|
-
return parent.consequent === returnStatement || parent.alternate === returnStatement;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// These parent's body need switch to `BlockStatement` too, but since they are "continueAble", won't fix
|
|
67
|
-
// case 'ForStatement':
|
|
68
|
-
// case 'ForInStatement':
|
|
69
|
-
// case 'ForOfStatement':
|
|
70
|
-
// case 'WhileStatement':
|
|
71
|
-
// case 'DoWhileStatement':
|
|
72
|
-
case 'WithStatement': {
|
|
73
|
-
return parent.body === returnStatement;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
default: {
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function getFixFunction(callExpression, functionInfo, context) {
|
|
83
|
-
const {sourceCode} = context;
|
|
84
|
-
const [callback] = callExpression.arguments;
|
|
85
|
-
const parameters = callback.params;
|
|
86
|
-
const iterableObject = callExpression.callee.object;
|
|
87
|
-
const {returnStatements} = functionInfo.get(callback);
|
|
88
|
-
const isOptionalObject = callExpression.callee.optional;
|
|
89
|
-
const ancestor = stripChainExpression(callExpression).parent;
|
|
90
|
-
const objectText = sourceCode.getText(iterableObject);
|
|
91
|
-
|
|
92
|
-
const getForOfLoopHeadText = () => {
|
|
93
|
-
const [elementText, indexText] = parameters.map(parameter => sourceCode.getText(parameter));
|
|
94
|
-
const shouldUseEntries = parameters.length === 2;
|
|
95
|
-
|
|
96
|
-
let text = 'for (';
|
|
97
|
-
text += isFunctionParameterVariableReassigned(callback, sourceCode) ? 'let' : 'const';
|
|
98
|
-
text += ' ';
|
|
99
|
-
text += shouldUseEntries ? `[${indexText}, ${elementText}]` : elementText;
|
|
100
|
-
text += ' of ';
|
|
101
|
-
|
|
102
|
-
const shouldAddParenthesesToObject
|
|
103
|
-
= isParenthesized(iterableObject, sourceCode)
|
|
104
|
-
|| (
|
|
105
|
-
// `1?.forEach()` -> `(1).entries()`
|
|
106
|
-
isOptionalObject
|
|
107
|
-
&& shouldUseEntries
|
|
108
|
-
&& shouldAddParenthesesToMemberExpressionObject(iterableObject, context)
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
text += shouldAddParenthesesToObject ? `(${objectText})` : objectText;
|
|
112
|
-
|
|
113
|
-
if (shouldUseEntries) {
|
|
114
|
-
text += '.entries()';
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
text += ') ';
|
|
118
|
-
|
|
119
|
-
return text;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
const getForOfLoopHeadRange = () => {
|
|
123
|
-
const [start] = sourceCode.getRange(callExpression);
|
|
124
|
-
const [end] = getParenthesizedRange(callback.body, context);
|
|
125
|
-
return [start, end];
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
function * replaceReturnStatement(returnStatement, fixer) {
|
|
129
|
-
const returnToken = sourceCode.getFirstToken(returnStatement);
|
|
130
|
-
assertToken(returnToken, {
|
|
131
|
-
expected: 'return',
|
|
132
|
-
ruleId: 'no-array-for-each',
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
if (!returnStatement.argument) {
|
|
136
|
-
yield fixer.replaceText(returnToken, 'continue');
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Remove `return`
|
|
141
|
-
yield fixer.remove(returnToken);
|
|
142
|
-
|
|
143
|
-
const previousToken = sourceCode.getTokenBefore(returnToken);
|
|
144
|
-
const nextToken = sourceCode.getTokenAfter(returnToken);
|
|
145
|
-
let textBefore = '';
|
|
146
|
-
let textAfter = '';
|
|
147
|
-
const shouldAddParentheses
|
|
148
|
-
= !isParenthesized(returnStatement.argument, sourceCode)
|
|
149
|
-
&& shouldAddParenthesesToExpressionStatementExpression(returnStatement.argument);
|
|
150
|
-
if (shouldAddParentheses) {
|
|
151
|
-
textBefore = `(${textBefore}`;
|
|
152
|
-
textAfter = `${textAfter})`;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const insertBraces = shouldSwitchReturnStatementToBlockStatement(returnStatement);
|
|
156
|
-
if (insertBraces) {
|
|
157
|
-
textBefore = `{ ${textBefore}`;
|
|
158
|
-
} else if (needsSemicolon(previousToken, context, shouldAddParentheses ? '(' : nextToken.value)) {
|
|
159
|
-
textBefore = `;${textBefore}`;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
if (textBefore) {
|
|
163
|
-
yield fixer.insertTextBefore(nextToken, textBefore);
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
if (textAfter) {
|
|
167
|
-
yield fixer.insertTextAfter(returnStatement.argument, textAfter);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const returnStatementHasSemicolon = isSemicolonToken(sourceCode.getLastToken(returnStatement));
|
|
171
|
-
if (!returnStatementHasSemicolon) {
|
|
172
|
-
yield fixer.insertTextAfter(returnStatement, ';');
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
yield fixer.insertTextAfter(returnStatement, ' continue;');
|
|
176
|
-
|
|
177
|
-
if (insertBraces) {
|
|
178
|
-
yield fixer.insertTextAfter(returnStatement, ' }');
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
const shouldRemoveExpressionStatementLastToken = token => {
|
|
183
|
-
if (!isSemicolonToken(token)) {
|
|
184
|
-
return false;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if (callback.body.type !== 'BlockStatement') {
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
return true;
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
function * removeCallbackParentheses(fixer) {
|
|
195
|
-
// Opening parenthesis tokens already included in `getForOfLoopHeadRange`
|
|
196
|
-
const closingParenthesisTokens = getParentheses(callback, context)
|
|
197
|
-
.filter(token => isClosingParenToken(token));
|
|
198
|
-
|
|
199
|
-
for (const closingParenthesisToken of closingParenthesisTokens) {
|
|
200
|
-
yield fixer.remove(closingParenthesisToken);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return function * (fixer) {
|
|
205
|
-
// `(( foo.forEach(bar => bar) ))`
|
|
206
|
-
yield removeParentheses(callExpression, fixer, context);
|
|
207
|
-
|
|
208
|
-
// Replace these with `for (const … of …) `
|
|
209
|
-
// foo.forEach(bar => bar)
|
|
210
|
-
// ^^^^^^^^^^^^^^^^^^^^^^
|
|
211
|
-
// foo.forEach(bar => (bar))
|
|
212
|
-
// ^^^^^^^^^^^^^^^^^^^^^^
|
|
213
|
-
// foo.forEach(bar => {})
|
|
214
|
-
// ^^^^^^^^^^^^^^^^^^^^^^
|
|
215
|
-
// foo.forEach(function(bar) {})
|
|
216
|
-
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
217
|
-
yield fixer.replaceTextRange(getForOfLoopHeadRange(), getForOfLoopHeadText());
|
|
218
|
-
|
|
219
|
-
// Parenthesized callback function
|
|
220
|
-
// foo.forEach( ((bar => {})) )
|
|
221
|
-
// ^^
|
|
222
|
-
yield removeCallbackParentheses(fixer);
|
|
223
|
-
|
|
224
|
-
const [
|
|
225
|
-
penultimateToken,
|
|
226
|
-
lastToken,
|
|
227
|
-
] = sourceCode.getLastTokens(callExpression, 2);
|
|
228
|
-
|
|
229
|
-
// The possible trailing comma token of `Array#forEach()` CallExpression
|
|
230
|
-
// foo.forEach(bar => {},)
|
|
231
|
-
// ^
|
|
232
|
-
if (isCommaToken(penultimateToken)) {
|
|
233
|
-
yield fixer.remove(penultimateToken);
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
// The closing parenthesis token of `Array#forEach()` CallExpression
|
|
237
|
-
// foo.forEach(bar => {})
|
|
238
|
-
// ^
|
|
239
|
-
yield fixer.remove(lastToken);
|
|
240
|
-
|
|
241
|
-
for (const returnStatement of returnStatements) {
|
|
242
|
-
yield replaceReturnStatement(returnStatement, fixer);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
if (ancestor.type === 'ExpressionStatement') {
|
|
246
|
-
const expressionStatementLastToken = sourceCode.getLastToken(ancestor);
|
|
247
|
-
// Remove semicolon if it's not needed anymore
|
|
248
|
-
// foo.forEach(bar => {});
|
|
249
|
-
// ^
|
|
250
|
-
if (shouldRemoveExpressionStatementLastToken(expressionStatementLastToken)) {
|
|
251
|
-
yield fixer.remove(expressionStatementLastToken, fixer);
|
|
252
|
-
}
|
|
253
|
-
} else if (ancestor.type === 'ArrowFunctionExpression') {
|
|
254
|
-
yield fixer.insertTextBefore(callExpression, '{ ');
|
|
255
|
-
yield fixer.insertTextAfter(callExpression, ' }');
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
yield fixSpaceAroundKeyword(fixer, callExpression.parent, context);
|
|
259
|
-
|
|
260
|
-
if (isOptionalObject) {
|
|
261
|
-
yield fixer.insertTextBefore(callExpression, `if (${objectText}) `);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// Prevent possible variable conflicts
|
|
265
|
-
yield extendFixRange(fixer, sourceCode.getRange(callExpression.parent));
|
|
266
|
-
};
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
const isChildScope = (child, parent) => {
|
|
270
|
-
for (let scope = child; scope; scope = scope.upper) {
|
|
271
|
-
if (scope === parent) {
|
|
272
|
-
return true;
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
return false;
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
function isFunctionParametersSafeToFix(callbackFunction, {sourceCode, scope, callExpression, allIdentifiers}) {
|
|
280
|
-
const variables = sourceCode.getDeclaredVariables(callbackFunction);
|
|
281
|
-
|
|
282
|
-
for (const variable of variables) {
|
|
283
|
-
if (variable.defs.length !== 1) {
|
|
284
|
-
return false;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
const [definition] = variable.defs;
|
|
288
|
-
if (definition.type !== 'Parameter') {
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
const variableName = definition.name.name;
|
|
293
|
-
const [callExpressionStart, callExpressionEnd] = sourceCode.getRange(callExpression);
|
|
294
|
-
for (const identifier of allIdentifiers) {
|
|
295
|
-
const {name} = identifier;
|
|
296
|
-
const [start, end] = sourceCode.getRange(identifier);
|
|
297
|
-
if (
|
|
298
|
-
name !== variableName
|
|
299
|
-
|| start < callExpressionStart
|
|
300
|
-
|| end > callExpressionEnd
|
|
301
|
-
) {
|
|
302
|
-
continue;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
const variable = findVariable(scope, identifier);
|
|
306
|
-
if (!variable || variable.scope === scope || isChildScope(scope, variable.scope)) {
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function isFunctionParameterVariableReassigned(callbackFunction, sourceCode) {
|
|
316
|
-
return sourceCode.getDeclaredVariables(callbackFunction)
|
|
317
|
-
.filter(variable => variable.defs[0].type === 'Parameter')
|
|
318
|
-
.some(variable =>
|
|
319
|
-
variable.references.some(reference => !reference.init && reference.isWrite()),
|
|
320
|
-
);
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
function isFixable(callExpression, {scope, functionInfo, allIdentifiers, sourceCode}) {
|
|
324
|
-
// Check `CallExpression`
|
|
325
|
-
if (callExpression.optional || callExpression.arguments.length !== 1) {
|
|
326
|
-
return false;
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// Check ancestors, we only fix `ExpressionStatement`
|
|
330
|
-
const callOrChainExpression = stripChainExpression(callExpression);
|
|
331
|
-
if (
|
|
332
|
-
callOrChainExpression.parent.type !== 'ExpressionStatement'
|
|
333
|
-
&& !isArrowFunctionBody(callOrChainExpression)
|
|
334
|
-
) {
|
|
335
|
-
return false;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
// Check `CallExpression.arguments[0]`;
|
|
339
|
-
const [callback] = callExpression.arguments;
|
|
340
|
-
if (
|
|
341
|
-
// Leave non-function type to `no-array-callback-reference` rule
|
|
342
|
-
(callback.type !== 'FunctionExpression' && callback.type !== 'ArrowFunctionExpression')
|
|
343
|
-
|| callback.async
|
|
344
|
-
|| callback.generator
|
|
345
|
-
) {
|
|
346
|
-
return false;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// Check `callback.params`
|
|
350
|
-
const parameters = callback.params;
|
|
351
|
-
if (
|
|
352
|
-
!(parameters.length === 1 || parameters.length === 2)
|
|
353
|
-
// `array.forEach((element = defaultValue) => {})`
|
|
354
|
-
|| (parameters.length === 1 && parameters[0].type === 'AssignmentPattern')
|
|
355
|
-
// https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1814
|
|
356
|
-
|| (parameters.length === 2 && parameters[1].type !== 'Identifier')
|
|
357
|
-
|| parameters.some(({type, typeAnnotation}) => type === 'RestElement' || typeAnnotation)
|
|
358
|
-
|| !isFunctionParametersSafeToFix(callback, {
|
|
359
|
-
scope,
|
|
360
|
-
callExpression,
|
|
361
|
-
allIdentifiers,
|
|
362
|
-
sourceCode,
|
|
363
|
-
})
|
|
364
|
-
) {
|
|
365
|
-
return false;
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// Check `ReturnStatement`s in `callback`
|
|
369
|
-
const {returnStatements, scope: callbackScope} = functionInfo.get(callback);
|
|
370
|
-
if (returnStatements.some(returnStatement => isReturnStatementInContinueAbleNodes(returnStatement, callback))) {
|
|
371
|
-
return false;
|
|
372
|
-
}
|
|
373
|
-
|
|
374
|
-
if (isFunctionSelfUsedInside(callback, callbackScope)) {
|
|
375
|
-
return false;
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
return true;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
const ignoredObjects = [
|
|
382
|
-
'React.Children',
|
|
383
|
-
'Children',
|
|
384
|
-
'R',
|
|
385
|
-
// https://www.npmjs.com/package/p-iteration
|
|
386
|
-
'pIteration',
|
|
387
|
-
// https://www.npmjs.com/package/effect
|
|
388
|
-
'Effect',
|
|
389
|
-
];
|
|
390
|
-
|
|
391
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
392
|
-
const create = context => {
|
|
393
|
-
const functionStack = [];
|
|
394
|
-
const callExpressions = [];
|
|
395
|
-
const allIdentifiers = [];
|
|
396
|
-
const functionInfo = new Map();
|
|
397
|
-
const {sourceCode} = context;
|
|
398
|
-
|
|
399
|
-
context.on(functionTypes, node => {
|
|
400
|
-
functionStack.push(node);
|
|
401
|
-
functionInfo.set(node, {
|
|
402
|
-
returnStatements: [],
|
|
403
|
-
scope: sourceCode.getScope(node),
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
|
|
407
|
-
context.onExit(functionTypes, () => {
|
|
408
|
-
functionStack.pop();
|
|
409
|
-
});
|
|
410
|
-
|
|
411
|
-
context.on('Identifier', node => {
|
|
412
|
-
if (isReferenceIdentifier(node)) {
|
|
413
|
-
allIdentifiers.push(node);
|
|
414
|
-
}
|
|
415
|
-
});
|
|
416
|
-
|
|
417
|
-
context.on('ReturnStatement', node => {
|
|
418
|
-
const currentFunction = functionStack.at(-1);
|
|
419
|
-
if (!currentFunction) {
|
|
420
|
-
return;
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
const {returnStatements} = functionInfo.get(currentFunction);
|
|
424
|
-
returnStatements.push(node);
|
|
425
|
-
});
|
|
426
|
-
|
|
427
|
-
context.on('CallExpression', node => {
|
|
428
|
-
if (
|
|
429
|
-
!isMethodCall(node, {
|
|
430
|
-
method: 'forEach',
|
|
431
|
-
})
|
|
432
|
-
|| isNodeMatches(node.callee.object, ignoredObjects)
|
|
433
|
-
) {
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
callExpressions.push({
|
|
438
|
-
node,
|
|
439
|
-
scope: sourceCode.getScope(node),
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
|
|
443
|
-
context.onExit('Program', function * () {
|
|
444
|
-
for (const {node, scope} of callExpressions) {
|
|
445
|
-
const iterable = node.callee;
|
|
446
|
-
|
|
447
|
-
const problem = {
|
|
448
|
-
node: iterable.property,
|
|
449
|
-
messageId: MESSAGE_ID_ERROR,
|
|
450
|
-
};
|
|
451
|
-
|
|
452
|
-
if (!isFixable(node, {
|
|
453
|
-
scope,
|
|
454
|
-
allIdentifiers,
|
|
455
|
-
functionInfo,
|
|
456
|
-
sourceCode,
|
|
457
|
-
})) {
|
|
458
|
-
yield problem;
|
|
459
|
-
continue;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
const shouldUseSuggestion = iterable.optional && hasSideEffect(iterable, sourceCode);
|
|
463
|
-
const fix = getFixFunction(node, functionInfo, context);
|
|
464
|
-
|
|
465
|
-
if (shouldUseSuggestion) {
|
|
466
|
-
problem.suggest = [
|
|
467
|
-
{
|
|
468
|
-
messageId: MESSAGE_ID_SUGGESTION,
|
|
469
|
-
fix,
|
|
470
|
-
},
|
|
471
|
-
];
|
|
472
|
-
} else {
|
|
473
|
-
problem.fix = fix;
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
yield problem;
|
|
477
|
-
}
|
|
478
|
-
});
|
|
479
|
-
};
|
|
480
|
-
|
|
481
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
482
|
-
const config = {
|
|
483
|
-
create,
|
|
484
|
-
meta: {
|
|
485
|
-
type: 'suggestion',
|
|
486
|
-
docs: {
|
|
487
|
-
description: 'Prefer `for…of` over the `forEach` method.',
|
|
488
|
-
recommended: 'unopinionated',
|
|
489
|
-
},
|
|
490
|
-
fixable: 'code',
|
|
491
|
-
hasSuggestions: true,
|
|
492
|
-
messages,
|
|
493
|
-
},
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
export default config;
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import {hasSideEffect} from '@eslint-community/eslint-utils';
|
|
2
|
-
import {removeArgument} from './fix/index.js';
|
|
3
|
-
import {getParentheses, getParenthesizedText} from './utils/parentheses.js';
|
|
4
|
-
import shouldAddParenthesesToMemberExpressionObject from './utils/should-add-parentheses-to-member-expression-object.js';
|
|
5
|
-
import {isNodeMatches} from './utils/is-node-matches.js';
|
|
6
|
-
import {isNodeValueNotFunction} from './utils/index.js';
|
|
7
|
-
import {isMethodCall} from './ast/index.js';
|
|
8
|
-
|
|
9
|
-
const ERROR_PROTOTYPE_METHOD = 'error-prototype-method';
|
|
10
|
-
const ERROR_STATIC_METHOD = 'error-static-method';
|
|
11
|
-
const SUGGESTION_BIND = 'suggestion-bind';
|
|
12
|
-
const SUGGESTION_REMOVE = 'suggestion-remove';
|
|
13
|
-
const messages = {
|
|
14
|
-
[ERROR_PROTOTYPE_METHOD]: 'Do not use the `this` argument in `Array#{{method}}()`.',
|
|
15
|
-
[ERROR_STATIC_METHOD]: 'Do not use the `this` argument in `Array.{{method}}()`.',
|
|
16
|
-
[SUGGESTION_REMOVE]: 'Remove this argument.',
|
|
17
|
-
[SUGGESTION_BIND]: 'Use a bound function.',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const ignored = [
|
|
21
|
-
'lodash.every',
|
|
22
|
-
'_.every',
|
|
23
|
-
'underscore.every',
|
|
24
|
-
|
|
25
|
-
'lodash.filter',
|
|
26
|
-
'_.filter',
|
|
27
|
-
'underscore.filter',
|
|
28
|
-
'Vue.filter',
|
|
29
|
-
'R.filter',
|
|
30
|
-
|
|
31
|
-
'lodash.find',
|
|
32
|
-
'_.find',
|
|
33
|
-
'underscore.find',
|
|
34
|
-
'R.find',
|
|
35
|
-
|
|
36
|
-
'lodash.findLast',
|
|
37
|
-
'_.findLast',
|
|
38
|
-
'underscore.findLast',
|
|
39
|
-
'R.findLast',
|
|
40
|
-
|
|
41
|
-
'lodash.findIndex',
|
|
42
|
-
'_.findIndex',
|
|
43
|
-
'underscore.findIndex',
|
|
44
|
-
'R.findIndex',
|
|
45
|
-
|
|
46
|
-
'lodash.findLastIndex',
|
|
47
|
-
'_.findLastIndex',
|
|
48
|
-
'underscore.findLastIndex',
|
|
49
|
-
'R.findLastIndex',
|
|
50
|
-
|
|
51
|
-
'lodash.flatMap',
|
|
52
|
-
'_.flatMap',
|
|
53
|
-
|
|
54
|
-
'lodash.forEach',
|
|
55
|
-
'_.forEach',
|
|
56
|
-
'React.Children.forEach',
|
|
57
|
-
'Children.forEach',
|
|
58
|
-
'R.forEach',
|
|
59
|
-
|
|
60
|
-
'lodash.map',
|
|
61
|
-
'_.map',
|
|
62
|
-
'underscore.map',
|
|
63
|
-
'React.Children.map',
|
|
64
|
-
'Children.map',
|
|
65
|
-
'jQuery.map',
|
|
66
|
-
'$.map',
|
|
67
|
-
'R.map',
|
|
68
|
-
|
|
69
|
-
'lodash.some',
|
|
70
|
-
'_.some',
|
|
71
|
-
'underscore.some',
|
|
72
|
-
];
|
|
73
|
-
|
|
74
|
-
function removeThisArgument(thisArgumentNode, context) {
|
|
75
|
-
return fixer => removeArgument(fixer, thisArgumentNode, context);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function useBoundFunction(callbackNode, thisArgumentNode, context) {
|
|
79
|
-
return function * (fixer) {
|
|
80
|
-
yield removeThisArgument(thisArgumentNode, context)(fixer);
|
|
81
|
-
|
|
82
|
-
const callbackParentheses = getParentheses(callbackNode, context);
|
|
83
|
-
const isParenthesized = callbackParentheses.length > 0;
|
|
84
|
-
const callbackLastToken = isParenthesized
|
|
85
|
-
? callbackParentheses.at(-1)
|
|
86
|
-
: callbackNode;
|
|
87
|
-
if (
|
|
88
|
-
!isParenthesized
|
|
89
|
-
&& shouldAddParenthesesToMemberExpressionObject(callbackNode, context)
|
|
90
|
-
) {
|
|
91
|
-
yield fixer.insertTextBefore(callbackLastToken, '(');
|
|
92
|
-
yield fixer.insertTextAfter(callbackLastToken, ')');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const thisArgumentText = getParenthesizedText(thisArgumentNode, context);
|
|
96
|
-
// `thisArgument` was a argument, no need add extra parentheses
|
|
97
|
-
yield fixer.insertTextAfter(callbackLastToken, `.bind(${thisArgumentText})`);
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function getProblem({
|
|
102
|
-
context,
|
|
103
|
-
callExpression,
|
|
104
|
-
callbackNode,
|
|
105
|
-
thisArgumentNode,
|
|
106
|
-
messageId,
|
|
107
|
-
}) {
|
|
108
|
-
const problem = {
|
|
109
|
-
node: thisArgumentNode,
|
|
110
|
-
messageId,
|
|
111
|
-
data: {
|
|
112
|
-
method: callExpression.callee.property.name,
|
|
113
|
-
},
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const isArrowCallback = callbackNode.type === 'ArrowFunctionExpression';
|
|
117
|
-
if (isArrowCallback) {
|
|
118
|
-
const thisArgumentHasSideEffect = hasSideEffect(thisArgumentNode, context.sourceCode);
|
|
119
|
-
if (thisArgumentHasSideEffect) {
|
|
120
|
-
problem.suggest = [
|
|
121
|
-
{
|
|
122
|
-
messageId: SUGGESTION_REMOVE,
|
|
123
|
-
fix: removeThisArgument(thisArgumentNode, context),
|
|
124
|
-
},
|
|
125
|
-
];
|
|
126
|
-
} else {
|
|
127
|
-
problem.fix = removeThisArgument(thisArgumentNode, context);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return problem;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
problem.suggest = [
|
|
134
|
-
{
|
|
135
|
-
messageId: SUGGESTION_REMOVE,
|
|
136
|
-
fix: removeThisArgument(thisArgumentNode, context),
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
messageId: SUGGESTION_BIND,
|
|
140
|
-
fix: useBoundFunction(callbackNode, thisArgumentNode, context),
|
|
141
|
-
},
|
|
142
|
-
];
|
|
143
|
-
|
|
144
|
-
return problem;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
148
|
-
const create = context => {
|
|
149
|
-
// Prototype methods
|
|
150
|
-
context.on('CallExpression', callExpression => {
|
|
151
|
-
if (
|
|
152
|
-
!isMethodCall(callExpression, {
|
|
153
|
-
methods: [
|
|
154
|
-
'every',
|
|
155
|
-
'filter',
|
|
156
|
-
'find',
|
|
157
|
-
'findLast',
|
|
158
|
-
'findIndex',
|
|
159
|
-
'findLastIndex',
|
|
160
|
-
'flatMap',
|
|
161
|
-
'forEach',
|
|
162
|
-
'map',
|
|
163
|
-
'some',
|
|
164
|
-
],
|
|
165
|
-
argumentsLength: 2,
|
|
166
|
-
optionalCall: false,
|
|
167
|
-
})
|
|
168
|
-
|| isNodeMatches(callExpression.callee, ignored)
|
|
169
|
-
|| isNodeValueNotFunction(callExpression.arguments[0])
|
|
170
|
-
) {
|
|
171
|
-
return;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return getProblem({
|
|
175
|
-
context,
|
|
176
|
-
callExpression,
|
|
177
|
-
callbackNode: callExpression.arguments[0],
|
|
178
|
-
thisArgumentNode: callExpression.arguments[1],
|
|
179
|
-
messageId: ERROR_PROTOTYPE_METHOD,
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
// `Array.from()` and `Array.fromAsync()`
|
|
184
|
-
context.on('CallExpression', callExpression => {
|
|
185
|
-
if (
|
|
186
|
-
!isMethodCall(callExpression, {
|
|
187
|
-
object: 'Array',
|
|
188
|
-
methods: ['from', 'fromAsync'],
|
|
189
|
-
argumentsLength: 3,
|
|
190
|
-
optionalCall: false,
|
|
191
|
-
optionalMember: false,
|
|
192
|
-
})
|
|
193
|
-
|| isNodeValueNotFunction(callExpression.arguments[1])
|
|
194
|
-
) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
return getProblem({
|
|
199
|
-
context,
|
|
200
|
-
callExpression,
|
|
201
|
-
callbackNode: callExpression.arguments[1],
|
|
202
|
-
thisArgumentNode: callExpression.arguments[2],
|
|
203
|
-
messageId: ERROR_STATIC_METHOD,
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
209
|
-
const config = {
|
|
210
|
-
create,
|
|
211
|
-
meta: {
|
|
212
|
-
type: 'suggestion',
|
|
213
|
-
docs: {
|
|
214
|
-
description: 'Disallow using the `this` argument in array methods.',
|
|
215
|
-
recommended: 'unopinionated',
|
|
216
|
-
},
|
|
217
|
-
fixable: 'code',
|
|
218
|
-
hasSuggestions: true,
|
|
219
|
-
messages,
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export default config;
|