@alexlit/lint-kit 176.0.0 → 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-eslint/package.json +1 -1
- package/packages/config-eslint/plugins/vue.js +6 -0
- 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/prevent-abbreviations.js
DELETED
|
@@ -1,655 +0,0 @@
|
|
|
1
|
-
import path from 'node:path';
|
|
2
|
-
import {isRegExp} from 'node:util/types';
|
|
3
|
-
import {
|
|
4
|
-
getAvailableVariableName,
|
|
5
|
-
cartesianProductSamples,
|
|
6
|
-
isShorthandPropertyValue,
|
|
7
|
-
isShorthandImportLocal,
|
|
8
|
-
getVariableIdentifiers,
|
|
9
|
-
getScopes,
|
|
10
|
-
upperFirst,
|
|
11
|
-
lowerFirst,
|
|
12
|
-
} from './utils/index.js';
|
|
13
|
-
import {defaultReplacements, defaultAllowList, defaultIgnore} from './shared/abbreviations.js';
|
|
14
|
-
import {renameVariable} from './fix/index.js';
|
|
15
|
-
import {isStaticRequire} from './ast/index.js';
|
|
16
|
-
|
|
17
|
-
const MESSAGE_ID_REPLACE = 'replace';
|
|
18
|
-
const MESSAGE_ID_SUGGESTION = 'suggestion';
|
|
19
|
-
const anotherNameMessage = 'A more descriptive name will do too.';
|
|
20
|
-
const messages = {
|
|
21
|
-
[MESSAGE_ID_REPLACE]: `The {{nameTypeText}} \`{{discouragedName}}\` should be named \`{{replacement}}\`. ${anotherNameMessage}`,
|
|
22
|
-
[MESSAGE_ID_SUGGESTION]: `Please rename the {{nameTypeText}} \`{{discouragedName}}\`. Suggested names are: {{replacementsText}}. ${anotherNameMessage}`,
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const isUpperCase = string => string === string.toUpperCase();
|
|
26
|
-
const isUpperFirst = string => isUpperCase(string[0]);
|
|
27
|
-
|
|
28
|
-
const prepareOptions = ({
|
|
29
|
-
checkProperties = false,
|
|
30
|
-
checkVariables = true,
|
|
31
|
-
|
|
32
|
-
checkDefaultAndNamespaceImports = 'internal',
|
|
33
|
-
checkShorthandImports = 'internal',
|
|
34
|
-
checkShorthandProperties = false,
|
|
35
|
-
|
|
36
|
-
checkFilenames = true,
|
|
37
|
-
|
|
38
|
-
extendDefaultReplacements = true,
|
|
39
|
-
replacements = {},
|
|
40
|
-
|
|
41
|
-
extendDefaultAllowList = true,
|
|
42
|
-
allowList = {},
|
|
43
|
-
|
|
44
|
-
ignore = [],
|
|
45
|
-
} = {}) => {
|
|
46
|
-
const mergedReplacements = extendDefaultReplacements
|
|
47
|
-
? Object.fromEntries(
|
|
48
|
-
[...Object.keys(defaultReplacements), ...Object.keys(replacements)]
|
|
49
|
-
.map(name => [name, replacements[name] === false ? {} : {...defaultReplacements[name], ...replacements[name]}]),
|
|
50
|
-
)
|
|
51
|
-
: replacements;
|
|
52
|
-
|
|
53
|
-
const mergedAllowList = extendDefaultAllowList
|
|
54
|
-
? {...defaultAllowList, ...allowList}
|
|
55
|
-
: allowList;
|
|
56
|
-
|
|
57
|
-
ignore = [...defaultIgnore, ...ignore];
|
|
58
|
-
|
|
59
|
-
ignore = ignore.map(
|
|
60
|
-
pattern => isRegExp(pattern) ? pattern : new RegExp(pattern, 'u'),
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
return {
|
|
64
|
-
checkProperties,
|
|
65
|
-
checkVariables,
|
|
66
|
-
|
|
67
|
-
checkDefaultAndNamespaceImports,
|
|
68
|
-
checkShorthandImports,
|
|
69
|
-
checkShorthandProperties,
|
|
70
|
-
|
|
71
|
-
checkFilenames,
|
|
72
|
-
|
|
73
|
-
replacements: new Map(
|
|
74
|
-
Object.entries(mergedReplacements).map(
|
|
75
|
-
([discouragedName, replacements]) =>
|
|
76
|
-
[discouragedName, new Map(Object.entries(replacements))],
|
|
77
|
-
),
|
|
78
|
-
),
|
|
79
|
-
allowList: new Map(Object.entries(mergedAllowList)),
|
|
80
|
-
|
|
81
|
-
ignore,
|
|
82
|
-
};
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
const getWordReplacements = (word, {replacements, allowList}) => {
|
|
86
|
-
// Skip constants and allowList
|
|
87
|
-
if (isUpperCase(word) || allowList.get(word)) {
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const replacement = replacements.get(lowerFirst(word))
|
|
92
|
-
|| replacements.get(word)
|
|
93
|
-
|| replacements.get(upperFirst(word));
|
|
94
|
-
|
|
95
|
-
let wordReplacement = [];
|
|
96
|
-
if (replacement) {
|
|
97
|
-
const transform = isUpperFirst(word) ? upperFirst : lowerFirst;
|
|
98
|
-
wordReplacement = [...replacement.keys()]
|
|
99
|
-
.filter(name => replacement.get(name))
|
|
100
|
-
.map(name => transform(name));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return wordReplacement.length > 0 ? wordReplacement.toSorted() : [];
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
const getNameReplacements = (name, options, limit = 3) => {
|
|
107
|
-
const {allowList, ignore} = options;
|
|
108
|
-
|
|
109
|
-
// Skip constants and allowList
|
|
110
|
-
if (isUpperCase(name) || allowList.get(name) || ignore.some(regexp => regexp.test(name))) {
|
|
111
|
-
return {total: 0};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// Find exact replacements
|
|
115
|
-
const exactReplacements = getWordReplacements(name, options);
|
|
116
|
-
|
|
117
|
-
if (exactReplacements.length > 0) {
|
|
118
|
-
return {
|
|
119
|
-
total: exactReplacements.length,
|
|
120
|
-
samples: exactReplacements.slice(0, limit),
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// Split words
|
|
125
|
-
const words = name.split(/(?=\P{Lowercase_Letter})|(?<=\P{Letter})/u).filter(Boolean);
|
|
126
|
-
|
|
127
|
-
let hasReplacements = false;
|
|
128
|
-
const combinations = words.map(word => {
|
|
129
|
-
const wordReplacements = getWordReplacements(word, options);
|
|
130
|
-
|
|
131
|
-
if (wordReplacements.length > 0) {
|
|
132
|
-
hasReplacements = true;
|
|
133
|
-
return wordReplacements;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return [word];
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
// No replacements for any word
|
|
140
|
-
if (!hasReplacements) {
|
|
141
|
-
return {total: 0};
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const {
|
|
145
|
-
total,
|
|
146
|
-
samples,
|
|
147
|
-
} = cartesianProductSamples(combinations, limit);
|
|
148
|
-
|
|
149
|
-
// `retVal` -> `['returnValue', 'Value']` -> `['returnValue']`
|
|
150
|
-
for (const parts of samples) {
|
|
151
|
-
for (let index = parts.length - 1; index > 0; index--) {
|
|
152
|
-
const word = parts[index];
|
|
153
|
-
if (/^[A-Za-z]+$/.test(word) && parts[index - 1].endsWith(parts[index])) {
|
|
154
|
-
parts.splice(index, 1);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
return {
|
|
160
|
-
total,
|
|
161
|
-
samples: samples.map(words => words.join('')),
|
|
162
|
-
};
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
const getMessage = (discouragedName, replacements, nameTypeText) => {
|
|
166
|
-
const {total, samples = []} = replacements;
|
|
167
|
-
|
|
168
|
-
if (total === 1) {
|
|
169
|
-
return {
|
|
170
|
-
messageId: MESSAGE_ID_REPLACE,
|
|
171
|
-
data: {
|
|
172
|
-
nameTypeText,
|
|
173
|
-
discouragedName,
|
|
174
|
-
replacement: samples[0],
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
let replacementsText = samples
|
|
180
|
-
.map(replacement => `\`${replacement}\``)
|
|
181
|
-
.join(', ');
|
|
182
|
-
|
|
183
|
-
const omittedReplacementsCount = total - samples.length;
|
|
184
|
-
if (omittedReplacementsCount > 0) {
|
|
185
|
-
replacementsText += `, ... (${omittedReplacementsCount > 99 ? '99+' : omittedReplacementsCount} more omitted)`;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
return {
|
|
189
|
-
messageId: MESSAGE_ID_SUGGESTION,
|
|
190
|
-
data: {
|
|
191
|
-
nameTypeText,
|
|
192
|
-
discouragedName,
|
|
193
|
-
replacementsText,
|
|
194
|
-
},
|
|
195
|
-
};
|
|
196
|
-
};
|
|
197
|
-
|
|
198
|
-
const isExportedIdentifier = identifier => {
|
|
199
|
-
if (
|
|
200
|
-
identifier.parent.type === 'VariableDeclarator'
|
|
201
|
-
&& identifier.parent.id === identifier
|
|
202
|
-
) {
|
|
203
|
-
return (
|
|
204
|
-
identifier.parent.parent.type === 'VariableDeclaration'
|
|
205
|
-
&& identifier.parent.parent.parent.type === 'ExportNamedDeclaration'
|
|
206
|
-
);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
if (
|
|
210
|
-
identifier.parent.type === 'FunctionDeclaration'
|
|
211
|
-
&& identifier.parent.id === identifier
|
|
212
|
-
) {
|
|
213
|
-
return identifier.parent.parent.type === 'ExportNamedDeclaration';
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
if (
|
|
217
|
-
identifier.parent.type === 'ClassDeclaration'
|
|
218
|
-
&& identifier.parent.id === identifier
|
|
219
|
-
) {
|
|
220
|
-
return identifier.parent.parent.type === 'ExportNamedDeclaration';
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
identifier.parent.type === 'TSTypeAliasDeclaration'
|
|
225
|
-
&& identifier.parent.id === identifier
|
|
226
|
-
) {
|
|
227
|
-
return identifier.parent.parent.type === 'ExportNamedDeclaration';
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return false;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
const shouldFix = variable => getVariableIdentifiers(variable)
|
|
234
|
-
.every(identifier =>
|
|
235
|
-
!isExportedIdentifier(identifier)
|
|
236
|
-
// In typescript parser, only `JSXOpeningElement` is added to variable
|
|
237
|
-
// `<foo></foo>` -> `<bar></foo>` will cause parse error
|
|
238
|
-
&& identifier.type !== 'JSXIdentifier',
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
const isDefaultOrNamespaceImportName = identifier => {
|
|
242
|
-
if (
|
|
243
|
-
identifier.parent.type === 'ImportDefaultSpecifier'
|
|
244
|
-
&& identifier.parent.local === identifier
|
|
245
|
-
) {
|
|
246
|
-
return true;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
if (
|
|
250
|
-
identifier.parent.type === 'ImportNamespaceSpecifier'
|
|
251
|
-
&& identifier.parent.local === identifier
|
|
252
|
-
) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
if (
|
|
257
|
-
identifier.parent.type === 'ImportSpecifier'
|
|
258
|
-
&& identifier.parent.local === identifier
|
|
259
|
-
&& identifier.parent.imported.type === 'Identifier'
|
|
260
|
-
&& identifier.parent.imported.name === 'default'
|
|
261
|
-
) {
|
|
262
|
-
return true;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
if (
|
|
266
|
-
identifier.parent.type === 'VariableDeclarator'
|
|
267
|
-
&& identifier.parent.id === identifier
|
|
268
|
-
&& isStaticRequire(identifier.parent.init)
|
|
269
|
-
) {
|
|
270
|
-
return true;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
return false;
|
|
274
|
-
};
|
|
275
|
-
|
|
276
|
-
const isClassVariable = variable => {
|
|
277
|
-
if (variable.defs.length !== 1) {
|
|
278
|
-
return false;
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
const [definition] = variable.defs;
|
|
282
|
-
|
|
283
|
-
return definition.type === 'ClassName';
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const shouldReportIdentifierAsProperty = identifier => {
|
|
287
|
-
if (
|
|
288
|
-
identifier.parent.type === 'MemberExpression'
|
|
289
|
-
&& identifier.parent.property === identifier
|
|
290
|
-
&& !identifier.parent.computed
|
|
291
|
-
&& identifier.parent.parent.type === 'AssignmentExpression'
|
|
292
|
-
&& identifier.parent.parent.left === identifier.parent
|
|
293
|
-
) {
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
if (
|
|
298
|
-
identifier.parent.type === 'Property'
|
|
299
|
-
&& identifier.parent.key === identifier
|
|
300
|
-
&& !identifier.parent.computed
|
|
301
|
-
&& !identifier.parent.shorthand // Shorthand properties are reported and fixed as variables
|
|
302
|
-
&& identifier.parent.parent.type === 'ObjectExpression'
|
|
303
|
-
) {
|
|
304
|
-
return true;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if (
|
|
308
|
-
identifier.parent.type === 'ExportSpecifier'
|
|
309
|
-
&& identifier.parent.exported === identifier
|
|
310
|
-
&& identifier.parent.local !== identifier // Same as shorthand properties above
|
|
311
|
-
) {
|
|
312
|
-
return true;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
if (
|
|
316
|
-
(
|
|
317
|
-
identifier.parent.type === 'MethodDefinition'
|
|
318
|
-
|| identifier.parent.type === 'PropertyDefinition'
|
|
319
|
-
)
|
|
320
|
-
&& identifier.parent.key === identifier
|
|
321
|
-
&& !identifier.parent.computed
|
|
322
|
-
) {
|
|
323
|
-
return true;
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return false;
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
const isInternalImport = node => {
|
|
330
|
-
let source = '';
|
|
331
|
-
|
|
332
|
-
if (node.type === 'Variable') {
|
|
333
|
-
source = node.node.init.arguments[0].value;
|
|
334
|
-
} else if (node.type === 'ImportBinding') {
|
|
335
|
-
source = node.parent.source.value;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
return (
|
|
339
|
-
!source.includes('node_modules')
|
|
340
|
-
&& (source.startsWith('.') || source.startsWith('/'))
|
|
341
|
-
);
|
|
342
|
-
};
|
|
343
|
-
|
|
344
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
345
|
-
const create = context => {
|
|
346
|
-
const options = prepareOptions(context.options[0]);
|
|
347
|
-
const filenameWithExtension = context.physicalFilename;
|
|
348
|
-
|
|
349
|
-
// A `class` declaration produces two variables in two scopes:
|
|
350
|
-
// the inner class scope, and the outer one (wherever the class is declared).
|
|
351
|
-
// This map holds the outer ones to be later processed when the inner one is encountered.
|
|
352
|
-
// For why this is not a eslint issue see https://github.com/eslint/eslint-scope/issues/48#issuecomment-464358754
|
|
353
|
-
const identifierToOuterClassVariable = new WeakMap();
|
|
354
|
-
|
|
355
|
-
const checkPossiblyWeirdClassVariable = variable => {
|
|
356
|
-
if (isClassVariable(variable)) {
|
|
357
|
-
if (variable.scope.type === 'class') { // The inner class variable
|
|
358
|
-
const [definition] = variable.defs;
|
|
359
|
-
const outerClassVariable = identifierToOuterClassVariable.get(definition.name);
|
|
360
|
-
|
|
361
|
-
if (!outerClassVariable) {
|
|
362
|
-
return checkVariable(variable);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
// Create a normal-looking variable (like a `var` or a `function`)
|
|
366
|
-
// For which a single `variable` holds all references, unlike with a `class`
|
|
367
|
-
const combinedReferencesVariable = {
|
|
368
|
-
name: variable.name,
|
|
369
|
-
scope: variable.scope,
|
|
370
|
-
defs: variable.defs,
|
|
371
|
-
identifiers: variable.identifiers,
|
|
372
|
-
references: [...variable.references, ...outerClassVariable.references],
|
|
373
|
-
};
|
|
374
|
-
|
|
375
|
-
// Call the common checker with the newly forged normalized class variable
|
|
376
|
-
return checkVariable(combinedReferencesVariable);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// The outer class variable, we save it for later, when it's inner counterpart is encountered
|
|
380
|
-
const [definition] = variable.defs;
|
|
381
|
-
identifierToOuterClassVariable.set(definition.name, variable);
|
|
382
|
-
|
|
383
|
-
return;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
return checkVariable(variable);
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
// Holds a map from a `Scope` to a `Set` of new variable names generated by our fixer.
|
|
390
|
-
// Used to avoid generating duplicate names, see for instance `let errCb, errorCb` test.
|
|
391
|
-
const scopeToNamesGeneratedByFixer = new WeakMap();
|
|
392
|
-
const isSafeName = (name, scopes) => scopes.every(scope => {
|
|
393
|
-
const generatedNames = scopeToNamesGeneratedByFixer.get(scope);
|
|
394
|
-
return !generatedNames || !generatedNames.has(name);
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
const checkVariable = variable => {
|
|
398
|
-
if (variable.defs.length === 0) {
|
|
399
|
-
return;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
const [definition] = variable.defs;
|
|
403
|
-
|
|
404
|
-
if (isDefaultOrNamespaceImportName(definition.name)) {
|
|
405
|
-
if (!options.checkDefaultAndNamespaceImports) {
|
|
406
|
-
return;
|
|
407
|
-
}
|
|
408
|
-
|
|
409
|
-
if (
|
|
410
|
-
options.checkDefaultAndNamespaceImports === 'internal'
|
|
411
|
-
&& !isInternalImport(definition)
|
|
412
|
-
) {
|
|
413
|
-
return;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
if (isShorthandImportLocal(definition.name, context)) {
|
|
418
|
-
if (!options.checkShorthandImports) {
|
|
419
|
-
return;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
if (
|
|
423
|
-
options.checkShorthandImports === 'internal'
|
|
424
|
-
&& !isInternalImport(definition)
|
|
425
|
-
) {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
if (
|
|
431
|
-
!options.checkShorthandProperties
|
|
432
|
-
&& isShorthandPropertyValue(definition.name)
|
|
433
|
-
) {
|
|
434
|
-
return;
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
const variableReplacements = getNameReplacements(variable.name, options);
|
|
438
|
-
|
|
439
|
-
if (variableReplacements.total === 0) {
|
|
440
|
-
return;
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
const scopes = [
|
|
444
|
-
...variable.references.map(reference => reference.from),
|
|
445
|
-
variable.scope,
|
|
446
|
-
];
|
|
447
|
-
variableReplacements.samples = variableReplacements.samples.map(
|
|
448
|
-
name => getAvailableVariableName(name, scopes, isSafeName),
|
|
449
|
-
);
|
|
450
|
-
|
|
451
|
-
const problem = {
|
|
452
|
-
...getMessage(definition.name.name, variableReplacements, 'variable'),
|
|
453
|
-
node: definition.name,
|
|
454
|
-
};
|
|
455
|
-
|
|
456
|
-
if (
|
|
457
|
-
variableReplacements.total === 1
|
|
458
|
-
&& shouldFix(variable)
|
|
459
|
-
&& variableReplacements.samples[0]
|
|
460
|
-
&& !variable.references.some(reference => reference.vueUsedInTemplate)
|
|
461
|
-
) {
|
|
462
|
-
const [replacement] = variableReplacements.samples;
|
|
463
|
-
|
|
464
|
-
for (const scope of scopes) {
|
|
465
|
-
if (!scopeToNamesGeneratedByFixer.has(scope)) {
|
|
466
|
-
scopeToNamesGeneratedByFixer.set(scope, new Set());
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
const generatedNames = scopeToNamesGeneratedByFixer.get(scope);
|
|
470
|
-
generatedNames.add(replacement);
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
problem.fix = fixer => renameVariable(variable, replacement, context, fixer);
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
context.report(problem);
|
|
477
|
-
};
|
|
478
|
-
|
|
479
|
-
const checkVariables = scope => {
|
|
480
|
-
for (const variable of scope.variables) {
|
|
481
|
-
checkPossiblyWeirdClassVariable(variable);
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
const checkScope = scope => {
|
|
486
|
-
const scopes = getScopes(scope);
|
|
487
|
-
for (const scope of scopes) {
|
|
488
|
-
checkVariables(scope);
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
return {
|
|
493
|
-
Identifier(node) {
|
|
494
|
-
if (!options.checkProperties) {
|
|
495
|
-
return;
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
if (node.name === '__proto__') {
|
|
499
|
-
return;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
const identifierReplacements = getNameReplacements(node.name, options);
|
|
503
|
-
|
|
504
|
-
if (identifierReplacements.total === 0) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if (!shouldReportIdentifierAsProperty(node)) {
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
const problem = {
|
|
513
|
-
...getMessage(node.name, identifierReplacements, 'property'),
|
|
514
|
-
node,
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
context.report(problem);
|
|
518
|
-
},
|
|
519
|
-
|
|
520
|
-
Program(node) {
|
|
521
|
-
if (!options.checkFilenames) {
|
|
522
|
-
return;
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (
|
|
526
|
-
filenameWithExtension === '<input>'
|
|
527
|
-
|| filenameWithExtension === '<text>'
|
|
528
|
-
) {
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
const filename = path.basename(filenameWithExtension);
|
|
533
|
-
const extension = path.extname(filename);
|
|
534
|
-
const filenameReplacements = getNameReplacements(path.basename(filename, extension), options);
|
|
535
|
-
|
|
536
|
-
if (filenameReplacements.total === 0) {
|
|
537
|
-
return;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
filenameReplacements.samples = filenameReplacements.samples.map(replacement => `${replacement}${extension}`);
|
|
541
|
-
|
|
542
|
-
context.report({
|
|
543
|
-
...getMessage(filename, filenameReplacements, 'filename'),
|
|
544
|
-
node,
|
|
545
|
-
});
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
'Program:exit'(program) {
|
|
549
|
-
if (!options.checkVariables) {
|
|
550
|
-
return;
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
checkScope(context.sourceCode.getScope(program));
|
|
554
|
-
},
|
|
555
|
-
};
|
|
556
|
-
};
|
|
557
|
-
|
|
558
|
-
const schema = {
|
|
559
|
-
type: 'array',
|
|
560
|
-
additionalItems: false,
|
|
561
|
-
items: [
|
|
562
|
-
{
|
|
563
|
-
type: 'object',
|
|
564
|
-
additionalProperties: false,
|
|
565
|
-
properties: {
|
|
566
|
-
checkProperties: {
|
|
567
|
-
type: 'boolean',
|
|
568
|
-
},
|
|
569
|
-
checkVariables: {
|
|
570
|
-
type: 'boolean',
|
|
571
|
-
},
|
|
572
|
-
checkDefaultAndNamespaceImports: {
|
|
573
|
-
type: [
|
|
574
|
-
'boolean',
|
|
575
|
-
'string',
|
|
576
|
-
],
|
|
577
|
-
pattern: 'internal',
|
|
578
|
-
},
|
|
579
|
-
checkShorthandImports: {
|
|
580
|
-
type: [
|
|
581
|
-
'boolean',
|
|
582
|
-
'string',
|
|
583
|
-
],
|
|
584
|
-
pattern: 'internal',
|
|
585
|
-
},
|
|
586
|
-
checkShorthandProperties: {
|
|
587
|
-
type: 'boolean',
|
|
588
|
-
},
|
|
589
|
-
checkFilenames: {
|
|
590
|
-
type: 'boolean',
|
|
591
|
-
},
|
|
592
|
-
extendDefaultReplacements: {
|
|
593
|
-
type: 'boolean',
|
|
594
|
-
},
|
|
595
|
-
replacements: {
|
|
596
|
-
$ref: '#/definitions/abbreviations',
|
|
597
|
-
},
|
|
598
|
-
extendDefaultAllowList: {
|
|
599
|
-
type: 'boolean',
|
|
600
|
-
},
|
|
601
|
-
allowList: {
|
|
602
|
-
$ref: '#/definitions/booleanObject',
|
|
603
|
-
},
|
|
604
|
-
ignore: {
|
|
605
|
-
type: 'array',
|
|
606
|
-
uniqueItems: true,
|
|
607
|
-
},
|
|
608
|
-
},
|
|
609
|
-
},
|
|
610
|
-
],
|
|
611
|
-
definitions: {
|
|
612
|
-
abbreviations: {
|
|
613
|
-
type: 'object',
|
|
614
|
-
additionalProperties: {
|
|
615
|
-
$ref: '#/definitions/replacements',
|
|
616
|
-
},
|
|
617
|
-
},
|
|
618
|
-
replacements: {
|
|
619
|
-
anyOf: [
|
|
620
|
-
{
|
|
621
|
-
enum: [
|
|
622
|
-
false,
|
|
623
|
-
],
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
$ref: '#/definitions/booleanObject',
|
|
627
|
-
},
|
|
628
|
-
],
|
|
629
|
-
},
|
|
630
|
-
booleanObject: {
|
|
631
|
-
type: 'object',
|
|
632
|
-
additionalProperties: {
|
|
633
|
-
type: 'boolean',
|
|
634
|
-
},
|
|
635
|
-
},
|
|
636
|
-
},
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
640
|
-
const config = {
|
|
641
|
-
create,
|
|
642
|
-
meta: {
|
|
643
|
-
type: 'suggestion',
|
|
644
|
-
docs: {
|
|
645
|
-
description: 'Prevent abbreviations.',
|
|
646
|
-
recommended: true,
|
|
647
|
-
},
|
|
648
|
-
fixable: 'code',
|
|
649
|
-
schema,
|
|
650
|
-
defaultOptions: [{}],
|
|
651
|
-
messages,
|
|
652
|
-
},
|
|
653
|
-
};
|
|
654
|
-
|
|
655
|
-
export default config;
|