@nr1e/commons 0.1.0-alpha.1 → 0.1.1-alpha.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/.editorconfig +19 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +4 -0
- package/.git/COMMIT_EDITMSG +5 -0
- package/.git/FETCH_HEAD +1 -0
- package/.git/HEAD +1 -0
- package/.git/config +18 -0
- package/.git/config.worktree +5 -0
- package/.git/description +1 -0
- package/.git/hooks/applypatch-msg.sample +15 -0
- package/.git/hooks/commit-msg.sample +24 -0
- package/.git/hooks/fsmonitor-watchman.sample +174 -0
- package/.git/hooks/post-update.sample +8 -0
- package/.git/hooks/pre-applypatch.sample +14 -0
- package/.git/hooks/pre-commit.sample +49 -0
- package/.git/hooks/pre-merge-commit.sample +13 -0
- package/.git/hooks/pre-push.sample +53 -0
- package/.git/hooks/pre-rebase.sample +169 -0
- package/.git/hooks/pre-receive.sample +24 -0
- package/.git/hooks/prepare-commit-msg.sample +42 -0
- package/.git/hooks/push-to-checkout.sample +78 -0
- package/.git/hooks/sendemail-validate.sample +77 -0
- package/.git/hooks/update.sample +128 -0
- package/.git/index +0 -0
- package/.git/info/exclude +6 -0
- package/.git/logs/HEAD +2 -0
- package/.git/logs/refs/heads/develop +2 -0
- package/.git/logs/refs/remotes/origin/develop +2 -0
- package/.git/objects/07/c0af7cd711cab6a55ad3dc349ac8c70775623c +0 -0
- package/.git/objects/09/8fb5a5ff070a1ee3ea11db1a3568af3fea6fa2 +0 -0
- package/.git/objects/0d/698432e2c44311c17b845cc63093a898972b95 +0 -0
- package/.git/objects/10/ba4a7d64968326293182d571a9c73f5e041fb6 +3 -0
- package/.git/objects/12/069a5aa45479564e00749f730582627a276a55 +3 -0
- package/.git/objects/14/5ab9cf82c40696a07ab42f117ba199acb2a50b +4 -0
- package/.git/objects/17/7b0dc4bf884f8ae0403b4aad053e76baafd632 +2 -0
- package/.git/objects/1d/a517ce3527df45a4f28e52ff2c0d9d1c8179f6 +0 -0
- package/.git/objects/26/d9a4912af870ce319f5cb5102651d49baac4ab +1 -0
- package/.git/objects/27/50076ed23b5211a52ef834f40f183ddecb917a +0 -0
- package/.git/objects/2a/96e4bb57fa4bd69c719dca224b17b569e94e82 +2 -0
- package/.git/objects/2b/38c26b4ec43b8f5574acb164d2ba64bca8e230 +0 -0
- package/.git/objects/2c/61d463bee185f04e7c2bd1d2a15ad1117c589e +0 -0
- package/.git/objects/2d/22dbc836cfd75c8d7640ebe5a4fe90bd2c23c6 +0 -0
- package/.git/objects/38/0be191ee415827a1217f46626fea4fefba48e5 +0 -0
- package/.git/objects/4c/bb28de66d7aaeb4d7737cc2be955adc0c886b5 +0 -0
- package/.git/objects/50/150b739272269be2ede552448013eba65323da +0 -0
- package/.git/objects/53/2b7b796ffd3223f913a5a5e1e17743ee3591fe +0 -0
- package/.git/objects/54/f13d9d62fbedd19b41134ba17153c4328de95b +0 -0
- package/.git/objects/5d/4aa0709f62f1bc1fa80251208b570cb3b89d9c +0 -0
- package/.git/objects/63/1c43e00d4c34ba914c510f4fe2e6df15b8b06e +0 -0
- package/.git/objects/63/9900d13c6182e452e33a3bd638e70a0146c785 +2 -0
- package/.git/objects/64/3fa02661c3a1b54205729a75d2fb5f013833af +0 -0
- package/.git/objects/6c/59086d862516d2fffa5da2035e5003100fb5c7 +0 -0
- package/.git/objects/6c/b74f90a0c799eea1c54a04d8d6a8a9e9691cca +2 -0
- package/.git/objects/6d/f39e776d6a89628ce4a005a011911298651635 +0 -0
- package/.git/objects/70/0e093acb1c1e55d523507411b7940a01a3bb65 +0 -0
- package/.git/objects/74/c82ffe8eb71efecbccfdf67b590949c944dd1a +0 -0
- package/.git/objects/76/1413a07839108abb46ef0e4490bd1c1444b4fc +0 -0
- package/.git/objects/77/96f8282f2c553ecdde72bc976478eb3a8a948e +0 -0
- package/.git/objects/79/ee123c2b23e069e35ed634d687e17f731cc702 +0 -0
- package/.git/objects/7d/80af9735f0527db35ecc79ae3c887e445cb3e0 +0 -0
- package/.git/objects/85/1d8d26c2a946ccfd5461a2573665c1fb7d71f7 +0 -0
- package/.git/objects/85/c5f24b8c55496f82a2680f94a7d3fa32887ea0 +0 -0
- package/.git/objects/87/00b3833597b600e6f0ffcfbaf622fd8cfaa9c3 +1 -0
- package/.git/objects/87/f31d3df8e7edbf96e45d80126f878b8e0c243f +0 -0
- package/.git/objects/8d/d819967bdc8457f04c1b5498bce89380d6552b +7 -0
- package/.git/objects/92/608c4e069a4301d466d8d18daecbe7abc9500e +0 -0
- package/.git/objects/94/a25f7f4cb416c083d265558da75d457237d671 +0 -0
- package/.git/objects/9c/69411050eac81b5dce09314516a30b38c41a20 +3 -0
- package/.git/objects/9f/54b5b21769da383f12fb9c7bd364bdb05e13a9 +0 -0
- package/.git/objects/a5/886c22eb68b152bb95ec5151504676d8e78ae1 +0 -0
- package/.git/objects/a6/582c9510e264f3b46fc3b20597a16923a03523 +0 -0
- package/.git/objects/a9/d7db9c0a81b2db47ca92e4e180b30090b27632 +0 -0
- package/.git/objects/aa/8ae6a0af7014d738cc551d1ffebeb4e19e6b73 +0 -0
- package/.git/objects/ad/c418f9105db9ec488de6831584b82e3929eaef +0 -0
- package/.git/objects/ae/14b04cdf65ade0f70577cdea2f85203f4c1bde +0 -0
- package/.git/objects/b0/c1c68fbbad6b190434cd2bb0e807796bd56fca +0 -0
- package/.git/objects/b1/0f0d0ef3bc5aaf3a91be0b991cb6fe0fcadc40 +0 -0
- package/.git/objects/b1/3c15806ef3856ecd8660b0bb36f39830daa3c2 +0 -0
- package/.git/objects/b6/3b642cfb4254fc0f7058903abc5b481895c4ef +0 -0
- package/.git/objects/b8/a2c461d7ffed9d4ba242c58a52341832b99e0a +0 -0
- package/.git/objects/bc/91e0079eb00d56dcde16714748f36a10dbd525 +0 -0
- package/.git/objects/c1/beeb895b71b709e48560460199db11b3fc18af +0 -0
- package/.git/objects/c5/166c2aeebaeb0a0f7654223c843c50cd4c8953 +0 -0
- package/.git/objects/d4/0a2096fc36c1fd9c7a9263c458d5e8a4a5bee7 +0 -0
- package/.git/objects/e8/019be9e978a8e2f094e748cbb6ce0c7163adee +0 -0
- package/.git/objects/eb/1d744c4e9b47bc902647298424320078e32980 +0 -0
- package/.git/objects/ee/15af38be7f3c3862229e59c6b5688f8e0f6099 +0 -0
- package/.git/objects/f1/9e0f429f231c34432784f9e33b92ac1d598c17 +0 -0
- package/.git/objects/f9/86f2fe82493e85651396b6d5886316d1c890dd +0 -0
- package/.git/refs/heads/develop +1 -0
- package/.git/refs/remotes/origin/develop +1 -0
- package/.git/shallow +1 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/ci.yml +12 -0
- package/.github/workflows/issues.yml +13 -0
- package/.github/workflows/publish.yml +20 -0
- package/.gitignore +13 -0
- package/.idea/.gitignore +10 -0
- package/.idea/aws.xml +11 -0
- package/.idea/codeStyles/Project.xml +58 -0
- package/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.idea/commons-js.iml +14 -0
- package/.idea/inspectionProfiles/Project_Default.xml +7 -0
- package/.idea/misc.xml +6 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +6 -0
- package/.idea/vcs.xml +6 -0
- package/.npmrc +1 -0
- package/.prettierignore +7 -0
- package/.prettierrc.cjs +3 -0
- package/LICENSE +26 -0
- package/README.md +14 -0
- package/coverage/base.css +224 -0
- package/coverage/bitsnbytes/b64.mts.html +559 -0
- package/coverage/bitsnbytes/index.html +131 -0
- package/coverage/bitsnbytes/index.mts.html +88 -0
- package/coverage/clover.xml +1003 -0
- package/coverage/coverage-final.json +15 -0
- package/coverage/errors/errors.mts.html +898 -0
- package/coverage/errors/index.html +131 -0
- package/coverage/errors/index.mts.html +88 -0
- package/coverage/favicon.png +0 -0
- package/coverage/http/http-method.mts.html +112 -0
- package/coverage/http/http-status-code.mts.html +211 -0
- package/coverage/http/index.html +146 -0
- package/coverage/http/index.mts.html +91 -0
- package/coverage/index.html +191 -0
- package/coverage/lang/index.html +146 -0
- package/coverage/lang/index.mts.html +91 -0
- package/coverage/lang/sleep.mts.html +109 -0
- package/coverage/lang/type-functions.mts.html +124 -0
- package/coverage/oauth/crypto-functions.mts.html +217 -0
- package/coverage/oauth/index.html +131 -0
- package/coverage/oauth/index.mts.html +88 -0
- package/coverage/prettify.css +1 -0
- package/coverage/sort-arrow-sprite.png +0 -0
- package/coverage/validator/index.html +131 -0
- package/coverage/validator/index.mts.html +88 -0
- package/coverage/validator/validators.mts.html +1237 -0
- package/dist/package.json +72 -0
- package/node_modules/@eslint/eslintrc/LICENSE +19 -0
- package/node_modules/@eslint/eslintrc/README.md +115 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +1104 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +1 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +4344 -0
- package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +1 -0
- package/node_modules/@eslint/eslintrc/package.json +82 -0
- package/node_modules/@eslint/eslintrc/universal.js +9 -0
- package/node_modules/@eslint/js/LICENSE +19 -0
- package/node_modules/@eslint/js/README.md +57 -0
- package/node_modules/@eslint/js/package.json +31 -0
- package/node_modules/@eslint/js/src/index.js +17 -0
- package/node_modules/@eslint-community/eslint-utils/LICENSE +21 -0
- package/node_modules/@eslint-community/eslint-utils/README.md +37 -0
- package/node_modules/@eslint-community/eslint-utils/index.js +2068 -0
- package/node_modules/@eslint-community/eslint-utils/index.js.map +1 -0
- package/node_modules/@eslint-community/eslint-utils/index.mjs +2027 -0
- package/node_modules/@eslint-community/eslint-utils/index.mjs.map +1 -0
- package/node_modules/@eslint-community/eslint-utils/package.json +73 -0
- package/node_modules/@eslint-community/regexpp/LICENSE +21 -0
- package/node_modules/@eslint-community/regexpp/README.md +177 -0
- package/node_modules/@eslint-community/regexpp/index.d.ts +1065 -0
- package/node_modules/@eslint-community/regexpp/index.js +2747 -0
- package/node_modules/@eslint-community/regexpp/index.js.map +1 -0
- package/node_modules/@eslint-community/regexpp/index.mjs +2737 -0
- package/node_modules/@eslint-community/regexpp/index.mjs.map +1 -0
- package/node_modules/@eslint-community/regexpp/package.json +93 -0
- package/node_modules/@types/node/LICENSE +21 -0
- package/node_modules/@types/node/README.md +15 -0
- package/node_modules/@types/node/package.json +217 -0
- package/node_modules/@typescript-eslint/eslint-plugin/LICENSE +21 -0
- package/node_modules/@typescript-eslint/eslint-plugin/README.md +10 -0
- package/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +23 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/README.md +23 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/TEMPLATE.md +26 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/adjacent-overload-signatures.md +93 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/array-type.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/await-thenable.md +40 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-ts-comment.md +148 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-tslint-comment.md +39 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-types.md +183 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/block-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/brace-style.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/camelcase.md +10 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/class-literal-property-style.md +114 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-dangle.md +22 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-generic-constructors.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-indexed-object-style.md +80 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-assertions.md +108 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-definitions.md +82 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-exports.md +100 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-imports.md +105 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/default-param-last.md +48 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/dot-notation.md +77 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-function-return-type.md +319 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-member-accessibility.md +331 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-module-boundary-types.md +250 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/func-call-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/indent.md +20 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/init-declarations.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/key-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/keyword-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/lines-around-comment.md +37 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/lines-between-class-members.md +63 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-delimiter-style.md +161 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-ordering.md +1360 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/method-signature-style.md +110 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/naming-convention.md +706 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-array-constructor.md +35 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-base-to-string.md +88 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md +56 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-void-expression.md +116 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dupe-class-members.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-enum-values.md +50 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-imports.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-type-constituents.md +61 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dynamic-delete.md +53 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-function.md +88 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-interface.md +70 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-explicit-any.md +174 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-non-null-assertion.md +52 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-parens.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-semi.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extraneous-class.md +294 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-floating-promises.md +106 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-for-in-array.md +56 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implicit-any-catch.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implied-eval.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-import-type-side-effects.md +75 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-inferrable-types.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-this.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-void-type.md +113 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loop-func.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loss-of-precision.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-magic-numbers.md +131 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-meaningless-void-operator.md +47 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-new.md +46 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-promises.md +245 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-mixed-enums.md +88 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-namespace.md +129 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md +49 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md +35 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-assertion.md +42 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-parameter-properties.md +406 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redeclare.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redundant-type-constituents.md +78 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-require-imports.md +37 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-restricted-imports.md +63 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-shadow.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-this-alias.md +38 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-throw-literal.md +111 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-type-alias.md +602 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md +133 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-condition.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +51 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +73 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +77 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +55 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-argument.md +83 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-assignment.md +86 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-call.md +58 -0
- 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-enum-comparison.md +75 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-member-access.md +64 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-return.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-expressions.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-vars.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-use-before-define.md +97 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-constructor.md +21 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-empty-export.md +43 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-var-requires.md +37 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md +41 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/object-curly-spacing.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/padding-line-between-statements.md +35 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/parameter-properties.md +485 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-as-const.md +44 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-enum-initializers.md +62 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-for-of.md +46 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-function-type.md +92 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-includes.md +77 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-literal-enum-member.md +101 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-namespace-keyword.md +47 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +164 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-optional-chain.md +71 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +268 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly.md +87 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +58 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-regexp-exec.md +46 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-return-this-type.md +87 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md +57 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-ts-expect-error.md +69 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/promise-function-async.md +59 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/quotes.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-array-sort-compare.md +78 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-await.md +24 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-plus-operands.md +208 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-template-expressions.md +117 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/return-await.md +216 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/semi.md +16 -0
- 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 +106 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-blocks.md +42 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-function-paren.md +12 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-infix-ops.md +16 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/strict-boolean-expressions.md +183 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +106 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/triple-slash-reference.md +61 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/type-annotation-spacing.md +303 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/typedef.md +320 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unbound-method.md +103 -0
- package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unified-signatures.md +70 -0
- package/node_modules/@typescript-eslint/eslint-plugin/index.d.ts +4 -0
- package/node_modules/@typescript-eslint/eslint-plugin/package.json +87 -0
- package/node_modules/@typescript-eslint/parser/LICENSE +22 -0
- package/node_modules/@typescript-eslint/parser/README.md +10 -0
- package/node_modules/@typescript-eslint/parser/dist/index.js +17 -0
- package/node_modules/@typescript-eslint/parser/package.json +75 -0
- package/node_modules/@typescript-eslint/scope-manager/LICENSE +21 -0
- package/node_modules/@typescript-eslint/scope-manager/README.md +8 -0
- package/node_modules/@typescript-eslint/scope-manager/dist/index.js +31 -0
- package/node_modules/@typescript-eslint/scope-manager/package.json +67 -0
- package/node_modules/@typescript-eslint/type-utils/LICENSE +21 -0
- package/node_modules/@typescript-eslint/type-utils/README.md +12 -0
- package/node_modules/@typescript-eslint/type-utils/dist/index.js +36 -0
- package/node_modules/@typescript-eslint/type-utils/package.json +71 -0
- package/node_modules/@typescript-eslint/types/LICENSE +21 -0
- package/node_modules/@typescript-eslint/types/README.md +12 -0
- package/node_modules/@typescript-eslint/types/dist/index.js +24 -0
- package/node_modules/@typescript-eslint/types/package.json +84 -0
- package/node_modules/@typescript-eslint/typescript-estree/LICENSE +26 -0
- package/node_modules/@typescript-eslint/typescript-estree/README.md +10 -0
- package/node_modules/@typescript-eslint/typescript-estree/dist/index.js +38 -0
- package/node_modules/@typescript-eslint/typescript-estree/package.json +85 -0
- package/node_modules/@typescript-eslint/utils/LICENSE +21 -0
- package/node_modules/@typescript-eslint/utils/README.md +10 -0
- package/node_modules/@typescript-eslint/utils/dist/index.js +41 -0
- package/node_modules/@typescript-eslint/utils/package.json +70 -0
- package/node_modules/@typescript-eslint/visitor-keys/LICENSE +21 -0
- package/node_modules/@typescript-eslint/visitor-keys/README.md +10 -0
- package/node_modules/@typescript-eslint/visitor-keys/dist/index.js +8 -0
- package/node_modules/@typescript-eslint/visitor-keys/package.json +60 -0
- package/node_modules/@vitest/coverage-v8/LICENSE +21 -0
- package/node_modules/@vitest/coverage-v8/dist/index.js +54 -0
- package/node_modules/@vitest/coverage-v8/package.json +72 -0
- package/package.json +6 -6
- package/pnpm-lock.yaml +3277 -0
- package/src/bitsnbytes/b64.mts +158 -0
- package/src/bitsnbytes/b64.test.mts +78 -0
- package/src/bitsnbytes/index.mts +1 -0
- package/src/errors/errors.mts +271 -0
- package/src/errors/errors.test.mts +74 -0
- package/src/errors/index.mts +1 -0
- package/src/http/http-method.mts +9 -0
- package/src/http/http-status-code.mts +42 -0
- package/src/http/index.mts +2 -0
- package/src/lang/index.mts +2 -0
- package/src/lang/sleep.mts +8 -0
- package/src/lang/type-functions.mts +13 -0
- package/src/oauth/crypto-functions.mts +44 -0
- package/src/oauth/crypto-functions.test.mts +48 -0
- package/src/oauth/index.mts +1 -0
- package/src/validator/index.mts +1 -0
- package/src/validator/validators.mts +384 -0
- package/src/validator/validators.test.mts +245 -0
- package/tsconfig.json +18 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.d.mts +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.d.mts.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.mjs +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.mjs.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.d.mts +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.d.mts.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.mjs +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/b64.test.mjs.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.d.mts +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.d.mts.map +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.mjs +0 -0
- /package/{bitsnbytes → dist/bitsnbytes}/index.mjs.map +0 -0
- /package/{errors → dist/errors}/errors.d.mts +0 -0
- /package/{errors → dist/errors}/errors.d.mts.map +0 -0
- /package/{errors → dist/errors}/errors.mjs +0 -0
- /package/{errors → dist/errors}/errors.mjs.map +0 -0
- /package/{errors → dist/errors}/errors.test.d.mts +0 -0
- /package/{errors → dist/errors}/errors.test.d.mts.map +0 -0
- /package/{errors → dist/errors}/errors.test.mjs +0 -0
- /package/{errors → dist/errors}/errors.test.mjs.map +0 -0
- /package/{errors → dist/errors}/index.d.mts +0 -0
- /package/{errors → dist/errors}/index.d.mts.map +0 -0
- /package/{errors → dist/errors}/index.mjs +0 -0
- /package/{errors → dist/errors}/index.mjs.map +0 -0
- /package/{http → dist/http}/http-method.d.mts +0 -0
- /package/{http → dist/http}/http-method.d.mts.map +0 -0
- /package/{http → dist/http}/http-method.mjs +0 -0
- /package/{http → dist/http}/http-method.mjs.map +0 -0
- /package/{http → dist/http}/http-status-code.d.mts +0 -0
- /package/{http → dist/http}/http-status-code.d.mts.map +0 -0
- /package/{http → dist/http}/http-status-code.mjs +0 -0
- /package/{http → dist/http}/http-status-code.mjs.map +0 -0
- /package/{http → dist/http}/index.d.mts +0 -0
- /package/{http → dist/http}/index.d.mts.map +0 -0
- /package/{http → dist/http}/index.mjs +0 -0
- /package/{http → dist/http}/index.mjs.map +0 -0
- /package/{lang → dist/lang}/index.d.mts +0 -0
- /package/{lang → dist/lang}/index.d.mts.map +0 -0
- /package/{lang → dist/lang}/index.mjs +0 -0
- /package/{lang → dist/lang}/index.mjs.map +0 -0
- /package/{lang → dist/lang}/sleep.d.mts +0 -0
- /package/{lang → dist/lang}/sleep.d.mts.map +0 -0
- /package/{lang → dist/lang}/sleep.mjs +0 -0
- /package/{lang → dist/lang}/sleep.mjs.map +0 -0
- /package/{lang → dist/lang}/type-functions.d.mts +0 -0
- /package/{lang → dist/lang}/type-functions.d.mts.map +0 -0
- /package/{lang → dist/lang}/type-functions.mjs +0 -0
- /package/{lang → dist/lang}/type-functions.mjs.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.d.mts +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.d.mts.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.mjs +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.mjs.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.d.mts +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.d.mts.map +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.mjs +0 -0
- /package/{oauth → dist/oauth}/crypto-functions.test.mjs.map +0 -0
- /package/{oauth → dist/oauth}/index.d.mts +0 -0
- /package/{oauth → dist/oauth}/index.d.mts.map +0 -0
- /package/{oauth → dist/oauth}/index.mjs +0 -0
- /package/{oauth → dist/oauth}/index.mjs.map +0 -0
- /package/{validator → dist/validator}/index.d.mts +0 -0
- /package/{validator → dist/validator}/index.d.mts.map +0 -0
- /package/{validator → dist/validator}/index.mjs +0 -0
- /package/{validator → dist/validator}/index.mjs.map +0 -0
- /package/{validator → dist/validator}/validators.d.mts +0 -0
- /package/{validator → dist/validator}/validators.d.mts.map +0 -0
- /package/{validator → dist/validator}/validators.mjs +0 -0
- /package/{validator → dist/validator}/validators.mjs.map +0 -0
- /package/{validator → dist/validator}/validators.test.d.mts +0 -0
- /package/{validator → dist/validator}/validators.test.d.mts.map +0 -0
- /package/{validator → dist/validator}/validators.test.mjs +0 -0
- /package/{validator → dist/validator}/validators.test.mjs.map +0 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Require consistent spacing around type annotations.'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
|
+
>
|
|
7
|
+
> See **https://typescript-eslint.io/rules/type-annotation-spacing** for documentation.
|
|
8
|
+
|
|
9
|
+
Spacing around type annotations improves readability of the code. Although the most commonly used style guideline for type annotations in TypeScript prescribes adding a space after the colon, but not before it, it is subjective to the preferences of a project. For example:
|
|
10
|
+
|
|
11
|
+
<!-- prettier-ignore -->
|
|
12
|
+
```ts
|
|
13
|
+
// with space after, but not before (default if no option is specified)
|
|
14
|
+
let foo: string = "bar";
|
|
15
|
+
|
|
16
|
+
// with no spaces
|
|
17
|
+
let foo:string = "bar";
|
|
18
|
+
|
|
19
|
+
// with space before and after
|
|
20
|
+
let foo : string = "bar";
|
|
21
|
+
|
|
22
|
+
// with space before, but not after
|
|
23
|
+
let foo :string = "bar";
|
|
24
|
+
|
|
25
|
+
// with spaces before and after the fat arrow (default if no option is specified)
|
|
26
|
+
type Foo = (string: name) => string;
|
|
27
|
+
|
|
28
|
+
// with no spaces between the fat arrow
|
|
29
|
+
type Foo = (string: name)=>string;
|
|
30
|
+
|
|
31
|
+
// with space after, but not before the fat arrow
|
|
32
|
+
type Foo = (string: name)=> string;
|
|
33
|
+
|
|
34
|
+
// with space before, but not after the fat arrow
|
|
35
|
+
type Foo = (string: name) =>string;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
This rule aims to enforce specific spacing patterns around type annotations and function types in type literals.
|
|
41
|
+
|
|
42
|
+
## Options
|
|
43
|
+
|
|
44
|
+
Examples of code for this rule with no options at all:
|
|
45
|
+
|
|
46
|
+
<!--tabs-->
|
|
47
|
+
|
|
48
|
+
### ❌ Incorrect
|
|
49
|
+
|
|
50
|
+
<!-- prettier-ignore -->
|
|
51
|
+
```ts
|
|
52
|
+
let foo:string = "bar";
|
|
53
|
+
let foo :string = "bar";
|
|
54
|
+
let foo : string = "bar";
|
|
55
|
+
|
|
56
|
+
function foo():string {}
|
|
57
|
+
function foo() :string {}
|
|
58
|
+
function foo() : string {}
|
|
59
|
+
|
|
60
|
+
class Foo {
|
|
61
|
+
name:string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
class Foo {
|
|
65
|
+
name :string;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
class Foo {
|
|
69
|
+
name : string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
type Foo = ()=>{};
|
|
73
|
+
type Foo = () =>{};
|
|
74
|
+
type Foo = ()=> {};
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### ✅ Correct
|
|
78
|
+
|
|
79
|
+
<!-- prettier-ignore -->
|
|
80
|
+
```ts
|
|
81
|
+
let foo: string = "bar";
|
|
82
|
+
|
|
83
|
+
function foo(): string {}
|
|
84
|
+
|
|
85
|
+
class Foo {
|
|
86
|
+
name: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
type Foo = () => {};
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### after
|
|
93
|
+
|
|
94
|
+
Examples of code for this rule with `{ "before": false, "after": true }`:
|
|
95
|
+
|
|
96
|
+
<!--tabs-->
|
|
97
|
+
|
|
98
|
+
#### ❌ Incorrect
|
|
99
|
+
|
|
100
|
+
<!-- prettier-ignore -->
|
|
101
|
+
```ts
|
|
102
|
+
let foo:string = "bar";
|
|
103
|
+
let foo :string = "bar";
|
|
104
|
+
let foo : string = "bar";
|
|
105
|
+
|
|
106
|
+
function foo():string {}
|
|
107
|
+
function foo() :string {}
|
|
108
|
+
function foo() : string {}
|
|
109
|
+
|
|
110
|
+
class Foo {
|
|
111
|
+
name:string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class Foo {
|
|
115
|
+
name :string;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
class Foo {
|
|
119
|
+
name : string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
type Foo = ()=>{};
|
|
123
|
+
type Foo = () =>{};
|
|
124
|
+
type Foo = () => {};
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
#### ✅ Correct
|
|
128
|
+
|
|
129
|
+
<!-- prettier-ignore -->
|
|
130
|
+
```ts
|
|
131
|
+
let foo: string = "bar";
|
|
132
|
+
|
|
133
|
+
function foo(): string {}
|
|
134
|
+
|
|
135
|
+
class Foo {
|
|
136
|
+
name: string;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
type Foo = ()=> {};
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### before
|
|
143
|
+
|
|
144
|
+
Examples of code for this rule with `{ "before": true, "after": true }` options:
|
|
145
|
+
|
|
146
|
+
<!--tabs-->
|
|
147
|
+
|
|
148
|
+
#### ❌ Incorrect
|
|
149
|
+
|
|
150
|
+
<!-- prettier-ignore -->
|
|
151
|
+
```ts
|
|
152
|
+
let foo: string = "bar";
|
|
153
|
+
let foo:string = "bar";
|
|
154
|
+
let foo :string = "bar";
|
|
155
|
+
|
|
156
|
+
function foo(): string {}
|
|
157
|
+
function foo():string {}
|
|
158
|
+
function foo() :string {}
|
|
159
|
+
|
|
160
|
+
class Foo {
|
|
161
|
+
name: string;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
class Foo {
|
|
165
|
+
name:string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
class Foo {
|
|
169
|
+
name :string;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
type Foo = ()=>{};
|
|
173
|
+
type Foo = () =>{};
|
|
174
|
+
type Foo = ()=> {};
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
#### ✅ Correct
|
|
178
|
+
|
|
179
|
+
<!-- prettier-ignore -->
|
|
180
|
+
```ts
|
|
181
|
+
let foo : string = "bar";
|
|
182
|
+
|
|
183
|
+
function foo() : string {}
|
|
184
|
+
|
|
185
|
+
class Foo {
|
|
186
|
+
name : string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
type Foo = () => {};
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### overrides - colon
|
|
193
|
+
|
|
194
|
+
Examples of code for this rule with `{ "before": false, "after": false, overrides: { colon: { before: true, after: true }} }` options:
|
|
195
|
+
|
|
196
|
+
<!--tabs-->
|
|
197
|
+
|
|
198
|
+
#### ❌ Incorrect
|
|
199
|
+
|
|
200
|
+
<!-- prettier-ignore -->
|
|
201
|
+
```ts
|
|
202
|
+
let foo: string = "bar";
|
|
203
|
+
let foo:string = "bar";
|
|
204
|
+
let foo :string = "bar";
|
|
205
|
+
|
|
206
|
+
function foo(): string {}
|
|
207
|
+
function foo():string {}
|
|
208
|
+
function foo() :string {}
|
|
209
|
+
|
|
210
|
+
class Foo {
|
|
211
|
+
name: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
class Foo {
|
|
215
|
+
name:string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
class Foo {
|
|
219
|
+
name :string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
type Foo = () =>{};
|
|
223
|
+
type Foo = ()=> {};
|
|
224
|
+
type Foo = () => {};
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
#### ✅ Correct
|
|
228
|
+
|
|
229
|
+
<!-- prettier-ignore -->
|
|
230
|
+
```ts
|
|
231
|
+
let foo : string = "bar";
|
|
232
|
+
|
|
233
|
+
function foo() : string {}
|
|
234
|
+
|
|
235
|
+
class Foo {
|
|
236
|
+
name : string;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
type Foo = {
|
|
240
|
+
name: (name : string)=>string;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
type Foo = ()=>{};
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### overrides - arrow
|
|
247
|
+
|
|
248
|
+
Examples of code for this rule with `{ "before": false, "after": false, overrides: { arrow: { before: true, after: true }} }` options:
|
|
249
|
+
|
|
250
|
+
<!--tabs-->
|
|
251
|
+
|
|
252
|
+
#### ❌ Incorrect
|
|
253
|
+
|
|
254
|
+
<!-- prettier-ignore -->
|
|
255
|
+
```ts
|
|
256
|
+
let foo: string = "bar";
|
|
257
|
+
let foo : string = "bar";
|
|
258
|
+
let foo :string = "bar";
|
|
259
|
+
|
|
260
|
+
function foo(): string {}
|
|
261
|
+
function foo():string {}
|
|
262
|
+
function foo() :string {}
|
|
263
|
+
|
|
264
|
+
class Foo {
|
|
265
|
+
name: string;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
class Foo {
|
|
269
|
+
name : string;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
class Foo {
|
|
273
|
+
name :string;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
type Foo = ()=>{};
|
|
277
|
+
type Foo = () =>{};
|
|
278
|
+
type Foo = ()=> {};
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
#### ✅ Correct
|
|
282
|
+
|
|
283
|
+
<!-- prettier-ignore -->
|
|
284
|
+
```ts
|
|
285
|
+
let foo:string = "bar";
|
|
286
|
+
|
|
287
|
+
function foo():string {}
|
|
288
|
+
|
|
289
|
+
class Foo {
|
|
290
|
+
name:string;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
type Foo = () => {};
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
## When Not To Use It
|
|
297
|
+
|
|
298
|
+
If you don't want to enforce spacing for your type annotations, you can safely turn this rule off.
|
|
299
|
+
|
|
300
|
+
## Further Reading
|
|
301
|
+
|
|
302
|
+
- [TypeScript Type System](https://basarat.gitbooks.io/typescript/docs/types/type-system.html)
|
|
303
|
+
- [Type Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html)
|
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Require type annotations in certain places.'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
|
+
>
|
|
7
|
+
> See **https://typescript-eslint.io/rules/typedef** for documentation.
|
|
8
|
+
|
|
9
|
+
TypeScript cannot always infer types for all places in code.
|
|
10
|
+
Some locations require type annotations for their types to be inferred.
|
|
11
|
+
|
|
12
|
+
This rule can enforce type annotations in locations regardless of whether they're required.
|
|
13
|
+
This is typically used to maintain consistency for element types that sometimes require them.
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
class ContainsText {
|
|
17
|
+
// There must be a type annotation here to infer the type
|
|
18
|
+
delayedText: string;
|
|
19
|
+
|
|
20
|
+
// `typedef` requires a type annotation here to maintain consistency
|
|
21
|
+
immediateTextExplicit: string = 'text';
|
|
22
|
+
|
|
23
|
+
// This is still a string type because of its initial value
|
|
24
|
+
immediateTextImplicit = 'text';
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
> To enforce type definitions existing on call signatures, use [`explicit-function-return-type`](./explicit-function-return-type.md), or [`explicit-module-boundary-types`](./explicit-module-boundary-types.md).
|
|
29
|
+
|
|
30
|
+
:::caution
|
|
31
|
+
|
|
32
|
+
Requiring type annotations unnecessarily can be cumbersome to maintain and generally reduces code readability.
|
|
33
|
+
TypeScript is often better at inferring types than easily written type annotations would allow.
|
|
34
|
+
|
|
35
|
+
**Instead of enabling `typedef`, it is generally recommended to use the `--noImplicitAny` and `--strictPropertyInitialization` compiler options to enforce type annotations only when useful.**
|
|
36
|
+
|
|
37
|
+
:::
|
|
38
|
+
|
|
39
|
+
## Options
|
|
40
|
+
|
|
41
|
+
For example, with the following configuration:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"rules": {
|
|
46
|
+
"@typescript-eslint/typedef": [
|
|
47
|
+
"error",
|
|
48
|
+
{
|
|
49
|
+
"arrowParameter": true,
|
|
50
|
+
"variableDeclaration": true
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
- Type annotations on arrow function parameters are required
|
|
58
|
+
- Type annotations on variables are required
|
|
59
|
+
|
|
60
|
+
### `arrayDestructuring`
|
|
61
|
+
|
|
62
|
+
Whether to enforce type annotations on variables declared using array destructuring.
|
|
63
|
+
|
|
64
|
+
Examples of code with `{ "arrayDestructuring": true }`:
|
|
65
|
+
|
|
66
|
+
<!--tabs-->
|
|
67
|
+
|
|
68
|
+
#### ❌ Incorrect
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const [a] = [1];
|
|
72
|
+
const [b, c] = [1, 2];
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
#### ✅ Correct
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
const [a]: number[] = [1];
|
|
79
|
+
const [b]: [number] = [2];
|
|
80
|
+
const [c, d]: [boolean, string] = [true, 'text'];
|
|
81
|
+
|
|
82
|
+
for (const [key, val] of new Map([['key', 1]])) {
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### `arrowParameter`
|
|
87
|
+
|
|
88
|
+
Whether to enforce type annotations for parameters of arrow functions.
|
|
89
|
+
|
|
90
|
+
Examples of code with `{ "arrowParameter": true }`:
|
|
91
|
+
|
|
92
|
+
<!--tabs-->
|
|
93
|
+
|
|
94
|
+
#### ❌ Incorrect
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
const logsSize = size => console.log(size);
|
|
98
|
+
|
|
99
|
+
['hello', 'world'].map(text => text.length);
|
|
100
|
+
|
|
101
|
+
const mapper = {
|
|
102
|
+
map: text => text + '...',
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
#### ✅ Correct
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
const logsSize = (size: number) => console.log(size);
|
|
110
|
+
|
|
111
|
+
['hello', 'world'].map((text: string) => text.length);
|
|
112
|
+
|
|
113
|
+
const mapper = {
|
|
114
|
+
map: (text: string) => text + '...',
|
|
115
|
+
};
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### `memberVariableDeclaration`
|
|
119
|
+
|
|
120
|
+
Whether to enforce type annotations on member variables of classes.
|
|
121
|
+
|
|
122
|
+
Examples of code with `{ "memberVariableDeclaration": true }`:
|
|
123
|
+
|
|
124
|
+
<!--tabs-->
|
|
125
|
+
|
|
126
|
+
#### ❌ Incorrect
|
|
127
|
+
|
|
128
|
+
```ts
|
|
129
|
+
class ContainsText {
|
|
130
|
+
delayedText;
|
|
131
|
+
immediateTextImplicit = 'text';
|
|
132
|
+
}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
#### ✅ Correct
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
class ContainsText {
|
|
139
|
+
delayedText: string;
|
|
140
|
+
immediateTextImplicit: string = 'text';
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### `objectDestructuring`
|
|
145
|
+
|
|
146
|
+
Whether to enforce type annotations on variables declared using object destructuring.
|
|
147
|
+
|
|
148
|
+
Examples of code with `{ "objectDestructuring": true }`:
|
|
149
|
+
|
|
150
|
+
<!--tabs-->
|
|
151
|
+
|
|
152
|
+
#### ❌ Incorrect
|
|
153
|
+
|
|
154
|
+
```ts
|
|
155
|
+
const { length } = 'text';
|
|
156
|
+
const [b, c] = Math.random() ? [1, 2] : [3, 4];
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
#### ✅ Correct
|
|
160
|
+
|
|
161
|
+
```ts
|
|
162
|
+
const { length }: { length: number } = 'text';
|
|
163
|
+
const [b, c]: [number, number] = Math.random() ? [1, 2] : [3, 4];
|
|
164
|
+
|
|
165
|
+
for (const { key, val } of [{ key: 'key', val: 1 }]) {
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
### `parameter`
|
|
170
|
+
|
|
171
|
+
Whether to enforce type annotations for parameters of functions and methods.
|
|
172
|
+
|
|
173
|
+
Examples of code with `{ "parameter": true }`:
|
|
174
|
+
|
|
175
|
+
<!--tabs-->
|
|
176
|
+
|
|
177
|
+
#### ❌ Incorrect
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
function logsSize(size): void {
|
|
181
|
+
console.log(size);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const doublesSize = function (size): number {
|
|
185
|
+
return size * 2;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const divider = {
|
|
189
|
+
curriesSize(size): number {
|
|
190
|
+
return size;
|
|
191
|
+
},
|
|
192
|
+
dividesSize: function (size): number {
|
|
193
|
+
return size / 2;
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
class Logger {
|
|
198
|
+
log(text): boolean {
|
|
199
|
+
console.log('>', text);
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### ✅ Correct
|
|
206
|
+
|
|
207
|
+
```ts
|
|
208
|
+
function logsSize(size: number): void {
|
|
209
|
+
console.log(size);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
const doublesSize = function (size: number): number {
|
|
213
|
+
return size * 2;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
const divider = {
|
|
217
|
+
curriesSize(size: number): number {
|
|
218
|
+
return size;
|
|
219
|
+
},
|
|
220
|
+
dividesSize: function (size: number): number {
|
|
221
|
+
return size / 2;
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
|
|
225
|
+
class Logger {
|
|
226
|
+
log(text: boolean): boolean {
|
|
227
|
+
console.log('>', text);
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### `propertyDeclaration`
|
|
234
|
+
|
|
235
|
+
Whether to enforce type annotations for properties of interfaces and types.
|
|
236
|
+
|
|
237
|
+
Examples of code with `{ "propertyDeclaration": true }`:
|
|
238
|
+
|
|
239
|
+
<!--tabs-->
|
|
240
|
+
|
|
241
|
+
#### ❌ Incorrect
|
|
242
|
+
|
|
243
|
+
```ts
|
|
244
|
+
type Members = {
|
|
245
|
+
member;
|
|
246
|
+
otherMember;
|
|
247
|
+
};
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
#### ✅ Correct
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
type Members = {
|
|
254
|
+
member: boolean;
|
|
255
|
+
otherMember: string;
|
|
256
|
+
};
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### `variableDeclaration`
|
|
260
|
+
|
|
261
|
+
Whether to enforce type annotations for variable declarations, excluding array and object destructuring.
|
|
262
|
+
|
|
263
|
+
Examples of code with `{ "variableDeclaration": true }`:
|
|
264
|
+
|
|
265
|
+
<!--tabs-->
|
|
266
|
+
|
|
267
|
+
#### ❌ Incorrect
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
const text = 'text';
|
|
271
|
+
let initialText = 'text';
|
|
272
|
+
let delayedText;
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
#### ✅ Correct
|
|
276
|
+
|
|
277
|
+
```ts
|
|
278
|
+
const text: string = 'text';
|
|
279
|
+
let initialText: string = 'text';
|
|
280
|
+
let delayedText: string;
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
### `variableDeclarationIgnoreFunction`
|
|
284
|
+
|
|
285
|
+
Ignore variable declarations for non-arrow and arrow functions.
|
|
286
|
+
|
|
287
|
+
Examples of code with `{ "variableDeclaration": true, "variableDeclarationIgnoreFunction": true }`:
|
|
288
|
+
|
|
289
|
+
<!--tabs-->
|
|
290
|
+
|
|
291
|
+
#### ❌ Incorrect
|
|
292
|
+
|
|
293
|
+
```ts
|
|
294
|
+
const text = 'text';
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
#### ✅ Correct
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
const a = (): void => {};
|
|
301
|
+
const b = function (): void => {};
|
|
302
|
+
const c: () => void = (): void => {};
|
|
303
|
+
|
|
304
|
+
class Foo {
|
|
305
|
+
a = (): void => {};
|
|
306
|
+
b = function (): void => {};
|
|
307
|
+
c = () => void = (): void => {};
|
|
308
|
+
}
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## When Not To Use It
|
|
312
|
+
|
|
313
|
+
If you are using stricter TypeScript compiler options, particularly `--noImplicitAny` and/or `--strictPropertyInitialization`, you likely don't need this rule.
|
|
314
|
+
|
|
315
|
+
In general, if you do not consider the cost of writing unnecessary type annotations reasonable, then do not use this rule.
|
|
316
|
+
|
|
317
|
+
## Further Reading
|
|
318
|
+
|
|
319
|
+
- [TypeScript Type System](https://basarat.gitbooks.io/typescript/docs/types/type-system.html)
|
|
320
|
+
- [Type Inference](https://www.typescriptlang.org/docs/handbook/type-inference.html)
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: 'Enforce unbound methods are called with their expected scope.'
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
> 🛑 This file is source code, not the primary documentation location! 🛑
|
|
6
|
+
>
|
|
7
|
+
> See **https://typescript-eslint.io/rules/unbound-method** for documentation.
|
|
8
|
+
|
|
9
|
+
Class method functions don't preserve the class scope when passed as standalone variables ("unbound").
|
|
10
|
+
If your function does not access `this`, [you can annotate it with `this: void`](https://www.typescriptlang.org/docs/handbook/2/functions.html#declaring-this-in-a-function), or consider using an arrow function instead.
|
|
11
|
+
Otherwise, passing class methods around as values can remove type safety by failing to capture `this`.
|
|
12
|
+
|
|
13
|
+
This rule reports when a class method is referenced in an unbound manner.
|
|
14
|
+
|
|
15
|
+
:::note Tip
|
|
16
|
+
If you're working with `jest`, you can use [`eslint-plugin-jest`'s version of this rule](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md) to lint your test files, which knows when it's ok to pass an unbound method to `expect` calls.
|
|
17
|
+
:::
|
|
18
|
+
|
|
19
|
+
## Examples
|
|
20
|
+
|
|
21
|
+
<!--tabs-->
|
|
22
|
+
|
|
23
|
+
### ❌ Incorrect
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
class MyClass {
|
|
27
|
+
public log(): void {
|
|
28
|
+
console.log(this);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const instance = new MyClass();
|
|
33
|
+
|
|
34
|
+
// This logs the global scope (`window`/`global`), not the class instance
|
|
35
|
+
const myLog = instance.log;
|
|
36
|
+
myLog();
|
|
37
|
+
|
|
38
|
+
// This log might later be called with an incorrect scope
|
|
39
|
+
const { log } = instance;
|
|
40
|
+
|
|
41
|
+
// arith.double may refer to `this` internally
|
|
42
|
+
const arith = {
|
|
43
|
+
double(x: number): number {
|
|
44
|
+
return x * 2;
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const { double } = arith;
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### ✅ Correct
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
class MyClass {
|
|
54
|
+
public logUnbound(): void {
|
|
55
|
+
console.log(this);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public logBound = () => console.log(this);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const instance = new MyClass();
|
|
62
|
+
|
|
63
|
+
// logBound will always be bound with the correct scope
|
|
64
|
+
const { logBound } = instance;
|
|
65
|
+
logBound();
|
|
66
|
+
|
|
67
|
+
// .bind and lambdas will also add a correct scope
|
|
68
|
+
const dotBindLog = instance.logBound.bind(instance);
|
|
69
|
+
const innerLog = () => instance.logBound();
|
|
70
|
+
|
|
71
|
+
// arith.double explicitly declares that it does not refer to `this` internally
|
|
72
|
+
const arith = {
|
|
73
|
+
double(this: void, x: number): number {
|
|
74
|
+
return x * 2;
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
const { double } = arith;
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Options
|
|
81
|
+
|
|
82
|
+
### `ignoreStatic`
|
|
83
|
+
|
|
84
|
+
Examples of **correct** code for this rule with `{ ignoreStatic: true }`:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
class OtherClass {
|
|
88
|
+
static log() {
|
|
89
|
+
console.log(OtherClass);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// With `ignoreStatic`, statics are assumed to not rely on a particular scope
|
|
94
|
+
const { log } = OtherClass;
|
|
95
|
+
|
|
96
|
+
log();
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## When Not To Use It
|
|
100
|
+
|
|
101
|
+
If your code intentionally waits to bind methods after use, such as by passing a `scope: this` along with the method, you can disable this rule.
|
|
102
|
+
|
|
103
|
+
If you're wanting to use `toBeCalled` and similar matches in `jest` tests, you can disable this rule for your test files in favor of [`eslint-plugin-jest`'s version of this rule](https://github.com/jest-community/eslint-plugin-jest/blob/main/docs/rules/unbound-method.md).
|