@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,68 @@
|
|
|
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: 'default-param-last',
|
|
7
|
+
meta: {
|
|
8
|
+
type: 'suggestion',
|
|
9
|
+
docs: {
|
|
10
|
+
description: 'Enforce default parameters to be last',
|
|
11
|
+
extendsBaseRule: true,
|
|
12
|
+
frozen: true,
|
|
13
|
+
},
|
|
14
|
+
messages: {
|
|
15
|
+
shouldBeLast: 'Default parameters should be last.',
|
|
16
|
+
},
|
|
17
|
+
schema: [],
|
|
18
|
+
},
|
|
19
|
+
defaultOptions: [],
|
|
20
|
+
create(context) {
|
|
21
|
+
/**
|
|
22
|
+
* checks if node is optional parameter
|
|
23
|
+
* @param node the node to be evaluated
|
|
24
|
+
* @private
|
|
25
|
+
*/
|
|
26
|
+
function isOptionalParam(node) {
|
|
27
|
+
return ((node.type === utils_1.AST_NODE_TYPES.ArrayPattern ||
|
|
28
|
+
node.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
|
|
29
|
+
node.type === utils_1.AST_NODE_TYPES.Identifier ||
|
|
30
|
+
node.type === utils_1.AST_NODE_TYPES.ObjectPattern ||
|
|
31
|
+
node.type === utils_1.AST_NODE_TYPES.RestElement) &&
|
|
32
|
+
node.optional);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* checks if node is plain parameter
|
|
36
|
+
* @param node the node to be evaluated
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
function isPlainParam(node) {
|
|
40
|
+
return !(node.type === utils_1.AST_NODE_TYPES.AssignmentPattern ||
|
|
41
|
+
node.type === utils_1.AST_NODE_TYPES.RestElement ||
|
|
42
|
+
isOptionalParam(node));
|
|
43
|
+
}
|
|
44
|
+
function checkDefaultParamLast(node) {
|
|
45
|
+
let hasSeenPlainParam = false;
|
|
46
|
+
for (let i = node.params.length - 1; i >= 0; i--) {
|
|
47
|
+
const current = node.params[i];
|
|
48
|
+
const param = current.type === utils_1.AST_NODE_TYPES.TSParameterProperty
|
|
49
|
+
? current.parameter
|
|
50
|
+
: current;
|
|
51
|
+
if (isPlainParam(param)) {
|
|
52
|
+
hasSeenPlainParam = true;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (hasSeenPlainParam &&
|
|
56
|
+
(isOptionalParam(param) ||
|
|
57
|
+
param.type === utils_1.AST_NODE_TYPES.AssignmentPattern)) {
|
|
58
|
+
context.report({ node: current, messageId: 'shouldBeLast' });
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
ArrowFunctionExpression: checkDefaultParamLast,
|
|
64
|
+
FunctionDeclaration: checkDefaultParamLast,
|
|
65
|
+
FunctionExpression: checkDefaultParamLast,
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
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<"useBrackets" | "useDot", [{
|
|
4
|
+
allowIndexSignaturePropertyAccess?: boolean;
|
|
5
|
+
allowKeywords?: boolean;
|
|
6
|
+
allowPattern?: string;
|
|
7
|
+
allowPrivateClassPropertyAccess?: boolean;
|
|
8
|
+
allowProtectedClassPropertyAccess?: boolean;
|
|
9
|
+
}], unknown, {
|
|
10
|
+
MemberExpression(node: TSESTree.MemberExpression): void;
|
|
11
|
+
}>;
|
|
12
|
+
export type Options = InferOptionsTypeFromRule<typeof baseRule>;
|
|
13
|
+
export type MessageIds = InferMessageIdsTypeFromRule<typeof baseRule>;
|
|
14
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"useBrackets" | "useDot", [{
|
|
15
|
+
allowIndexSignaturePropertyAccess?: boolean;
|
|
16
|
+
allowKeywords?: boolean;
|
|
17
|
+
allowPattern?: string;
|
|
18
|
+
allowPrivateClassPropertyAccess?: boolean;
|
|
19
|
+
allowProtectedClassPropertyAccess?: boolean;
|
|
20
|
+
}], import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
21
|
+
name: string;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
@@ -0,0 +1,139 @@
|
|
|
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 getESLintCoreRule_1 = require("../util/getESLintCoreRule");
|
|
41
|
+
const baseRule = (0, getESLintCoreRule_1.getESLintCoreRule)('dot-notation');
|
|
42
|
+
const defaultOptions = [
|
|
43
|
+
{
|
|
44
|
+
allowIndexSignaturePropertyAccess: false,
|
|
45
|
+
allowKeywords: true,
|
|
46
|
+
allowPattern: '',
|
|
47
|
+
allowPrivateClassPropertyAccess: false,
|
|
48
|
+
allowProtectedClassPropertyAccess: false,
|
|
49
|
+
},
|
|
50
|
+
];
|
|
51
|
+
exports.default = (0, util_1.createRule)({
|
|
52
|
+
name: 'dot-notation',
|
|
53
|
+
meta: {
|
|
54
|
+
type: 'suggestion',
|
|
55
|
+
defaultOptions,
|
|
56
|
+
docs: {
|
|
57
|
+
description: 'Enforce dot notation whenever possible',
|
|
58
|
+
extendsBaseRule: true,
|
|
59
|
+
frozen: true,
|
|
60
|
+
recommended: 'stylistic',
|
|
61
|
+
requiresTypeChecking: true,
|
|
62
|
+
},
|
|
63
|
+
fixable: baseRule.meta.fixable,
|
|
64
|
+
hasSuggestions: baseRule.meta.hasSuggestions,
|
|
65
|
+
messages: baseRule.meta.messages,
|
|
66
|
+
schema: [
|
|
67
|
+
{
|
|
68
|
+
type: 'object',
|
|
69
|
+
additionalProperties: false,
|
|
70
|
+
properties: {
|
|
71
|
+
allowIndexSignaturePropertyAccess: {
|
|
72
|
+
type: 'boolean',
|
|
73
|
+
description: 'Whether to allow accessing properties matching an index signature with array notation.',
|
|
74
|
+
},
|
|
75
|
+
allowKeywords: {
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
description: 'Whether to allow keywords such as ["class"]`.',
|
|
78
|
+
},
|
|
79
|
+
allowPattern: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
description: 'Regular expression of names to allow.',
|
|
82
|
+
},
|
|
83
|
+
allowPrivateClassPropertyAccess: {
|
|
84
|
+
type: 'boolean',
|
|
85
|
+
description: 'Whether to allow accessing class members marked as `private` with array notation.',
|
|
86
|
+
},
|
|
87
|
+
allowProtectedClassPropertyAccess: {
|
|
88
|
+
type: 'boolean',
|
|
89
|
+
description: 'Whether to allow accessing class members marked as `protected` with array notation.',
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
defaultOptions,
|
|
96
|
+
create(context, [options]) {
|
|
97
|
+
const rules = baseRule.create(context);
|
|
98
|
+
const services = (0, util_1.getParserServices)(context);
|
|
99
|
+
const checker = services.program.getTypeChecker();
|
|
100
|
+
const allowPrivateClassPropertyAccess = options.allowPrivateClassPropertyAccess;
|
|
101
|
+
const allowProtectedClassPropertyAccess = options.allowProtectedClassPropertyAccess;
|
|
102
|
+
const allowIndexSignaturePropertyAccess = (options.allowIndexSignaturePropertyAccess ?? false) ||
|
|
103
|
+
tsutils.isCompilerOptionEnabled(services.program.getCompilerOptions(), 'noPropertyAccessFromIndexSignature');
|
|
104
|
+
return {
|
|
105
|
+
MemberExpression(node) {
|
|
106
|
+
if ((allowPrivateClassPropertyAccess ||
|
|
107
|
+
allowProtectedClassPropertyAccess ||
|
|
108
|
+
allowIndexSignaturePropertyAccess) &&
|
|
109
|
+
node.computed) {
|
|
110
|
+
// for perf reasons - only fetch symbols if we have to
|
|
111
|
+
const propertySymbol = services.getSymbolAtLocation(node.property) ??
|
|
112
|
+
services
|
|
113
|
+
.getTypeAtLocation(node.object)
|
|
114
|
+
.getNonNullableType()
|
|
115
|
+
.getProperties()
|
|
116
|
+
.find(propertySymbol => node.property.type === utils_1.AST_NODE_TYPES.Literal &&
|
|
117
|
+
propertySymbol.escapedName === node.property.value);
|
|
118
|
+
const modifierKind = (0, util_1.getModifiers)(propertySymbol?.getDeclarations()?.[0])?.[0].kind;
|
|
119
|
+
if ((allowPrivateClassPropertyAccess &&
|
|
120
|
+
modifierKind === ts.SyntaxKind.PrivateKeyword) ||
|
|
121
|
+
(allowProtectedClassPropertyAccess &&
|
|
122
|
+
modifierKind === ts.SyntaxKind.ProtectedKeyword)) {
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (propertySymbol == null && allowIndexSignaturePropertyAccess) {
|
|
126
|
+
const objectType = services
|
|
127
|
+
.getTypeAtLocation(node.object)
|
|
128
|
+
.getNonNullableType();
|
|
129
|
+
const indexInfos = checker.getIndexInfosOfType(objectType);
|
|
130
|
+
if (indexInfos.some(info => tsutils.isTypeFlagSet(info.keyType, ts.TypeFlags.StringLike))) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
rules.MemberExpression(node);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
},
|
|
139
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as ts from 'typescript';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieve only the Enum literals from a type. for example:
|
|
4
|
+
* - 123 --> []
|
|
5
|
+
* - {} --> []
|
|
6
|
+
* - Fruit.Apple --> [Fruit.Apple]
|
|
7
|
+
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit.Apple, Vegetable.Lettuce]
|
|
8
|
+
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit.Apple, Vegetable.Lettuce]
|
|
9
|
+
* - T extends Fruit --> [Fruit]
|
|
10
|
+
*/
|
|
11
|
+
export declare function getEnumLiterals(type: ts.Type): ts.LiteralType[];
|
|
12
|
+
/**
|
|
13
|
+
* A type can have 0 or more enum types. For example:
|
|
14
|
+
* - 123 --> []
|
|
15
|
+
* - {} --> []
|
|
16
|
+
* - Fruit.Apple --> [Fruit]
|
|
17
|
+
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit, Vegetable]
|
|
18
|
+
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit, Vegetable]
|
|
19
|
+
* - T extends Fruit --> [Fruit]
|
|
20
|
+
*/
|
|
21
|
+
export declare function getEnumTypes(typeChecker: ts.TypeChecker, type: ts.Type): ts.Type[];
|
|
22
|
+
/**
|
|
23
|
+
* Returns the enum key that matches the given literal node, or null if none
|
|
24
|
+
* match. For example:
|
|
25
|
+
* ```ts
|
|
26
|
+
* enum Fruit {
|
|
27
|
+
* Apple = 'apple',
|
|
28
|
+
* Banana = 'banana',
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'apple') --> 'Fruit.Apple'
|
|
32
|
+
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'banana') --> 'Fruit.Banana'
|
|
33
|
+
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'cherry') --> null
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export declare function getEnumKeyForLiteral(enumLiterals: ts.LiteralType[], literal: unknown): string | null;
|
|
@@ -0,0 +1,121 @@
|
|
|
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
|
+
exports.getEnumLiterals = getEnumLiterals;
|
|
37
|
+
exports.getEnumTypes = getEnumTypes;
|
|
38
|
+
exports.getEnumKeyForLiteral = getEnumKeyForLiteral;
|
|
39
|
+
const tsutils = __importStar(require("ts-api-utils"));
|
|
40
|
+
const ts = __importStar(require("typescript"));
|
|
41
|
+
const util_1 = require("../../util");
|
|
42
|
+
/*
|
|
43
|
+
* If passed an enum member, returns the type of the parent. Otherwise,
|
|
44
|
+
* returns itself.
|
|
45
|
+
*
|
|
46
|
+
* For example:
|
|
47
|
+
* - `Fruit` --> `Fruit`
|
|
48
|
+
* - `Fruit.Apple` --> `Fruit`
|
|
49
|
+
*/
|
|
50
|
+
function getBaseEnumType(typeChecker, type) {
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
52
|
+
const symbol = type.getSymbol();
|
|
53
|
+
if (!tsutils.isSymbolFlagSet(symbol, ts.SymbolFlags.EnumMember)) {
|
|
54
|
+
return type;
|
|
55
|
+
}
|
|
56
|
+
return typeChecker.getTypeAtLocation(symbol.valueDeclaration.parent);
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Retrieve only the Enum literals from a type. for example:
|
|
60
|
+
* - 123 --> []
|
|
61
|
+
* - {} --> []
|
|
62
|
+
* - Fruit.Apple --> [Fruit.Apple]
|
|
63
|
+
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit.Apple, Vegetable.Lettuce]
|
|
64
|
+
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit.Apple, Vegetable.Lettuce]
|
|
65
|
+
* - T extends Fruit --> [Fruit]
|
|
66
|
+
*/
|
|
67
|
+
function getEnumLiterals(type) {
|
|
68
|
+
return tsutils
|
|
69
|
+
.unionConstituents(type)
|
|
70
|
+
.filter((subType) => (0, util_1.isTypeFlagSet)(subType, ts.TypeFlags.EnumLiteral));
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* A type can have 0 or more enum types. For example:
|
|
74
|
+
* - 123 --> []
|
|
75
|
+
* - {} --> []
|
|
76
|
+
* - Fruit.Apple --> [Fruit]
|
|
77
|
+
* - Fruit.Apple | Vegetable.Lettuce --> [Fruit, Vegetable]
|
|
78
|
+
* - Fruit.Apple | Vegetable.Lettuce | 123 --> [Fruit, Vegetable]
|
|
79
|
+
* - T extends Fruit --> [Fruit]
|
|
80
|
+
*/
|
|
81
|
+
function getEnumTypes(typeChecker, type) {
|
|
82
|
+
return getEnumLiterals(type).map(type => getBaseEnumType(typeChecker, type));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Returns the enum key that matches the given literal node, or null if none
|
|
86
|
+
* match. For example:
|
|
87
|
+
* ```ts
|
|
88
|
+
* enum Fruit {
|
|
89
|
+
* Apple = 'apple',
|
|
90
|
+
* Banana = 'banana',
|
|
91
|
+
* }
|
|
92
|
+
*
|
|
93
|
+
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'apple') --> 'Fruit.Apple'
|
|
94
|
+
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'banana') --> 'Fruit.Banana'
|
|
95
|
+
* getEnumKeyForLiteral([Fruit.Apple, Fruit.Banana], 'cherry') --> null
|
|
96
|
+
* ```
|
|
97
|
+
*/
|
|
98
|
+
function getEnumKeyForLiteral(enumLiterals, literal) {
|
|
99
|
+
for (const enumLiteral of enumLiterals) {
|
|
100
|
+
if (enumLiteral.value === literal) {
|
|
101
|
+
const { symbol } = enumLiteral;
|
|
102
|
+
const memberDeclaration = symbol.valueDeclaration;
|
|
103
|
+
const enumDeclaration = memberDeclaration.parent;
|
|
104
|
+
const memberNameIdentifier = memberDeclaration.name;
|
|
105
|
+
const enumName = enumDeclaration.name.text;
|
|
106
|
+
switch (memberNameIdentifier.kind) {
|
|
107
|
+
case ts.SyntaxKind.Identifier:
|
|
108
|
+
return `${enumName}.${memberNameIdentifier.text}`;
|
|
109
|
+
case ts.SyntaxKind.StringLiteral: {
|
|
110
|
+
const memberName = memberNameIdentifier.text.replaceAll("'", "\\'");
|
|
111
|
+
return `${enumName}['${memberName}']`;
|
|
112
|
+
}
|
|
113
|
+
case ts.SyntaxKind.ComputedPropertyName:
|
|
114
|
+
return `${enumName}[${memberNameIdentifier.expression.getText()}]`;
|
|
115
|
+
default:
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type Options = [
|
|
2
|
+
{
|
|
3
|
+
allowConciseArrowFunctionExpressionsStartingWithVoid?: boolean;
|
|
4
|
+
allowDirectConstAssertionInArrowFunctions?: boolean;
|
|
5
|
+
allowedNames?: string[];
|
|
6
|
+
allowExpressions?: boolean;
|
|
7
|
+
allowFunctionsWithoutTypeParameters?: boolean;
|
|
8
|
+
allowHigherOrderFunctions?: boolean;
|
|
9
|
+
allowIIFEs?: boolean;
|
|
10
|
+
allowTypedFunctionExpressions?: boolean;
|
|
11
|
+
}
|
|
12
|
+
];
|
|
13
|
+
export type MessageIds = 'missingReturnType';
|
|
14
|
+
declare const _default: import("@typescript-eslint/utils/ts-eslint").RuleModule<"missingReturnType", Options, import("../../rules").ESLintPluginDocs, import("@typescript-eslint/utils/ts-eslint").RuleListener> & {
|
|
15
|
+
name: string;
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,179 @@
|
|
|
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 explicitReturnTypeUtils_1 = require("../util/explicitReturnTypeUtils");
|
|
6
|
+
exports.default = (0, util_1.createRule)({
|
|
7
|
+
name: 'explicit-function-return-type',
|
|
8
|
+
meta: {
|
|
9
|
+
type: 'problem',
|
|
10
|
+
docs: {
|
|
11
|
+
description: 'Require explicit return types on functions and class methods',
|
|
12
|
+
},
|
|
13
|
+
messages: {
|
|
14
|
+
missingReturnType: 'Missing return type on function.',
|
|
15
|
+
},
|
|
16
|
+
schema: [
|
|
17
|
+
{
|
|
18
|
+
type: 'object',
|
|
19
|
+
additionalProperties: false,
|
|
20
|
+
properties: {
|
|
21
|
+
allowConciseArrowFunctionExpressionsStartingWithVoid: {
|
|
22
|
+
type: 'boolean',
|
|
23
|
+
description: 'Whether to allow arrow functions that start with the `void` keyword.',
|
|
24
|
+
},
|
|
25
|
+
allowDirectConstAssertionInArrowFunctions: {
|
|
26
|
+
type: 'boolean',
|
|
27
|
+
description: 'Whether to ignore arrow functions immediately returning a `as const` value.',
|
|
28
|
+
},
|
|
29
|
+
allowedNames: {
|
|
30
|
+
type: 'array',
|
|
31
|
+
description: 'An array of function/method names that will not have their arguments or return values checked.',
|
|
32
|
+
items: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
allowExpressions: {
|
|
37
|
+
type: 'boolean',
|
|
38
|
+
description: 'Whether to ignore function expressions (functions which are not part of a declaration).',
|
|
39
|
+
},
|
|
40
|
+
allowFunctionsWithoutTypeParameters: {
|
|
41
|
+
type: 'boolean',
|
|
42
|
+
description: "Whether to ignore functions that don't have generic type parameters.",
|
|
43
|
+
},
|
|
44
|
+
allowHigherOrderFunctions: {
|
|
45
|
+
type: 'boolean',
|
|
46
|
+
description: 'Whether to ignore functions immediately returning another function expression.',
|
|
47
|
+
},
|
|
48
|
+
allowIIFEs: {
|
|
49
|
+
type: 'boolean',
|
|
50
|
+
description: 'Whether to ignore immediately invoked function expressions (IIFEs).',
|
|
51
|
+
},
|
|
52
|
+
allowTypedFunctionExpressions: {
|
|
53
|
+
type: 'boolean',
|
|
54
|
+
description: 'Whether to ignore type annotations on the variable of function expressions.',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
defaultOptions: [
|
|
61
|
+
{
|
|
62
|
+
allowConciseArrowFunctionExpressionsStartingWithVoid: false,
|
|
63
|
+
allowDirectConstAssertionInArrowFunctions: true,
|
|
64
|
+
allowedNames: [],
|
|
65
|
+
allowExpressions: false,
|
|
66
|
+
allowFunctionsWithoutTypeParameters: false,
|
|
67
|
+
allowHigherOrderFunctions: true,
|
|
68
|
+
allowIIFEs: false,
|
|
69
|
+
allowTypedFunctionExpressions: true,
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
create(context, [options]) {
|
|
73
|
+
const functionInfoStack = [];
|
|
74
|
+
function enterFunction(node) {
|
|
75
|
+
functionInfoStack.push({
|
|
76
|
+
node,
|
|
77
|
+
returns: [],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
function popFunctionInfo(exitNodeType) {
|
|
81
|
+
return (0, util_1.nullThrows)(functionInfoStack.pop(), `Stack should exist on ${exitNodeType} exit`);
|
|
82
|
+
}
|
|
83
|
+
function isAllowedFunction(node) {
|
|
84
|
+
if (options.allowFunctionsWithoutTypeParameters && !node.typeParameters) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
if (options.allowIIFEs && isIIFE(node)) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
if (!options.allowedNames?.length) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression ||
|
|
94
|
+
node.type === utils_1.AST_NODE_TYPES.FunctionExpression) {
|
|
95
|
+
const parent = node.parent;
|
|
96
|
+
let funcName;
|
|
97
|
+
if (node.id?.name) {
|
|
98
|
+
funcName = node.id.name;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
switch (parent.type) {
|
|
102
|
+
case utils_1.AST_NODE_TYPES.VariableDeclarator: {
|
|
103
|
+
if (parent.id.type === utils_1.AST_NODE_TYPES.Identifier) {
|
|
104
|
+
funcName = parent.id.name;
|
|
105
|
+
}
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
case utils_1.AST_NODE_TYPES.MethodDefinition:
|
|
109
|
+
case utils_1.AST_NODE_TYPES.PropertyDefinition:
|
|
110
|
+
case utils_1.AST_NODE_TYPES.Property: {
|
|
111
|
+
if (parent.key.type === utils_1.AST_NODE_TYPES.Identifier &&
|
|
112
|
+
!parent.computed) {
|
|
113
|
+
funcName = parent.key.name;
|
|
114
|
+
}
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
if (!!funcName && options.allowedNames.includes(funcName)) {
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
if (node.type === utils_1.AST_NODE_TYPES.FunctionDeclaration &&
|
|
124
|
+
node.id &&
|
|
125
|
+
options.allowedNames.includes(node.id.name)) {
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
function isIIFE(node) {
|
|
131
|
+
return node.parent.type === utils_1.AST_NODE_TYPES.CallExpression;
|
|
132
|
+
}
|
|
133
|
+
function exitFunctionExpression(node) {
|
|
134
|
+
const info = popFunctionInfo('function expression');
|
|
135
|
+
if (options.allowConciseArrowFunctionExpressionsStartingWithVoid &&
|
|
136
|
+
node.type === utils_1.AST_NODE_TYPES.ArrowFunctionExpression &&
|
|
137
|
+
node.expression &&
|
|
138
|
+
node.body.type === utils_1.AST_NODE_TYPES.UnaryExpression &&
|
|
139
|
+
node.body.operator === 'void') {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
if (isAllowedFunction(node)) {
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
if (options.allowTypedFunctionExpressions &&
|
|
146
|
+
((0, explicitReturnTypeUtils_1.isValidFunctionExpressionReturnType)(node, options) ||
|
|
147
|
+
(0, explicitReturnTypeUtils_1.ancestorHasReturnType)(node))) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(info, options, context.sourceCode, loc => context.report({
|
|
151
|
+
loc,
|
|
152
|
+
node,
|
|
153
|
+
messageId: 'missingReturnType',
|
|
154
|
+
}));
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
'ArrowFunctionExpression, FunctionExpression, FunctionDeclaration': enterFunction,
|
|
158
|
+
'ArrowFunctionExpression:exit': exitFunctionExpression,
|
|
159
|
+
'FunctionDeclaration:exit'(node) {
|
|
160
|
+
const info = popFunctionInfo('function declaration');
|
|
161
|
+
if (isAllowedFunction(node)) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (options.allowTypedFunctionExpressions && node.returnType) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
(0, explicitReturnTypeUtils_1.checkFunctionReturnType)(info, options, context.sourceCode, loc => context.report({
|
|
168
|
+
loc,
|
|
169
|
+
node,
|
|
170
|
+
messageId: 'missingReturnType',
|
|
171
|
+
}));
|
|
172
|
+
},
|
|
173
|
+
'FunctionExpression:exit': exitFunctionExpression,
|
|
174
|
+
ReturnStatement(node) {
|
|
175
|
+
functionInfoStack.at(-1)?.returns.push(node);
|
|
176
|
+
},
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { TSESLint } from '@typescript-eslint/utils';
|
|
2
|
+
type AccessibilityLevel = 'explicit' | 'no-public' | 'off';
|
|
3
|
+
export interface Config {
|
|
4
|
+
accessibility?: AccessibilityLevel;
|
|
5
|
+
ignoredMethodNames?: string[];
|
|
6
|
+
overrides?: {
|
|
7
|
+
accessors?: AccessibilityLevel;
|
|
8
|
+
constructors?: AccessibilityLevel;
|
|
9
|
+
methods?: AccessibilityLevel;
|
|
10
|
+
parameterProperties?: AccessibilityLevel;
|
|
11
|
+
properties?: AccessibilityLevel;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export type Options = [Config];
|
|
15
|
+
export type MessageIds = 'addExplicitAccessibility' | 'missingAccessibility' | 'unwantedPublicAccessibility';
|
|
16
|
+
declare const _default: TSESLint.RuleModule<MessageIds, Options, import("../../rules").ESLintPluginDocs, TSESLint.RuleListener> & {
|
|
17
|
+
name: string;
|
|
18
|
+
};
|
|
19
|
+
export default _default;
|