@alexlit/lint-kit 176.0.1 → 177.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packages/config-stylelint/package.json +5 -5
- package/packages/config-stylelint/plugins/color-format.js +1 -5
- package/packages/config-stylelint/plugins/logical-css.js +1 -4
- package/packages/config-eslint/node_modules/@eslint/core/LICENSE +0 -201
- package/packages/config-eslint/node_modules/@eslint/core/README.md +0 -29
- package/packages/config-eslint/node_modules/@eslint/core/dist/cjs/types.d.cts +0 -1179
- package/packages/config-eslint/node_modules/@eslint/core/dist/esm/types.d.ts +0 -1179
- package/packages/config-eslint/node_modules/@eslint/core/package.json +0 -49
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/LICENSE +0 -201
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/README.md +0 -273
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/cjs/index.cjs +0 -884
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts +0 -328
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/cjs/types.cts +0 -7
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/index.d.ts +0 -328
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/index.js +0 -879
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/types.d.ts +0 -6
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/dist/esm/types.ts +0 -7
- package/packages/config-eslint/node_modules/@eslint/plugin-kit/package.json +0 -61
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/configs/flat-config-base.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/index.d.ts +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/index.js +0 -91
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/license +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/globals.json +0 -3345
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/index.d.ts +0 -3452
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/index.js +0 -2
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/license +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/package.json +0 -117
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/node_modules/globals/readme.md +0 -42
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/package.json +0 -128
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/readme.md +0 -261
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/call-or-new-expression.js +0 -120
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/function-types.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/index.js +0 -30
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-arrow-function-body.js +0 -3
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-directive.js +0 -4
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-empty-array-expression.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-empty-node.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-expression-statement.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-function.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-member-expression.js +0 -98
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-method-call.js +0 -62
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-negative-one.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-reference-identifier.js +0 -159
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-static-require.js +0 -10
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-tagged-template-literal.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/is-undefined.js +0 -3
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/ast/literal.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/better-regex.js +0 -146
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/catch-error-name.js +0 -138
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-assert.js +0 -98
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-date-clone.js +0 -54
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-destructuring.js +0 -168
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-empty-array-spread.js +0 -127
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-existence-index-check.js +0 -137
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/consistent-function-scoping.js +0 -265
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/custom-error-definition.js +0 -218
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/empty-brace-spaces.js +0 -62
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/error-message.js +0 -98
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/escape-case.js +0 -86
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/expiring-todo-comments.js +0 -584
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/explicit-length-check.js +0 -236
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/filename-case.js +0 -276
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/add-parenthesizes-to-return-or-throw-expression.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/append-argument.js +0 -30
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/extend-fix-range.js +0 -11
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/fix-space-around-keywords.js +0 -43
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/index.js +0 -23
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-argument.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-expression-statement.js +0 -34
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-method-call.js +0 -28
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-object-property.js +0 -21
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-parentheses.js +0 -19
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-spaces-after.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/remove-specifier.js +0 -59
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/rename-variable.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-argument.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-member-expression-property.js +0 -25
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-node-or-token-and-spaces-before.js +0 -31
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-reference-identifier.js +0 -32
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-string-raw.js +0 -12
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/replace-template-element.js +0 -10
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/switch-call-expression-to-new-expression.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/fix/switch-new-expression-to-call-expression.js +0 -42
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/import-style.js +0 -375
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/index.js +0 -143
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/new-for-builtins.js +0 -112
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-abusive-eslint-disable.js +0 -63
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-accessor-recursion.js +0 -160
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-anonymous-default-export.js +0 -210
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-callback-reference.js +0 -285
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-for-each.js +0 -496
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-method-this-argument.js +0 -223
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-reduce.js +0 -128
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-reverse.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-array-sort.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-await-expression-member.js +0 -85
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-await-in-promise-methods.js +0 -69
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-console-spaces.js +0 -89
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-document-cookie.js +0 -27
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-empty-file.js +0 -58
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-for-loop.js +0 -419
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-hex-escape.js +0 -54
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-immediate-mutation.js +0 -778
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-instanceof-builtins.js +0 -216
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-invalid-fetch-options.js +0 -112
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-invalid-remove-event-listener.js +0 -61
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-keyword-prefix.js +0 -202
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-lonely-if.js +0 -155
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-magic-array-flat-depth.js +0 -55
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-named-default.js +0 -101
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-negated-condition.js +0 -145
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-negation-in-equality-check.js +0 -99
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-nested-ternary.js +0 -60
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-new-array.js +0 -106
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-new-buffer.js +0 -100
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-null.js +0 -153
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-object-as-default-parameter.js +0 -52
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-process-exit.js +0 -106
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-single-promise-in-promise-methods.js +0 -179
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-static-only-class.js +0 -226
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-thenable.js +0 -194
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-this-assignment.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-typeof-undefined.js +0 -146
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-array-flat-depth.js +0 -49
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-array-splice-count.js +0 -23
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-await.js +0 -110
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-polyfills.js +0 -174
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unnecessary-slice-end.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unreadable-array-destructuring.js +0 -85
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unreadable-iife.js +0 -43
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-unused-properties.js +0 -240
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-collection-argument.js +0 -101
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-error-capture-stack-trace.js +0 -146
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-fallback-in-spread.js +0 -66
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-length-check.js +0 -150
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-promise-resolve-reject.js +0 -210
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-spread.js +0 -389
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-switch-case.js +0 -59
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-useless-undefined.js +0 -275
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/no-zero-fractions.js +0 -81
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/number-literal-case.js +0 -82
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/numeric-separators-style.js +0 -189
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-add-event-listener.js +0 -191
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-find.js +0 -458
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-flat-map.js +0 -86
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-flat.js +0 -279
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-index-of.js +0 -34
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-array-some.js +0 -219
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-at.js +0 -380
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-bigint-literals.js +0 -129
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-blob-reading-methods.js +0 -47
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-class-fields.js +0 -158
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-classlist-toggle.js +0 -255
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-code-point.js +0 -56
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-date-now.js +0 -133
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-default-parameters.js +0 -218
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-append.js +0 -50
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-dataset.js +0 -135
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-remove.js +0 -124
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-dom-node-text-content.js +0 -77
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-event-target.js +0 -119
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-export-from.js +0 -367
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-global-this.js +0 -222
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-import-meta-properties.js +0 -320
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-includes.js +0 -111
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-json-parse-buffer.js +0 -161
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-keyboard-event-key.js +0 -188
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-logical-operator-over-ternary.js +0 -162
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-math-min-max.js +0 -205
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-math-trunc.js +0 -111
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-modern-dom-apis.js +0 -145
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-modern-math-apis.js +0 -210
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-module.js +0 -377
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-native-coercion-functions.js +0 -187
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-negative-index.js +0 -211
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-node-protocol.js +0 -86
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-number-properties.js +0 -142
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-object-from-entries.js +0 -256
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-optional-catch-binding.js +0 -77
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-prototype-methods.js +0 -162
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-query-selector.js +0 -170
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-reflect-apply.js +0 -99
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-regexp-test.js +0 -155
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-response-static-json.js +0 -85
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-set-has.js +0 -181
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-set-size.js +0 -106
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-single-call.js +0 -188
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-spread.js +0 -521
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-raw.js +0 -149
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-replace-all.js +0 -180
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-slice.js +0 -180
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-starts-ends-with.js +0 -201
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-trim-start-end.js +0 -46
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-structured-clone.js +0 -149
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-switch.js +0 -357
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-ternary.js +0 -288
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-top-level-await.js +0 -154
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-type-error.js +0 -169
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prevent-abbreviations.js +0 -655
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/relative-url-style.js +0 -171
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-array-join-separator.js +0 -65
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-module-attributes.js +0 -120
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-module-specifiers.js +0 -158
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-number-to-fixed-digits-argument.js +0 -55
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/require-post-message-target-origin.js +0 -74
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/get-documentation-url.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/index.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-create.js +0 -51
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-listener.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-problem.js +0 -38
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-rule-fixer.js +0 -49
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-rule.js +0 -38
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/to-eslint-rules.js +0 -13
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/unicorn-context.js +0 -36
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/unicorn-listeners.js +0 -65
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/rule/utilities.js +0 -27
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/abbreviations.js +0 -270
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/builtin-errors.js +0 -14
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/dom-events.js +0 -275
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/event-keys.js +0 -54
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/negative-index.js +0 -52
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/no-array-mutate-rule.js +0 -139
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/no-unnecessary-length-or-infinity-rule.js +0 -80
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/package-json.js +0 -42
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/simple-array-search-rule.js +0 -126
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/shared/typed-array.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/string-content.js +0 -192
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/switch-case-braces.js +0 -114
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/template-indent.js +0 -219
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/text-encoding-identifier-case.js +0 -130
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/throw-new-error.js +0 -60
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/array-or-object-prototype-property.js +0 -57
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/assert-token.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/boolean.js +0 -88
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/builtins.js +0 -30
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/cartesian-product-samples.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/create-deprecated-rules.js +0 -29
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/escape-string.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/escape-template-element-raw.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-ancestor.js +0 -15
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-available-variable-name.js +0 -147
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-builtin-rule.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-call-expression-arguments-text.js +0 -36
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-call-or-new-expression-tokens.js +0 -67
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-class-head-location.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-documentation-url.js +0 -9
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-indent-string.js +0 -18
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-references.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-scopes.js +0 -12
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-sibling-node.js +0 -38
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-switch-case-head-location.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-token-store.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/get-variable-identifiers.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/global-reference-tracker.js +0 -68
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/has-optional-chain-element.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/has-same-range.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/index.js +0 -59
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-function-self-used-inside.js +0 -39
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-left-hand-side.js +0 -20
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-logical-expression.js +0 -14
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-method-named.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-new-expression-with-parentheses.js +0 -28
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-node-matches.js +0 -58
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-node-value-not-dom-node.js +0 -20
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-node-value-not-function.js +0 -40
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-number.js +0 -224
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-object-method.js +0 -10
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-on-same-line.js +0 -7
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-same-identifier.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-same-reference.js +0 -170
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-export-local.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-import-local.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-property-assignment-pattern-left.js +0 -8
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-shorthand-property-value.js +0 -6
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-unresolved-variable.js +0 -14
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/is-value-not-usable.js +0 -5
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/needs-semicolon.js +0 -118
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/numeric.js +0 -49
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/parentheses.js +0 -71
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/resolve-variable-name.js +0 -18
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/rule.js +0 -27
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-await-expression-argument.js +0 -17
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-call-expression-callee.js +0 -18
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-conditional-expression-child.js +0 -13
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-expression-statement-expression.js +0 -22
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-logical-expression-child.js +0 -43
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-member-expression-object.js +0 -47
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-new-expression-callee.js +0 -28
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/should-add-parentheses-to-unary-expression.js +0 -24
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/singular.js +0 -16
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/string-cases.js +0 -2
- package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/utils/to-location.js +0 -25
package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-replace-all.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import {getStaticValue} from '@eslint-community/eslint-utils';
|
|
2
|
-
import regjsparser from 'regjsparser';
|
|
3
|
-
import {isRegexLiteral, isNewExpression, isMethodCall} from './ast/index.js';
|
|
4
|
-
|
|
5
|
-
const {parse: parseRegExp} = regjsparser;
|
|
6
|
-
const MESSAGE_ID_USE_REPLACE_ALL = 'method';
|
|
7
|
-
const MESSAGE_ID_USE_STRING = 'pattern';
|
|
8
|
-
const messages = {
|
|
9
|
-
[MESSAGE_ID_USE_REPLACE_ALL]: 'Prefer `String#replaceAll()` over `String#replace()`.',
|
|
10
|
-
[MESSAGE_ID_USE_STRING]: 'This pattern can be replaced with {{replacement}}.',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const QUOTE = '\'';
|
|
14
|
-
|
|
15
|
-
function getPatternReplacement(node) {
|
|
16
|
-
if (!isRegexLiteral(node)) {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const {pattern, flags} = node.regex;
|
|
21
|
-
if (flags.replace('u', '').replace('v', '') !== 'g') {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
let tree;
|
|
26
|
-
|
|
27
|
-
try {
|
|
28
|
-
tree = parseRegExp(pattern, flags, {
|
|
29
|
-
unicodePropertyEscape: flags.includes('u'),
|
|
30
|
-
unicodeSet: flags.includes('v'),
|
|
31
|
-
namedGroups: true,
|
|
32
|
-
lookbehind: true,
|
|
33
|
-
});
|
|
34
|
-
} catch {
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const parts = tree.type === 'alternative' ? tree.body : [tree];
|
|
39
|
-
if (parts.some(part => part.type !== 'value')) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return QUOTE
|
|
44
|
-
+ parts.map(part => {
|
|
45
|
-
const {kind, codePoint, raw} = part;
|
|
46
|
-
|
|
47
|
-
if (kind === 'controlLetter') {
|
|
48
|
-
if (codePoint === 13) {
|
|
49
|
-
return String.raw`\r`;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (codePoint === 10) {
|
|
53
|
-
return String.raw`\n`;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (codePoint === 9) {
|
|
57
|
-
return String.raw`\t`;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return String.raw`\u{${codePoint.toString(16)}}`;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (kind === 'octal') {
|
|
64
|
-
return String.raw`\u{${codePoint.toString(16)}}`;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
let character = raw;
|
|
68
|
-
if (kind === 'identifier') {
|
|
69
|
-
character = character.slice(1);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (character === QUOTE || character === '\\') {
|
|
73
|
-
return `\\${character}`;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return character;
|
|
77
|
-
}).join('')
|
|
78
|
-
+ QUOTE;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const isRegExpWithGlobalFlag = (node, scope) => {
|
|
82
|
-
if (isRegexLiteral(node)) {
|
|
83
|
-
return node.regex.flags.includes('g');
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (
|
|
87
|
-
isNewExpression(node, {name: 'RegExp'})
|
|
88
|
-
&& node.arguments[0]?.type !== 'SpreadElement'
|
|
89
|
-
&& node.arguments[1]?.type === 'Literal'
|
|
90
|
-
&& typeof node.arguments[1].value === 'string'
|
|
91
|
-
) {
|
|
92
|
-
return node.arguments[1].value.includes('g');
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
const staticResult = getStaticValue(node, scope);
|
|
96
|
-
|
|
97
|
-
// Don't know if there is `g` flag
|
|
98
|
-
if (!staticResult) {
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const {value} = staticResult;
|
|
103
|
-
return (
|
|
104
|
-
Object.prototype.toString.call(value) === '[object RegExp]'
|
|
105
|
-
&& value.global
|
|
106
|
-
);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
110
|
-
const create = context => ({
|
|
111
|
-
CallExpression(node) {
|
|
112
|
-
if (!isMethodCall(node, {
|
|
113
|
-
methods: ['replace', 'replaceAll'],
|
|
114
|
-
argumentsLength: 2,
|
|
115
|
-
optionalCall: false,
|
|
116
|
-
})) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const {
|
|
121
|
-
arguments: [pattern],
|
|
122
|
-
callee: {property},
|
|
123
|
-
} = node;
|
|
124
|
-
|
|
125
|
-
if (!isRegExpWithGlobalFlag(pattern, context.sourceCode.getScope(pattern))) {
|
|
126
|
-
return;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
const methodName = property.name;
|
|
130
|
-
const patternReplacement = getPatternReplacement(pattern);
|
|
131
|
-
|
|
132
|
-
if (methodName === 'replaceAll') {
|
|
133
|
-
if (!patternReplacement) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
node: pattern,
|
|
139
|
-
messageId: MESSAGE_ID_USE_STRING,
|
|
140
|
-
data: {
|
|
141
|
-
// Show `This pattern can be replaced with a string literal.` for long strings
|
|
142
|
-
replacement: patternReplacement.length < 20 ? patternReplacement : 'a string literal',
|
|
143
|
-
},
|
|
144
|
-
/** @param {import('eslint').Rule.RuleFixer} fixer */
|
|
145
|
-
fix: fixer => fixer.replaceText(pattern, patternReplacement),
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
node: property,
|
|
151
|
-
messageId: MESSAGE_ID_USE_REPLACE_ALL,
|
|
152
|
-
/** @param {import('eslint').Rule.RuleFixer} fixer */
|
|
153
|
-
* fix(fixer) {
|
|
154
|
-
yield fixer.insertTextAfter(property, 'All');
|
|
155
|
-
|
|
156
|
-
if (!patternReplacement) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
yield fixer.replaceText(pattern, patternReplacement);
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
167
|
-
const config = {
|
|
168
|
-
create,
|
|
169
|
-
meta: {
|
|
170
|
-
type: 'suggestion',
|
|
171
|
-
docs: {
|
|
172
|
-
description: 'Prefer `String#replaceAll()` over regex searches with the global flag.',
|
|
173
|
-
recommended: 'unopinionated',
|
|
174
|
-
},
|
|
175
|
-
fixable: 'code',
|
|
176
|
-
messages,
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default config;
|
package/packages/config-eslint/node_modules/eslint-plugin-unicorn/rules/prefer-string-slice.js
DELETED
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
import {getStaticValue} from '@eslint-community/eslint-utils';
|
|
2
|
-
import {getParenthesizedText, getParenthesizedRange} from './utils/parentheses.js';
|
|
3
|
-
import {replaceArgument} from './fix/index.js';
|
|
4
|
-
import {isNumericLiteral, isMethodCall} from './ast/index.js';
|
|
5
|
-
|
|
6
|
-
const MESSAGE_ID_SUBSTR = 'substr';
|
|
7
|
-
const MESSAGE_ID_SUBSTRING = 'substring';
|
|
8
|
-
const messages = {
|
|
9
|
-
[MESSAGE_ID_SUBSTR]: 'Prefer `String#slice()` over `String#substr()`.',
|
|
10
|
-
[MESSAGE_ID_SUBSTRING]: 'Prefer `String#slice()` over `String#substring()`.',
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const getNumericValue = node => {
|
|
14
|
-
if (isNumericLiteral(node)) {
|
|
15
|
-
return node.value;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (node.type === 'UnaryExpression' && node.operator === '-') {
|
|
19
|
-
return -getNumericValue(node.argument);
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
// This handles cases where the argument is very likely to be a number, such as `.substring('foo'.length)`.
|
|
24
|
-
const isLengthProperty = node => (
|
|
25
|
-
node?.type === 'MemberExpression'
|
|
26
|
-
&& node.computed === false
|
|
27
|
-
&& node.property.type === 'Identifier'
|
|
28
|
-
&& node.property.name === 'length'
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
function * fixSubstrArguments({node, fixer, context, abort}) {
|
|
32
|
-
const argumentNodes = node.arguments;
|
|
33
|
-
const [firstArgument, secondArgument] = argumentNodes;
|
|
34
|
-
|
|
35
|
-
if (!secondArgument) {
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const {sourceCode} = context;
|
|
40
|
-
const scope = sourceCode.getScope(node);
|
|
41
|
-
const firstArgumentStaticResult = getStaticValue(firstArgument, scope);
|
|
42
|
-
const secondArgumentRange = getParenthesizedRange(secondArgument, context);
|
|
43
|
-
const replaceSecondArgument = text => replaceArgument(fixer, secondArgument, text, context);
|
|
44
|
-
|
|
45
|
-
if (firstArgumentStaticResult?.value === 0) {
|
|
46
|
-
if (isNumericLiteral(secondArgument) || isLengthProperty(secondArgument)) {
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (typeof getNumericValue(secondArgument) === 'number') {
|
|
51
|
-
yield replaceSecondArgument(Math.max(0, getNumericValue(secondArgument)));
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
yield fixer.insertTextBeforeRange(secondArgumentRange, 'Math.max(0, ');
|
|
56
|
-
yield fixer.insertTextAfterRange(secondArgumentRange, ')');
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (argumentNodes.every(node => isNumericLiteral(node))) {
|
|
61
|
-
yield replaceSecondArgument(firstArgument.value + secondArgument.value);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return abort();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function * fixSubstringArguments({node, fixer, context, abort}) {
|
|
69
|
-
const [firstArgument, secondArgument] = node.arguments;
|
|
70
|
-
|
|
71
|
-
const firstNumber = firstArgument ? getNumericValue(firstArgument) : undefined;
|
|
72
|
-
const firstArgumentText = getParenthesizedText(firstArgument, context);
|
|
73
|
-
const replaceFirstArgument = text => replaceArgument(fixer, firstArgument, text, context);
|
|
74
|
-
|
|
75
|
-
if (!secondArgument) {
|
|
76
|
-
if (isLengthProperty(firstArgument)) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
if (firstNumber !== undefined) {
|
|
81
|
-
yield replaceFirstArgument(Math.max(0, firstNumber));
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const firstArgumentRange = getParenthesizedRange(firstArgument, context);
|
|
86
|
-
yield fixer.insertTextBeforeRange(firstArgumentRange, 'Math.max(0, ');
|
|
87
|
-
yield fixer.insertTextAfterRange(firstArgumentRange, ')');
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const secondNumber = getNumericValue(secondArgument);
|
|
92
|
-
const secondArgumentText = getParenthesizedText(secondArgument, context);
|
|
93
|
-
const replaceSecondArgument = text => replaceArgument(fixer, secondArgument, text, context);
|
|
94
|
-
|
|
95
|
-
if (firstNumber !== undefined && secondNumber !== undefined) {
|
|
96
|
-
const argumentsValue = [Math.max(0, firstNumber), Math.max(0, secondNumber)];
|
|
97
|
-
if (firstNumber > secondNumber) {
|
|
98
|
-
argumentsValue.reverse();
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (argumentsValue[0] !== firstNumber) {
|
|
102
|
-
yield replaceFirstArgument(argumentsValue[0]);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (argumentsValue[1] !== secondNumber) {
|
|
106
|
-
yield replaceSecondArgument(argumentsValue[1]);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
if (firstNumber === 0 || secondNumber === 0) {
|
|
113
|
-
yield replaceFirstArgument(0);
|
|
114
|
-
yield replaceSecondArgument(`Math.max(0, ${firstNumber === 0 ? secondArgumentText : firstArgumentText})`);
|
|
115
|
-
return;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// As values aren't Literal, we can not know whether secondArgument will become smaller than the first or not, causing an issue:
|
|
119
|
-
// .substring(0, 2) and .substring(2, 0) returns the same result
|
|
120
|
-
// .slice(0, 2) and .slice(2, 0) doesn't return the same result
|
|
121
|
-
// There's also an issue with us now knowing whether the value will be negative or not, due to:
|
|
122
|
-
// .substring() treats a negative number the same as it treats a zero.
|
|
123
|
-
// The latter issue could be solved by wrapping all dynamic numbers in Math.max(0, <value>), but the resulting code would not be nice
|
|
124
|
-
|
|
125
|
-
return abort();
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
129
|
-
const create = context => ({
|
|
130
|
-
CallExpression(node) {
|
|
131
|
-
if (!isMethodCall(node, {methods: ['substr', 'substring']})) {
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const method = node.callee.property.name;
|
|
136
|
-
|
|
137
|
-
return {
|
|
138
|
-
node,
|
|
139
|
-
messageId: method,
|
|
140
|
-
* fix(fixer, {abort}) {
|
|
141
|
-
yield fixer.replaceText(node.callee.property, 'slice');
|
|
142
|
-
|
|
143
|
-
if (node.arguments.length === 0) {
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
node.arguments.length > 2
|
|
149
|
-
|| node.arguments.some(node => node.type === 'SpreadElement')
|
|
150
|
-
) {
|
|
151
|
-
return abort();
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
const fixArguments = method === 'substr' ? fixSubstrArguments : fixSubstringArguments;
|
|
155
|
-
yield fixArguments({
|
|
156
|
-
node,
|
|
157
|
-
fixer,
|
|
158
|
-
context,
|
|
159
|
-
abort,
|
|
160
|
-
});
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
167
|
-
const config = {
|
|
168
|
-
create,
|
|
169
|
-
meta: {
|
|
170
|
-
type: 'suggestion',
|
|
171
|
-
docs: {
|
|
172
|
-
description: 'Prefer `String#slice()` over `String#substr()` and `String#substring()`.',
|
|
173
|
-
recommended: 'unopinionated',
|
|
174
|
-
},
|
|
175
|
-
fixable: 'code',
|
|
176
|
-
messages,
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export default config;
|
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
import {isParenthesized, getStaticValue} from '@eslint-community/eslint-utils';
|
|
2
|
-
import escapeString from './utils/escape-string.js';
|
|
3
|
-
import shouldAddParenthesesToMemberExpressionObject from './utils/should-add-parentheses-to-member-expression-object.js';
|
|
4
|
-
import shouldAddParenthesesToLogicalExpressionChild from './utils/should-add-parentheses-to-logical-expression-child.js';
|
|
5
|
-
import {getParenthesizedText, getParenthesizedRange} from './utils/parentheses.js';
|
|
6
|
-
import {isMethodCall, isRegexLiteral} from './ast/index.js';
|
|
7
|
-
|
|
8
|
-
const MESSAGE_STARTS_WITH = 'prefer-starts-with';
|
|
9
|
-
const MESSAGE_ENDS_WITH = 'prefer-ends-with';
|
|
10
|
-
const FIX_TYPE_STRING_CASTING = 'useStringCasting';
|
|
11
|
-
const FIX_TYPE_OPTIONAL_CHAINING = 'useOptionalChaining';
|
|
12
|
-
const FIX_TYPE_NULLISH_COALESCING = 'useNullishCoalescing';
|
|
13
|
-
const messages = {
|
|
14
|
-
[MESSAGE_STARTS_WITH]: 'Prefer `String#startsWith()` over a regex with `^`.',
|
|
15
|
-
[MESSAGE_ENDS_WITH]: 'Prefer `String#endsWith()` over a regex with `$`.',
|
|
16
|
-
[FIX_TYPE_STRING_CASTING]: 'Convert to string `String(…).{{method}}()`.',
|
|
17
|
-
[FIX_TYPE_OPTIONAL_CHAINING]: 'Use optional chaining `…?.{{method}}()`.',
|
|
18
|
-
[FIX_TYPE_NULLISH_COALESCING]: 'Use nullish coalescing `(… ?? \'\').{{method}}()`.',
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
const doesNotContain = (string, characters) => characters.every(character => !string.includes(character));
|
|
22
|
-
const isSimpleString = string => doesNotContain(
|
|
23
|
-
string,
|
|
24
|
-
['^', '$', '+', '[', '{', '(', '\\', '.', '?', '*', '|'],
|
|
25
|
-
);
|
|
26
|
-
const addParentheses = text => `(${text})`;
|
|
27
|
-
|
|
28
|
-
const checkRegex = ({pattern, flags}) => {
|
|
29
|
-
if (flags.includes('i') || flags.includes('m')) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (pattern.startsWith('^')) {
|
|
34
|
-
const string = pattern.slice(1);
|
|
35
|
-
|
|
36
|
-
if (isSimpleString(string)) {
|
|
37
|
-
return {
|
|
38
|
-
messageId: MESSAGE_STARTS_WITH,
|
|
39
|
-
string,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
if (pattern.endsWith('$')) {
|
|
45
|
-
const string = pattern.slice(0, -1);
|
|
46
|
-
|
|
47
|
-
if (isSimpleString(string)) {
|
|
48
|
-
return {
|
|
49
|
-
messageId: MESSAGE_ENDS_WITH,
|
|
50
|
-
string,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
57
|
-
const create = context => {
|
|
58
|
-
const {sourceCode} = context;
|
|
59
|
-
|
|
60
|
-
return {
|
|
61
|
-
CallExpression(node) {
|
|
62
|
-
if (
|
|
63
|
-
!isMethodCall(node, {
|
|
64
|
-
method: 'test',
|
|
65
|
-
argumentsLength: 1,
|
|
66
|
-
optionalCall: false,
|
|
67
|
-
optionalMember: false,
|
|
68
|
-
})
|
|
69
|
-
|| !isRegexLiteral(node.callee.object)
|
|
70
|
-
) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const regexNode = node.callee.object;
|
|
75
|
-
const {regex} = regexNode;
|
|
76
|
-
const result = checkRegex(regex);
|
|
77
|
-
if (!result) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const [target] = node.arguments;
|
|
82
|
-
const method = result.messageId === MESSAGE_STARTS_WITH ? 'startsWith' : 'endsWith';
|
|
83
|
-
|
|
84
|
-
let isString = target.type === 'TemplateLiteral'
|
|
85
|
-
|| (
|
|
86
|
-
target.type === 'CallExpression'
|
|
87
|
-
&& target.callee.type === 'Identifier'
|
|
88
|
-
&& target.callee.name === 'String'
|
|
89
|
-
);
|
|
90
|
-
let isNonString = false;
|
|
91
|
-
if (!isString) {
|
|
92
|
-
const staticValue = getStaticValue(target, sourceCode.getScope(target));
|
|
93
|
-
|
|
94
|
-
if (staticValue) {
|
|
95
|
-
isString = typeof staticValue.value === 'string';
|
|
96
|
-
isNonString = !isString;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const problem = {
|
|
101
|
-
node,
|
|
102
|
-
messageId: result.messageId,
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
function * fix(fixer, fixType) {
|
|
106
|
-
let targetText = getParenthesizedText(target, context);
|
|
107
|
-
const isRegexParenthesized = isParenthesized(regexNode, sourceCode);
|
|
108
|
-
const isTargetParenthesized = isParenthesized(target, sourceCode);
|
|
109
|
-
|
|
110
|
-
switch (fixType) {
|
|
111
|
-
// Goal: `(target ?? '').startsWith(pattern)`
|
|
112
|
-
case FIX_TYPE_NULLISH_COALESCING: {
|
|
113
|
-
if (
|
|
114
|
-
!isTargetParenthesized
|
|
115
|
-
&& shouldAddParenthesesToLogicalExpressionChild(target, {operator: '??', property: 'left'})
|
|
116
|
-
) {
|
|
117
|
-
targetText = addParentheses(targetText);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
targetText += ' ?? \'\'';
|
|
121
|
-
|
|
122
|
-
// `LogicalExpression` need add parentheses to call `.startsWith()`,
|
|
123
|
-
// but if regex is parenthesized, we can reuse it
|
|
124
|
-
if (!isRegexParenthesized) {
|
|
125
|
-
targetText = addParentheses(targetText);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// Goal: `String(target).startsWith(pattern)`
|
|
132
|
-
case FIX_TYPE_STRING_CASTING: {
|
|
133
|
-
// `target` was a call argument, don't need check parentheses
|
|
134
|
-
targetText = `String(${targetText})`;
|
|
135
|
-
// `CallExpression` don't need add parentheses to call `.startsWith()`
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// Goal: `target.startsWith(pattern)` or `target?.startsWith(pattern)`
|
|
140
|
-
case FIX_TYPE_OPTIONAL_CHAINING: {
|
|
141
|
-
// Optional chaining: `target.startsWith` => `target?.startsWith`
|
|
142
|
-
yield fixer.replaceText(sourceCode.getTokenBefore(node.callee.property), '?.');
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Fallthrough
|
|
146
|
-
default: {
|
|
147
|
-
if (
|
|
148
|
-
!isRegexParenthesized
|
|
149
|
-
&& !isTargetParenthesized
|
|
150
|
-
&& shouldAddParenthesesToMemberExpressionObject(target, context)
|
|
151
|
-
) {
|
|
152
|
-
targetText = addParentheses(targetText);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
// The regex literal always starts with `/` or `(`, so we don't need check ASI
|
|
158
|
-
|
|
159
|
-
// Replace regex with string
|
|
160
|
-
yield fixer.replaceText(regexNode, targetText);
|
|
161
|
-
|
|
162
|
-
// `.test` => `.startsWith` / `.endsWith`
|
|
163
|
-
yield fixer.replaceText(node.callee.property, method);
|
|
164
|
-
|
|
165
|
-
// Replace argument with result.string
|
|
166
|
-
yield fixer.replaceTextRange(getParenthesizedRange(target, context), escapeString(result.string));
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (isString || !isNonString) {
|
|
170
|
-
problem.fix = fix;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (!isString) {
|
|
174
|
-
problem.suggest = [
|
|
175
|
-
FIX_TYPE_STRING_CASTING,
|
|
176
|
-
FIX_TYPE_OPTIONAL_CHAINING,
|
|
177
|
-
FIX_TYPE_NULLISH_COALESCING,
|
|
178
|
-
].map(type => ({messageId: type, data: {method}, fix: fixer => fix(fixer, type)}));
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return problem;
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
187
|
-
const config = {
|
|
188
|
-
create,
|
|
189
|
-
meta: {
|
|
190
|
-
type: 'suggestion',
|
|
191
|
-
docs: {
|
|
192
|
-
description: 'Prefer `String#startsWith()` & `String#endsWith()` over `RegExp#test()`.',
|
|
193
|
-
recommended: 'unopinionated',
|
|
194
|
-
},
|
|
195
|
-
fixable: 'code',
|
|
196
|
-
hasSuggestions: true,
|
|
197
|
-
messages,
|
|
198
|
-
},
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
export default config;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import {isMethodCall} from './ast/index.js';
|
|
2
|
-
|
|
3
|
-
const MESSAGE_ID = 'prefer-string-trim-start-end';
|
|
4
|
-
const messages = {
|
|
5
|
-
[MESSAGE_ID]: 'Prefer `String#{{replacement}}()` over `String#{{method}}()`.',
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
/** @param {import('eslint').Rule.RuleContext} context */
|
|
9
|
-
const create = () => ({
|
|
10
|
-
CallExpression(callExpression) {
|
|
11
|
-
if (!isMethodCall(callExpression, {
|
|
12
|
-
methods: ['trimLeft', 'trimRight'],
|
|
13
|
-
argumentsLength: 0,
|
|
14
|
-
optionalCall: false,
|
|
15
|
-
})) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const node = callExpression.callee.property;
|
|
20
|
-
const method = node.name;
|
|
21
|
-
const replacement = method === 'trimLeft' ? 'trimStart' : 'trimEnd';
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
node,
|
|
25
|
-
messageId: MESSAGE_ID,
|
|
26
|
-
data: {method, replacement},
|
|
27
|
-
fix: fixer => fixer.replaceText(node, replacement),
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
/** @type {import('eslint').Rule.RuleModule} */
|
|
33
|
-
const config = {
|
|
34
|
-
create,
|
|
35
|
-
meta: {
|
|
36
|
-
type: 'suggestion',
|
|
37
|
-
docs: {
|
|
38
|
-
description: 'Prefer `String#trimStart()` / `String#trimEnd()` over `String#trimLeft()` / `String#trimRight()`.',
|
|
39
|
-
recommended: 'unopinionated',
|
|
40
|
-
},
|
|
41
|
-
fixable: 'code',
|
|
42
|
-
messages,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default config;
|