immosquare-cleaner 0.1.32 → 0.1.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/immosquare-cleaner/version.rb +1 -1
- data/node_modules/@eslint/eslintrc/README.md +15 -4
- data/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +57 -18
- data/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +1 -1
- data/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +60 -34
- data/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +1 -1
- data/node_modules/@eslint/eslintrc/lib/config-array/config-array.js +3 -16
- data/node_modules/@eslint/eslintrc/lib/shared/config-validator.js +63 -18
- data/node_modules/@eslint/eslintrc/package.json +4 -4
- data/node_modules/@eslint/js/package.json +2 -2
- data/node_modules/@eslint/js/src/configs/eslint-all.js +9 -1
- data/node_modules/@eslint/js/src/configs/eslint-recommended.js +12 -5
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/LICENSE +201 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/README.md +105 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.cjs +384 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/eslint-visitor-keys.d.cts +27 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/index.d.ts +16 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/dist/visitor-keys.d.ts +12 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/index.js +65 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/lib/visitor-keys.js +315 -0
- data/node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys/package.json +74 -0
- data/node_modules/@humanwhocodes/config-array/api.js +114 -16
- data/node_modules/@humanwhocodes/config-array/package.json +5 -3
- data/node_modules/@humanwhocodes/object-schema/CHANGELOG.md +7 -0
- data/node_modules/@humanwhocodes/object-schema/package.json +6 -1
- data/node_modules/@humanwhocodes/retry/LICENSE +201 -0
- data/node_modules/@humanwhocodes/retry/README.md +122 -0
- data/node_modules/@humanwhocodes/retry/dist/retrier.cjs +267 -0
- data/node_modules/@humanwhocodes/retry/dist/retrier.d.ts +24 -0
- data/node_modules/@humanwhocodes/retry/dist/retrier.js +265 -0
- data/node_modules/@humanwhocodes/retry/dist/retrier.min.js +1 -0
- data/node_modules/@humanwhocodes/retry/dist/retrier.mjs +265 -0
- data/node_modules/@humanwhocodes/retry/package.json +74 -0
- data/node_modules/@types/semver-utils/LICENSE +21 -0
- data/node_modules/@types/semver-utils/README.md +34 -0
- data/node_modules/@types/semver-utils/index.d.ts +15 -0
- data/node_modules/@types/semver-utils/package.json +25 -0
- data/node_modules/acorn/CHANGELOG.md +36 -0
- data/node_modules/acorn/README.md +8 -3
- data/node_modules/acorn/dist/acorn.d.mts +857 -26
- data/node_modules/acorn/dist/acorn.d.ts +833 -268
- data/node_modules/acorn/dist/acorn.js +33 -21
- data/node_modules/acorn/dist/acorn.mjs +33 -21
- data/node_modules/acorn/package.json +1 -1
- data/node_modules/cacheable-request/node_modules/keyv/README.md +429 -0
- data/node_modules/cacheable-request/node_modules/keyv/package.json +57 -0
- data/node_modules/cacheable-request/node_modules/keyv/src/index.d.ts +112 -0
- data/node_modules/cacheable-request/node_modules/keyv/src/index.js +264 -0
- data/node_modules/doctrine/CHANGELOG.md +0 -7
- data/node_modules/doctrine/lib/doctrine.js +1 -0
- data/node_modules/doctrine/package.json +8 -9
- data/node_modules/eslint/README.md +31 -28
- data/node_modules/eslint/bin/eslint.js +4 -3
- data/node_modules/eslint/conf/ecma-version.js +16 -0
- data/node_modules/eslint/conf/globals.js +1 -0
- data/node_modules/eslint/conf/rule-type-list.json +3 -1
- data/node_modules/eslint/lib/api.js +7 -11
- data/node_modules/eslint/lib/cli-engine/cli-engine.js +14 -3
- data/node_modules/eslint/lib/cli-engine/formatters/formatters-meta.json +1 -29
- data/node_modules/eslint/lib/cli-engine/lint-result-cache.js +2 -2
- data/node_modules/eslint/lib/cli.js +115 -36
- data/node_modules/eslint/lib/config/default-config.js +3 -0
- data/node_modules/eslint/lib/config/flat-config-array.js +110 -24
- data/node_modules/eslint/lib/config/flat-config-helpers.js +41 -20
- data/node_modules/eslint/lib/config/flat-config-schema.js +1 -7
- data/node_modules/eslint/lib/config/rule-validator.js +42 -6
- data/node_modules/eslint/lib/eslint/eslint-helpers.js +116 -58
- data/node_modules/eslint/lib/eslint/eslint.js +892 -377
- data/node_modules/eslint/lib/eslint/index.js +2 -2
- data/node_modules/eslint/lib/eslint/legacy-eslint.js +728 -0
- data/node_modules/eslint/lib/linter/apply-disable-directives.js +59 -31
- data/node_modules/eslint/lib/linter/code-path-analysis/code-path-analyzer.js +0 -1
- data/node_modules/eslint/lib/linter/code-path-analysis/code-path.js +32 -30
- data/node_modules/eslint/lib/linter/code-path-analysis/fork-context.js +1 -1
- data/node_modules/eslint/lib/linter/config-comment-parser.js +8 -11
- data/node_modules/eslint/lib/linter/index.js +1 -3
- data/node_modules/eslint/lib/linter/interpolate.js +24 -2
- data/node_modules/eslint/lib/linter/linter.js +428 -207
- data/node_modules/eslint/lib/linter/report-translator.js +3 -3
- data/node_modules/eslint/lib/linter/rules.js +6 -15
- data/node_modules/eslint/lib/linter/source-code-fixer.js +1 -1
- data/node_modules/eslint/lib/linter/timing.js +16 -8
- data/node_modules/eslint/lib/options.js +35 -3
- data/node_modules/eslint/lib/rule-tester/index.js +3 -1
- data/node_modules/eslint/lib/rule-tester/rule-tester.js +424 -347
- data/node_modules/eslint/lib/rules/array-bracket-newline.js +1 -1
- data/node_modules/eslint/lib/rules/array-bracket-spacing.js +1 -1
- data/node_modules/eslint/lib/rules/block-scoped-var.js +1 -1
- data/node_modules/eslint/lib/rules/callback-return.js +2 -2
- data/node_modules/eslint/lib/rules/camelcase.js +3 -5
- data/node_modules/eslint/lib/rules/capitalized-comments.js +10 -7
- data/node_modules/eslint/lib/rules/comma-dangle.js +1 -1
- data/node_modules/eslint/lib/rules/comma-style.js +2 -2
- data/node_modules/eslint/lib/rules/complexity.js +14 -1
- data/node_modules/eslint/lib/rules/constructor-super.js +99 -100
- data/node_modules/eslint/lib/rules/default-case.js +1 -1
- data/node_modules/eslint/lib/rules/eol-last.js +2 -2
- data/node_modules/eslint/lib/rules/function-paren-newline.js +2 -2
- data/node_modules/eslint/lib/rules/indent-legacy.js +5 -5
- data/node_modules/eslint/lib/rules/indent.js +5 -5
- data/node_modules/eslint/lib/rules/index.js +1 -2
- data/node_modules/eslint/lib/rules/key-spacing.js +2 -2
- data/node_modules/eslint/lib/rules/line-comment-position.js +1 -1
- data/node_modules/eslint/lib/rules/lines-around-directive.js +2 -2
- data/node_modules/eslint/lib/rules/max-depth.js +1 -1
- data/node_modules/eslint/lib/rules/max-len.js +3 -3
- data/node_modules/eslint/lib/rules/max-lines.js +3 -3
- data/node_modules/eslint/lib/rules/max-nested-callbacks.js +1 -1
- data/node_modules/eslint/lib/rules/max-params.js +1 -1
- data/node_modules/eslint/lib/rules/max-statements.js +1 -1
- data/node_modules/eslint/lib/rules/multiline-comment-style.js +7 -7
- data/node_modules/eslint/lib/rules/new-cap.js +1 -1
- data/node_modules/eslint/lib/rules/newline-after-var.js +1 -1
- data/node_modules/eslint/lib/rules/newline-before-return.js +1 -1
- data/node_modules/eslint/lib/rules/no-case-declarations.js +13 -1
- data/node_modules/eslint/lib/rules/no-constant-binary-expression.js +7 -8
- data/node_modules/eslint/lib/rules/no-constant-condition.js +18 -7
- data/node_modules/eslint/lib/rules/no-constructor-return.js +2 -2
- data/node_modules/eslint/lib/rules/no-dupe-class-members.js +2 -2
- data/node_modules/eslint/lib/rules/no-else-return.js +1 -1
- data/node_modules/eslint/lib/rules/no-empty-function.js +2 -2
- data/node_modules/eslint/lib/rules/no-empty-static-block.js +1 -1
- data/node_modules/eslint/lib/rules/no-extend-native.js +1 -2
- data/node_modules/eslint/lib/rules/no-extra-semi.js +1 -1
- data/node_modules/eslint/lib/rules/no-fallthrough.js +41 -16
- data/node_modules/eslint/lib/rules/no-implicit-coercion.js +66 -24
- data/node_modules/eslint/lib/rules/no-inner-declarations.js +23 -2
- data/node_modules/eslint/lib/rules/no-invalid-regexp.js +1 -1
- data/node_modules/eslint/lib/rules/no-invalid-this.js +1 -1
- data/node_modules/eslint/lib/rules/no-lone-blocks.js +3 -3
- data/node_modules/eslint/lib/rules/no-loss-of-precision.js +1 -1
- data/node_modules/eslint/lib/rules/no-misleading-character-class.js +225 -69
- data/node_modules/eslint/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
- data/node_modules/eslint/lib/rules/no-multiple-empty-lines.js +1 -1
- data/node_modules/eslint/lib/rules/no-new-native-nonconstructor.js +1 -1
- data/node_modules/eslint/lib/rules/no-new-symbol.js +8 -1
- data/node_modules/eslint/lib/rules/no-restricted-globals.js +1 -1
- data/node_modules/eslint/lib/rules/no-restricted-imports.js +186 -40
- data/node_modules/eslint/lib/rules/no-restricted-modules.js +2 -2
- data/node_modules/eslint/lib/rules/no-return-await.js +1 -1
- data/node_modules/eslint/lib/rules/no-sequences.js +1 -0
- data/node_modules/eslint/lib/rules/no-this-before-super.js +45 -13
- data/node_modules/eslint/lib/rules/no-trailing-spaces.js +2 -3
- data/node_modules/eslint/lib/rules/no-unneeded-ternary.js +1 -1
- data/node_modules/eslint/lib/rules/no-unsafe-optional-chaining.js +1 -1
- data/node_modules/eslint/lib/rules/no-unused-private-class-members.js +1 -1
- data/node_modules/eslint/lib/rules/no-unused-vars.js +197 -36
- data/node_modules/eslint/lib/rules/no-useless-assignment.js +566 -0
- data/node_modules/eslint/lib/rules/no-useless-backreference.js +1 -1
- data/node_modules/eslint/lib/rules/no-useless-computed-key.js +2 -2
- data/node_modules/eslint/lib/rules/no-useless-return.js +7 -2
- data/node_modules/eslint/lib/rules/object-curly-spacing.js +3 -3
- data/node_modules/eslint/lib/rules/object-property-newline.js +1 -1
- data/node_modules/eslint/lib/rules/one-var.js +5 -5
- data/node_modules/eslint/lib/rules/padded-blocks.js +7 -7
- data/node_modules/eslint/lib/rules/prefer-arrow-callback.js +3 -3
- data/node_modules/eslint/lib/rules/prefer-reflect.js +1 -1
- data/node_modules/eslint/lib/rules/prefer-regex-literals.js +1 -1
- data/node_modules/eslint/lib/rules/prefer-template.js +1 -1
- data/node_modules/eslint/lib/rules/radix.js +2 -2
- data/node_modules/eslint/lib/rules/semi-style.js +1 -1
- data/node_modules/eslint/lib/rules/sort-imports.js +1 -1
- data/node_modules/eslint/lib/rules/sort-keys.js +1 -1
- data/node_modules/eslint/lib/rules/sort-vars.js +1 -1
- data/node_modules/eslint/lib/rules/space-unary-ops.js +1 -1
- data/node_modules/eslint/lib/rules/strict.js +1 -1
- data/node_modules/eslint/lib/rules/use-isnan.js +101 -7
- data/node_modules/eslint/lib/rules/utils/ast-utils.js +16 -7
- data/node_modules/eslint/lib/rules/utils/char-source.js +240 -0
- data/node_modules/eslint/lib/rules/utils/lazy-loading-rule-map.js +1 -1
- data/node_modules/eslint/lib/rules/utils/unicode/index.js +9 -4
- data/node_modules/eslint/lib/rules/yield-star-spacing.js +1 -1
- data/node_modules/eslint/lib/shared/runtime-info.js +1 -0
- data/node_modules/eslint/lib/shared/serialization.js +55 -0
- data/node_modules/eslint/lib/shared/stats.js +30 -0
- data/node_modules/eslint/lib/shared/string-utils.js +9 -11
- data/node_modules/eslint/lib/shared/types.js +35 -1
- data/node_modules/eslint/lib/source-code/index.js +3 -1
- data/node_modules/eslint/lib/source-code/source-code.js +299 -85
- data/node_modules/eslint/lib/source-code/token-store/backward-token-cursor.js +3 -3
- data/node_modules/eslint/lib/source-code/token-store/cursors.js +4 -2
- data/node_modules/eslint/lib/source-code/token-store/forward-token-comment-cursor.js +3 -3
- data/node_modules/eslint/lib/source-code/token-store/forward-token-cursor.js +3 -3
- data/node_modules/eslint/lib/source-code/token-store/index.js +2 -2
- data/node_modules/eslint/lib/unsupported-api.js +3 -5
- data/node_modules/eslint/messages/no-config-found.js +1 -1
- data/node_modules/eslint/messages/plugin-conflict.js +1 -1
- data/node_modules/eslint/messages/plugin-invalid.js +1 -1
- data/node_modules/eslint/messages/plugin-missing.js +1 -1
- data/node_modules/eslint/package.json +32 -29
- data/node_modules/eslint-scope/README.md +23 -2
- data/node_modules/eslint-scope/dist/eslint-scope.cjs +84 -58
- data/node_modules/eslint-scope/lib/index.js +0 -3
- data/node_modules/eslint-scope/lib/pattern-visitor.js +4 -3
- data/node_modules/eslint-scope/lib/referencer.js +13 -11
- data/node_modules/eslint-scope/lib/scope-manager.js +2 -8
- data/node_modules/eslint-scope/lib/scope.js +64 -43
- data/node_modules/eslint-scope/lib/version.js +1 -1
- data/node_modules/eslint-scope/package.json +21 -19
- data/node_modules/eslint-visitor-keys/README.md +1 -1
- data/node_modules/eslint-visitor-keys/package.json +2 -2
- data/node_modules/espree/README.md +1 -1
- data/node_modules/espree/dist/espree.cjs +1 -1
- data/node_modules/espree/lib/version.js +1 -1
- data/node_modules/espree/package.json +18 -20
- data/node_modules/file-entry-cache/LICENSE +1 -1
- data/node_modules/file-entry-cache/README.md +6 -3
- data/node_modules/file-entry-cache/package.json +19 -43
- data/node_modules/flat-cache/README.md +8 -6
- data/node_modules/flat-cache/changelog.md +155 -205
- data/node_modules/flat-cache/package.json +16 -39
- data/node_modules/flat-cache/src/cache.js +22 -26
- data/node_modules/flat-cache/src/del.js +28 -11
- data/node_modules/flat-cache/src/utils.js +39 -41
- data/node_modules/globals/globals.json +25 -0
- data/node_modules/globals/index.d.ts +2074 -3
- data/node_modules/globals/package.json +10 -7
- data/node_modules/globals/readme.md +2 -14
- data/node_modules/keyv/package.json +4 -4
- data/node_modules/keyv/src/index.js +6 -11
- data/node_modules/npm-check-updates/build/cli.js +22 -21
- data/node_modules/npm-check-updates/build/cli.js.map +1 -1
- data/node_modules/npm-check-updates/build/index-5sFb3Tvv.js +66 -0
- data/node_modules/npm-check-updates/build/index-5sFb3Tvv.js.map +1 -0
- data/node_modules/npm-check-updates/build/index-BmUFwMVL.js +6 -0
- data/node_modules/npm-check-updates/build/index-BmUFwMVL.js.map +1 -0
- data/node_modules/npm-check-updates/build/index.d.ts +5 -2
- data/node_modules/npm-check-updates/build/index.js +560 -1
- data/node_modules/npm-check-updates/build/index.js.map +1 -1
- data/node_modules/npm-check-updates/build/package.json +4 -3
- data/node_modules/npm-check-updates/build/src/index.js +1 -1
- data/node_modules/npm-check-updates/build/src/index.js.map +1 -1
- data/node_modules/npm-check-updates/build/src/lib/libnpmconfig/index.js +2 -2
- data/node_modules/npm-check-updates/build/src/lib/libnpmconfig/index.js.map +1 -1
- data/node_modules/npm-check-updates/build/src/package-managers/bun.js +0 -6
- data/node_modules/npm-check-updates/build/src/package-managers/bun.js.map +1 -1
- data/node_modules/npm-check-updates/package.json +4 -3
- data/node_modules/type-fest/index.d.ts +95 -2
- data/node_modules/type-fest/package.json +12 -18
- data/node_modules/type-fest/readme.md +299 -52
- data/node_modules/type-fest/source/async-return-type.d.ts +4 -2
- data/node_modules/type-fest/source/asyncify.d.ts +5 -3
- data/node_modules/type-fest/source/basic.d.ts +21 -43
- data/node_modules/type-fest/{ts41 → source}/camel-case.d.ts +18 -17
- data/node_modules/type-fest/source/camel-cased-properties-deep.d.ts +54 -0
- data/node_modules/type-fest/source/camel-cased-properties.d.ts +36 -0
- data/node_modules/type-fest/source/conditional-except.d.ts +6 -4
- data/node_modules/type-fest/source/conditional-keys.d.ts +5 -1
- data/node_modules/type-fest/source/conditional-pick.d.ts +5 -3
- data/node_modules/type-fest/{ts41 → source}/delimiter-case.d.ts +16 -8
- data/node_modules/type-fest/source/delimiter-cased-properties-deep.d.ts +60 -0
- data/node_modules/type-fest/source/delimiter-cased-properties.d.ts +37 -0
- data/node_modules/type-fest/source/entries.d.ts +8 -3
- data/node_modules/type-fest/source/entry.d.ts +8 -3
- data/node_modules/type-fest/source/exact.d.ts +73 -0
- data/node_modules/type-fest/source/except.d.ts +38 -3
- data/node_modules/type-fest/source/fixed-length-array.d.ts +6 -1
- data/node_modules/type-fest/source/get.d.ts +184 -0
- data/node_modules/type-fest/source/has-optional-keys.d.ts +21 -0
- data/node_modules/type-fest/source/has-required-keys.d.ts +59 -0
- data/node_modules/type-fest/source/includes.d.ts +22 -0
- data/node_modules/type-fest/source/internal.d.ts +59 -0
- data/node_modules/type-fest/source/invariant-of.d.ts +76 -0
- data/node_modules/type-fest/source/iterable-element.d.ts +8 -0
- data/node_modules/type-fest/source/join.d.ts +30 -0
- data/node_modules/type-fest/source/jsonify.d.ts +90 -0
- data/node_modules/type-fest/{ts41 → source}/kebab-case.d.ts +7 -5
- data/node_modules/type-fest/source/kebab-cased-properties-deep.d.ts +47 -0
- data/node_modules/type-fest/source/kebab-cased-properties.d.ts +30 -0
- data/node_modules/type-fest/source/last-array-element.d.ts +28 -0
- data/node_modules/type-fest/source/literal-to-primitive.d.ts +36 -0
- data/node_modules/type-fest/source/literal-union.d.ts +7 -5
- data/node_modules/type-fest/source/merge-exclusive.d.ts +3 -1
- data/node_modules/type-fest/source/merge.d.ts +8 -3
- data/node_modules/type-fest/source/multidimensional-array.d.ts +43 -0
- data/node_modules/type-fest/source/multidimensional-readonly-array.d.ts +47 -0
- data/node_modules/type-fest/source/mutable.d.ts +4 -21
- data/node_modules/type-fest/source/numeric.d.ts +170 -0
- data/node_modules/type-fest/source/observable-like.d.ts +62 -0
- data/node_modules/type-fest/source/opaque.d.ts +45 -3
- data/node_modules/type-fest/source/optional-keys-of.d.ts +38 -0
- data/node_modules/type-fest/source/package-json.d.ts +64 -12
- data/node_modules/type-fest/source/partial-deep.d.ts +57 -16
- data/node_modules/type-fest/source/partial-on-undefined-deep.d.ts +70 -0
- data/node_modules/type-fest/{ts41 → source}/pascal-case.d.ts +6 -4
- data/node_modules/type-fest/source/pascal-cased-properties-deep.d.ts +54 -0
- data/node_modules/type-fest/source/pascal-cased-properties.d.ts +34 -0
- data/node_modules/type-fest/source/primitive.d.ts +13 -0
- data/node_modules/type-fest/source/promisable.d.ts +5 -3
- data/node_modules/type-fest/source/promise-value.d.ts +9 -7
- data/node_modules/type-fest/source/readonly-deep.d.ts +33 -7
- data/node_modules/type-fest/source/readonly-tuple.d.ts +41 -0
- data/node_modules/type-fest/source/remove-index-signature.d.ts +104 -0
- data/node_modules/type-fest/source/replace.d.ts +67 -0
- data/node_modules/type-fest/source/require-all-or-none.d.ts +36 -0
- data/node_modules/type-fest/source/require-at-least-one.d.ts +5 -3
- data/node_modules/type-fest/source/require-exactly-one.d.ts +4 -5
- data/node_modules/type-fest/source/required-keys-of.d.ts +29 -0
- data/node_modules/type-fest/source/schema.d.ts +72 -0
- data/node_modules/type-fest/source/screaming-snake-case.d.ts +33 -0
- data/node_modules/type-fest/source/set-non-nullable.d.ts +35 -0
- data/node_modules/type-fest/source/set-optional.d.ts +12 -11
- data/node_modules/type-fest/source/set-required.d.ts +12 -11
- data/node_modules/type-fest/source/set-return-type.d.ts +3 -1
- data/node_modules/type-fest/source/simplify.d.ts +83 -0
- data/node_modules/type-fest/{ts41 → source}/snake-case.d.ts +7 -4
- data/node_modules/type-fest/source/snake-cased-properties-deep.d.ts +47 -0
- data/node_modules/type-fest/source/snake-cased-properties.d.ts +30 -0
- data/node_modules/type-fest/source/split.d.ts +29 -0
- data/node_modules/type-fest/source/spread.d.ts +85 -0
- data/node_modules/type-fest/source/string-key-of.d.ts +25 -0
- data/node_modules/type-fest/source/stringified.d.ts +3 -1
- data/node_modules/type-fest/source/trim.d.ts +25 -0
- data/node_modules/type-fest/source/tsconfig-json.d.ts +316 -14
- data/node_modules/type-fest/source/typed-array.d.ts +17 -0
- data/node_modules/type-fest/source/union-to-intersection.d.ts +4 -2
- data/node_modules/type-fest/source/value-of.d.ts +3 -1
- data/node_modules/type-fest/source/writable.d.ts +40 -0
- data/package.json +2 -2
- metadata +86 -63
- data/linters/rubocop-2.7.6.yml +0 -86
- data/node_modules/@humanwhocodes/object-schema/tests/merge-strategy.js +0 -66
- data/node_modules/@humanwhocodes/object-schema/tests/object-schema.js +0 -659
- data/node_modules/@humanwhocodes/object-schema/tests/validation-strategy.js +0 -186
- data/node_modules/eslint/conf/config-schema.js +0 -93
- data/node_modules/eslint/lib/cli-engine/formatters/checkstyle.js +0 -60
- data/node_modules/eslint/lib/cli-engine/formatters/compact.js +0 -60
- data/node_modules/eslint/lib/cli-engine/formatters/jslint-xml.js +0 -41
- data/node_modules/eslint/lib/cli-engine/formatters/junit.js +0 -82
- data/node_modules/eslint/lib/cli-engine/formatters/tap.js +0 -95
- data/node_modules/eslint/lib/cli-engine/formatters/unix.js +0 -58
- data/node_modules/eslint/lib/cli-engine/formatters/visualstudio.js +0 -63
- data/node_modules/eslint/lib/cli-engine/xml-escape.js +0 -34
- data/node_modules/eslint/lib/eslint/flat-eslint.js +0 -1155
- data/node_modules/eslint/lib/rule-tester/flat-rule-tester.js +0 -1131
- data/node_modules/eslint/lib/rules/require-jsdoc.js +0 -122
- data/node_modules/eslint/lib/rules/utils/patterns/letters.js +0 -36
- data/node_modules/eslint/lib/rules/valid-jsdoc.js +0 -516
- data/node_modules/eslint/lib/shared/config-validator.js +0 -347
- data/node_modules/eslint/lib/shared/deprecation-warnings.js +0 -58
- data/node_modules/eslint/lib/shared/relative-module-resolver.js +0 -50
- data/node_modules/file-entry-cache/changelog.md +0 -163
- data/node_modules/flat-cache/node_modules/rimraf/CHANGELOG.md +0 -65
- data/node_modules/flat-cache/node_modules/rimraf/LICENSE +0 -15
- data/node_modules/flat-cache/node_modules/rimraf/README.md +0 -101
- data/node_modules/flat-cache/node_modules/rimraf/bin.js +0 -68
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/LICENSE +0 -21
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/README.md +0 -378
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/common.js +0 -238
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/glob.js +0 -790
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/LICENSE +0 -15
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/README.md +0 -230
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/minimatch.js +0 -947
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/LICENSE +0 -21
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/README.md +0 -129
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +0 -201
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +0 -47
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/node_modules/minimatch/package.json +0 -33
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/package.json +0 -55
- data/node_modules/flat-cache/node_modules/rimraf/node_modules/glob/sync.js +0 -486
- data/node_modules/flat-cache/node_modules/rimraf/package.json +0 -32
- data/node_modules/flat-cache/node_modules/rimraf/rimraf.js +0 -360
- data/node_modules/npm-check-updates/build/index-CI_x-D21.js +0 -593
- data/node_modules/npm-check-updates/build/index-CI_x-D21.js.map +0 -1
- data/node_modules/npm-check-updates/build/index-Ci8A2QXv.js +0 -6
- data/node_modules/npm-check-updates/build/index-Ci8A2QXv.js.map +0 -1
- data/node_modules/npm-check-updates/build/index-DgVn3Gax.js +0 -36
- data/node_modules/npm-check-updates/build/index-DgVn3Gax.js.map +0 -1
- data/node_modules/npm-check-updates/build/src/types/SpawnPleaseOptions.d.ts +0 -6
- data/node_modules/npm-check-updates/build/src/types/SpawnPleaseOptions.js +0 -3
- data/node_modules/npm-check-updates/build/src/types/SpawnPleaseOptions.js.map +0 -1
- data/node_modules/type-fest/base.d.ts +0 -38
- data/node_modules/type-fest/license +0 -9
- data/node_modules/type-fest/source/utilities.d.ts +0 -3
- data/node_modules/type-fest/ts41/index.d.ts +0 -9
@@ -0,0 +1,41 @@
|
|
1
|
+
/**
|
2
|
+
Creates a read-only tuple of type `Element` and with the length of `Length`.
|
3
|
+
|
4
|
+
@private
|
5
|
+
@see `ReadonlyTuple` which is safer because it tests if `Length` is a specific finite number.
|
6
|
+
*/
|
7
|
+
type BuildTupleHelper<Element, Length extends number, Rest extends Element[]> =
|
8
|
+
Rest['length'] extends Length ?
|
9
|
+
readonly [...Rest] : // Terminate with readonly array (aka tuple)
|
10
|
+
BuildTupleHelper<Element, Length, [Element, ...Rest]>;
|
11
|
+
|
12
|
+
/**
|
13
|
+
Create a type that represents a read-only tuple of the given type and length.
|
14
|
+
|
15
|
+
Use-cases:
|
16
|
+
- Declaring fixed-length tuples with a large number of items.
|
17
|
+
- Creating a range union (for example, `0 | 1 | 2 | 3 | 4` from the keys of such a type) without having to resort to recursive types.
|
18
|
+
- Creating a tuple of coordinates with a static length, for example, length of 3 for a 3D vector.
|
19
|
+
|
20
|
+
@example
|
21
|
+
```
|
22
|
+
import {ReadonlyTuple} from 'type-fest';
|
23
|
+
|
24
|
+
type FencingTeam = ReadonlyTuple<string, 3>;
|
25
|
+
|
26
|
+
const guestFencingTeam: FencingTeam = ['Josh', 'Michael', 'Robert'];
|
27
|
+
|
28
|
+
const homeFencingTeam: FencingTeam = ['George', 'John'];
|
29
|
+
//=> error TS2322: Type string[] is not assignable to type 'FencingTeam'
|
30
|
+
|
31
|
+
guestFencingTeam.push('Sam');
|
32
|
+
//=> error TS2339: Property 'push' does not exist on type 'FencingTeam'
|
33
|
+
```
|
34
|
+
|
35
|
+
@category Utilities
|
36
|
+
*/
|
37
|
+
export type ReadonlyTuple<Element, Length extends number> =
|
38
|
+
number extends Length
|
39
|
+
// Because `Length extends number` and `number extends Length`, then `Length` is not a specific finite number.
|
40
|
+
? readonly Element[] // It's not fixed length.
|
41
|
+
: BuildTupleHelper<Element, Length, []>; // Otherwise it is a fixed length tuple.
|
@@ -0,0 +1,104 @@
|
|
1
|
+
/**
|
2
|
+
Remove any index signatures from the given object type, so that only explicitly defined properties remain.
|
3
|
+
|
4
|
+
Use-cases:
|
5
|
+
- Remove overly permissive signatures from third-party types.
|
6
|
+
|
7
|
+
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
8
|
+
|
9
|
+
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
10
|
+
|
11
|
+
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
12
|
+
|
13
|
+
```
|
14
|
+
const indexed: Record<string, unknown> = {}; // Allowed
|
15
|
+
|
16
|
+
const keyed: Record<'foo', unknown> = {}; // Error
|
17
|
+
// => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
18
|
+
```
|
19
|
+
|
20
|
+
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
21
|
+
|
22
|
+
```
|
23
|
+
type Indexed = {} extends Record<string, unknown>
|
24
|
+
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
25
|
+
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
26
|
+
// => '✅ `{}` is assignable to `Record<string, unknown>`'
|
27
|
+
|
28
|
+
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
29
|
+
? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
|
30
|
+
: "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
|
31
|
+
// => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
|
32
|
+
```
|
33
|
+
|
34
|
+
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
35
|
+
|
36
|
+
```
|
37
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
38
|
+
|
39
|
+
type RemoveIndexSignature<ObjectType> = {
|
40
|
+
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
41
|
+
]: ObjectType[KeyType]; // ...to its original value, i.e. `RemoveIndexSignature<Foo> == Foo`.
|
42
|
+
};
|
43
|
+
```
|
44
|
+
|
45
|
+
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
46
|
+
|
47
|
+
```
|
48
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
49
|
+
|
50
|
+
type RemoveIndexSignature<ObjectType> = {
|
51
|
+
[KeyType in keyof ObjectType
|
52
|
+
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
53
|
+
as {} extends Record<KeyType, unknown>
|
54
|
+
? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
55
|
+
: ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
56
|
+
]: ObjectType[KeyType];
|
57
|
+
};
|
58
|
+
```
|
59
|
+
|
60
|
+
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
61
|
+
|
62
|
+
```
|
63
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
64
|
+
|
65
|
+
type RemoveIndexSignature<ObjectType> = {
|
66
|
+
[KeyType in keyof ObjectType
|
67
|
+
as {} extends Record<KeyType, unknown>
|
68
|
+
? never // => Remove this `KeyType`.
|
69
|
+
: KeyType // => Keep this `KeyType` as it is.
|
70
|
+
]: ObjectType[KeyType];
|
71
|
+
};
|
72
|
+
```
|
73
|
+
|
74
|
+
@example
|
75
|
+
```
|
76
|
+
import type {RemoveIndexSignature} from 'type-fest';
|
77
|
+
|
78
|
+
interface Example {
|
79
|
+
// These index signatures will be removed.
|
80
|
+
[x: string]: any
|
81
|
+
[x: number]: any
|
82
|
+
[x: symbol]: any
|
83
|
+
[x: `head-${string}`]: string
|
84
|
+
[x: `${string}-tail`]: string
|
85
|
+
[x: `head-${string}-tail`]: string
|
86
|
+
[x: `${bigint}`]: string
|
87
|
+
[x: `embedded-${number}`]: string
|
88
|
+
|
89
|
+
// These explicitly defined keys will remain.
|
90
|
+
foo: 'bar';
|
91
|
+
qux?: 'baz';
|
92
|
+
}
|
93
|
+
|
94
|
+
type ExampleWithoutIndexSignatures = RemoveIndexSignature<Example>;
|
95
|
+
// => { foo: 'bar'; qux?: 'baz' | undefined; }
|
96
|
+
```
|
97
|
+
|
98
|
+
@category Object
|
99
|
+
*/
|
100
|
+
export type RemoveIndexSignature<ObjectType> = {
|
101
|
+
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
|
102
|
+
? never
|
103
|
+
: KeyType]: ObjectType[KeyType];
|
104
|
+
};
|
@@ -0,0 +1,67 @@
|
|
1
|
+
type ReplaceOptions = {
|
2
|
+
all?: boolean;
|
3
|
+
};
|
4
|
+
|
5
|
+
/**
|
6
|
+
Represents a string with some or all matches replaced by a replacement.
|
7
|
+
|
8
|
+
Use-case:
|
9
|
+
- `snake-case-path` to `dotted.path.notation`
|
10
|
+
- Changing date/time format: `01-08-2042` → `01/08/2042`
|
11
|
+
- Manipulation of type properties, for example, removal of prefixes
|
12
|
+
|
13
|
+
@example
|
14
|
+
```
|
15
|
+
import {Replace} from 'type-fest';
|
16
|
+
|
17
|
+
declare function replace<
|
18
|
+
Input extends string,
|
19
|
+
Search extends string,
|
20
|
+
Replacement extends string
|
21
|
+
>(
|
22
|
+
input: Input,
|
23
|
+
search: Search,
|
24
|
+
replacement: Replacement
|
25
|
+
): Replace<Input, Search, Replacement>;
|
26
|
+
|
27
|
+
declare function replaceAll<
|
28
|
+
Input extends string,
|
29
|
+
Search extends string,
|
30
|
+
Replacement extends string
|
31
|
+
>(
|
32
|
+
input: Input,
|
33
|
+
search: Search,
|
34
|
+
replacement: Replacement
|
35
|
+
): Replace<Input, Search, Replacement, {all: true}>;
|
36
|
+
|
37
|
+
// The return type is the exact string literal, not just `string`.
|
38
|
+
|
39
|
+
replace('hello ?', '?', '🦄');
|
40
|
+
//=> 'hello 🦄'
|
41
|
+
|
42
|
+
replace('hello ??', '?', '❓');
|
43
|
+
//=> 'hello ❓?'
|
44
|
+
|
45
|
+
replaceAll('10:42:00', ':', '-');
|
46
|
+
//=> '10-42-00'
|
47
|
+
|
48
|
+
replaceAll('__userName__', '__', '');
|
49
|
+
//=> 'userName'
|
50
|
+
|
51
|
+
replaceAll('My Cool Title', ' ', '');
|
52
|
+
//=> 'MyCoolTitle'
|
53
|
+
```
|
54
|
+
|
55
|
+
@category String
|
56
|
+
@category Template literal
|
57
|
+
*/
|
58
|
+
export type Replace<
|
59
|
+
Input extends string,
|
60
|
+
Search extends string,
|
61
|
+
Replacement extends string,
|
62
|
+
Options extends ReplaceOptions = {},
|
63
|
+
> = Input extends `${infer Head}${Search}${infer Tail}`
|
64
|
+
? Options['all'] extends true
|
65
|
+
? `${Head}${Replacement}${Replace<Tail, Search, Replacement, Options>}`
|
66
|
+
: `${Head}${Replacement}${Tail}`
|
67
|
+
: Input;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
/**
|
2
|
+
Create a type that requires all of the given keys or none of the given keys. The remaining keys are kept as is.
|
3
|
+
|
4
|
+
Use-cases:
|
5
|
+
- Creating interfaces for components with mutually-inclusive keys.
|
6
|
+
|
7
|
+
The caveat with `RequireAllOrNone` is that TypeScript doesn't always know at compile time every key that will exist at runtime. Therefore `RequireAllOrNone` can't do anything to prevent extra keys it doesn't know about.
|
8
|
+
|
9
|
+
@example
|
10
|
+
```
|
11
|
+
import type {RequireAllOrNone} from 'type-fest';
|
12
|
+
|
13
|
+
type Responder = {
|
14
|
+
text?: () => string;
|
15
|
+
json?: () => string;
|
16
|
+
secure: boolean;
|
17
|
+
};
|
18
|
+
|
19
|
+
const responder1: RequireAllOrNone<Responder, 'text' | 'json'> = {
|
20
|
+
secure: true
|
21
|
+
};
|
22
|
+
|
23
|
+
const responder2: RequireAllOrNone<Responder, 'text' | 'json'> = {
|
24
|
+
text: () => '{"message": "hi"}',
|
25
|
+
json: () => '{"message": "ok"}',
|
26
|
+
secure: true
|
27
|
+
};
|
28
|
+
```
|
29
|
+
|
30
|
+
@category Object
|
31
|
+
*/
|
32
|
+
export type RequireAllOrNone<ObjectType, KeysType extends keyof ObjectType = never> = (
|
33
|
+
| Required<Pick<ObjectType, KeysType>> // Require all of the given keys.
|
34
|
+
| Partial<Record<KeysType, never>> // Require none of the given keys.
|
35
|
+
) &
|
36
|
+
Omit<ObjectType, KeysType>; // The rest of the keys.
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import {Except} from './except';
|
1
|
+
import type {Except} from './except';
|
2
2
|
|
3
3
|
/**
|
4
4
|
Create a type that requires at least one of the given keys. The remaining keys are kept as is.
|
5
5
|
|
6
6
|
@example
|
7
7
|
```
|
8
|
-
import {RequireAtLeastOne} from 'type-fest';
|
8
|
+
import type {RequireAtLeastOne} from 'type-fest';
|
9
9
|
|
10
10
|
type Responder = {
|
11
11
|
text?: () => string;
|
@@ -19,10 +19,12 @@ const responder: RequireAtLeastOne<Responder, 'text' | 'json'> = {
|
|
19
19
|
secure: true
|
20
20
|
};
|
21
21
|
```
|
22
|
+
|
23
|
+
@category Object
|
22
24
|
*/
|
23
25
|
export type RequireAtLeastOne<
|
24
26
|
ObjectType,
|
25
|
-
KeysType extends keyof ObjectType = keyof ObjectType
|
27
|
+
KeysType extends keyof ObjectType = keyof ObjectType,
|
26
28
|
> = {
|
27
29
|
// For each `Key` in `KeysType` make a mapped type:
|
28
30
|
[Key in KeysType]-?: Required<Pick<ObjectType, Key>> & // 1. Make `Key`'s type required
|
@@ -1,6 +1,3 @@
|
|
1
|
-
// TODO: Remove this when we target TypeScript >=3.5.
|
2
|
-
type _Omit<T, K extends keyof any> = Pick<T, Exclude<keyof T, K>>;
|
3
|
-
|
4
1
|
/**
|
5
2
|
Create a type that requires exactly one of the given keys and disallows more. The remaining keys are kept as is.
|
6
3
|
|
@@ -12,7 +9,7 @@ The caveat with `RequireExactlyOne` is that TypeScript doesn't always know at co
|
|
12
9
|
|
13
10
|
@example
|
14
11
|
```
|
15
|
-
import {RequireExactlyOne} from 'type-fest';
|
12
|
+
import type {RequireExactlyOne} from 'type-fest';
|
16
13
|
|
17
14
|
type Responder = {
|
18
15
|
text: () => string;
|
@@ -27,9 +24,11 @@ const responder: RequireExactlyOne<Responder, 'text' | 'json'> = {
|
|
27
24
|
secure: true
|
28
25
|
};
|
29
26
|
```
|
27
|
+
|
28
|
+
@category Object
|
30
29
|
*/
|
31
30
|
export type RequireExactlyOne<ObjectType, KeysType extends keyof ObjectType = keyof ObjectType> =
|
32
31
|
{[Key in KeysType]: (
|
33
32
|
Required<Pick<ObjectType, Key>> &
|
34
33
|
Partial<Record<Exclude<KeysType, Key>, never>>
|
35
|
-
)}[KeysType] &
|
34
|
+
)}[KeysType] & Omit<ObjectType, KeysType>;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
/**
|
2
|
+
Extract all required keys from the given type.
|
3
|
+
|
4
|
+
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
5
|
+
|
6
|
+
@example
|
7
|
+
```
|
8
|
+
import type {RequiredKeysOf} from 'type-fest';
|
9
|
+
|
10
|
+
declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
|
11
|
+
|
12
|
+
interface User {
|
13
|
+
name: string;
|
14
|
+
surname: string;
|
15
|
+
|
16
|
+
luckyNumber?: number;
|
17
|
+
}
|
18
|
+
|
19
|
+
const validator1 = createValidation<User>('name', value => value.length < 25);
|
20
|
+
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
21
|
+
```
|
22
|
+
|
23
|
+
@category Utilities
|
24
|
+
*/
|
25
|
+
export type RequiredKeysOf<BaseType extends object> = Exclude<{
|
26
|
+
[Key in keyof BaseType]: BaseType extends Record<Key, BaseType[Key]>
|
27
|
+
? Key
|
28
|
+
: never
|
29
|
+
}[keyof BaseType], undefined>;
|
@@ -0,0 +1,72 @@
|
|
1
|
+
/**
|
2
|
+
Create a deep version of another object type where property values are recursively replaced into a given value type.
|
3
|
+
|
4
|
+
Use-cases:
|
5
|
+
- Form validation: Define how each field should be validated.
|
6
|
+
- Form settings: Define configuration for input fields.
|
7
|
+
- Parsing: Define types that specify special behavior for specific fields.
|
8
|
+
|
9
|
+
@example
|
10
|
+
```
|
11
|
+
import type {Schema} from 'type-fest';
|
12
|
+
|
13
|
+
interface User {
|
14
|
+
id: string;
|
15
|
+
name: {
|
16
|
+
firstname: string;
|
17
|
+
lastname: string;
|
18
|
+
};
|
19
|
+
created: Date;
|
20
|
+
active: boolean;
|
21
|
+
passwordHash: string;
|
22
|
+
}
|
23
|
+
|
24
|
+
type UserMask = Schema<User, 'mask' | 'hide' | 'show'>;
|
25
|
+
|
26
|
+
const userMaskSettings: UserMask = {
|
27
|
+
id: 'show',
|
28
|
+
name: {
|
29
|
+
firstname: 'show',
|
30
|
+
lastname: 'mask',
|
31
|
+
},
|
32
|
+
phoneNumbers: 'mask',
|
33
|
+
created: 'show',
|
34
|
+
active: 'show',
|
35
|
+
passwordHash: 'hide',
|
36
|
+
}
|
37
|
+
```
|
38
|
+
|
39
|
+
@category Object
|
40
|
+
*/
|
41
|
+
export type Schema<ObjectType, ValueType> = ObjectType extends string
|
42
|
+
? ValueType
|
43
|
+
: ObjectType extends Map<unknown, unknown>
|
44
|
+
? ValueType
|
45
|
+
: ObjectType extends Set<unknown>
|
46
|
+
? ValueType
|
47
|
+
: ObjectType extends ReadonlyMap<unknown, unknown>
|
48
|
+
? ValueType
|
49
|
+
: ObjectType extends ReadonlySet<unknown>
|
50
|
+
? ValueType
|
51
|
+
: ObjectType extends readonly unknown[]
|
52
|
+
? ValueType
|
53
|
+
: ObjectType extends unknown[]
|
54
|
+
? ValueType
|
55
|
+
: ObjectType extends (...arguments: unknown[]) => unknown
|
56
|
+
? ValueType
|
57
|
+
: ObjectType extends Date
|
58
|
+
? ValueType
|
59
|
+
: ObjectType extends Function
|
60
|
+
? ValueType
|
61
|
+
: ObjectType extends RegExp
|
62
|
+
? ValueType
|
63
|
+
: ObjectType extends object
|
64
|
+
? SchemaObject<ObjectType, ValueType>
|
65
|
+
: ValueType;
|
66
|
+
|
67
|
+
/**
|
68
|
+
Same as `Schema`, but accepts only `object`s as inputs. Internal helper for `Schema`.
|
69
|
+
*/
|
70
|
+
type SchemaObject<ObjectType extends object, K> = {
|
71
|
+
[KeyType in keyof ObjectType]: Schema<ObjectType[KeyType], K> | K;
|
72
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import type {SplitIncludingDelimiters} from './delimiter-case';
|
2
|
+
import type {SnakeCase} from './snake-case';
|
3
|
+
import type {Includes} from './includes';
|
4
|
+
|
5
|
+
/**
|
6
|
+
Returns a boolean for whether the string is screaming snake case.
|
7
|
+
*/
|
8
|
+
type IsScreamingSnakeCase<Value extends string> = Value extends Uppercase<Value>
|
9
|
+
? Includes<SplitIncludingDelimiters<Lowercase<Value>, '_'>, '_'> extends true
|
10
|
+
? true
|
11
|
+
: false
|
12
|
+
: false;
|
13
|
+
|
14
|
+
/**
|
15
|
+
Convert a string literal to screaming-snake-case.
|
16
|
+
|
17
|
+
This can be useful when, for example, converting a camel-cased object property to a screaming-snake-cased SQL column name.
|
18
|
+
|
19
|
+
@example
|
20
|
+
```
|
21
|
+
import type {ScreamingSnakeCase} from 'type-fest';
|
22
|
+
|
23
|
+
const someVariable: ScreamingSnakeCase<'fooBar'> = 'FOO_BAR';
|
24
|
+
```
|
25
|
+
|
26
|
+
@category Change case
|
27
|
+
@category Template literal
|
28
|
+
*/
|
29
|
+
export type ScreamingSnakeCase<Value> = Value extends string
|
30
|
+
? IsScreamingSnakeCase<Value> extends true
|
31
|
+
? Value
|
32
|
+
: Uppercase<SnakeCase<Value>>
|
33
|
+
: Value;
|
@@ -0,0 +1,35 @@
|
|
1
|
+
import type {Except} from './except';
|
2
|
+
import type {Simplify} from './simplify';
|
3
|
+
|
4
|
+
/**
|
5
|
+
Create a type that makes the given keys non-nullable. The remaining keys are kept as is.
|
6
|
+
|
7
|
+
Use-case: You want to define a single model where the only thing that changes is whether or not some of the keys are non-nullable.
|
8
|
+
|
9
|
+
@example
|
10
|
+
```
|
11
|
+
import type {SetNonNullable} from 'type-fest';
|
12
|
+
|
13
|
+
type Foo = {
|
14
|
+
a: number;
|
15
|
+
b: string | undefined;
|
16
|
+
c?: boolean | null;
|
17
|
+
}
|
18
|
+
|
19
|
+
type SomeNonNullable = SetNonNullable<Foo, 'b' | 'c'>;
|
20
|
+
// type SomeNonNullable = {
|
21
|
+
// a: number;
|
22
|
+
// b: string; // Can no longer be undefined.
|
23
|
+
// c?: boolean; // Can no longer be null, but is still optional.
|
24
|
+
// }
|
25
|
+
```
|
26
|
+
|
27
|
+
@category Object
|
28
|
+
*/
|
29
|
+
export type SetNonNullable<BaseType, Keys extends keyof BaseType> =
|
30
|
+
Simplify<
|
31
|
+
// Pick just the keys that are readonly from the base type.
|
32
|
+
Except<BaseType, Keys> &
|
33
|
+
// Pick the keys that should be non-nullable from the base type and make them non-nullable.
|
34
|
+
{[Key in Keys]: NonNullable<BaseType[Key]>}
|
35
|
+
>;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {Except} from './except';
|
1
|
+
import type {Except} from './except';
|
2
|
+
import type {Simplify} from './simplify';
|
2
3
|
|
3
4
|
/**
|
4
5
|
Create a type that makes the given keys optional. The remaining keys are kept as is. The sister of the `SetRequired` type.
|
@@ -7,7 +8,7 @@ Use-case: You want to define a single model where the only thing that changes is
|
|
7
8
|
|
8
9
|
@example
|
9
10
|
```
|
10
|
-
import {SetOptional} from 'type-fest';
|
11
|
+
import type {SetOptional} from 'type-fest';
|
11
12
|
|
12
13
|
type Foo = {
|
13
14
|
a: number;
|
@@ -22,13 +23,13 @@ type SomeOptional = SetOptional<Foo, 'b' | 'c'>;
|
|
22
23
|
// c?: boolean; // Is now optional.
|
23
24
|
// }
|
24
25
|
```
|
26
|
+
|
27
|
+
@category Object
|
25
28
|
*/
|
26
|
-
export type SetOptional<BaseType, Keys extends keyof BaseType
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
? {[KeyType in keyof InferredType]: InferredType[KeyType]}
|
34
|
-
: never;
|
29
|
+
export type SetOptional<BaseType, Keys extends keyof BaseType> =
|
30
|
+
Simplify<
|
31
|
+
// Pick just the keys that are readonly from the base type.
|
32
|
+
Except<BaseType, Keys> &
|
33
|
+
// Pick the keys that should be mutable from the base type and make them mutable.
|
34
|
+
Partial<Pick<BaseType, Keys>>
|
35
|
+
>;
|
@@ -1,4 +1,5 @@
|
|
1
|
-
import {Except} from './except';
|
1
|
+
import type {Except} from './except';
|
2
|
+
import type {Simplify} from './simplify';
|
2
3
|
|
3
4
|
/**
|
4
5
|
Create a type that makes the given keys required. The remaining keys are kept as is. The sister of the `SetOptional` type.
|
@@ -7,7 +8,7 @@ Use-case: You want to define a single model where the only thing that changes is
|
|
7
8
|
|
8
9
|
@example
|
9
10
|
```
|
10
|
-
import {SetRequired} from 'type-fest';
|
11
|
+
import type {SetRequired} from 'type-fest';
|
11
12
|
|
12
13
|
type Foo = {
|
13
14
|
a?: number;
|
@@ -22,13 +23,13 @@ type SomeRequired = SetRequired<Foo, 'b' | 'c'>;
|
|
22
23
|
// c: boolean; // Is now required.
|
23
24
|
// }
|
24
25
|
```
|
26
|
+
|
27
|
+
@category Object
|
25
28
|
*/
|
26
|
-
export type SetRequired<BaseType, Keys extends keyof BaseType
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
? {[KeyType in keyof InferredType]: InferredType[KeyType]}
|
34
|
-
: never;
|
29
|
+
export type SetRequired<BaseType, Keys extends keyof BaseType> =
|
30
|
+
Simplify<
|
31
|
+
// Pick just the keys that are optional from the base type.
|
32
|
+
Except<BaseType, Keys> &
|
33
|
+
// Pick the keys that should be required from the base type and make them required.
|
34
|
+
Required<Pick<BaseType, Keys>>
|
35
|
+
>;
|
@@ -9,13 +9,15 @@ Use-case: You want to define a wrapped function that returns something different
|
|
9
9
|
|
10
10
|
@example
|
11
11
|
```
|
12
|
-
import {SetReturnType} from 'type-fest';
|
12
|
+
import type {SetReturnType} from 'type-fest';
|
13
13
|
|
14
14
|
type MyFunctionThatCanThrow = (foo: SomeType, bar: unknown) => SomeOtherType;
|
15
15
|
|
16
16
|
type MyWrappedFunction = SetReturnType<MyFunctionThatCanThrow, SomeOtherType | undefined>;
|
17
17
|
//=> type MyWrappedFunction = (foo: SomeType, bar: unknown) => SomeOtherType | undefined;
|
18
18
|
```
|
19
|
+
|
20
|
+
@category Function
|
19
21
|
*/
|
20
22
|
export type SetReturnType<Fn extends (...args: any[]) => any, TypeToReturn> =
|
21
23
|
// Just using `Parameters<Fn>` isn't ideal because it doesn't handle the `this` fake parameter.
|
@@ -0,0 +1,83 @@
|
|
1
|
+
/**
|
2
|
+
@see Simplify
|
3
|
+
*/
|
4
|
+
export interface SimplifyOptions {
|
5
|
+
/**
|
6
|
+
Do the simplification recursively.
|
7
|
+
|
8
|
+
@default false
|
9
|
+
*/
|
10
|
+
deep?: boolean;
|
11
|
+
}
|
12
|
+
|
13
|
+
// Flatten a type without worrying about the result.
|
14
|
+
type Flatten<
|
15
|
+
AnyType,
|
16
|
+
Options extends SimplifyOptions = {},
|
17
|
+
> = Options['deep'] extends true
|
18
|
+
? {[KeyType in keyof AnyType]: Simplify<AnyType[KeyType], Options>}
|
19
|
+
: {[KeyType in keyof AnyType]: AnyType[KeyType]};
|
20
|
+
|
21
|
+
/**
|
22
|
+
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
23
|
+
|
24
|
+
@example
|
25
|
+
```
|
26
|
+
import type {Simplify} from 'type-fest';
|
27
|
+
|
28
|
+
type PositionProps = {
|
29
|
+
top: number;
|
30
|
+
left: number;
|
31
|
+
};
|
32
|
+
|
33
|
+
type SizeProps = {
|
34
|
+
width: number;
|
35
|
+
height: number;
|
36
|
+
};
|
37
|
+
|
38
|
+
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
39
|
+
type Props = Simplify<PositionProps & SizeProps>;
|
40
|
+
```
|
41
|
+
|
42
|
+
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
43
|
+
|
44
|
+
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
45
|
+
|
46
|
+
@example
|
47
|
+
```
|
48
|
+
import type {Simplify} from 'type-fest';
|
49
|
+
|
50
|
+
interface SomeInterface {
|
51
|
+
foo: number;
|
52
|
+
bar?: string;
|
53
|
+
baz: number | undefined;
|
54
|
+
}
|
55
|
+
|
56
|
+
type SomeType = {
|
57
|
+
foo: number;
|
58
|
+
bar?: string;
|
59
|
+
baz: number | undefined;
|
60
|
+
};
|
61
|
+
|
62
|
+
const literal = {foo: 123, bar: 'hello', baz: 456};
|
63
|
+
const someType: SomeType = literal;
|
64
|
+
const someInterface: SomeInterface = literal;
|
65
|
+
|
66
|
+
function fn(object: Record<string, unknown>): void {}
|
67
|
+
|
68
|
+
fn(literal); // Good: literal object type is sealed
|
69
|
+
fn(someType); // Good: type is sealed
|
70
|
+
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
71
|
+
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
72
|
+
```
|
73
|
+
|
74
|
+
@link https://github.com/microsoft/TypeScript/issues/15300
|
75
|
+
|
76
|
+
@category Object
|
77
|
+
*/
|
78
|
+
export type Simplify<
|
79
|
+
AnyType,
|
80
|
+
Options extends SimplifyOptions = {},
|
81
|
+
> = Flatten<AnyType> extends AnyType
|
82
|
+
? Flatten<AnyType, Options>
|
83
|
+
: AnyType;
|