@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/prefer-keyboard-event-key.js
DELETED
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
import escapeString from './utils/escape-string.js';
|
|
2
|
-
import translateToKey from './shared/event-keys.js';
|
|
3
|
-
import {isNumericLiteral} from './ast/index.js';
|
|
4
|
-
|
|
5
|
-
const MESSAGE_ID = 'prefer-keyboard-event-key';
|
|
6
|
-
const messages = {
|
|
7
|
-
[MESSAGE_ID]: 'Use `.key` instead of `.{{name}}`.',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const keys = new Set([
|
|
11
|
-
'keyCode',
|
|
12
|
-
'charCode',
|
|
13
|
-
'which',
|
|
14
|
-
]);
|
|
15
|
-
|
|
16
|
-
const isPropertyNamedAddEventListener = node =>
|
|
17
|
-
node?.type === 'CallExpression'
|
|
18
|
-
&& node.callee.type === 'MemberExpression'
|
|
19
|
-
&& node.callee.property.name === 'addEventListener';
|
|
20
|
-
|
|
21
|
-
const getEventNodeAndReferences = (context, node) => {
|
|
22
|
-
const eventListener = getMatchingAncestorOfType(node, 'CallExpression', isPropertyNamedAddEventListener);
|
|
23
|
-
const callback = eventListener?.arguments[1];
|
|
24
|
-
switch (callback?.type) {
|
|
25
|
-
case 'ArrowFunctionExpression':
|
|
26
|
-
case 'FunctionExpression': {
|
|
27
|
-
const eventVariable = context.sourceCode.getDeclaredVariables(callback)[0];
|
|
28
|
-
const references = eventVariable?.references;
|
|
29
|
-
return {
|
|
30
|
-
event: callback.params[0],
|
|
31
|
-
references,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
default: {
|
|
36
|
-
return {};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const isPropertyOf = (node, eventNode) =>
|
|
42
|
-
node?.parent?.type === 'MemberExpression'
|
|
43
|
-
&& node.parent.object === eventNode;
|
|
44
|
-
|
|
45
|
-
// The third argument is a condition function, as one passed to `Array#filter()`
|
|
46
|
-
// Helpful if nearest node of type also needs to have some other property
|
|
47
|
-
const getMatchingAncestorOfType = (node, type, testFunction = () => true) => {
|
|
48
|
-
let current = node;
|
|
49
|
-
while (current) {
|
|
50
|
-
if (current.type === type && testFunction(current)) {
|
|
51
|
-
return current;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
current = current.parent;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const getParentByLevel = (node, level) => {
|
|
59
|
-
let current = node;
|
|
60
|
-
while (current && level) {
|
|
61
|
-
level--;
|
|
62
|
-
current = current.parent;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/* c8 ignore next 3 */
|
|
66
|
-
if (level === 0) {
|
|
67
|
-
return current;
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const fix = node => fixer => {
|
|
72
|
-
// Since we're only fixing direct property access usages, like `event.keyCode`
|
|
73
|
-
const nearestIf = getParentByLevel(node, 3);
|
|
74
|
-
if (!nearestIf || nearestIf.type !== 'IfStatement') {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const {type, operator, right} = nearestIf.test;
|
|
79
|
-
if (
|
|
80
|
-
!(
|
|
81
|
-
type === 'BinaryExpression'
|
|
82
|
-
&& (operator === '==' || operator === '===')
|
|
83
|
-
&& isNumericLiteral(right)
|
|
84
|
-
)
|
|
85
|
-
) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// Either a meta key or a printable character
|
|
90
|
-
const key = translateToKey[right.value] || String.fromCodePoint(right.value);
|
|
91
|
-
// And if we recognize the `.keyCode`
|
|
92
|
-
if (!key) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Apply fixes
|
|
97
|
-
return [
|
|
98
|
-
fixer.replaceText(node, 'key'),
|
|
99
|
-
fixer.replaceText(right, escapeString(key)),
|
|
100
|
-
];
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const getProblem = node => ({
|
|
104
|
-
messageId: MESSAGE_ID,
|
|
105
|
-
data: {name: node.name},
|
|
106
|
-
node,
|
|
107
|
-
fix: fix(node),
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
111
|
-
const create = context => ({
|
|
112
|
-
Identifier(node) {
|
|
113
|
-
if (
|
|
114
|
-
node.name !== 'keyCode'
|
|
115
|
-
&& node.name !== 'charCode'
|
|
116
|
-
&& node.name !== 'which'
|
|
117
|
-
) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// Normal case when usage is direct -> `event.keyCode`
|
|
122
|
-
const {event, references} = getEventNodeAndReferences(context, node);
|
|
123
|
-
if (!event) {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (
|
|
128
|
-
references
|
|
129
|
-
&& references.some(reference => isPropertyOf(node, reference.identifier))
|
|
130
|
-
) {
|
|
131
|
-
return getProblem(node);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
Property(node) {
|
|
136
|
-
// Destructured case
|
|
137
|
-
const propertyName = node.value.name;
|
|
138
|
-
if (!keys.has(propertyName)) {
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const {event, references} = getEventNodeAndReferences(context, node);
|
|
143
|
-
if (!event) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
const nearestVariableDeclarator = getMatchingAncestorOfType(
|
|
148
|
-
node,
|
|
149
|
-
'VariableDeclarator',
|
|
150
|
-
);
|
|
151
|
-
const initObject = nearestVariableDeclarator?.init;
|
|
152
|
-
|
|
153
|
-
// Make sure initObject is a reference of eventVariable
|
|
154
|
-
if (
|
|
155
|
-
references
|
|
156
|
-
&& references.some(reference => reference.identifier === initObject)
|
|
157
|
-
) {
|
|
158
|
-
return getProblem(node.value);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
// When the event parameter itself is destructured directly
|
|
162
|
-
const isEventParameterDestructured = event.type === 'ObjectPattern';
|
|
163
|
-
if (isEventParameterDestructured) {
|
|
164
|
-
// Check for properties
|
|
165
|
-
for (const property of event.properties) {
|
|
166
|
-
if (property === node) {
|
|
167
|
-
return getProblem(node.value);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
175
|
-
const config = {
|
|
176
|
-
create,
|
|
177
|
-
meta: {
|
|
178
|
-
type: 'suggestion',
|
|
179
|
-
docs: {
|
|
180
|
-
description: 'Prefer `KeyboardEvent#key` over `KeyboardEvent#keyCode`.',
|
|
181
|
-
recommended: 'unopinionated',
|
|
182
|
-
},
|
|
183
|
-
fixable: 'code',
|
|
184
|
-
messages,
|
|
185
|
-
},
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
export default config;
|
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import {isParenthesized, getParenthesizedText} from './utils/parentheses.js';
|
|
2
|
-
import isSameReference from './utils/is-same-reference.js';
|
|
3
|
-
import shouldAddParenthesesToLogicalExpressionChild from './utils/should-add-parentheses-to-logical-expression-child.js';
|
|
4
|
-
import needsSemicolon from './utils/needs-semicolon.js';
|
|
5
|
-
|
|
6
|
-
const MESSAGE_ID_ERROR = 'prefer-logical-operator-over-ternary/error';
|
|
7
|
-
const MESSAGE_ID_SUGGESTION = 'prefer-logical-operator-over-ternary/suggestion';
|
|
8
|
-
const messages = {
|
|
9
|
-
[MESSAGE_ID_ERROR]: 'Prefer using a logical operator over a ternary.',
|
|
10
|
-
[MESSAGE_ID_SUGGESTION]: 'Switch to `{{operator}}` operator.',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
function isSameNode(left, right, sourceCode) {
|
|
14
|
-
if (isSameReference(left, right)) {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (left.type !== right.type) {
|
|
19
|
-
return false;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
switch (left.type) {
|
|
23
|
-
case 'AwaitExpression': {
|
|
24
|
-
return isSameNode(left.argument, right.argument, sourceCode);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
case 'LogicalExpression': {
|
|
28
|
-
return (
|
|
29
|
-
left.operator === right.operator
|
|
30
|
-
&& isSameNode(left.left, right.left, sourceCode)
|
|
31
|
-
&& isSameNode(left.right, right.right, sourceCode)
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
case 'UnaryExpression': {
|
|
36
|
-
return (
|
|
37
|
-
left.operator === right.operator
|
|
38
|
-
&& left.prefix === right.prefix
|
|
39
|
-
&& isSameNode(left.argument, right.argument, sourceCode)
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
case 'UpdateExpression': {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// No default
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return sourceCode.getText(left) === sourceCode.getText(right);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function fix({
|
|
54
|
-
fixer,
|
|
55
|
-
context,
|
|
56
|
-
conditionalExpression,
|
|
57
|
-
left,
|
|
58
|
-
right,
|
|
59
|
-
operator,
|
|
60
|
-
}) {
|
|
61
|
-
const {sourceCode} = context;
|
|
62
|
-
let text = [left, right].map((node, index) => {
|
|
63
|
-
const isNodeParenthesized = isParenthesized(node, sourceCode);
|
|
64
|
-
let text = isNodeParenthesized ? getParenthesizedText(node, context) : sourceCode.getText(node);
|
|
65
|
-
|
|
66
|
-
if (
|
|
67
|
-
!isNodeParenthesized
|
|
68
|
-
&& shouldAddParenthesesToLogicalExpressionChild(node, {operator, property: index === 0 ? 'left' : 'right'})
|
|
69
|
-
) {
|
|
70
|
-
text = `(${text})`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return text;
|
|
74
|
-
}).join(` ${operator} `);
|
|
75
|
-
|
|
76
|
-
// According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Operator_Precedence#table
|
|
77
|
-
// There should be no cases need add parentheses when switching ternary to logical expression
|
|
78
|
-
|
|
79
|
-
// ASI
|
|
80
|
-
if (needsSemicolon(sourceCode.getTokenBefore(conditionalExpression), context, text)) {
|
|
81
|
-
text = `;${text}`;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return fixer.replaceText(conditionalExpression, text);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function getProblem({
|
|
88
|
-
context,
|
|
89
|
-
conditionalExpression,
|
|
90
|
-
left,
|
|
91
|
-
right,
|
|
92
|
-
}) {
|
|
93
|
-
return {
|
|
94
|
-
node: conditionalExpression,
|
|
95
|
-
messageId: MESSAGE_ID_ERROR,
|
|
96
|
-
suggest: ['??', '||'].map(operator => ({
|
|
97
|
-
messageId: MESSAGE_ID_SUGGESTION,
|
|
98
|
-
data: {operator},
|
|
99
|
-
fix: fixer => fix({
|
|
100
|
-
fixer,
|
|
101
|
-
context,
|
|
102
|
-
conditionalExpression,
|
|
103
|
-
left,
|
|
104
|
-
right,
|
|
105
|
-
operator,
|
|
106
|
-
}),
|
|
107
|
-
})),
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
112
|
-
const create = context => {
|
|
113
|
-
const {sourceCode} = context;
|
|
114
|
-
|
|
115
|
-
return {
|
|
116
|
-
ConditionalExpression(conditionalExpression) {
|
|
117
|
-
const {test, consequent, alternate} = conditionalExpression;
|
|
118
|
-
|
|
119
|
-
// `foo ? foo : bar`
|
|
120
|
-
if (isSameNode(test, consequent, sourceCode)) {
|
|
121
|
-
return getProblem({
|
|
122
|
-
context,
|
|
123
|
-
conditionalExpression,
|
|
124
|
-
left: test,
|
|
125
|
-
right: alternate,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// `!bar ? foo : bar`
|
|
130
|
-
if (
|
|
131
|
-
test.type === 'UnaryExpression'
|
|
132
|
-
&& test.operator === '!'
|
|
133
|
-
&& test.prefix
|
|
134
|
-
&& isSameNode(test.argument, alternate, sourceCode)
|
|
135
|
-
) {
|
|
136
|
-
return getProblem({
|
|
137
|
-
context,
|
|
138
|
-
conditionalExpression,
|
|
139
|
-
left: test.argument,
|
|
140
|
-
right: consequent,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
},
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
148
|
-
const config = {
|
|
149
|
-
create,
|
|
150
|
-
meta: {
|
|
151
|
-
type: 'suggestion',
|
|
152
|
-
docs: {
|
|
153
|
-
description: 'Prefer using a logical operator over a ternary.',
|
|
154
|
-
recommended: 'unopinionated',
|
|
155
|
-
},
|
|
156
|
-
|
|
157
|
-
hasSuggestions: true,
|
|
158
|
-
messages,
|
|
159
|
-
},
|
|
160
|
-
};
|
|
161
|
-
|
|
162
|
-
export default config;
|
package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-math-min-max.js
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/* eslint-disable complexity */
|
|
2
|
-
import {isBigIntLiteral, isCallExpression} from './ast/index.js';
|
|
3
|
-
import {fixSpaceAroundKeyword} from './fix/index.js';
|
|
4
|
-
|
|
5
|
-
const MESSAGE_ID = 'prefer-math-min-max';
|
|
6
|
-
const messages = {
|
|
7
|
-
[MESSAGE_ID]: 'Prefer `Math.{{method}}()` to simplify ternary expressions.',
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
const isNumberTypeAnnotation = typeAnnotation => {
|
|
11
|
-
if (typeAnnotation.type === 'TSNumberKeyword') {
|
|
12
|
-
return true;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (typeAnnotation.type === 'TSTypeAnnotation' && typeAnnotation.typeAnnotation.type === 'TSNumberKeyword') {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (typeAnnotation.type === 'TSTypeReference' && typeAnnotation.typeName.name === 'Number') {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return false;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const getExpressionText = (node, sourceCode) => {
|
|
27
|
-
const expressionNode = node.type === 'TSAsExpression' ? node.expression : node;
|
|
28
|
-
|
|
29
|
-
if (node.type === 'TSAsExpression') {
|
|
30
|
-
return getExpressionText(expressionNode, sourceCode);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return sourceCode.getText(expressionNode);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
37
|
-
const create = context => ({
|
|
38
|
-
/** @param {import('estree').ConditionalExpression} conditionalExpression */
|
|
39
|
-
ConditionalExpression(conditionalExpression) {
|
|
40
|
-
const {test, consequent, alternate} = conditionalExpression;
|
|
41
|
-
|
|
42
|
-
if (test.type !== 'BinaryExpression') {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const {operator, left, right} = test;
|
|
47
|
-
|
|
48
|
-
const hasBigInt = [left, right].some(
|
|
49
|
-
node =>
|
|
50
|
-
isBigIntLiteral(node)
|
|
51
|
-
|| isCallExpression(node, {
|
|
52
|
-
name: 'BigInt',
|
|
53
|
-
argumentsLength: 1,
|
|
54
|
-
optional: false,
|
|
55
|
-
}),
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
if (hasBigInt) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const [leftText, rightText, alternateText, consequentText] = [left, right, alternate, consequent].map(node => getExpressionText(node, context.sourceCode));
|
|
63
|
-
|
|
64
|
-
const isGreaterOrEqual = operator === '>' || operator === '>=';
|
|
65
|
-
const isLessOrEqual = operator === '<' || operator === '<=';
|
|
66
|
-
|
|
67
|
-
let method;
|
|
68
|
-
|
|
69
|
-
// Prefer `Math.min()`
|
|
70
|
-
if (
|
|
71
|
-
// `height > 50 ? 50 : height`
|
|
72
|
-
(isGreaterOrEqual && leftText === alternateText && rightText === consequentText)
|
|
73
|
-
// `height < 50 ? height : 50`
|
|
74
|
-
|| (isLessOrEqual && leftText === consequentText && rightText === alternateText)
|
|
75
|
-
) {
|
|
76
|
-
method = 'min';
|
|
77
|
-
} else if (
|
|
78
|
-
// `height > 50 ? height : 50`
|
|
79
|
-
(isGreaterOrEqual && leftText === consequentText && rightText === alternateText)
|
|
80
|
-
// `height < 50 ? 50 : height`
|
|
81
|
-
|| (isLessOrEqual && leftText === alternateText && rightText === consequentText)
|
|
82
|
-
) {
|
|
83
|
-
method = 'max';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (!method) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
for (const node of [left, right]) {
|
|
91
|
-
let expressionNode = node;
|
|
92
|
-
|
|
93
|
-
if (expressionNode.typeAnnotation && expressionNode.type === 'TSAsExpression') {
|
|
94
|
-
// Ignore if the test is not a number comparison operator
|
|
95
|
-
if (!isNumberTypeAnnotation(expressionNode.typeAnnotation)) {
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
expressionNode = expressionNode.expression;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
// Find variable declaration
|
|
103
|
-
if (expressionNode.type === 'Identifier') {
|
|
104
|
-
const variable = context.sourceCode.getScope(expressionNode).variables.find(variable => variable.name === expressionNode.name);
|
|
105
|
-
|
|
106
|
-
for (const definition of variable?.defs ?? []) {
|
|
107
|
-
switch (definition.type) {
|
|
108
|
-
case 'Parameter': {
|
|
109
|
-
const identifier = definition.name;
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
Capture the following statement
|
|
113
|
-
|
|
114
|
-
```js
|
|
115
|
-
function foo(a: number) {}
|
|
116
|
-
```
|
|
117
|
-
*/
|
|
118
|
-
if (identifier.typeAnnotation?.type === 'TSTypeAnnotation' && !isNumberTypeAnnotation(identifier.typeAnnotation)) {
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
Capture the following statement
|
|
124
|
-
|
|
125
|
-
```js
|
|
126
|
-
function foo(a = 10) {}
|
|
127
|
-
```
|
|
128
|
-
*/
|
|
129
|
-
if (identifier.parent.type === 'AssignmentPattern' && identifier.parent.right.type === 'Literal' && typeof identifier.parent.right.value !== 'number') {
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
case 'Variable': {
|
|
137
|
-
/** @type {import('estree').VariableDeclarator} */
|
|
138
|
-
const variableDeclarator = definition.node;
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
Capture the following statement
|
|
142
|
-
|
|
143
|
-
```js
|
|
144
|
-
var foo: number
|
|
145
|
-
```
|
|
146
|
-
*/
|
|
147
|
-
if (variableDeclarator.id.typeAnnotation?.type === 'TSTypeAnnotation' && !isNumberTypeAnnotation(variableDeclarator.id.typeAnnotation)) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
Capture the following statement
|
|
153
|
-
|
|
154
|
-
```js
|
|
155
|
-
var foo = 10
|
|
156
|
-
```
|
|
157
|
-
*/
|
|
158
|
-
if (variableDeclarator.init?.type === 'Literal' && typeof variableDeclarator.init.value !== 'number') {
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
default:
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
node: conditionalExpression,
|
|
173
|
-
messageId: MESSAGE_ID,
|
|
174
|
-
data: {method},
|
|
175
|
-
/** @param {import('eslint').Rule.RuleFixer} fixer */
|
|
176
|
-
* fix(fixer) {
|
|
177
|
-
const {sourceCode} = context;
|
|
178
|
-
|
|
179
|
-
yield fixSpaceAroundKeyword(fixer, conditionalExpression, context);
|
|
180
|
-
|
|
181
|
-
const argumentsText = [left, right]
|
|
182
|
-
.map(node => node.type === 'SequenceExpression' ? `(${sourceCode.getText(node)})` : sourceCode.getText(node))
|
|
183
|
-
.join(', ');
|
|
184
|
-
|
|
185
|
-
yield fixer.replaceText(conditionalExpression, `Math.${method}(${argumentsText})`);
|
|
186
|
-
},
|
|
187
|
-
};
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
192
|
-
const config = {
|
|
193
|
-
create,
|
|
194
|
-
meta: {
|
|
195
|
-
type: 'problem',
|
|
196
|
-
docs: {
|
|
197
|
-
description: 'Prefer `Math.min()` and `Math.max()` over ternaries for simple comparisons.',
|
|
198
|
-
recommended: 'unopinionated',
|
|
199
|
-
},
|
|
200
|
-
fixable: 'code',
|
|
201
|
-
messages,
|
|
202
|
-
},
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
export default config;
|
package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-math-trunc.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {hasSideEffect} from '@eslint-community/eslint-utils';
|
|
2
|
-
import {fixSpaceAroundKeyword} from './fix/index.js';
|
|
3
|
-
import {isLiteral} from './ast/index.js';
|
|
4
|
-
|
|
5
|
-
const ERROR_BITWISE = 'error-bitwise';
|
|
6
|
-
const ERROR_BITWISE_NOT = 'error-bitwise-not';
|
|
7
|
-
const SUGGESTION_BITWISE = 'suggestion-bitwise';
|
|
8
|
-
const messages = {
|
|
9
|
-
[ERROR_BITWISE]: 'Use `Math.trunc` instead of `{{operator}} {{value}}`.',
|
|
10
|
-
[ERROR_BITWISE_NOT]: 'Use `Math.trunc` instead of `~~`.',
|
|
11
|
-
[SUGGESTION_BITWISE]: 'Replace `{{operator}} {{value}}` with `Math.trunc`.',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
// Bitwise operators
|
|
15
|
-
const bitwiseOperators = new Set(['|', '>>', '<<', '^']);
|
|
16
|
-
const isBitwiseNot = node =>
|
|
17
|
-
node.type === 'UnaryExpression'
|
|
18
|
-
&& node.operator === '~';
|
|
19
|
-
|
|
20
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
21
|
-
const create = context => {
|
|
22
|
-
const {sourceCode} = context;
|
|
23
|
-
|
|
24
|
-
const mathTruncFunctionCall = node => {
|
|
25
|
-
const text = sourceCode.getText(node);
|
|
26
|
-
const parenthesized = node.type === 'SequenceExpression' ? `(${text})` : text;
|
|
27
|
-
return `Math.trunc(${parenthesized})`;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
context.on(['BinaryExpression', 'AssignmentExpression'], node => {
|
|
31
|
-
const {type, operator, right, left} = node;
|
|
32
|
-
const isAssignment = type === 'AssignmentExpression';
|
|
33
|
-
if (
|
|
34
|
-
!isLiteral(right, 0)
|
|
35
|
-
|| !bitwiseOperators.has(isAssignment ? operator.slice(0, -1) : operator)
|
|
36
|
-
) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const problem = {
|
|
41
|
-
node,
|
|
42
|
-
messageId: ERROR_BITWISE,
|
|
43
|
-
data: {
|
|
44
|
-
operator,
|
|
45
|
-
value: right.raw,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
if (!isAssignment || !hasSideEffect(left, sourceCode)) {
|
|
50
|
-
const fix = function * (fixer) {
|
|
51
|
-
const fixed = mathTruncFunctionCall(left);
|
|
52
|
-
if (isAssignment) {
|
|
53
|
-
const operatorToken = sourceCode.getTokenAfter(left, token => token.type === 'Punctuator' && token.value === operator);
|
|
54
|
-
yield fixer.replaceText(operatorToken, '=');
|
|
55
|
-
yield fixer.replaceText(right, fixed);
|
|
56
|
-
} else {
|
|
57
|
-
yield fixSpaceAroundKeyword(fixer, node, context);
|
|
58
|
-
yield fixer.replaceText(node, fixed);
|
|
59
|
-
}
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
if (operator === '|') {
|
|
63
|
-
problem.suggest = [
|
|
64
|
-
{
|
|
65
|
-
messageId: SUGGESTION_BITWISE,
|
|
66
|
-
fix,
|
|
67
|
-
},
|
|
68
|
-
];
|
|
69
|
-
} else {
|
|
70
|
-
problem.fix = fix;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return problem;
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
// Unary Expression Selector: Inner-most 2 bitwise NOT
|
|
78
|
-
context.on('UnaryExpression', node => {
|
|
79
|
-
if (
|
|
80
|
-
isBitwiseNot(node)
|
|
81
|
-
&& isBitwiseNot(node.argument)
|
|
82
|
-
&& !isBitwiseNot(node.argument.argument)
|
|
83
|
-
) {
|
|
84
|
-
return {
|
|
85
|
-
node,
|
|
86
|
-
messageId: ERROR_BITWISE_NOT,
|
|
87
|
-
* fix(fixer) {
|
|
88
|
-
yield fixer.replaceText(node, mathTruncFunctionCall(node.argument.argument));
|
|
89
|
-
yield fixSpaceAroundKeyword(fixer, node, context);
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
97
|
-
const config = {
|
|
98
|
-
create,
|
|
99
|
-
meta: {
|
|
100
|
-
type: 'suggestion',
|
|
101
|
-
docs: {
|
|
102
|
-
description: 'Enforce the use of `Math.trunc` instead of bitwise operators.',
|
|
103
|
-
recommended: 'unopinionated',
|
|
104
|
-
},
|
|
105
|
-
fixable: 'code',
|
|
106
|
-
hasSuggestions: true,
|
|
107
|
-
messages,
|
|
108
|
-
},
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export default config;
|