@depup/typescript-eslint__eslint-plugin 8.57.1-depup.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/LICENSE +21 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/dist/configs/eslint-recommended-raw.d.ts +10 -0
- package/dist/configs/eslint-recommended-raw.js +46 -0
- package/dist/configs/eslintrc/all.d.ts +159 -0
- package/dist/configs/eslintrc/all.js +165 -0
- package/dist/configs/eslintrc/base.d.ts +8 -0
- package/dist/configs/eslintrc/base.js +6 -0
- package/dist/configs/eslintrc/disable-type-checked.d.ts +71 -0
- package/dist/configs/eslintrc/disable-type-checked.js +73 -0
- package/dist/configs/eslintrc/eslint-recommended.d.ts +12 -0
- package/dist/configs/eslintrc/eslint-recommended.js +13 -0
- package/dist/configs/eslintrc/recommended-type-checked-only.d.ts +33 -0
- package/dist/configs/eslintrc/recommended-type-checked-only.js +39 -0
- package/dist/configs/eslintrc/recommended-type-checked.d.ts +56 -0
- package/dist/configs/eslintrc/recommended-type-checked.js +62 -0
- package/dist/configs/eslintrc/recommended.d.ts +29 -0
- package/dist/configs/eslintrc/recommended.js +35 -0
- package/dist/configs/eslintrc/strict-type-checked-only.d.ts +64 -0
- package/dist/configs/eslintrc/strict-type-checked-only.js +79 -0
- package/dist/configs/eslintrc/strict-type-checked.d.ts +98 -0
- package/dist/configs/eslintrc/strict-type-checked.js +114 -0
- package/dist/configs/eslintrc/strict.d.ts +40 -0
- package/dist/configs/eslintrc/strict.js +47 -0
- package/dist/configs/eslintrc/stylistic-type-checked-only.d.ts +15 -0
- package/dist/configs/eslintrc/stylistic-type-checked-only.js +21 -0
- package/dist/configs/eslintrc/stylistic-type-checked.d.ts +29 -0
- package/dist/configs/eslintrc/stylistic-type-checked.js +35 -0
- package/dist/configs/eslintrc/stylistic.d.ts +20 -0
- package/dist/configs/eslintrc/stylistic.js +26 -0
- package/dist/configs/flat/all.d.ts +7 -0
- package/dist/configs/flat/all.js +179 -0
- package/dist/configs/flat/base.d.ts +8 -0
- package/dist/configs/flat/base.js +17 -0
- package/dist/configs/flat/disable-type-checked.d.ts +7 -0
- package/dist/configs/flat/disable-type-checked.js +81 -0
- package/dist/configs/flat/eslint-recommended.d.ts +9 -0
- package/dist/configs/flat/eslint-recommended.js +16 -0
- package/dist/configs/flat/recommended-type-checked-only.d.ts +7 -0
- package/dist/configs/flat/recommended-type-checked-only.js +53 -0
- package/dist/configs/flat/recommended-type-checked.d.ts +7 -0
- package/dist/configs/flat/recommended-type-checked.js +76 -0
- package/dist/configs/flat/recommended.d.ts +7 -0
- package/dist/configs/flat/recommended.js +49 -0
- package/dist/configs/flat/strict-type-checked-only.d.ts +7 -0
- package/dist/configs/flat/strict-type-checked-only.js +93 -0
- package/dist/configs/flat/strict-type-checked.d.ts +7 -0
- package/dist/configs/flat/strict-type-checked.js +128 -0
- package/dist/configs/flat/strict.d.ts +7 -0
- package/dist/configs/flat/strict.js +61 -0
- package/dist/configs/flat/stylistic-type-checked-only.d.ts +7 -0
- package/dist/configs/flat/stylistic-type-checked-only.js +35 -0
- package/dist/configs/flat/stylistic-type-checked.d.ts +7 -0
- package/dist/configs/flat/stylistic-type-checked.js +49 -0
- package/dist/configs/flat/stylistic.d.ts +7 -0
- package/dist/configs/flat/stylistic.js +40 -0
- package/dist/index.d.ts +1128 -0
- package/dist/index.js +6 -0
- package/dist/raw-plugin.d.ts +1152 -0
- package/dist/raw-plugin.js +122 -0
- package/dist/rules/adjacent-overload-signatures.d.ts +4 -0
- package/dist/rules/adjacent-overload-signatures.js +124 -0
- package/dist/rules/array-type.d.ts +12 -0
- package/dist/rules/array-type.js +232 -0
- package/dist/rules/await-thenable.d.ts +6 -0
- package/dist/rules/await-thenable.js +228 -0
- package/dist/rules/ban-ts-comment.d.ts +17 -0
- package/dist/rules/ban-ts-comment.js +195 -0
- package/dist/rules/ban-tslint-comment.d.ts +4 -0
- package/dist/rules/ban-tslint-comment.js +53 -0
- package/dist/rules/class-literal-property-style.d.ts +7 -0
- package/dist/rules/class-literal-property-style.js +160 -0
- package/dist/rules/class-methods-use-this.d.ts +13 -0
- package/dist/rules/class-methods-use-this.js +219 -0
- package/dist/rules/consistent-generic-constructors.d.ts +6 -0
- package/dist/rules/consistent-generic-constructors.js +126 -0
- package/dist/rules/consistent-indexed-object-style.d.ts +7 -0
- package/dist/rules/consistent-indexed-object-style.js +256 -0
- package/dist/rules/consistent-return.d.ts +18 -0
- package/dist/rules/consistent-return.js +135 -0
- package/dist/rules/consistent-type-assertions.d.ts +14 -0
- package/dist/rules/consistent-type-assertions.js +256 -0
- package/dist/rules/consistent-type-definitions.d.ts +5 -0
- package/dist/rules/consistent-type-definitions.js +100 -0
- package/dist/rules/consistent-type-exports.d.ts +11 -0
- package/dist/rules/consistent-type-exports.js +335 -0
- package/dist/rules/consistent-type-imports.d.ts +15 -0
- package/dist/rules/consistent-type-imports.js +608 -0
- package/dist/rules/default-param-last.d.ts +4 -0
- package/dist/rules/default-param-last.js +68 -0
- package/dist/rules/dot-notation.d.ts +23 -0
- package/dist/rules/dot-notation.js +139 -0
- package/dist/rules/enum-utils/shared.d.ts +36 -0
- package/dist/rules/enum-utils/shared.js +121 -0
- package/dist/rules/explicit-function-return-type.d.ts +17 -0
- package/dist/rules/explicit-function-return-type.js +179 -0
- package/dist/rules/explicit-member-accessibility.d.ts +19 -0
- package/dist/rules/explicit-member-accessibility.js +299 -0
- package/dist/rules/explicit-module-boundary-types.d.ts +15 -0
- package/dist/rules/explicit-module-boundary-types.js +386 -0
- package/dist/rules/index.d.ts +448 -0
- package/dist/rules/index.js +275 -0
- package/dist/rules/init-declarations.d.ts +15 -0
- package/dist/rules/init-declarations.js +105 -0
- package/dist/rules/max-params.d.ts +25 -0
- package/dist/rules/max-params.js +72 -0
- package/dist/rules/member-ordering.d.ts +33 -0
- package/dist/rules/member-ordering.js +833 -0
- package/dist/rules/method-signature-style.d.ts +6 -0
- package/dist/rules/method-signature-style.js +186 -0
- package/dist/rules/naming-convention-utils/enums.d.ts +79 -0
- package/dist/rules/naming-convention-utils/enums.js +102 -0
- package/dist/rules/naming-convention-utils/format.d.ts +2 -0
- package/dist/rules/naming-convention-utils/format.js +89 -0
- package/dist/rules/naming-convention-utils/index.d.ts +6 -0
- package/dist/rules/naming-convention-utils/index.js +11 -0
- package/dist/rules/naming-convention-utils/parse-options.d.ts +2 -0
- package/dist/rules/naming-convention-utils/parse-options.js +69 -0
- package/dist/rules/naming-convention-utils/schema.d.ts +2 -0
- package/dist/rules/naming-convention-utils/schema.js +305 -0
- package/dist/rules/naming-convention-utils/shared.d.ts +5 -0
- package/dist/rules/naming-convention-utils/shared.js +16 -0
- package/dist/rules/naming-convention-utils/types.d.ts +39 -0
- package/dist/rules/naming-convention-utils/types.js +2 -0
- package/dist/rules/naming-convention-utils/validator.d.ts +3 -0
- package/dist/rules/naming-convention-utils/validator.js +349 -0
- package/dist/rules/naming-convention.d.ts +8 -0
- package/dist/rules/naming-convention.js +505 -0
- package/dist/rules/no-array-constructor.d.ts +4 -0
- package/dist/rules/no-array-constructor.js +62 -0
- package/dist/rules/no-array-delete.d.ts +6 -0
- package/dist/rules/no-array-delete.js +80 -0
- package/dist/rules/no-base-to-string.d.ts +11 -0
- package/dist/rules/no-base-to-string.js +324 -0
- package/dist/rules/no-confusing-non-null-assertion.d.ts +6 -0
- package/dist/rules/no-confusing-non-null-assertion.js +142 -0
- package/dist/rules/no-confusing-void-expression.d.ts +13 -0
- package/dist/rules/no-confusing-void-expression.js +357 -0
- package/dist/rules/no-deprecated.d.ts +11 -0
- package/dist/rules/no-deprecated.js +402 -0
- package/dist/rules/no-dupe-class-members.d.ts +14 -0
- package/dist/rules/no-dupe-class-members.js +39 -0
- package/dist/rules/no-duplicate-enum-values.d.ts +4 -0
- package/dist/rules/no-duplicate-enum-values.js +83 -0
- package/dist/rules/no-duplicate-type-constituents.d.ts +11 -0
- package/dist/rules/no-duplicate-type-constituents.js +219 -0
- package/dist/rules/no-dynamic-delete.d.ts +4 -0
- package/dist/rules/no-dynamic-delete.js +42 -0
- package/dist/rules/no-empty-function.d.ts +16 -0
- package/dist/rules/no-empty-function.js +134 -0
- package/dist/rules/no-empty-interface.d.ts +11 -0
- package/dist/rules/no-empty-interface.js +102 -0
- package/dist/rules/no-empty-object-type.d.ts +15 -0
- package/dist/rules/no-empty-object-type.js +143 -0
- package/dist/rules/no-explicit-any.d.ts +12 -0
- package/dist/rules/no-explicit-any.js +197 -0
- package/dist/rules/no-extra-non-null-assertion.d.ts +4 -0
- package/dist/rules/no-extra-non-null-assertion.js +35 -0
- package/dist/rules/no-extraneous-class.d.ts +13 -0
- package/dist/rules/no-extraneous-class.js +120 -0
- package/dist/rules/no-floating-promises.d.ts +16 -0
- package/dist/rules/no-floating-promises.js +365 -0
- package/dist/rules/no-for-in-array.d.ts +4 -0
- package/dist/rules/no-for-in-array.js +86 -0
- package/dist/rules/no-implied-eval.d.ts +4 -0
- package/dist/rules/no-implied-eval.js +152 -0
- package/dist/rules/no-import-type-side-effects.d.ts +7 -0
- package/dist/rules/no-import-type-side-effects.js +53 -0
- package/dist/rules/no-inferrable-types.d.ts +11 -0
- package/dist/rules/no-inferrable-types.js +182 -0
- package/dist/rules/no-invalid-this.d.ts +15 -0
- package/dist/rules/no-invalid-this.js +75 -0
- package/dist/rules/no-invalid-void-type.d.ts +9 -0
- package/dist/rules/no-invalid-void-type.js +210 -0
- package/dist/rules/no-loop-func.d.ts +13 -0
- package/dist/rules/no-loop-func.js +187 -0
- package/dist/rules/no-loss-of-precision.d.ts +9 -0
- package/dist/rules/no-loss-of-precision.js +35 -0
- package/dist/rules/no-magic-numbers.d.ts +29 -0
- package/dist/rules/no-magic-numbers.js +248 -0
- package/dist/rules/no-meaningless-void-operator.d.ts +10 -0
- package/dist/rules/no-meaningless-void-operator.js +102 -0
- package/dist/rules/no-misused-new.d.ts +4 -0
- package/dist/rules/no-misused-new.js +81 -0
- package/dist/rules/no-misused-promises.d.ts +21 -0
- package/dist/rules/no-misused-promises.js +765 -0
- package/dist/rules/no-misused-spread.d.ts +12 -0
- package/dist/rules/no-misused-spread.js +260 -0
- package/dist/rules/no-mixed-enums.d.ts +4 -0
- package/dist/rules/no-mixed-enums.js +200 -0
- package/dist/rules/no-namespace.d.ts +11 -0
- package/dist/rules/no-namespace.js +60 -0
- package/dist/rules/no-non-null-asserted-nullish-coalescing.d.ts +5 -0
- package/dist/rules/no-non-null-asserted-nullish-coalescing.js +73 -0
- package/dist/rules/no-non-null-asserted-optional-chain.d.ts +5 -0
- package/dist/rules/no-non-null-asserted-optional-chain.js +65 -0
- package/dist/rules/no-non-null-assertion.d.ts +6 -0
- package/dist/rules/no-non-null-assertion.js +93 -0
- package/dist/rules/no-redeclare.d.ts +12 -0
- package/dist/rules/no-redeclare.js +199 -0
- package/dist/rules/no-redundant-type-constituents.d.ts +4 -0
- package/dist/rules/no-redundant-type-constituents.js +431 -0
- package/dist/rules/no-require-imports.d.ts +11 -0
- package/dist/rules/no-require-imports.js +115 -0
- package/dist/rules/no-restricted-imports.d.ts +9 -0
- package/dist/rules/no-restricted-imports.js +243 -0
- package/dist/rules/no-restricted-types.d.ts +16 -0
- package/dist/rules/no-restricted-types.js +165 -0
- package/dist/rules/no-shadow.d.ts +16 -0
- package/dist/rules/no-shadow.js +521 -0
- package/dist/rules/no-this-alias.d.ts +11 -0
- package/dist/rules/no-this-alias.js +66 -0
- package/dist/rules/no-type-alias.d.ts +18 -0
- package/dist/rules/no-type-alias.js +268 -0
- package/dist/rules/no-unnecessary-boolean-literal-compare.d.ts +12 -0
- package/dist/rules/no-unnecessary-boolean-literal-compare.js +263 -0
- package/dist/rules/no-unnecessary-condition.d.ts +14 -0
- package/dist/rules/no-unnecessary-condition.js +675 -0
- package/dist/rules/no-unnecessary-parameter-property-assignment.d.ts +4 -0
- package/dist/rules/no-unnecessary-parameter-property-assignment.js +148 -0
- package/dist/rules/no-unnecessary-qualifier.d.ts +4 -0
- package/dist/rules/no-unnecessary-qualifier.js +156 -0
- package/dist/rules/no-unnecessary-template-expression.d.ts +6 -0
- package/dist/rules/no-unnecessary-template-expression.js +361 -0
- package/dist/rules/no-unnecessary-type-arguments.d.ts +5 -0
- package/dist/rules/no-unnecessary-type-arguments.js +197 -0
- package/dist/rules/no-unnecessary-type-assertion.d.ts +11 -0
- package/dist/rules/no-unnecessary-type-assertion.js +353 -0
- package/dist/rules/no-unnecessary-type-constraint.d.ts +5 -0
- package/dist/rules/no-unnecessary-type-constraint.js +119 -0
- package/dist/rules/no-unnecessary-type-conversion.d.ts +5 -0
- package/dist/rules/no-unnecessary-type-conversion.js +356 -0
- package/dist/rules/no-unnecessary-type-parameters.d.ts +5 -0
- package/dist/rules/no-unnecessary-type-parameters.js +422 -0
- package/dist/rules/no-unsafe-argument.d.ts +5 -0
- package/dist/rules/no-unsafe-argument.js +272 -0
- package/dist/rules/no-unsafe-assignment.d.ts +4 -0
- package/dist/rules/no-unsafe-assignment.js +322 -0
- package/dist/rules/no-unsafe-call.d.ts +5 -0
- package/dist/rules/no-unsafe-call.js +136 -0
- package/dist/rules/no-unsafe-declaration-merging.d.ts +4 -0
- package/dist/rules/no-unsafe-declaration-merging.js +54 -0
- package/dist/rules/no-unsafe-enum-comparison.d.ts +5 -0
- package/dist/rules/no-unsafe-enum-comparison.js +192 -0
- package/dist/rules/no-unsafe-function-type.d.ts +4 -0
- package/dist/rules/no-unsafe-function-type.js +45 -0
- package/dist/rules/no-unsafe-member-access.d.ts +10 -0
- package/dist/rules/no-unsafe-member-access.js +183 -0
- package/dist/rules/no-unsafe-return.d.ts +4 -0
- package/dist/rules/no-unsafe-return.js +183 -0
- package/dist/rules/no-unsafe-type-assertion.d.ts +4 -0
- package/dist/rules/no-unsafe-type-assertion.js +158 -0
- package/dist/rules/no-unsafe-unary-minus.d.ts +6 -0
- package/dist/rules/no-unsafe-unary-minus.js +78 -0
- package/dist/rules/no-unused-expressions.d.ts +19 -0
- package/dist/rules/no-unused-expressions.js +64 -0
- package/dist/rules/no-unused-private-class-members.d.ts +6 -0
- package/dist/rules/no-unused-private-class-members.js +44 -0
- package/dist/rules/no-unused-vars.d.ts +24 -0
- package/dist/rules/no-unused-vars.js +1033 -0
- package/dist/rules/no-use-before-define.d.ts +16 -0
- package/dist/rules/no-use-before-define.js +303 -0
- package/dist/rules/no-useless-constructor.d.ts +11 -0
- package/dist/rules/no-useless-constructor.js +57 -0
- package/dist/rules/no-useless-default-assignment.d.ts +11 -0
- package/dist/rules/no-useless-default-assignment.js +318 -0
- package/dist/rules/no-useless-empty-export.d.ts +4 -0
- package/dist/rules/no-useless-empty-export.js +70 -0
- package/dist/rules/no-var-requires.d.ts +10 -0
- package/dist/rules/no-var-requires.js +83 -0
- package/dist/rules/no-wrapper-object-types.d.ts +5 -0
- package/dist/rules/no-wrapper-object-types.js +60 -0
- package/dist/rules/non-nullable-type-assertion-style.d.ts +4 -0
- package/dist/rules/non-nullable-type-assertion-style.js +132 -0
- package/dist/rules/only-throw-error.d.ts +14 -0
- package/dist/rules/only-throw-error.js +158 -0
- package/dist/rules/parameter-properties.d.ts +13 -0
- package/dist/rules/parameter-properties.js +164 -0
- package/dist/rules/prefer-as-const.d.ts +5 -0
- package/dist/rules/prefer-as-const.js +72 -0
- package/dist/rules/prefer-destructuring.d.ts +19 -0
- package/dist/rules/prefer-destructuring.js +216 -0
- package/dist/rules/prefer-enum-initializers.d.ts +6 -0
- package/dist/rules/prefer-enum-initializers.js +62 -0
- package/dist/rules/prefer-find.d.ts +5 -0
- package/dist/rules/prefer-find.js +247 -0
- package/dist/rules/prefer-for-of.d.ts +5 -0
- package/dist/rules/prefer-for-of.js +115 -0
- package/dist/rules/prefer-function-type.d.ts +9 -0
- package/dist/rules/prefer-function-type.js +186 -0
- package/dist/rules/prefer-includes.d.ts +5 -0
- package/dist/rules/prefer-includes.js +242 -0
- package/dist/rules/prefer-literal-enum-member.d.ts +6 -0
- package/dist/rules/prefer-literal-enum-member.js +116 -0
- package/dist/rules/prefer-namespace-keyword.d.ts +4 -0
- package/dist/rules/prefer-namespace-keyword.js +42 -0
- package/dist/rules/prefer-nullish-coalescing.d.ts +22 -0
- package/dist/rules/prefer-nullish-coalescing.js +647 -0
- package/dist/rules/prefer-optional-chain-utils/PreferOptionalChainOptions.d.ts +11 -0
- package/dist/rules/prefer-optional-chain-utils/PreferOptionalChainOptions.js +2 -0
- package/dist/rules/prefer-optional-chain-utils/analyzeChain.d.ts +7 -0
- package/dist/rules/prefer-optional-chain-utils/analyzeChain.js +569 -0
- package/dist/rules/prefer-optional-chain-utils/checkNullishAndReport.d.ts +6 -0
- package/dist/rules/prefer-optional-chain-utils/checkNullishAndReport.js +45 -0
- package/dist/rules/prefer-optional-chain-utils/compareNodes.d.ts +15 -0
- package/dist/rules/prefer-optional-chain-utils/compareNodes.js +326 -0
- package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.d.ts +61 -0
- package/dist/rules/prefer-optional-chain-utils/gatherLogicalOperands.js +411 -0
- package/dist/rules/prefer-optional-chain.d.ts +5 -0
- package/dist/rules/prefer-optional-chain.js +150 -0
- package/dist/rules/prefer-promise-reject-errors.d.ts +14 -0
- package/dist/rules/prefer-promise-reject-errors.js +124 -0
- package/dist/rules/prefer-readonly-parameter-types.d.ts +14 -0
- package/dist/rules/prefer-readonly-parameter-types.js +89 -0
- package/dist/rules/prefer-readonly.d.ts +10 -0
- package/dist/rules/prefer-readonly.js +439 -0
- package/dist/rules/prefer-reduce-type-parameter.d.ts +4 -0
- package/dist/rules/prefer-reduce-type-parameter.js +114 -0
- package/dist/rules/prefer-regexp-exec.d.ts +4 -0
- package/dist/rules/prefer-regexp-exec.js +178 -0
- package/dist/rules/prefer-return-this-type.d.ts +4 -0
- package/dist/rules/prefer-return-this-type.js +154 -0
- package/dist/rules/prefer-string-starts-ends-with.d.ts +12 -0
- package/dist/rules/prefer-string-starts-ends-with.js +512 -0
- package/dist/rules/prefer-ts-expect-error.d.ts +5 -0
- package/dist/rules/prefer-ts-expect-error.js +71 -0
- package/dist/rules/promise-function-async.d.ts +15 -0
- package/dist/rules/promise-function-async.js +204 -0
- package/dist/rules/related-getter-setter-pairs.d.ts +4 -0
- package/dist/rules/related-getter-setter-pairs.js +71 -0
- package/dist/rules/require-array-sort-compare.d.ts +10 -0
- package/dist/rules/require-array-sort-compare.js +63 -0
- package/dist/rules/require-await.d.ts +4 -0
- package/dist/rules/require-await.js +263 -0
- package/dist/rules/restrict-plus-operands.d.ts +15 -0
- package/dist/rules/restrict-plus-operands.js +231 -0
- package/dist/rules/restrict-template-expressions.d.ts +19 -0
- package/dist/rules/restrict-template-expressions.js +119 -0
- package/dist/rules/return-await.d.ts +5 -0
- package/dist/rules/return-await.js +363 -0
- package/dist/rules/sort-type-constituents.d.ts +14 -0
- package/dist/rules/sort-type-constituents.js +272 -0
- package/dist/rules/strict-boolean-expressions.d.ts +19 -0
- package/dist/rules/strict-boolean-expressions.js +882 -0
- package/dist/rules/strict-void-return.d.ts +10 -0
- package/dist/rules/strict-void-return.js +374 -0
- package/dist/rules/switch-exhaustiveness-check.d.ts +33 -0
- package/dist/rules/switch-exhaustiveness-check.js +291 -0
- package/dist/rules/triple-slash-reference.d.ts +12 -0
- package/dist/rules/triple-slash-reference.js +110 -0
- package/dist/rules/typedef.d.ts +16 -0
- package/dist/rules/typedef.js +239 -0
- package/dist/rules/unbound-method.d.ts +9 -0
- package/dist/rules/unbound-method.js +334 -0
- package/dist/rules/unified-signatures.d.ts +11 -0
- package/dist/rules/unified-signatures.js +465 -0
- package/dist/rules/use-unknown-in-catch-callback-variable.d.ts +6 -0
- package/dist/rules/use-unknown-in-catch-callback-variable.js +261 -0
- package/dist/util/assertionFunctionUtils.d.ts +16 -0
- package/dist/util/assertionFunctionUtils.js +116 -0
- package/dist/util/astUtils.d.ts +17 -0
- package/dist/util/astUtils.js +143 -0
- package/dist/util/baseTypeUtils.d.ts +13 -0
- package/dist/util/baseTypeUtils.js +75 -0
- package/dist/util/class-scope-analyzer/classScopeAnalyzer.d.ts +52 -0
- package/dist/util/class-scope-analyzer/classScopeAnalyzer.js +566 -0
- package/dist/util/class-scope-analyzer/extractComputedName.d.ts +17 -0
- package/dist/util/class-scope-analyzer/extractComputedName.js +70 -0
- package/dist/util/class-scope-analyzer/types.d.ts +12 -0
- package/dist/util/class-scope-analyzer/types.js +10 -0
- package/dist/util/collectUnusedVariables.d.ts +15 -0
- package/dist/util/collectUnusedVariables.js +598 -0
- package/dist/util/createRule.d.ts +5 -0
- package/dist/util/createRule.js +5 -0
- package/dist/util/escapeRegExp.d.ts +1 -0
- package/dist/util/escapeRegExp.js +14 -0
- package/dist/util/explicitReturnTypeUtils.d.ts +47 -0
- package/dist/util/explicitReturnTypeUtils.js +238 -0
- package/dist/util/getBaseTypesOfClassMember.d.ts +11 -0
- package/dist/util/getBaseTypesOfClassMember.js +31 -0
- package/dist/util/getConstraintInfo.d.ts +35 -0
- package/dist/util/getConstraintInfo.js +70 -0
- package/dist/util/getESLintCoreRule.d.ts +27 -0
- package/dist/util/getESLintCoreRule.js +16 -0
- package/dist/util/getFixOrSuggest.d.ts +9 -0
- package/dist/util/getFixOrSuggest.js +13 -0
- package/dist/util/getForStatementHeadLoc.d.ts +17 -0
- package/dist/util/getForStatementHeadLoc.js +26 -0
- package/dist/util/getFunctionHeadLoc.d.ts +101 -0
- package/dist/util/getFunctionHeadLoc.js +161 -0
- package/dist/util/getMemberHeadLoc.d.ts +36 -0
- package/dist/util/getMemberHeadLoc.js +79 -0
- package/dist/util/getOperatorPrecedence.d.ts +39 -0
- package/dist/util/getOperatorPrecedence.js +421 -0
- package/dist/util/getParentFunctionNode.d.ts +2 -0
- package/dist/util/getParentFunctionNode.js +18 -0
- package/dist/util/getStaticStringValue.d.ts +11 -0
- package/dist/util/getStaticStringValue.js +44 -0
- package/dist/util/getStringLength.d.ts +1 -0
- package/dist/util/getStringLength.js +14 -0
- package/dist/util/getTextWithParentheses.d.ts +3 -0
- package/dist/util/getTextWithParentheses.js +16 -0
- package/dist/util/getThisExpression.d.ts +2 -0
- package/dist/util/getThisExpression.js +24 -0
- package/dist/util/getValueOfLiteralType.d.ts +2 -0
- package/dist/util/getValueOfLiteralType.js +16 -0
- package/dist/util/getWrappedCode.d.ts +2 -0
- package/dist/util/getWrappedCode.js +6 -0
- package/dist/util/getWrappingFixer.d.ts +42 -0
- package/dist/util/getWrappingFixer.js +184 -0
- package/dist/util/hasOverloadSignatures.d.ts +6 -0
- package/dist/util/hasOverloadSignatures.js +47 -0
- package/dist/util/index.d.ts +40 -0
- package/dist/util/index.js +53 -0
- package/dist/util/isArrayMethodCallWithPredicate.d.ts +3 -0
- package/dist/util/isArrayMethodCallWithPredicate.js +64 -0
- package/dist/util/isAssignee.d.ts +2 -0
- package/dist/util/isAssignee.js +50 -0
- package/dist/util/isHigherPrecedenceThanAwait.d.ts +2 -0
- package/dist/util/isHigherPrecedenceThanAwait.js +46 -0
- package/dist/util/isNodeEqual.d.ts +2 -0
- package/dist/util/isNodeEqual.js +25 -0
- package/dist/util/isNullLiteral.d.ts +2 -0
- package/dist/util/isNullLiteral.js +7 -0
- package/dist/util/isPromiseAggregatorMethod.d.ts +3 -0
- package/dist/util/isPromiseAggregatorMethod.js +22 -0
- package/dist/util/isStartOfExpressionStatement.d.ts +7 -0
- package/dist/util/isStartOfExpressionStatement.js +22 -0
- package/dist/util/isTypeImport.d.ts +12 -0
- package/dist/util/isTypeImport.js +21 -0
- package/dist/util/isUndefinedIdentifier.d.ts +2 -0
- package/dist/util/isUndefinedIdentifier.js +7 -0
- package/dist/util/misc.d.ts +115 -0
- package/dist/util/misc.js +270 -0
- package/dist/util/needsPrecedingSemiColon.d.ts +11 -0
- package/dist/util/needsPrecedingSemiColon.js +97 -0
- package/dist/util/needsToBeAwaited.d.ts +7 -0
- package/dist/util/needsToBeAwaited.js +63 -0
- package/dist/util/objectIterators.d.ts +3 -0
- package/dist/util/objectIterators.js +25 -0
- package/dist/util/promiseUtils.d.ts +27 -0
- package/dist/util/promiseUtils.js +98 -0
- package/dist/util/rangeToLoc.d.ts +2 -0
- package/dist/util/rangeToLoc.js +9 -0
- package/dist/util/referenceContainsTypeQuery.d.ts +5 -0
- package/dist/util/referenceContainsTypeQuery.js +19 -0
- package/dist/util/scopeUtils.d.ts +3 -0
- package/dist/util/scopeUtils.js +10 -0
- package/dist/util/skipChainExpression.d.ts +2 -0
- package/dist/util/skipChainExpression.js +7 -0
- package/dist/util/truthinessUtils.d.ts +3 -0
- package/dist/util/truthinessUtils.js +60 -0
- package/dist/util/types.d.ts +2 -0
- package/dist/util/types.js +2 -0
- package/dist/util/walkStatements.d.ts +7 -0
- package/dist/util/walkStatements.js +56 -0
- package/index.d.ts +13 -0
- package/package.json +137 -0
- package/raw-plugin.d.ts +25 -0
- package/rules.d.ts +87 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
37
|
+
const tsutils = __importStar(require("ts-api-utils"));
|
|
38
|
+
const ts = __importStar(require("typescript"));
|
|
39
|
+
const util_1 = require("../util");
|
|
40
|
+
const astIgnoreKeys = new Set(['loc', 'parent', 'range']);
|
|
41
|
+
const isSameAstNode = (actualNode, expectedNode) => {
|
|
42
|
+
if (actualNode === expectedNode) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
if (actualNode &&
|
|
46
|
+
expectedNode &&
|
|
47
|
+
typeof actualNode === 'object' &&
|
|
48
|
+
typeof expectedNode === 'object') {
|
|
49
|
+
if (Array.isArray(actualNode) && Array.isArray(expectedNode)) {
|
|
50
|
+
if (actualNode.length !== expectedNode.length) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
return !actualNode.some((nodeEle, index) => !isSameAstNode(nodeEle, expectedNode[index]));
|
|
54
|
+
}
|
|
55
|
+
const actualNodeKeys = Object.keys(actualNode).filter(key => !astIgnoreKeys.has(key));
|
|
56
|
+
const expectedNodeKeys = Object.keys(expectedNode).filter(key => !astIgnoreKeys.has(key));
|
|
57
|
+
if (actualNodeKeys.length !== expectedNodeKeys.length) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
if (actualNodeKeys.some(actualNodeKey => !Object.hasOwn(expectedNode, actualNodeKey))) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (actualNodeKeys.some(actualNodeKey => !isSameAstNode(actualNode[actualNodeKey], expectedNode[actualNodeKey]))) {
|
|
64
|
+
return false;
|
|
65
|
+
}
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
};
|
|
70
|
+
exports.default = (0, util_1.createRule)({
|
|
71
|
+
name: 'no-duplicate-type-constituents',
|
|
72
|
+
meta: {
|
|
73
|
+
type: 'suggestion',
|
|
74
|
+
docs: {
|
|
75
|
+
description: 'Disallow duplicate constituents of union or intersection types',
|
|
76
|
+
recommended: 'recommended',
|
|
77
|
+
requiresTypeChecking: true,
|
|
78
|
+
},
|
|
79
|
+
fixable: 'code',
|
|
80
|
+
messages: {
|
|
81
|
+
duplicate: '{{type}} type constituent is duplicated with {{previous}}.',
|
|
82
|
+
unnecessary: 'Explicit undefined is unnecessary on an optional parameter.',
|
|
83
|
+
},
|
|
84
|
+
schema: [
|
|
85
|
+
{
|
|
86
|
+
type: 'object',
|
|
87
|
+
additionalProperties: false,
|
|
88
|
+
properties: {
|
|
89
|
+
ignoreIntersections: {
|
|
90
|
+
type: 'boolean',
|
|
91
|
+
description: 'Whether to ignore `&` intersections.',
|
|
92
|
+
},
|
|
93
|
+
ignoreUnions: {
|
|
94
|
+
type: 'boolean',
|
|
95
|
+
description: 'Whether to ignore `|` unions.',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
defaultOptions: [
|
|
102
|
+
{
|
|
103
|
+
ignoreIntersections: false,
|
|
104
|
+
ignoreUnions: false,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
create(context, [{ ignoreIntersections, ignoreUnions }]) {
|
|
108
|
+
const parserServices = (0, util_1.getParserServices)(context);
|
|
109
|
+
const { sourceCode } = context;
|
|
110
|
+
function report(messageId, constituentNode, data) {
|
|
111
|
+
const getUnionOrIntersectionToken = (where, at) => sourceCode[`getTokens${where}`](constituentNode, {
|
|
112
|
+
filter: token => ['&', '|'].includes(token.value) &&
|
|
113
|
+
constituentNode.parent.range[0] <= token.range[0] &&
|
|
114
|
+
token.range[1] <= constituentNode.parent.range[1],
|
|
115
|
+
}).at(at);
|
|
116
|
+
const beforeUnionOrIntersectionToken = getUnionOrIntersectionToken('Before', -1);
|
|
117
|
+
let afterUnionOrIntersectionToken;
|
|
118
|
+
let bracketBeforeTokens;
|
|
119
|
+
let bracketAfterTokens;
|
|
120
|
+
if (beforeUnionOrIntersectionToken) {
|
|
121
|
+
bracketBeforeTokens = sourceCode.getTokensBetween(beforeUnionOrIntersectionToken, constituentNode);
|
|
122
|
+
bracketAfterTokens = sourceCode.getTokensAfter(constituentNode, {
|
|
123
|
+
count: bracketBeforeTokens.length,
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
afterUnionOrIntersectionToken = (0, util_1.nullThrows)(getUnionOrIntersectionToken('After', 0), util_1.NullThrowsReasons.MissingToken('union or intersection token', 'duplicate type constituent'));
|
|
128
|
+
bracketAfterTokens = sourceCode.getTokensBetween(constituentNode, afterUnionOrIntersectionToken);
|
|
129
|
+
bracketBeforeTokens = sourceCode.getTokensBefore(constituentNode, {
|
|
130
|
+
count: bracketAfterTokens.length,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
context.report({
|
|
134
|
+
loc: {
|
|
135
|
+
start: constituentNode.loc.start,
|
|
136
|
+
end: (bracketAfterTokens.at(-1) ?? constituentNode).loc.end,
|
|
137
|
+
},
|
|
138
|
+
node: constituentNode,
|
|
139
|
+
messageId,
|
|
140
|
+
data,
|
|
141
|
+
fix: fixer => [
|
|
142
|
+
beforeUnionOrIntersectionToken,
|
|
143
|
+
...bracketBeforeTokens,
|
|
144
|
+
constituentNode,
|
|
145
|
+
...bracketAfterTokens,
|
|
146
|
+
afterUnionOrIntersectionToken,
|
|
147
|
+
].flatMap(token => (token ? fixer.remove(token) : [])),
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function checkDuplicateRecursively(unionOrIntersection, constituentNode, uniqueConstituents, cachedTypeMap, forEachNodeType) {
|
|
151
|
+
const type = parserServices.getTypeAtLocation(constituentNode);
|
|
152
|
+
if (tsutils.isIntrinsicErrorType(type)) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
const duplicatedPrevious = uniqueConstituents.find(ele => isSameAstNode(ele, constituentNode)) ??
|
|
156
|
+
cachedTypeMap.get(type);
|
|
157
|
+
if (duplicatedPrevious) {
|
|
158
|
+
report('duplicate', constituentNode, {
|
|
159
|
+
type: unionOrIntersection,
|
|
160
|
+
previous: sourceCode.getText(duplicatedPrevious),
|
|
161
|
+
});
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
forEachNodeType?.(type, constituentNode);
|
|
165
|
+
cachedTypeMap.set(type, constituentNode);
|
|
166
|
+
uniqueConstituents.push(constituentNode);
|
|
167
|
+
if ((unionOrIntersection === 'Union' &&
|
|
168
|
+
constituentNode.type === utils_1.AST_NODE_TYPES.TSUnionType) ||
|
|
169
|
+
(unionOrIntersection === 'Intersection' &&
|
|
170
|
+
constituentNode.type === utils_1.AST_NODE_TYPES.TSIntersectionType)) {
|
|
171
|
+
for (const constituent of constituentNode.types) {
|
|
172
|
+
checkDuplicateRecursively(unionOrIntersection, constituent, uniqueConstituents, cachedTypeMap, forEachNodeType);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
function checkDuplicate(node, forEachNodeType) {
|
|
177
|
+
const cachedTypeMap = new Map();
|
|
178
|
+
const uniqueConstituents = [];
|
|
179
|
+
const unionOrIntersection = node.type === utils_1.AST_NODE_TYPES.TSIntersectionType
|
|
180
|
+
? 'Intersection'
|
|
181
|
+
: 'Union';
|
|
182
|
+
for (const type of node.types) {
|
|
183
|
+
checkDuplicateRecursively(unionOrIntersection, type, uniqueConstituents, cachedTypeMap, forEachNodeType);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
return {
|
|
187
|
+
...(!ignoreIntersections && {
|
|
188
|
+
TSIntersectionType(node) {
|
|
189
|
+
if (node.parent.type === utils_1.AST_NODE_TYPES.TSIntersectionType) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
checkDuplicate(node);
|
|
193
|
+
},
|
|
194
|
+
}),
|
|
195
|
+
...(!ignoreUnions && {
|
|
196
|
+
TSUnionType: (node) => {
|
|
197
|
+
if (node.parent.type === utils_1.AST_NODE_TYPES.TSUnionType) {
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
checkDuplicate(node, (constituentNodeType, constituentNode) => {
|
|
201
|
+
const maybeTypeAnnotation = node.parent;
|
|
202
|
+
if (maybeTypeAnnotation.type === utils_1.AST_NODE_TYPES.TSTypeAnnotation) {
|
|
203
|
+
const maybeIdentifier = maybeTypeAnnotation.parent;
|
|
204
|
+
if (maybeIdentifier.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
205
|
+
maybeIdentifier.optional) {
|
|
206
|
+
const maybeFunction = maybeIdentifier.parent;
|
|
207
|
+
if ((0, util_1.isFunctionOrFunctionType)(maybeFunction) &&
|
|
208
|
+
maybeFunction.params.includes(maybeIdentifier) &&
|
|
209
|
+
tsutils.isTypeFlagSet(constituentNodeType, ts.TypeFlags.Undefined)) {
|
|
210
|
+
report('unnecessary', constituentNode);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
}),
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
exports.default = (0, util_1.createRule)({
|
|
6
|
+
name: 'no-dynamic-delete',
|
|
7
|
+
meta: {
|
|
8
|
+
type: 'suggestion',
|
|
9
|
+
docs: {
|
|
10
|
+
description: 'Disallow using the `delete` operator on computed key expressions',
|
|
11
|
+
recommended: 'strict',
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
dynamicDelete: 'Do not delete dynamically computed property keys.',
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
},
|
|
18
|
+
defaultOptions: [],
|
|
19
|
+
create(context) {
|
|
20
|
+
return {
|
|
21
|
+
'UnaryExpression[operator=delete]'(node) {
|
|
22
|
+
if (node.argument.type !== utils_1.AST_NODE_TYPES.MemberExpression ||
|
|
23
|
+
!node.argument.computed ||
|
|
24
|
+
isAcceptableIndexExpression(node.argument.property)) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
context.report({
|
|
28
|
+
node: node.argument.property,
|
|
29
|
+
messageId: 'dynamicDelete',
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
function isAcceptableIndexExpression(property) {
|
|
36
|
+
return ((property.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
37
|
+
['number', 'string'].includes(typeof property.value)) ||
|
|
38
|
+
(property.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
|
39
|
+
property.operator === '-' &&
|
|
40
|
+
property.argument.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
41
|
+
typeof property.argument.value === 'number'));
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TSESTree } from '@typescript-eslint/utils';
|
|
2
|
+
import type { InferMessageIdsTypeFromRule, InferOptionsTypeFromRule } from '../util';
|
|
3
|
+
declare const baseRule: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpected" | "suggestComment", [{
|
|
4
|
+
allow?: string[];
|
|
5
|
+
}], unknown, {
|
|
6
|
+
FunctionDeclaration(node: TSESTree.FunctionDeclaration): void;
|
|
7
|
+
FunctionExpression(node: TSESTree.FunctionExpression): void;
|
|
8
|
+
}>;
|
|
9
|
+
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
|
|
10
|
+
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
|
|
11
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"unexpected" | "suggestComment", [{
|
|
12
|
+
allow?: string[];
|
|
13
|
+
}], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
14
|
+
name: string;
|
|
15
|
+
};
|
|
16
|
+
export default _default;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
const getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
|
6
|
+
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('no-empty-function');
|
|
7
|
+
const defaultOptions = [
|
|
8
|
+
{
|
|
9
|
+
allow: [],
|
|
10
|
+
},
|
|
11
|
+
];
|
|
12
|
+
const schema = (0, util_1.deepMerge)(
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument -- https://github.com/microsoft/TypeScript/issues/17002
|
|
14
|
+
Array.isArray(baseRule.meta.schema)
|
|
15
|
+
? baseRule.meta.schema[0]
|
|
16
|
+
: baseRule.meta.schema, {
|
|
17
|
+
properties: {
|
|
18
|
+
allow: {
|
|
19
|
+
description: 'Locations and kinds of functions that are allowed to be empty.',
|
|
20
|
+
items: {
|
|
21
|
+
type: 'string',
|
|
22
|
+
enum: [
|
|
23
|
+
'functions',
|
|
24
|
+
'arrowFunctions',
|
|
25
|
+
'generatorFunctions',
|
|
26
|
+
'methods',
|
|
27
|
+
'generatorMethods',
|
|
28
|
+
'getters',
|
|
29
|
+
'setters',
|
|
30
|
+
'constructors',
|
|
31
|
+
'private-constructors',
|
|
32
|
+
'protected-constructors',
|
|
33
|
+
'asyncFunctions',
|
|
34
|
+
'asyncMethods',
|
|
35
|
+
'decoratedFunctions',
|
|
36
|
+
'overrideMethods',
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
exports.default = (0, util_1.createRule)({
|
|
43
|
+
name: 'no-empty-function',
|
|
44
|
+
meta: {
|
|
45
|
+
type: 'suggestion',
|
|
46
|
+
defaultOptions,
|
|
47
|
+
docs: {
|
|
48
|
+
description: 'Disallow empty functions',
|
|
49
|
+
extendsBaseRule: true,
|
|
50
|
+
recommended: 'stylistic',
|
|
51
|
+
},
|
|
52
|
+
hasSuggestions: baseRule.meta.hasSuggestions,
|
|
53
|
+
messages: baseRule.meta.messages,
|
|
54
|
+
schema: [schema],
|
|
55
|
+
},
|
|
56
|
+
defaultOptions,
|
|
57
|
+
create(context, [{ allow = [] }]) {
|
|
58
|
+
const rules = baseRule.create(context);
|
|
59
|
+
const isAllowedProtectedConstructors = allow.includes('protected-constructors');
|
|
60
|
+
const isAllowedPrivateConstructors = allow.includes('private-constructors');
|
|
61
|
+
const isAllowedDecoratedFunctions = allow.includes('decoratedFunctions');
|
|
62
|
+
const isAllowedOverrideMethods = allow.includes('overrideMethods');
|
|
63
|
+
/**
|
|
64
|
+
* Check if the method body is empty
|
|
65
|
+
* @param node the node to be validated
|
|
66
|
+
* @returns true if the body is empty
|
|
67
|
+
* @private
|
|
68
|
+
*/
|
|
69
|
+
function isBodyEmpty(node) {
|
|
70
|
+
return node.body.body.length === 0;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if method has parameter properties
|
|
74
|
+
* @param node the node to be validated
|
|
75
|
+
* @returns true if the body has parameter properties
|
|
76
|
+
* @private
|
|
77
|
+
*/
|
|
78
|
+
function hasParameterProperties(node) {
|
|
79
|
+
return node.params.some(param => param.type === utils_1.AST_NODE_TYPES.TSParameterProperty);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @param node the node to be validated
|
|
83
|
+
* @returns true if the constructor is allowed to be empty
|
|
84
|
+
* @private
|
|
85
|
+
*/
|
|
86
|
+
function isAllowedEmptyConstructor(node) {
|
|
87
|
+
const parent = node.parent;
|
|
88
|
+
if (isBodyEmpty(node) &&
|
|
89
|
+
parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
|
90
|
+
parent.kind === 'constructor') {
|
|
91
|
+
const { accessibility } = parent;
|
|
92
|
+
return (
|
|
93
|
+
// allow protected constructors
|
|
94
|
+
(accessibility === 'protected' && isAllowedProtectedConstructors) ||
|
|
95
|
+
// allow private constructors
|
|
96
|
+
(accessibility === 'private' && isAllowedPrivateConstructors) ||
|
|
97
|
+
// allow constructors which have parameter properties
|
|
98
|
+
hasParameterProperties(node));
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* @param node the node to be validated
|
|
104
|
+
* @returns true if a function has decorators
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
function isAllowedEmptyDecoratedFunctions(node) {
|
|
108
|
+
if (isAllowedDecoratedFunctions && isBodyEmpty(node)) {
|
|
109
|
+
const decorators = node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition
|
|
110
|
+
? node.parent.decorators
|
|
111
|
+
: undefined;
|
|
112
|
+
return !!decorators && !!decorators.length;
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
function isAllowedEmptyOverrideMethod(node) {
|
|
117
|
+
return (isAllowedOverrideMethods &&
|
|
118
|
+
isBodyEmpty(node) &&
|
|
119
|
+
node.parent.type === utils_1.AST_NODE_TYPES.MethodDefinition &&
|
|
120
|
+
node.parent.override);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
...rules,
|
|
124
|
+
FunctionExpression(node) {
|
|
125
|
+
if (isAllowedEmptyConstructor(node) ||
|
|
126
|
+
isAllowedEmptyDecoratedFunctions(node) ||
|
|
127
|
+
isAllowedEmptyOverrideMethod(node)) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
rules.FunctionExpression(node);
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
},
|
|
134
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export type Options = [
|
|
3
|
+
{
|
|
4
|
+
allowSingleExtends?: boolean;
|
|
5
|
+
}
|
|
6
|
+
];
|
|
7
|
+
export type MessageIds = 'noEmpty' | 'noEmptyWithSuper';
|
|
8
|
+
declare const _default: TSESLint.RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
|
|
9
|
+
name: string;
|
|
10
|
+
};
|
|
11
|
+
export default _default;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const scope_manager_1 = require("@typescript-eslint/scope-manager");
|
|
4
|
+
const utils_1 = require("@typescript-eslint/utils");
|
|
5
|
+
const util_1 = require("../util");
|
|
6
|
+
exports.default = (0, util_1.createRule)({
|
|
7
|
+
name: 'no-empty-interface',
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'suggestion',
|
|
10
|
+
deprecated: {
|
|
11
|
+
deprecatedSince: '8.0.0',
|
|
12
|
+
replacedBy: [
|
|
13
|
+
{
|
|
14
|
+
rule: {
|
|
15
|
+
name: '@typescript-eslint/no-empty-object-type',
|
|
16
|
+
url: 'https://typescript-eslint.io/rules/no-empty-object-type',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
url: 'https://github.com/typescript-eslint/typescript-eslint/pull/8977',
|
|
21
|
+
},
|
|
22
|
+
docs: {
|
|
23
|
+
description: 'Disallow the declaration of empty interfaces',
|
|
24
|
+
},
|
|
25
|
+
fixable: 'code',
|
|
26
|
+
hasSuggestions: true,
|
|
27
|
+
messages: {
|
|
28
|
+
noEmpty: 'An empty interface is equivalent to `{}`.',
|
|
29
|
+
noEmptyWithSuper: 'An interface declaring no members is equivalent to its supertype.',
|
|
30
|
+
},
|
|
31
|
+
replacedBy: ['@typescript-eslint/no-empty-object-type'],
|
|
32
|
+
schema: [
|
|
33
|
+
{
|
|
34
|
+
type: 'object',
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
properties: {
|
|
37
|
+
allowSingleExtends: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
description: 'Whether to allow empty interfaces that extend a single other interface.',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
defaultOptions: [
|
|
46
|
+
{
|
|
47
|
+
allowSingleExtends: false,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
create(context, [{ allowSingleExtends }]) {
|
|
51
|
+
return {
|
|
52
|
+
TSInterfaceDeclaration(node) {
|
|
53
|
+
if (node.body.body.length !== 0) {
|
|
54
|
+
// interface contains members --> Nothing to report
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const extend = node.extends;
|
|
58
|
+
if (extend.length === 0) {
|
|
59
|
+
context.report({
|
|
60
|
+
node: node.id,
|
|
61
|
+
messageId: 'noEmpty',
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
else if (extend.length === 1 &&
|
|
65
|
+
// interface extends exactly 1 interface --> Report depending on rule setting
|
|
66
|
+
!allowSingleExtends) {
|
|
67
|
+
const fix = (fixer) => {
|
|
68
|
+
let typeParam = '';
|
|
69
|
+
if (node.typeParameters) {
|
|
70
|
+
typeParam = context.sourceCode.getText(node.typeParameters);
|
|
71
|
+
}
|
|
72
|
+
return fixer.replaceText(node, `type ${context.sourceCode.getText(node.id)}${typeParam} = ${context.sourceCode.getText(extend[0])}`);
|
|
73
|
+
};
|
|
74
|
+
const scope = context.sourceCode.getScope(node);
|
|
75
|
+
const mergedWithClassDeclaration = scope.set
|
|
76
|
+
.get(node.id.name)
|
|
77
|
+
?.defs.some(def => def.node.type === utils_1.AST_NODE_TYPES.ClassDeclaration);
|
|
78
|
+
const isInAmbientDeclaration = (0, util_1.isDefinitionFile)(context.filename) &&
|
|
79
|
+
scope.type === scope_manager_1.ScopeType.tsModule &&
|
|
80
|
+
scope.block.declare;
|
|
81
|
+
const useAutoFix = !(isInAmbientDeclaration || mergedWithClassDeclaration);
|
|
82
|
+
context.report({
|
|
83
|
+
node: node.id,
|
|
84
|
+
messageId: 'noEmptyWithSuper',
|
|
85
|
+
...(useAutoFix
|
|
86
|
+
? { fix }
|
|
87
|
+
: !mergedWithClassDeclaration
|
|
88
|
+
? {
|
|
89
|
+
suggest: [
|
|
90
|
+
{
|
|
91
|
+
messageId: 'noEmptyWithSuper',
|
|
92
|
+
fix,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
}
|
|
96
|
+
: null),
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
export type AllowInterfaces = 'always' | 'never' | 'with-single-extends';
|
|
3
|
+
export type AllowObjectTypes = 'always' | 'never';
|
|
4
|
+
export type Options = [
|
|
5
|
+
{
|
|
6
|
+
allowInterfaces?: AllowInterfaces;
|
|
7
|
+
allowObjectTypes?: AllowObjectTypes;
|
|
8
|
+
allowWithName?: string;
|
|
9
|
+
}
|
|
10
|
+
];
|
|
11
|
+
export type MessageIds = 'noEmptyInterface' | 'noEmptyInterfaceWithSuper' | 'noEmptyObject' | 'replaceEmptyInterface' | 'replaceEmptyInterfaceWithSuper' | 'replaceEmptyObjectType';
|
|
12
|
+
declare const _default: TSESLint.RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
|
|
13
|
+
name: string;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|