xo 0.52.4 → 0.53.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/cli.js +1 -0
- package/node_modules/@types/semver/LICENSE +21 -0
- package/node_modules/@types/semver/README.md +16 -0
- package/node_modules/@types/semver/classes/comparator.d.ts +17 -0
- package/node_modules/@types/semver/classes/range.d.ts +21 -0
- package/node_modules/@types/semver/classes/semver.d.ts +62 -0
- package/node_modules/@types/semver/functions/clean.d.ts +8 -0
- package/node_modules/@types/semver/functions/cmp.d.ts +16 -0
- package/node_modules/@types/semver/functions/coerce.d.ts +12 -0
- package/node_modules/@types/semver/functions/compare-build.d.ts +21 -0
- package/node_modules/@types/semver/functions/compare-loose.d.ts +5 -0
- package/node_modules/@types/semver/functions/compare.d.ts +20 -0
- package/node_modules/@types/semver/functions/diff.d.ts +9 -0
- package/node_modules/@types/semver/functions/eq.d.ts +9 -0
- package/node_modules/@types/semver/functions/gt.d.ts +9 -0
- package/node_modules/@types/semver/functions/gte.d.ts +9 -0
- package/node_modules/@types/semver/functions/inc.d.ts +15 -0
- package/node_modules/@types/semver/functions/lt.d.ts +9 -0
- package/node_modules/@types/semver/functions/lte.d.ts +8 -0
- package/node_modules/@types/semver/functions/major.d.ts +9 -0
- package/node_modules/@types/semver/functions/minor.d.ts +9 -0
- package/node_modules/@types/semver/functions/neq.d.ts +9 -0
- package/node_modules/@types/semver/functions/parse.d.ts +12 -0
- package/node_modules/@types/semver/functions/patch.d.ts +9 -0
- package/node_modules/@types/semver/functions/prerelease.d.ts +12 -0
- package/node_modules/@types/semver/functions/rcompare.d.ts +15 -0
- package/node_modules/@types/semver/functions/rsort.d.ts +9 -0
- package/node_modules/@types/semver/functions/satisfies.d.ts +14 -0
- package/node_modules/@types/semver/functions/sort.d.ts +9 -0
- package/node_modules/@types/semver/functions/valid.d.ts +11 -0
- package/node_modules/@types/semver/index.d.ts +136 -0
- package/node_modules/@types/semver/internals/identifiers.d.ts +13 -0
- package/node_modules/@types/semver/package.json +50 -0
- package/node_modules/@types/semver/preload.d.ts +2 -0
- package/node_modules/@types/semver/ranges/gtr.d.ts +14 -0
- package/node_modules/@types/semver/ranges/intersects.d.ts +13 -0
- package/node_modules/@types/semver/ranges/ltr.d.ts +14 -0
- package/node_modules/@types/semver/ranges/max-satisfying.d.ts +14 -0
- package/node_modules/@types/semver/ranges/min-satisfying.d.ts +14 -0
- package/node_modules/@types/semver/ranges/min-version.d.ts +10 -0
- package/node_modules/@types/semver/ranges/outside.d.ts +15 -0
- package/node_modules/@types/semver/ranges/simplify.d.ts +14 -0
- package/node_modules/@types/semver/ranges/subset.d.ts +9 -0
- package/node_modules/@types/semver/ranges/to-comparators.d.ts +9 -0
- package/node_modules/@types/semver/ranges/valid.d.ts +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js +2 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/all.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js +1 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/configs/strict.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/adjacent-overload-signatures.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/array-type.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/ban-ts-comment.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/comma-spacing.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-indexed-object-style.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js +99 -24
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/consistent-type-imports.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js +4 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/index.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js +2 -2
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-delimiter-style.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js +29 -10
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/member-ordering.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js +4 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/enums.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/schema.js +19 -2
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention-utils/schema.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention.js +29 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/naming-convention.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-base-to-string.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-base-to-string.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-extra-non-null-assertion.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-extra-non-null-assertion.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-extra-parens.js +14 -2
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-extra-parens.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-invalid-void-type.js +11 -5
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-invalid-void-type.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-misused-promises.js +51 -11
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-misused-promises.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-namespace.js +2 -2
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-namespace.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-shadow.js +1 -2
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-shadow.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unnecessary-condition.js +4 -3
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unnecessary-condition.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unsafe-declaration-merging.js +78 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/no-unsafe-declaration-merging.js.map +1 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-nullish-coalescing.js +0 -3
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-nullish-coalescing.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-optional-chain.js +167 -68
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/prefer-optional-chain.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/promise-function-async.js +2 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/promise-function-async.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/restrict-plus-operands.js +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/restrict-plus-operands.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/sort-type-constituents.js +245 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/sort-type-constituents.js.map +1 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/sort-type-union-intersection-members.js +3 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/rules/sort-type-union-intersection-members.js.map +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/TEMPLATE.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/adjacent-overload-signatures.md +5 -5
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/array-type.md +4 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/await-thenable.md +5 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-ts-comment.md +3 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-tslint-comment.md +2 -2
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-types.md +2 -2
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/brace-style.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/class-literal-property-style.md +4 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-dangle.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-spacing.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-generic-constructors.md +3 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-indexed-object-style.md +1 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-assertions.md +12 -5
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-definitions.md +4 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-exports.md +7 -13
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-imports.md +47 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/default-param-last.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/dot-notation.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-function-return-type.md +7 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-member-accessibility.md +10 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-module-boundary-types.md +3 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/func-call-spacing.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/indent.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/init-declarations.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/keyword-spacing.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/lines-between-class-members.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-delimiter-style.md +7 -60
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-ordering.md +19 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/method-signature-style.md +6 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/naming-convention.md +29 -30
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-array-constructor.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-base-to-string.md +12 -11
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md +4 -2
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-void-expression.md +4 -5
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dupe-class-members.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-enum-values.md +5 -2
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dynamic-delete.md +4 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-function.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-interface.md +5 -5
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-explicit-any.md +13 -8
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-non-null-assertion.md +4 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-parens.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-semi.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extraneous-class.md +4 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-floating-promises.md +2 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-for-in-array.md +26 -18
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implicit-any-catch.md +1 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implied-eval.md +1 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-inferrable-types.md +12 -43
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-this.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-void-type.md +6 -13
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loop-func.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loss-of-precision.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-magic-numbers.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-meaningless-void-operator.md +8 -21
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-new.md +13 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-promises.md +53 -91
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-namespace.md +6 -7
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md +3 -13
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md +4 -27
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-assertion.md +14 -13
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-parameter-properties.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redeclare.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redundant-type-constituents.md +1 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-require-imports.md +12 -15
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-restricted-imports.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-shadow.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-this-alias.md +9 -15
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-throw-literal.md +1 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-type-alias.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md +15 -14
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-condition.md +3 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +12 -46
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +22 -8
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +4 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +6 -20
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-argument.md +10 -7
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-assignment.md +9 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-call.md +6 -5
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-declaration-merging.md +54 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-member-access.md +5 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-return.md +9 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-expressions.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-vars.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-use-before-define.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-constructor.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-empty-export.md +4 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-var-requires.md +6 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md +7 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/object-curly-spacing.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/padding-line-between-statements.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/parameter-properties.md +3 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-as-const.md +7 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-enum-initializers.md +5 -23
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-for-of.md +15 -16
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-function-type.md +22 -22
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-includes.md +28 -30
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-literal-enum-member.md +12 -13
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-namespace-keyword.md +27 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +6 -54
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-optional-chain.md +21 -49
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +1 -3
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly.md +3 -5
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +6 -8
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-regexp-exec.md +6 -11
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-return-this-type.md +10 -25
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md +10 -6
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-ts-expect-error.md +5 -11
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/promise-function-async.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/quotes.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-array-sort-compare.md +5 -14
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-await.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-plus-operands.md +18 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-template-expressions.md +9 -2
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/return-await.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/semi.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/sort-type-constituents.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/sort-type-union-intersection-members.md +8 -16
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-blocks.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-function-paren.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/strict-boolean-expressions.md +0 -2
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +15 -24
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/triple-slash-reference.md +4 -2
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/type-annotation-spacing.md +1 -1
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/typedef.md +5 -7
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unbound-method.md +7 -4
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unified-signatures.md +5 -3
- package/node_modules/@typescript-eslint/eslint-plugin/package.json +7 -5
- package/node_modules/@typescript-eslint/parser/README.md +2 -0
- package/node_modules/@typescript-eslint/parser/package.json +5 -5
- package/node_modules/@typescript-eslint/scope-manager/package.json +5 -5
- package/node_modules/@typescript-eslint/type-utils/dist/isTypeReadonly.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/type-utils/dist/isTypeReadonly.js +3 -0
- package/node_modules/@typescript-eslint/type-utils/dist/isTypeReadonly.js.map +1 -1
- package/node_modules/@typescript-eslint/type-utils/package.json +5 -5
- package/node_modules/@typescript-eslint/types/_ts3.4/dist/generated/ast-spec.d.ts +3 -3
- package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts +3 -3
- package/node_modules/@typescript-eslint/types/dist/generated/ast-spec.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/types/package.json +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/ast-converter.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/createDefaultProgram.d.ts +3 -6
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/createIsolatedProgram.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/createProjectProgram.d.ts +4 -6
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/createSourceFile.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/createWatchProgram.d.ts +4 -7
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/shared.d.ts +5 -4
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/create-program/useProvidedPrograms.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parseSettings/createParseSettings.d.ts +4 -0
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parseSettings/index.d.ts +102 -0
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parseSettings/inferSingleRun.d.ts +15 -0
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parseSettings/warnAboutTSVersion.d.ts +3 -0
- package/node_modules/@typescript-eslint/typescript-estree/_ts3.4/dist/parser-options.d.ts +0 -26
- package/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.js +8 -8
- package/node_modules/@typescript-eslint/typescript-estree/dist/ast-converter.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createDefaultProgram.d.ts +3 -6
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createDefaultProgram.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createDefaultProgram.js +13 -15
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createDefaultProgram.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createIsolatedProgram.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createIsolatedProgram.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createIsolatedProgram.js +7 -7
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createIsolatedProgram.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectProgram.d.ts +4 -6
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectProgram.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectProgram.js +51 -38
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createProjectProgram.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createSourceFile.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createSourceFile.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createSourceFile.js +4 -4
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createSourceFile.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.d.ts +4 -7
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.js +21 -22
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/createWatchProgram.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.d.ts +5 -4
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.js +7 -7
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/shared.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/useProvidedPrograms.d.ts +2 -2
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/useProvidedPrograms.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/useProvidedPrograms.js +4 -4
- package/node_modules/@typescript-eslint/typescript-estree/dist/create-program/useProvidedPrograms.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/createParseSettings.d.ts +4 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/createParseSettings.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/createParseSettings.js +145 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/createParseSettings.js.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.d.ts +102 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.js +3 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/index.js.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/inferSingleRun.d.ts +15 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/inferSingleRun.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/inferSingleRun.js +53 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/inferSingleRun.js.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.d.ts +3 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js +68 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parseSettings/warnAboutTSVersion.js.map +1 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser-options.d.ts +0 -26
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser-options.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser.js +32 -388
- package/node_modules/@typescript-eslint/typescript-estree/dist/parser.js.map +1 -1
- package/node_modules/@typescript-eslint/typescript-estree/package.json +5 -5
- package/node_modules/@typescript-eslint/utils/_ts3.4/dist/eslint-utils/batchedSingleLineTests.d.ts +1 -1
- package/node_modules/@typescript-eslint/utils/_ts3.4/dist/eslint-utils/index.d.ts +1 -1
- package/node_modules/@typescript-eslint/utils/_ts3.4/dist/eslint-utils/rule-tester/RuleTester.d.ts +48 -0
- package/node_modules/@typescript-eslint/utils/_ts3.4/dist/eslint-utils/rule-tester/dependencyConstraints.d.ts +17 -0
- package/node_modules/@typescript-eslint/utils/_ts3.4/dist/ts-eslint/RuleTester.d.ts +21 -17
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/batchedSingleLineTests.d.ts +1 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/batchedSingleLineTests.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/batchedSingleLineTests.js.map +1 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.d.ts +1 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js +1 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/index.js.map +1 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/RuleTester.d.ts +49 -0
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/RuleTester.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/RuleTester.js +238 -0
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/RuleTester.js.map +1 -0
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/dependencyConstraints.d.ts +17 -0
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/dependencyConstraints.d.ts.map +1 -0
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/dependencyConstraints.js +52 -0
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/rule-tester/dependencyConstraints.js.map +1 -0
- package/node_modules/@typescript-eslint/utils/dist/ts-eslint/RuleTester.d.ts +16 -9
- package/node_modules/@typescript-eslint/utils/dist/ts-eslint/RuleTester.d.ts.map +1 -1
- package/node_modules/@typescript-eslint/utils/dist/ts-eslint/RuleTester.js.map +1 -1
- package/node_modules/@typescript-eslint/utils/package.json +9 -6
- package/node_modules/@typescript-eslint/visitor-keys/package.json +3 -3
- package/node_modules/eslint-config-xo-typescript/index.js +7 -1
- package/node_modules/eslint-config-xo-typescript/package.json +5 -5
- package/node_modules/natural-compare-lite/README.md +126 -0
- package/node_modules/natural-compare-lite/index.js +57 -0
- package/node_modules/natural-compare-lite/package.json +42 -0
- package/node_modules/semver/classes/range.js +3 -0
- package/node_modules/semver/index.js +81 -41
- package/node_modules/{lru-cache → semver/node_modules/lru-cache}/LICENSE +0 -0
- package/node_modules/{lru-cache → semver/node_modules/lru-cache}/README.md +0 -0
- package/node_modules/{lru-cache → semver/node_modules/lru-cache}/index.js +0 -0
- package/node_modules/{lru-cache → semver/node_modules/lru-cache}/package.json +0 -0
- package/node_modules/semver/package.json +21 -10
- package/package.json +24 -24
- package/readme.md +1 -1
- package/node_modules/@typescript-eslint/utils/_ts3.4/dist/eslint-utils/RuleTester.d.ts +0 -18
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleTester.d.ts +0 -18
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleTester.d.ts.map +0 -1
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleTester.js +0 -133
- package/node_modules/@typescript-eslint/utils/dist/eslint-utils/RuleTester.js.map +0 -1
package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-nullish-coalescing.md
CHANGED
|
@@ -6,65 +6,17 @@ description: 'Enforce using the nullish coalescing operator instead of logical c
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/prefer-nullish-coalescing** for documentation.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
The `??` nullish coalescing runtime operator allows providing a default value when dealing with `null` or `undefined`.
|
|
10
|
+
Because the nullish coalescing operator _only_ coalesces when the original value is `null` or `undefined`, it is much safer than relying upon logical OR operator chaining `||`, which coalesces on any _falsy_ value.
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
function myFunc(foo: string | null) {
|
|
14
|
-
return foo ?? 'a string';
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// is equivalent to
|
|
18
|
-
|
|
19
|
-
function myFunc(foo: string | null) {
|
|
20
|
-
return foo !== null && foo !== undefined ? foo : 'a string';
|
|
21
|
-
}
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Because the nullish coalescing operator _only_ coalesces when the original value is `null` or `undefined`, it is much safer than relying upon logical OR operator chaining `||`; which coalesces on any _falsy_ value:
|
|
25
|
-
|
|
26
|
-
```ts
|
|
27
|
-
const emptyString = '';
|
|
28
|
-
|
|
29
|
-
const nullish1 = emptyString ?? 'unsafe';
|
|
30
|
-
const logical1 = emptyString || 'unsafe';
|
|
12
|
+
This rule reports when an `||` operator can be safely replaced with a `??`.
|
|
31
13
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
declare const nullString: string | null;
|
|
36
|
-
|
|
37
|
-
const nullish2 = nullString ?? 'safe';
|
|
38
|
-
const logical2 = nullString || 'safe';
|
|
39
|
-
|
|
40
|
-
// nullish2 === 'safe'
|
|
41
|
-
// logical2 === 'safe'
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
## Rule Details
|
|
45
|
-
|
|
46
|
-
This rule aims enforce the usage of the safer operator.
|
|
14
|
+
:::caution
|
|
15
|
+
This rule will not work as expected if [`strictNullChecks`](https://www.typescriptlang.org/tsconfig#strictNullChecks) is not enabled.
|
|
16
|
+
:::
|
|
47
17
|
|
|
48
18
|
## Options
|
|
49
19
|
|
|
50
|
-
```ts
|
|
51
|
-
type Options = [
|
|
52
|
-
{
|
|
53
|
-
ignoreTernaryTests?: boolean;
|
|
54
|
-
ignoreConditionalTests?: boolean;
|
|
55
|
-
ignoreMixedLogicalExpressions?: boolean;
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
|
|
59
|
-
const defaultOptions = [
|
|
60
|
-
{
|
|
61
|
-
ignoreTernaryTests: true;
|
|
62
|
-
ignoreConditionalTests: true,
|
|
63
|
-
ignoreMixedLogicalExpressions: true,
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
```
|
|
67
|
-
|
|
68
20
|
### `ignoreTernaryTests`
|
|
69
21
|
|
|
70
22
|
Setting this option to `true` (the default) will cause the rule to ignore any ternary expressions that could be simplified by using the nullish coalescing operator.
|
|
@@ -1,60 +1,18 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 'Enforce using concise optional chain expressions instead of chained logical ands.'
|
|
2
|
+
description: 'Enforce using concise optional chain expressions instead of chained logical ands, negated logical ors, or empty objects.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/prefer-optional-chain** for documentation.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
This operator allows you to safely access properties and methods on objects when they are potentially `null` or `undefined`.
|
|
11
|
-
|
|
12
|
-
```ts
|
|
13
|
-
type T = {
|
|
14
|
-
a?: {
|
|
15
|
-
b?: {
|
|
16
|
-
c: string;
|
|
17
|
-
method?: () => void;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function myFunc(foo: T | null) {
|
|
23
|
-
return foo?.a?.b?.c;
|
|
24
|
-
}
|
|
25
|
-
// is roughly equivalent to
|
|
26
|
-
function myFunc(foo: T | null) {
|
|
27
|
-
return foo && foo.a && foo.a.b && foo.a.b.c;
|
|
28
|
-
}
|
|
29
|
-
// or
|
|
30
|
-
function myFunc(foo: T | null) {
|
|
31
|
-
return (((foo || {}).a || {}).b || {}).c;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function myFunc(foo: T | null) {
|
|
35
|
-
return foo?.['a']?.b?.c;
|
|
36
|
-
}
|
|
37
|
-
// is roughly equivalent to
|
|
38
|
-
function myFunc(foo: T | null) {
|
|
39
|
-
return foo && foo['a'] && foo['a'].b && foo['a'].b.c;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function myFunc(foo: T | null) {
|
|
43
|
-
return foo?.a?.b?.method?.();
|
|
44
|
-
}
|
|
45
|
-
// is roughly equivalent to
|
|
46
|
-
function myFunc(foo: T | null) {
|
|
47
|
-
return foo && foo.a && foo.a.b && foo.a.b.method && foo.a.b.method();
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
9
|
+
`?.` optional chain expressions provide `undefined` if an object is `null` or `undefined`.
|
|
51
10
|
Because the optional chain operator _only_ chains when the property value is `null` or `undefined`, it is much safer than relying upon logical AND operator chaining `&&`; which chains on any _truthy_ value.
|
|
11
|
+
It is also often less code to use `?.` optional chaining than `&&` truthiness checks.
|
|
52
12
|
|
|
53
|
-
|
|
13
|
+
This rule reports on code where an `&&` operator can be safely replaced with `?.` optional chaining.
|
|
54
14
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
Examples of code for this rule:
|
|
15
|
+
## Examples
|
|
58
16
|
|
|
59
17
|
<!--tabs-->
|
|
60
18
|
|
|
@@ -65,9 +23,15 @@ foo && foo.a && foo.a.b && foo.a.b.c;
|
|
|
65
23
|
foo && foo['a'] && foo['a'].b && foo['a'].b.c;
|
|
66
24
|
foo && foo.a && foo.a.b && foo.a.b.method && foo.a.b.method();
|
|
67
25
|
|
|
26
|
+
// With empty objects
|
|
68
27
|
(((foo || {}).a || {}).b || {}).c;
|
|
69
28
|
(((foo || {})['a'] || {}).b || {}).c;
|
|
70
29
|
|
|
30
|
+
// With negated `or`s
|
|
31
|
+
!foo || !foo.bar;
|
|
32
|
+
!foo || !foo[bar];
|
|
33
|
+
!foo || !foo.bar || !foo.bar.baz || !foo.bar.baz();
|
|
34
|
+
|
|
71
35
|
// this rule also supports converting chained strict nullish checks:
|
|
72
36
|
foo &&
|
|
73
37
|
foo.a != null &&
|
|
@@ -85,13 +49,21 @@ foo?.['a']?.b?.c;
|
|
|
85
49
|
foo?.a?.b?.method?.();
|
|
86
50
|
|
|
87
51
|
foo?.a?.b?.c?.d?.e;
|
|
52
|
+
|
|
53
|
+
!foo?.bar;
|
|
54
|
+
!foo?.[bar];
|
|
55
|
+
!foo?.bar?.baz?.();
|
|
88
56
|
```
|
|
89
57
|
|
|
90
|
-
|
|
58
|
+
<!--/tabs-->
|
|
59
|
+
|
|
60
|
+
:::note
|
|
61
|
+
There are a few edge cases where this rule will false positive. Use your best judgement when evaluating reported errors.
|
|
62
|
+
:::
|
|
91
63
|
|
|
92
64
|
## When Not To Use It
|
|
93
65
|
|
|
94
|
-
If you
|
|
66
|
+
If you don't mind using more explicit `&&`s, you don't need this rule.
|
|
95
67
|
|
|
96
68
|
## Further Reading
|
|
97
69
|
|
package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md
CHANGED
|
@@ -10,8 +10,6 @@ Mutating function arguments can lead to confusing, hard to debug behavior.
|
|
|
10
10
|
Whilst it's easy to implicitly remember to not modify function arguments, explicitly typing arguments as readonly provides clear contract to consumers.
|
|
11
11
|
This contract makes it easier for a consumer to reason about if a function has side-effects.
|
|
12
12
|
|
|
13
|
-
## Rule Details
|
|
14
|
-
|
|
15
13
|
This rule allows you to enforce that function parameters resolve to readonly types.
|
|
16
14
|
A type is considered readonly if:
|
|
17
15
|
|
|
@@ -21,7 +19,7 @@ A type is considered readonly if:
|
|
|
21
19
|
- it is a readonly tuple type whose elements are all considered readonly.
|
|
22
20
|
- it is an object type whose properties are all marked as readonly, and whose values are all considered readonly.
|
|
23
21
|
|
|
24
|
-
Examples
|
|
22
|
+
## Examples
|
|
25
23
|
|
|
26
24
|
<!--tabs-->
|
|
27
25
|
|
|
@@ -6,14 +6,12 @@ description: "Require private members to be marked as `readonly` if they're neve
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/prefer-readonly** for documentation.
|
|
8
8
|
|
|
9
|
-
This rule enforces that private members are marked as `readonly` if they're never modified outside of the constructor.
|
|
10
|
-
|
|
11
|
-
## Rule Details
|
|
12
|
-
|
|
13
9
|
Member variables with the privacy `private` are never permitted to be modified outside of their declaring class.
|
|
14
10
|
If that class never modifies their value, they may safely be marked as `readonly`.
|
|
15
11
|
|
|
16
|
-
|
|
12
|
+
This rule reports on private members are marked as `readonly` if they're never modified outside of the constructor.
|
|
13
|
+
|
|
14
|
+
## Examples
|
|
17
15
|
|
|
18
16
|
<!--tabs-->
|
|
19
17
|
|
package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md
CHANGED
|
@@ -12,18 +12,16 @@ Since these values are empty, their types are not usable:
|
|
|
12
12
|
- `[]` has type `never[]`, which can't have items pushed into it as nothing is type `never`
|
|
13
13
|
- `{}` has type `{}`, which doesn't have an index signature and so can't have properties added to it
|
|
14
14
|
|
|
15
|
-
A common solution to this problem is to
|
|
16
|
-
solution as
|
|
15
|
+
A common solution to this problem is to use an `as` assertion on the initial value.
|
|
16
|
+
While this will work, it's not the most optimal solution as type assertions have subtle effects on the underlying types that can allow bugs to slip in.
|
|
17
17
|
|
|
18
|
-
A better
|
|
18
|
+
A better solution is to pass the type in as a generic type argument to `Array#reduce` explicitly.
|
|
19
19
|
This means that TypeScript doesn't have to try to infer the type, and avoids the common pitfalls that come with casting.
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
This rule looks for calls to `Array#reduce`, and reports if an initial value is being passed & asserted.
|
|
22
|
+
It will suggest instead pass the asserted type to `Array#reduce` as a generic type argument.
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
suggesting instead to pass the cast type to `Array#reduce` as its generic parameter.
|
|
25
|
-
|
|
26
|
-
Examples of code for this rule:
|
|
24
|
+
## Examples
|
|
27
25
|
|
|
28
26
|
<!--tabs-->
|
|
29
27
|
|
|
@@ -6,19 +6,14 @@ description: 'Enforce `RegExp#exec` over `String#match` if no global flag is pro
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/prefer-regexp-exec** for documentation.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
`String#match` is defined to work the same as `RegExp#exec` when the regular expression does not include the `g` flag.
|
|
10
|
+
Keeping to consistently using one of the two can help improve code readability.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
This rule reports when a `String#match` call can be replaced with an equivalent `RegExp#exec`.
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
> `RegExp#exec` may also be slightly faster than `String#match`; this is the reason to choose it as the preferred usage.
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
> If the regular expression does not include the g flag, returns the same result as `RegExp.exec()`.
|
|
18
|
-
|
|
19
|
-
`RegExp#exec` may also be slightly faster than `String#match`; this is the reason to choose it as the preferred usage.
|
|
20
|
-
|
|
21
|
-
Examples of code for this rule:
|
|
16
|
+
## Examples
|
|
22
17
|
|
|
23
18
|
<!--tabs-->
|
|
24
19
|
|
|
@@ -48,4 +43,4 @@ search.exec(text);
|
|
|
48
43
|
|
|
49
44
|
## When Not To Use It
|
|
50
45
|
|
|
51
|
-
If you prefer consistent use of `String#match` for both
|
|
46
|
+
If you prefer consistent use of `String#match` for both with `g` flag and without it, you can turn this rule off.
|
|
@@ -6,12 +6,17 @@ description: 'Enforce that `this` is used when only `this` type is returned.'
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/prefer-return-this-type** for documentation.
|
|
8
8
|
|
|
9
|
-
[Method chaining](https://en.wikipedia.org/wiki/Method_chaining) is a common pattern in OOP languages and TypeScript provides a special [polymorphic this type](https://www.typescriptlang.org/docs/handbook/2/classes.html#this-types).
|
|
10
|
-
|
|
9
|
+
[Method chaining](https://en.wikipedia.org/wiki/Method_chaining) is a common pattern in OOP languages and TypeScript provides a special [polymorphic `this` type](https://www.typescriptlang.org/docs/handbook/2/classes.html#this-types) to facilitate it.
|
|
10
|
+
Class methods that explicitly declare a return type of the class name instead of `this` make it harder for extending classes to call that method: the returned object will be typed as the base class, not the derived class.
|
|
11
|
+
|
|
12
|
+
This rule reports when a class method declares a return type of that class name instead of `this`.
|
|
11
13
|
|
|
12
14
|
```ts
|
|
13
15
|
class Animal {
|
|
14
16
|
eat(): Animal {
|
|
17
|
+
// ~~~~~~
|
|
18
|
+
// Either removing this type annotation or replacing
|
|
19
|
+
// it with `this` would remove the type error below.
|
|
15
20
|
console.log("I'm moving!");
|
|
16
21
|
return this;
|
|
17
22
|
}
|
|
@@ -25,33 +30,13 @@ class Cat extends Animal {
|
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
const cat = new Cat();
|
|
33
|
+
cat.eat().meow();
|
|
34
|
+
// ~~~~
|
|
28
35
|
// Error: Property 'meow' does not exist on type 'Animal'.
|
|
29
36
|
// because `eat` returns `Animal` and not all animals meow.
|
|
30
|
-
cat.eat().meow();
|
|
31
|
-
|
|
32
|
-
// the error can be fixed by removing the return type of `eat` or use `this` as the return type.
|
|
33
|
-
class Animal {
|
|
34
|
-
eat(): this {
|
|
35
|
-
console.log("I'm moving!");
|
|
36
|
-
return this;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class Cat extends Animal {
|
|
41
|
-
meow(): this {
|
|
42
|
-
console.log('Meow~');
|
|
43
|
-
return this;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const cat = new Cat();
|
|
48
|
-
// no errors. Because `eat` returns `Cat` now
|
|
49
|
-
cat.eat().meow();
|
|
50
37
|
```
|
|
51
38
|
|
|
52
|
-
##
|
|
53
|
-
|
|
54
|
-
Examples of code for this rule:
|
|
39
|
+
## Examples
|
|
55
40
|
|
|
56
41
|
<!--tabs-->
|
|
57
42
|
|
package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md
CHANGED
|
@@ -7,20 +7,19 @@ description: 'Enforce using `String#startsWith` and `String#endsWith` over other
|
|
|
7
7
|
> See **https://typescript-eslint.io/rules/prefer-string-starts-ends-with** for documentation.
|
|
8
8
|
|
|
9
9
|
There are multiple ways to verify if a string starts or ends with a specific string, such as `foo.indexOf('bar') === 0`.
|
|
10
|
-
|
|
10
|
+
As of ES2015, the most common way in JavaScript is to use `String#startsWith` and `String#endsWith`.
|
|
11
|
+
Keeping to those methods consistently helps with code readability.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
This rule reports when a string method can be replaced safely with `String#startsWith` or `String#endsWith`.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Examples of code for this rule:
|
|
15
|
+
## Examples
|
|
17
16
|
|
|
18
17
|
<!--tabs-->
|
|
19
18
|
|
|
20
19
|
### ❌ Incorrect
|
|
21
20
|
|
|
22
21
|
```ts
|
|
23
|
-
|
|
22
|
+
declare const foo: string;
|
|
24
23
|
|
|
25
24
|
// starts with
|
|
26
25
|
foo[0] === 'b';
|
|
@@ -44,7 +43,12 @@ foo.match(/bar$/) != null;
|
|
|
44
43
|
### ✅ Correct
|
|
45
44
|
|
|
46
45
|
```ts
|
|
46
|
+
declare const foo: string;
|
|
47
|
+
|
|
48
|
+
// starts with
|
|
47
49
|
foo.startsWith('bar');
|
|
50
|
+
|
|
51
|
+
// ends with
|
|
48
52
|
foo.endsWith('bar');
|
|
49
53
|
```
|
|
50
54
|
|
|
@@ -6,21 +6,15 @@ description: 'Enforce using `@ts-expect-error` over `@ts-ignore`.'
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/prefer-ts-expect-error** for documentation.
|
|
8
8
|
|
|
9
|
-
TypeScript allows you to suppress all errors on a line by placing a
|
|
10
|
-
|
|
9
|
+
TypeScript allows you to suppress all errors on a line by placing a comment starting with `@ts-ignore` or `@ts-expect-error` immediately before the erroring line.
|
|
10
|
+
The two directives work the same, except `@ts-expect-error` causes a type error if placed before a line that's not erroring in the first place.
|
|
11
11
|
|
|
12
12
|
This means its easy for `@ts-ignore`s to be forgotten about, and remain in code even after the error they were suppressing is fixed.
|
|
13
13
|
This is dangerous, as if a new error arises on that line it'll be suppressed by the forgotten about `@ts-ignore`, and so be missed.
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
## Examples
|
|
16
16
|
|
|
17
|
-
This
|
|
18
|
-
|
|
19
|
-
## Rule Details
|
|
20
|
-
|
|
21
|
-
This rule looks for usages of `@ts-ignore`, and flags them to be replaced with `@ts-expect-error`.
|
|
22
|
-
|
|
23
|
-
Examples of code for this rule:
|
|
17
|
+
This rule reports any usage of `@ts-ignore`, including a fixer to replace with `@ts-expect-error`.
|
|
24
18
|
|
|
25
19
|
<!--tabs-->
|
|
26
20
|
|
|
@@ -68,7 +62,7 @@ const isOptionEnabled = (key: string): boolean => {
|
|
|
68
62
|
|
|
69
63
|
## When Not To Use It
|
|
70
64
|
|
|
71
|
-
If you are
|
|
65
|
+
If you are compiling against multiple versions of TypeScript and using `@ts-ignore` to ignore version-specific type errors, this rule might get in your way.
|
|
72
66
|
|
|
73
67
|
## Further Reading
|
|
74
68
|
|
|
@@ -15,7 +15,7 @@ In contrast, non-`async` `Promise` - returning functions are technically capable
|
|
|
15
15
|
Code that handles the results of those functions will often need to handle both cases, which can get complex.
|
|
16
16
|
This rule's practice removes a requirement for creating code to handle both cases.
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Examples
|
|
19
19
|
|
|
20
20
|
Examples of code for this rule
|
|
21
21
|
|
|
@@ -6,7 +6,7 @@ description: 'Enforce the consistent use of either backticks, double, or single
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/quotes** for documentation.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Examples
|
|
10
10
|
|
|
11
11
|
This rule extends the base [`eslint/quotes`](https://eslint.org/docs/rules/quotes) rule.
|
|
12
12
|
It adds support for TypeScript features which allow quoted names, but not backtick quoted names.
|
package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-array-sort-compare.md
CHANGED
|
@@ -6,30 +6,21 @@ description: 'Require `Array#sort` calls to always provide a `compareFunction`.'
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/require-array-sort-compare** for documentation.
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
When called without a compare function, `Array#sort()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units.
|
|
9
|
+
When called without a compare function, `Array#sort()` converts all non-undefined array elements into strings and then compares said strings based off their UTF-16 code units [[ECMA specification](https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare)].
|
|
11
10
|
|
|
12
11
|
The result is that elements are sorted alphabetically, regardless of their type.
|
|
13
|
-
|
|
12
|
+
For example, when sorting numbers, this results in a "10 before 2" order:
|
|
14
13
|
|
|
15
14
|
```ts
|
|
16
15
|
[1, 2, 3, 10, 20, 30].sort(); //→ [1, 10, 2, 20, 3, 30]
|
|
17
16
|
```
|
|
18
17
|
|
|
19
|
-
This
|
|
18
|
+
This rule reports on any call to the `Array#sort()` method that doesn't provide a `compare` argument.
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
Method calls performed by the `ToString` abstract operations in steps 5 and 7 have the potential to cause `SortCompare` to not behave as a consistent comparison function.
|
|
23
|
-
|
|
24
|
-
https://www.ecma-international.org/ecma-262/9.0/#sec-sortcompare
|
|
25
|
-
:::
|
|
26
|
-
|
|
27
|
-
## Rule Details
|
|
20
|
+
## Examples
|
|
28
21
|
|
|
29
22
|
This rule aims to ensure all calls of the native `Array#sort` method provide a `compareFunction`, while ignoring calls to user-defined `sort` methods.
|
|
30
23
|
|
|
31
|
-
Examples of code for this rule:
|
|
32
|
-
|
|
33
24
|
<!--tabs-->
|
|
34
25
|
|
|
35
26
|
### ❌ Incorrect
|
|
@@ -84,4 +75,4 @@ const three = '3';
|
|
|
84
75
|
|
|
85
76
|
## When Not To Use It
|
|
86
77
|
|
|
87
|
-
If you understand the language specification enough, you can turn this rule off safely.
|
|
78
|
+
If you understand the language specification enough, and/or only ever sort arrays in a string-like manner, you can turn this rule off safely.
|
|
@@ -6,7 +6,7 @@ description: 'Disallow async functions which have no `await` expression.'
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/require-await** for documentation.
|
|
8
8
|
|
|
9
|
-
##
|
|
9
|
+
## Examples
|
|
10
10
|
|
|
11
11
|
This rule extends the base [`eslint/require-await`](https://eslint.org/docs/rules/require-await) rule.
|
|
12
12
|
It uses type information to add support for `async` functions that return a `Promise`.
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
---
|
|
2
|
-
description: 'Require both operands of addition to
|
|
2
|
+
description: 'Require both operands of addition to be the same type and be `bigint`, `number`, or `string`.'
|
|
3
3
|
---
|
|
4
4
|
|
|
5
5
|
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/restrict-plus-operands** for documentation.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
TypeScript allows `+` adding together two values of any type(s).
|
|
10
|
+
However, adding values that are not the same type and/or are not the same primitive type is often a sign of programmer error.
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
This rule reports when a `+` operation combines two values of different types, or a type that is not `bigint`, `number`, or `string`.
|
|
13
|
+
|
|
14
|
+
## Examples
|
|
12
15
|
|
|
13
16
|
<!--tabs-->
|
|
14
17
|
|
|
@@ -81,4 +84,15 @@ var fn = (a: any, b: bigint) => a + b;
|
|
|
81
84
|
var fn = (a: any, b: number) => a + b;
|
|
82
85
|
```
|
|
83
86
|
|
|
84
|
-
##
|
|
87
|
+
## When Not To Use It
|
|
88
|
+
|
|
89
|
+
If you don't mind `"[object Object]"` in your strings, then you will not need this rule.
|
|
90
|
+
|
|
91
|
+
## Related To
|
|
92
|
+
|
|
93
|
+
- [`no-base-to-string`](./no-base-to-string.md)
|
|
94
|
+
- [`restrict-template-expressions`](./restrict-template-expressions.md)
|
|
95
|
+
|
|
96
|
+
## Further Reading
|
|
97
|
+
|
|
98
|
+
- [`Object.prototype.toString()` MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/toString)
|
package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-template-expressions.md
CHANGED
|
@@ -6,9 +6,11 @@ description: 'Enforce template literal expressions to be of `string` type.'
|
|
|
6
6
|
>
|
|
7
7
|
> See **https://typescript-eslint.io/rules/restrict-template-expressions** for documentation.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
JavaScript will call `toString()` on an object when it is converted to a string, such as when `+` adding to a string or in `${}` template literals.
|
|
10
|
+
The default Object `.toString()` returns `"[object Object]"`, which is often not what was intended.
|
|
11
|
+
This rule reports on values used in a template literal string that aren't primitives and don't define a more useful `.toString()` method.
|
|
10
12
|
|
|
11
|
-
Examples
|
|
13
|
+
## Examples
|
|
12
14
|
|
|
13
15
|
<!--tabs-->
|
|
14
16
|
|
|
@@ -87,3 +89,8 @@ const msg1 = `arg = ${arg}`;
|
|
|
87
89
|
const arg = /foo/;
|
|
88
90
|
const msg1 = `arg = ${arg}`;
|
|
89
91
|
```
|
|
92
|
+
|
|
93
|
+
## Related To
|
|
94
|
+
|
|
95
|
+
- [`no-base-to-string`](./no-base-to-string.md)
|
|
96
|
+
- [`restrict-plus-operands`](./restrict-plus-operands.md)
|
|
@@ -8,7 +8,7 @@ description: 'Enforce consistent returning of awaited values.'
|
|
|
8
8
|
|
|
9
9
|
Returning an awaited promise can make sense for better stack trace information as well as for consistent error handling (returned promises will not be caught in an async function try/catch).
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Examples
|
|
12
12
|
|
|
13
13
|
This rule builds on top of the [`eslint/no-return-await`](https://eslint.org/docs/rules/no-return-await) rule.
|
|
14
14
|
It expands upon the base rule to add support for optionally requiring `return await` in certain cases.
|
|
@@ -8,7 +8,7 @@ description: 'Require or disallow semicolons instead of ASI.'
|
|
|
8
8
|
|
|
9
9
|
This rule enforces consistent use of semicolons after statements.
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Examples
|
|
12
12
|
|
|
13
13
|
This rule extends the base [`eslint/semi`](https://eslint.org/docs/rules/semi) rule.
|
|
14
14
|
It adds support for TypeScript features that require semicolons.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Enforce constituents of a type union/intersection to be sorted alphabetically.'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
|
+
>
|
|
7
|
+
> See **https://typescript-eslint.io/rules/sort-type-constituents** for documentation.
|
|
8
|
+
|
|
9
|
+
Sorting union (`|`) and intersection (`&`) types can help:
|
|
10
|
+
|
|
11
|
+
- keep your codebase standardized
|
|
12
|
+
- find repeated types
|
|
13
|
+
- reduce diff churn
|
|
14
|
+
|
|
15
|
+
This rule reports on any types that aren't sorted alphabetically.
|
|
16
|
+
|
|
17
|
+
> Types are sorted case-insensitively and treating numbers like a human would, falling back to character code sorting in case of ties.
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
<!--tabs-->
|
|
22
|
+
|
|
23
|
+
### ❌ Incorrect
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
type T1 = B | A;
|
|
27
|
+
|
|
28
|
+
type T2 = { b: string } & { a: string };
|
|
29
|
+
|
|
30
|
+
type T3 = [1, 2, 4] & [1, 2, 3];
|
|
31
|
+
|
|
32
|
+
type T4 =
|
|
33
|
+
| [1, 2, 4]
|
|
34
|
+
| [1, 2, 3]
|
|
35
|
+
| { b: string }
|
|
36
|
+
| { a: string }
|
|
37
|
+
| (() => void)
|
|
38
|
+
| (() => string)
|
|
39
|
+
| 'b'
|
|
40
|
+
| 'a'
|
|
41
|
+
| 'b'
|
|
42
|
+
| 'a'
|
|
43
|
+
| readonly string[]
|
|
44
|
+
| readonly number[]
|
|
45
|
+
| string[]
|
|
46
|
+
| number[]
|
|
47
|
+
| B
|
|
48
|
+
| A
|
|
49
|
+
| string
|
|
50
|
+
| any;
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### ✅ Correct
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
type T1 = A | B;
|
|
57
|
+
|
|
58
|
+
type T2 = { a: string } & { b: string };
|
|
59
|
+
|
|
60
|
+
type T3 = [1, 2, 3] & [1, 2, 4];
|
|
61
|
+
|
|
62
|
+
type T4 =
|
|
63
|
+
| any
|
|
64
|
+
| string
|
|
65
|
+
| A
|
|
66
|
+
| B
|
|
67
|
+
| number[]
|
|
68
|
+
| string[]
|
|
69
|
+
| readonly number[]
|
|
70
|
+
| readonly string[]
|
|
71
|
+
| 'a'
|
|
72
|
+
| 'b'
|
|
73
|
+
| 'a'
|
|
74
|
+
| 'b'
|
|
75
|
+
| (() => string)
|
|
76
|
+
| (() => void)
|
|
77
|
+
| { a: string }
|
|
78
|
+
| { b: string }
|
|
79
|
+
| [1, 2, 3]
|
|
80
|
+
| [1, 2, 4];
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Options
|
|
84
|
+
|
|
85
|
+
### `groupOrder`
|
|
86
|
+
|
|
87
|
+
Each constituent of the type is placed into a group, and then the rule sorts alphabetically within each group.
|
|
88
|
+
The ordering of groups is determined by this option.
|
|
89
|
+
|
|
90
|
+
- `conditional` - Conditional types (`A extends B ? C : D`)
|
|
91
|
+
- `function` - Function and constructor types (`() => void`, `new () => type`)
|
|
92
|
+
- `import` - Import types (`import('path')`)
|
|
93
|
+
- `intersection` - Intersection types (`A & B`)
|
|
94
|
+
- `keyword` - Keyword types (`any`, `string`, etc)
|
|
95
|
+
- `literal` - Literal types (`1`, `'b'`, `true`, etc)
|
|
96
|
+
- `named` - Named types (`A`, `A['prop']`, `B[]`, `Array<C>`)
|
|
97
|
+
- `object` - Object types (`{ a: string }`, `{ [key: string]: number }`)
|
|
98
|
+
- `operator` - Operator types (`keyof A`, `typeof B`, `readonly C[]`)
|
|
99
|
+
- `tuple` - Tuple types (`[A, B, C]`)
|
|
100
|
+
- `union` - Union types (`A | B`)
|
|
101
|
+
- `nullish` - `null` and `undefined`
|