@nr1e/commons 0.1.0 → 0.1.1

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.
Files changed (440) hide show
  1. package/.editorconfig +19 -0
  2. package/.eslintignore +3 -0
  3. package/.eslintrc.json +4 -0
  4. package/.git/COMMIT_EDITMSG +5 -0
  5. package/.git/FETCH_HEAD +1 -0
  6. package/.git/HEAD +1 -0
  7. package/.git/config +18 -0
  8. package/.git/config.worktree +5 -0
  9. package/.git/description +1 -0
  10. package/.git/hooks/applypatch-msg.sample +15 -0
  11. package/.git/hooks/commit-msg.sample +24 -0
  12. package/.git/hooks/fsmonitor-watchman.sample +174 -0
  13. package/.git/hooks/post-update.sample +8 -0
  14. package/.git/hooks/pre-applypatch.sample +14 -0
  15. package/.git/hooks/pre-commit.sample +49 -0
  16. package/.git/hooks/pre-merge-commit.sample +13 -0
  17. package/.git/hooks/pre-push.sample +53 -0
  18. package/.git/hooks/pre-rebase.sample +169 -0
  19. package/.git/hooks/pre-receive.sample +24 -0
  20. package/.git/hooks/prepare-commit-msg.sample +42 -0
  21. package/.git/hooks/push-to-checkout.sample +78 -0
  22. package/.git/hooks/sendemail-validate.sample +77 -0
  23. package/.git/hooks/update.sample +128 -0
  24. package/.git/index +0 -0
  25. package/.git/info/exclude +6 -0
  26. package/.git/logs/HEAD +2 -0
  27. package/.git/logs/refs/heads/main +2 -0
  28. package/.git/logs/refs/remotes/origin/main +2 -0
  29. package/.git/objects/07/c0af7cd711cab6a55ad3dc349ac8c70775623c +0 -0
  30. package/.git/objects/0d/698432e2c44311c17b845cc63093a898972b95 +0 -0
  31. package/.git/objects/10/ba4a7d64968326293182d571a9c73f5e041fb6 +3 -0
  32. package/.git/objects/12/069a5aa45479564e00749f730582627a276a55 +3 -0
  33. package/.git/objects/14/5ab9cf82c40696a07ab42f117ba199acb2a50b +4 -0
  34. package/.git/objects/17/7b0dc4bf884f8ae0403b4aad053e76baafd632 +2 -0
  35. package/.git/objects/1d/a517ce3527df45a4f28e52ff2c0d9d1c8179f6 +0 -0
  36. package/.git/objects/27/50076ed23b5211a52ef834f40f183ddecb917a +0 -0
  37. package/.git/objects/2a/96e4bb57fa4bd69c719dca224b17b569e94e82 +2 -0
  38. package/.git/objects/2b/38c26b4ec43b8f5574acb164d2ba64bca8e230 +0 -0
  39. package/.git/objects/2c/61d463bee185f04e7c2bd1d2a15ad1117c589e +0 -0
  40. package/.git/objects/2d/22dbc836cfd75c8d7640ebe5a4fe90bd2c23c6 +0 -0
  41. package/.git/objects/2e/58414df7b4d5c972167a83270f78fc4ed508f5 +0 -0
  42. package/.git/objects/38/0be191ee415827a1217f46626fea4fefba48e5 +0 -0
  43. package/.git/objects/3a/93aa29cd19bdc95a87d15910baec8455f8b7b7 +0 -0
  44. package/.git/objects/50/150b739272269be2ede552448013eba65323da +0 -0
  45. package/.git/objects/53/2b7b796ffd3223f913a5a5e1e17743ee3591fe +0 -0
  46. package/.git/objects/54/a8535f50287f6a7a8c00aed143ca6e5ee5f5d1 +0 -0
  47. package/.git/objects/5d/4aa0709f62f1bc1fa80251208b570cb3b89d9c +0 -0
  48. package/.git/objects/63/1c43e00d4c34ba914c510f4fe2e6df15b8b06e +0 -0
  49. package/.git/objects/63/9900d13c6182e452e33a3bd638e70a0146c785 +2 -0
  50. package/.git/objects/64/3fa02661c3a1b54205729a75d2fb5f013833af +0 -0
  51. package/.git/objects/6c/59086d862516d2fffa5da2035e5003100fb5c7 +0 -0
  52. package/.git/objects/6c/b74f90a0c799eea1c54a04d8d6a8a9e9691cca +2 -0
  53. package/.git/objects/70/0e093acb1c1e55d523507411b7940a01a3bb65 +0 -0
  54. package/.git/objects/71/1ba2014bc137dece4c4156ff5e77e6abaeb95c +0 -0
  55. package/.git/objects/74/c82ffe8eb71efecbccfdf67b590949c944dd1a +0 -0
  56. package/.git/objects/76/1413a07839108abb46ef0e4490bd1c1444b4fc +0 -0
  57. package/.git/objects/77/96f8282f2c553ecdde72bc976478eb3a8a948e +0 -0
  58. package/.git/objects/79/ee123c2b23e069e35ed634d687e17f731cc702 +0 -0
  59. package/.git/objects/7d/80af9735f0527db35ecc79ae3c887e445cb3e0 +0 -0
  60. package/.git/objects/85/1d8d26c2a946ccfd5461a2573665c1fb7d71f7 +0 -0
  61. package/.git/objects/85/c5f24b8c55496f82a2680f94a7d3fa32887ea0 +0 -0
  62. package/.git/objects/87/00b3833597b600e6f0ffcfbaf622fd8cfaa9c3 +1 -0
  63. package/.git/objects/87/f31d3df8e7edbf96e45d80126f878b8e0c243f +0 -0
  64. package/.git/objects/8b/cc95b71b20c79513e9157b921238ca2c79f906 +0 -0
  65. package/.git/objects/8d/d819967bdc8457f04c1b5498bce89380d6552b +7 -0
  66. package/.git/objects/91/b0fba96bf994b6232bb923f2a9929fc258a05f +0 -0
  67. package/.git/objects/92/608c4e069a4301d466d8d18daecbe7abc9500e +0 -0
  68. package/.git/objects/94/a25f7f4cb416c083d265558da75d457237d671 +0 -0
  69. package/.git/objects/9c/69411050eac81b5dce09314516a30b38c41a20 +3 -0
  70. package/.git/objects/9f/54b5b21769da383f12fb9c7bd364bdb05e13a9 +0 -0
  71. package/.git/objects/a5/886c22eb68b152bb95ec5151504676d8e78ae1 +0 -0
  72. package/.git/objects/a6/582c9510e264f3b46fc3b20597a16923a03523 +0 -0
  73. package/.git/objects/a9/d7db9c0a81b2db47ca92e4e180b30090b27632 +0 -0
  74. package/.git/objects/ad/c418f9105db9ec488de6831584b82e3929eaef +0 -0
  75. package/.git/objects/b0/c1c68fbbad6b190434cd2bb0e807796bd56fca +0 -0
  76. package/.git/objects/b1/0f0d0ef3bc5aaf3a91be0b991cb6fe0fcadc40 +0 -0
  77. package/.git/objects/b6/3b642cfb4254fc0f7058903abc5b481895c4ef +0 -0
  78. package/.git/objects/b8/a2c461d7ffed9d4ba242c58a52341832b99e0a +0 -0
  79. package/.git/objects/ba/5b53857ced8d97f6d6e3fb3538b3273743dafc +2 -0
  80. package/.git/objects/ba/5ef7104c0d019a9692cd2d78261d96f29e916f +0 -0
  81. package/.git/objects/bc/91e0079eb00d56dcde16714748f36a10dbd525 +0 -0
  82. package/.git/objects/c1/beeb895b71b709e48560460199db11b3fc18af +0 -0
  83. package/.git/objects/c5/166c2aeebaeb0a0f7654223c843c50cd4c8953 +0 -0
  84. package/.git/objects/d4/0a2096fc36c1fd9c7a9263c458d5e8a4a5bee7 +0 -0
  85. package/.git/objects/e1/b744bc6076ebeb02fa86af98583ac22e070ec0 +0 -0
  86. package/.git/objects/e8/019be9e978a8e2f094e748cbb6ce0c7163adee +0 -0
  87. package/.git/objects/eb/1d744c4e9b47bc902647298424320078e32980 +0 -0
  88. package/.git/objects/ee/15af38be7f3c3862229e59c6b5688f8e0f6099 +0 -0
  89. package/.git/objects/f1/9e0f429f231c34432784f9e33b92ac1d598c17 +0 -0
  90. package/.git/objects/f9/86f2fe82493e85651396b6d5886316d1c890dd +0 -0
  91. package/.git/refs/heads/main +1 -0
  92. package/.git/refs/remotes/origin/main +1 -0
  93. package/.git/refs/tags/v0.1.1 +1 -0
  94. package/.git/shallow +1 -0
  95. package/.github/dependabot.yml +10 -0
  96. package/.github/workflows/ci.yml +12 -0
  97. package/.github/workflows/issues.yml +13 -0
  98. package/.github/workflows/publish.yml +21 -0
  99. package/.gitignore +13 -0
  100. package/.idea/.gitignore +10 -0
  101. package/.idea/aws.xml +11 -0
  102. package/.idea/codeStyles/Project.xml +58 -0
  103. package/.idea/codeStyles/codeStyleConfig.xml +5 -0
  104. package/.idea/commons-js.iml +14 -0
  105. package/.idea/inspectionProfiles/Project_Default.xml +7 -0
  106. package/.idea/misc.xml +6 -0
  107. package/.idea/modules.xml +8 -0
  108. package/.idea/prettier.xml +6 -0
  109. package/.idea/vcs.xml +6 -0
  110. package/.npmrc +1 -0
  111. package/.prettierignore +7 -0
  112. package/.prettierrc.cjs +3 -0
  113. package/LICENSE +26 -0
  114. package/README.md +14 -0
  115. package/coverage/base.css +224 -0
  116. package/coverage/bitsnbytes/b64.mts.html +559 -0
  117. package/coverage/bitsnbytes/index.html +131 -0
  118. package/coverage/bitsnbytes/index.mts.html +88 -0
  119. package/coverage/clover.xml +1003 -0
  120. package/coverage/coverage-final.json +15 -0
  121. package/coverage/errors/errors.mts.html +898 -0
  122. package/coverage/errors/index.html +131 -0
  123. package/coverage/errors/index.mts.html +88 -0
  124. package/coverage/favicon.png +0 -0
  125. package/coverage/http/http-method.mts.html +112 -0
  126. package/coverage/http/http-status-code.mts.html +211 -0
  127. package/coverage/http/index.html +146 -0
  128. package/coverage/http/index.mts.html +91 -0
  129. package/coverage/index.html +191 -0
  130. package/coverage/lang/index.html +146 -0
  131. package/coverage/lang/index.mts.html +91 -0
  132. package/coverage/lang/sleep.mts.html +109 -0
  133. package/coverage/lang/type-functions.mts.html +124 -0
  134. package/coverage/oauth/crypto-functions.mts.html +217 -0
  135. package/coverage/oauth/index.html +131 -0
  136. package/coverage/oauth/index.mts.html +88 -0
  137. package/coverage/prettify.css +1 -0
  138. package/coverage/sort-arrow-sprite.png +0 -0
  139. package/coverage/validator/index.html +131 -0
  140. package/coverage/validator/index.mts.html +88 -0
  141. package/coverage/validator/validators.mts.html +1237 -0
  142. package/dist/package.json +72 -0
  143. package/node_modules/@eslint/eslintrc/LICENSE +19 -0
  144. package/node_modules/@eslint/eslintrc/README.md +115 -0
  145. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs +1104 -0
  146. package/node_modules/@eslint/eslintrc/dist/eslintrc-universal.cjs.map +1 -0
  147. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs +4344 -0
  148. package/node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map +1 -0
  149. package/node_modules/@eslint/eslintrc/package.json +82 -0
  150. package/node_modules/@eslint/eslintrc/universal.js +9 -0
  151. package/node_modules/@eslint/js/LICENSE +19 -0
  152. package/node_modules/@eslint/js/README.md +57 -0
  153. package/node_modules/@eslint/js/package.json +31 -0
  154. package/node_modules/@eslint/js/src/index.js +17 -0
  155. package/node_modules/@eslint-community/eslint-utils/LICENSE +21 -0
  156. package/node_modules/@eslint-community/eslint-utils/README.md +37 -0
  157. package/node_modules/@eslint-community/eslint-utils/index.js +2068 -0
  158. package/node_modules/@eslint-community/eslint-utils/index.js.map +1 -0
  159. package/node_modules/@eslint-community/eslint-utils/index.mjs +2027 -0
  160. package/node_modules/@eslint-community/eslint-utils/index.mjs.map +1 -0
  161. package/node_modules/@eslint-community/eslint-utils/package.json +73 -0
  162. package/node_modules/@eslint-community/regexpp/LICENSE +21 -0
  163. package/node_modules/@eslint-community/regexpp/README.md +177 -0
  164. package/node_modules/@eslint-community/regexpp/index.d.ts +1065 -0
  165. package/node_modules/@eslint-community/regexpp/index.js +2747 -0
  166. package/node_modules/@eslint-community/regexpp/index.js.map +1 -0
  167. package/node_modules/@eslint-community/regexpp/index.mjs +2737 -0
  168. package/node_modules/@eslint-community/regexpp/index.mjs.map +1 -0
  169. package/node_modules/@eslint-community/regexpp/package.json +93 -0
  170. package/node_modules/@types/node/LICENSE +21 -0
  171. package/node_modules/@types/node/README.md +15 -0
  172. package/node_modules/@types/node/package.json +217 -0
  173. package/node_modules/@typescript-eslint/eslint-plugin/LICENSE +21 -0
  174. package/node_modules/@typescript-eslint/eslint-plugin/README.md +10 -0
  175. package/node_modules/@typescript-eslint/eslint-plugin/dist/index.js +23 -0
  176. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/README.md +23 -0
  177. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/TEMPLATE.md +26 -0
  178. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/adjacent-overload-signatures.md +93 -0
  179. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/array-type.md +103 -0
  180. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/await-thenable.md +40 -0
  181. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-ts-comment.md +148 -0
  182. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-tslint-comment.md +39 -0
  183. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/ban-types.md +183 -0
  184. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/block-spacing.md +12 -0
  185. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/brace-style.md +12 -0
  186. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/camelcase.md +10 -0
  187. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/class-literal-property-style.md +114 -0
  188. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-dangle.md +22 -0
  189. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/comma-spacing.md +12 -0
  190. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-generic-constructors.md +73 -0
  191. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-indexed-object-style.md +80 -0
  192. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-assertions.md +108 -0
  193. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-definitions.md +82 -0
  194. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-exports.md +100 -0
  195. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/consistent-type-imports.md +105 -0
  196. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/default-param-last.md +48 -0
  197. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/dot-notation.md +77 -0
  198. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-function-return-type.md +319 -0
  199. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-member-accessibility.md +331 -0
  200. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/explicit-module-boundary-types.md +250 -0
  201. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/func-call-spacing.md +12 -0
  202. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/indent.md +20 -0
  203. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/init-declarations.md +12 -0
  204. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/key-spacing.md +12 -0
  205. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/keyword-spacing.md +12 -0
  206. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/lines-around-comment.md +37 -0
  207. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/lines-between-class-members.md +63 -0
  208. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-delimiter-style.md +161 -0
  209. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/member-ordering.md +1360 -0
  210. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/method-signature-style.md +110 -0
  211. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/naming-convention.md +706 -0
  212. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-array-constructor.md +35 -0
  213. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-base-to-string.md +88 -0
  214. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-non-null-assertion.md +56 -0
  215. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-confusing-void-expression.md +116 -0
  216. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dupe-class-members.md +12 -0
  217. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-enum-values.md +50 -0
  218. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-imports.md +12 -0
  219. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-duplicate-type-constituents.md +61 -0
  220. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-dynamic-delete.md +53 -0
  221. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-function.md +88 -0
  222. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-empty-interface.md +70 -0
  223. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-explicit-any.md +174 -0
  224. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-non-null-assertion.md +52 -0
  225. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-parens.md +12 -0
  226. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extra-semi.md +12 -0
  227. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-extraneous-class.md +294 -0
  228. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-floating-promises.md +106 -0
  229. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-for-in-array.md +56 -0
  230. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implicit-any-catch.md +73 -0
  231. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-implied-eval.md +101 -0
  232. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-import-type-side-effects.md +75 -0
  233. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-inferrable-types.md +103 -0
  234. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-this.md +12 -0
  235. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-invalid-void-type.md +113 -0
  236. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loop-func.md +12 -0
  237. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-loss-of-precision.md +12 -0
  238. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-magic-numbers.md +131 -0
  239. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-meaningless-void-operator.md +47 -0
  240. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-new.md +46 -0
  241. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-misused-promises.md +245 -0
  242. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-mixed-enums.md +88 -0
  243. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-namespace.md +129 -0
  244. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-nullish-coalescing.md +49 -0
  245. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-asserted-optional-chain.md +35 -0
  246. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-non-null-assertion.md +42 -0
  247. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-parameter-properties.md +406 -0
  248. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redeclare.md +73 -0
  249. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-redundant-type-constituents.md +78 -0
  250. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-require-imports.md +37 -0
  251. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-restricted-imports.md +63 -0
  252. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-shadow.md +101 -0
  253. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-this-alias.md +38 -0
  254. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-throw-literal.md +111 -0
  255. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-type-alias.md +602 -0
  256. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-boolean-literal-compare.md +133 -0
  257. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-condition.md +103 -0
  258. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-qualifier.md +51 -0
  259. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-arguments.md +73 -0
  260. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-assertion.md +77 -0
  261. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unnecessary-type-constraint.md +55 -0
  262. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-argument.md +83 -0
  263. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-assignment.md +86 -0
  264. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-call.md +58 -0
  265. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-declaration-merging.md +54 -0
  266. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-enum-comparison.md +75 -0
  267. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-member-access.md +64 -0
  268. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unsafe-return.md +103 -0
  269. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-expressions.md +12 -0
  270. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-unused-vars.md +12 -0
  271. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-use-before-define.md +97 -0
  272. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-constructor.md +21 -0
  273. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-useless-empty-export.md +43 -0
  274. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/no-var-requires.md +37 -0
  275. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/non-nullable-type-assertion-style.md +41 -0
  276. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/object-curly-spacing.md +12 -0
  277. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/padding-line-between-statements.md +35 -0
  278. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/parameter-properties.md +485 -0
  279. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-as-const.md +44 -0
  280. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-enum-initializers.md +62 -0
  281. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-for-of.md +46 -0
  282. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-function-type.md +92 -0
  283. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-includes.md +77 -0
  284. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-literal-enum-member.md +101 -0
  285. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-namespace-keyword.md +47 -0
  286. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-nullish-coalescing.md +164 -0
  287. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-optional-chain.md +71 -0
  288. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly-parameter-types.md +268 -0
  289. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-readonly.md +87 -0
  290. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-reduce-type-parameter.md +58 -0
  291. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-regexp-exec.md +46 -0
  292. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-return-this-type.md +87 -0
  293. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-string-starts-ends-with.md +57 -0
  294. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/prefer-ts-expect-error.md +69 -0
  295. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/promise-function-async.md +59 -0
  296. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/quotes.md +12 -0
  297. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-array-sort-compare.md +78 -0
  298. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/require-await.md +24 -0
  299. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-plus-operands.md +208 -0
  300. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/restrict-template-expressions.md +117 -0
  301. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/return-await.md +216 -0
  302. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/semi.md +16 -0
  303. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/sort-type-constituents.md +101 -0
  304. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/sort-type-union-intersection-members.md +106 -0
  305. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-blocks.md +42 -0
  306. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-before-function-paren.md +12 -0
  307. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/space-infix-ops.md +16 -0
  308. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/strict-boolean-expressions.md +183 -0
  309. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/switch-exhaustiveness-check.md +106 -0
  310. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/triple-slash-reference.md +61 -0
  311. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/type-annotation-spacing.md +303 -0
  312. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/typedef.md +320 -0
  313. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unbound-method.md +103 -0
  314. package/node_modules/@typescript-eslint/eslint-plugin/docs/rules/unified-signatures.md +70 -0
  315. package/node_modules/@typescript-eslint/eslint-plugin/index.d.ts +4 -0
  316. package/node_modules/@typescript-eslint/eslint-plugin/package.json +87 -0
  317. package/node_modules/@typescript-eslint/parser/LICENSE +22 -0
  318. package/node_modules/@typescript-eslint/parser/README.md +10 -0
  319. package/node_modules/@typescript-eslint/parser/dist/index.js +17 -0
  320. package/node_modules/@typescript-eslint/parser/package.json +75 -0
  321. package/node_modules/@typescript-eslint/scope-manager/LICENSE +21 -0
  322. package/node_modules/@typescript-eslint/scope-manager/README.md +8 -0
  323. package/node_modules/@typescript-eslint/scope-manager/dist/index.js +31 -0
  324. package/node_modules/@typescript-eslint/scope-manager/package.json +67 -0
  325. package/node_modules/@typescript-eslint/type-utils/LICENSE +21 -0
  326. package/node_modules/@typescript-eslint/type-utils/README.md +12 -0
  327. package/node_modules/@typescript-eslint/type-utils/dist/index.js +36 -0
  328. package/node_modules/@typescript-eslint/type-utils/package.json +71 -0
  329. package/node_modules/@typescript-eslint/types/LICENSE +21 -0
  330. package/node_modules/@typescript-eslint/types/README.md +12 -0
  331. package/node_modules/@typescript-eslint/types/dist/index.js +24 -0
  332. package/node_modules/@typescript-eslint/types/package.json +84 -0
  333. package/node_modules/@typescript-eslint/typescript-estree/LICENSE +26 -0
  334. package/node_modules/@typescript-eslint/typescript-estree/README.md +10 -0
  335. package/node_modules/@typescript-eslint/typescript-estree/dist/index.js +38 -0
  336. package/node_modules/@typescript-eslint/typescript-estree/package.json +85 -0
  337. package/node_modules/@typescript-eslint/utils/LICENSE +21 -0
  338. package/node_modules/@typescript-eslint/utils/README.md +10 -0
  339. package/node_modules/@typescript-eslint/utils/dist/index.js +41 -0
  340. package/node_modules/@typescript-eslint/utils/package.json +70 -0
  341. package/node_modules/@typescript-eslint/visitor-keys/LICENSE +21 -0
  342. package/node_modules/@typescript-eslint/visitor-keys/README.md +10 -0
  343. package/node_modules/@typescript-eslint/visitor-keys/dist/index.js +8 -0
  344. package/node_modules/@typescript-eslint/visitor-keys/package.json +60 -0
  345. package/node_modules/@vitest/coverage-v8/LICENSE +21 -0
  346. package/node_modules/@vitest/coverage-v8/dist/index.js +54 -0
  347. package/node_modules/@vitest/coverage-v8/package.json +72 -0
  348. package/package.json +6 -6
  349. package/pnpm-lock.yaml +3277 -0
  350. package/src/bitsnbytes/b64.mts +158 -0
  351. package/src/bitsnbytes/b64.test.mts +78 -0
  352. package/src/bitsnbytes/index.mts +1 -0
  353. package/src/errors/errors.mts +271 -0
  354. package/src/errors/errors.test.mts +74 -0
  355. package/src/errors/index.mts +1 -0
  356. package/src/http/http-method.mts +9 -0
  357. package/src/http/http-status-code.mts +42 -0
  358. package/src/http/index.mts +2 -0
  359. package/src/lang/index.mts +2 -0
  360. package/src/lang/sleep.mts +8 -0
  361. package/src/lang/type-functions.mts +13 -0
  362. package/src/oauth/crypto-functions.mts +44 -0
  363. package/src/oauth/crypto-functions.test.mts +48 -0
  364. package/src/oauth/index.mts +1 -0
  365. package/src/validator/index.mts +1 -0
  366. package/src/validator/validators.mts +384 -0
  367. package/src/validator/validators.test.mts +245 -0
  368. package/tsconfig.json +18 -0
  369. /package/{bitsnbytes → dist/bitsnbytes}/b64.d.mts +0 -0
  370. /package/{bitsnbytes → dist/bitsnbytes}/b64.d.mts.map +0 -0
  371. /package/{bitsnbytes → dist/bitsnbytes}/b64.mjs +0 -0
  372. /package/{bitsnbytes → dist/bitsnbytes}/b64.mjs.map +0 -0
  373. /package/{bitsnbytes → dist/bitsnbytes}/b64.test.d.mts +0 -0
  374. /package/{bitsnbytes → dist/bitsnbytes}/b64.test.d.mts.map +0 -0
  375. /package/{bitsnbytes → dist/bitsnbytes}/b64.test.mjs +0 -0
  376. /package/{bitsnbytes → dist/bitsnbytes}/b64.test.mjs.map +0 -0
  377. /package/{bitsnbytes → dist/bitsnbytes}/index.d.mts +0 -0
  378. /package/{bitsnbytes → dist/bitsnbytes}/index.d.mts.map +0 -0
  379. /package/{bitsnbytes → dist/bitsnbytes}/index.mjs +0 -0
  380. /package/{bitsnbytes → dist/bitsnbytes}/index.mjs.map +0 -0
  381. /package/{errors → dist/errors}/errors.d.mts +0 -0
  382. /package/{errors → dist/errors}/errors.d.mts.map +0 -0
  383. /package/{errors → dist/errors}/errors.mjs +0 -0
  384. /package/{errors → dist/errors}/errors.mjs.map +0 -0
  385. /package/{errors → dist/errors}/errors.test.d.mts +0 -0
  386. /package/{errors → dist/errors}/errors.test.d.mts.map +0 -0
  387. /package/{errors → dist/errors}/errors.test.mjs +0 -0
  388. /package/{errors → dist/errors}/errors.test.mjs.map +0 -0
  389. /package/{errors → dist/errors}/index.d.mts +0 -0
  390. /package/{errors → dist/errors}/index.d.mts.map +0 -0
  391. /package/{errors → dist/errors}/index.mjs +0 -0
  392. /package/{errors → dist/errors}/index.mjs.map +0 -0
  393. /package/{http → dist/http}/http-method.d.mts +0 -0
  394. /package/{http → dist/http}/http-method.d.mts.map +0 -0
  395. /package/{http → dist/http}/http-method.mjs +0 -0
  396. /package/{http → dist/http}/http-method.mjs.map +0 -0
  397. /package/{http → dist/http}/http-status-code.d.mts +0 -0
  398. /package/{http → dist/http}/http-status-code.d.mts.map +0 -0
  399. /package/{http → dist/http}/http-status-code.mjs +0 -0
  400. /package/{http → dist/http}/http-status-code.mjs.map +0 -0
  401. /package/{http → dist/http}/index.d.mts +0 -0
  402. /package/{http → dist/http}/index.d.mts.map +0 -0
  403. /package/{http → dist/http}/index.mjs +0 -0
  404. /package/{http → dist/http}/index.mjs.map +0 -0
  405. /package/{lang → dist/lang}/index.d.mts +0 -0
  406. /package/{lang → dist/lang}/index.d.mts.map +0 -0
  407. /package/{lang → dist/lang}/index.mjs +0 -0
  408. /package/{lang → dist/lang}/index.mjs.map +0 -0
  409. /package/{lang → dist/lang}/sleep.d.mts +0 -0
  410. /package/{lang → dist/lang}/sleep.d.mts.map +0 -0
  411. /package/{lang → dist/lang}/sleep.mjs +0 -0
  412. /package/{lang → dist/lang}/sleep.mjs.map +0 -0
  413. /package/{lang → dist/lang}/type-functions.d.mts +0 -0
  414. /package/{lang → dist/lang}/type-functions.d.mts.map +0 -0
  415. /package/{lang → dist/lang}/type-functions.mjs +0 -0
  416. /package/{lang → dist/lang}/type-functions.mjs.map +0 -0
  417. /package/{oauth → dist/oauth}/crypto-functions.d.mts +0 -0
  418. /package/{oauth → dist/oauth}/crypto-functions.d.mts.map +0 -0
  419. /package/{oauth → dist/oauth}/crypto-functions.mjs +0 -0
  420. /package/{oauth → dist/oauth}/crypto-functions.mjs.map +0 -0
  421. /package/{oauth → dist/oauth}/crypto-functions.test.d.mts +0 -0
  422. /package/{oauth → dist/oauth}/crypto-functions.test.d.mts.map +0 -0
  423. /package/{oauth → dist/oauth}/crypto-functions.test.mjs +0 -0
  424. /package/{oauth → dist/oauth}/crypto-functions.test.mjs.map +0 -0
  425. /package/{oauth → dist/oauth}/index.d.mts +0 -0
  426. /package/{oauth → dist/oauth}/index.d.mts.map +0 -0
  427. /package/{oauth → dist/oauth}/index.mjs +0 -0
  428. /package/{oauth → dist/oauth}/index.mjs.map +0 -0
  429. /package/{validator → dist/validator}/index.d.mts +0 -0
  430. /package/{validator → dist/validator}/index.d.mts.map +0 -0
  431. /package/{validator → dist/validator}/index.mjs +0 -0
  432. /package/{validator → dist/validator}/index.mjs.map +0 -0
  433. /package/{validator → dist/validator}/validators.d.mts +0 -0
  434. /package/{validator → dist/validator}/validators.d.mts.map +0 -0
  435. /package/{validator → dist/validator}/validators.mjs +0 -0
  436. /package/{validator → dist/validator}/validators.mjs.map +0 -0
  437. /package/{validator → dist/validator}/validators.test.d.mts +0 -0
  438. /package/{validator → dist/validator}/validators.test.d.mts.map +0 -0
  439. /package/{validator → dist/validator}/validators.test.mjs +0 -0
  440. /package/{validator → dist/validator}/validators.test.mjs.map +0 -0
@@ -0,0 +1,114 @@
1
+ ---
2
+ description: 'Enforce that literals on classes are exposed in a consistent style.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/class-literal-property-style** for documentation.
8
+
9
+ Some TypeScript applications store literal values on classes using fields with the `readonly` modifier to prevent them from being reassigned.
10
+ When writing TypeScript libraries that could be used by JavaScript users, however, it's typically safer to expose these literals using `getter`s, since the `readonly` modifier is enforced at compile type.
11
+
12
+ This rule aims to ensure that literals exposed by classes are done so consistently, in one of the two style described above.
13
+ By default this rule prefers the `fields` style as it means JS doesn't have to setup & teardown a function closure.
14
+
15
+ ## Options
16
+
17
+ :::note
18
+
19
+ This rule only checks for constant _literal_ values (string, template string, number, bigint, boolean, regexp, null). It does not check objects or arrays, because a readonly field behaves differently to a getter in those cases. It also does not check functions, as it is a common pattern to use readonly fields with arrow function values as auto-bound methods.
20
+ This is because these types can be mutated and carry with them more complex implications about their usage.
21
+
22
+ :::
23
+
24
+ ### `"fields"`
25
+
26
+ This style checks for any getter methods that return literal values, and requires them to be defined using fields with the `readonly` modifier instead.
27
+
28
+ Examples of code with the `fields` style:
29
+
30
+ <!--tabs-->
31
+
32
+ #### ❌ Incorrect
33
+
34
+ ```ts
35
+ /* eslint @typescript-eslint/class-literal-property-style: ["error", "fields"] */
36
+
37
+ class Mx {
38
+ public static get myField1() {
39
+ return 1;
40
+ }
41
+
42
+ private get ['myField2']() {
43
+ return 'hello world';
44
+ }
45
+ }
46
+ ```
47
+
48
+ #### ✅ Correct
49
+
50
+ ```ts
51
+ /* eslint @typescript-eslint/class-literal-property-style: ["error", "fields"] */
52
+
53
+ class Mx {
54
+ public readonly myField1 = 1;
55
+
56
+ // not a literal
57
+ public readonly myField2 = [1, 2, 3];
58
+
59
+ private readonly ['myField3'] = 'hello world';
60
+
61
+ public get myField4() {
62
+ return `hello from ${window.location.href}`;
63
+ }
64
+ }
65
+ ```
66
+
67
+ ### `"getters"`
68
+
69
+ This style checks for any `readonly` fields that are assigned literal values, and requires them to be defined as getters instead.
70
+ This style pairs well with the [`@typescript-eslint/prefer-readonly`](prefer-readonly.md) rule,
71
+ as it will identify fields that can be `readonly`, and thus should be made into getters.
72
+
73
+ Examples of code with the `getters` style:
74
+
75
+ <!--tabs-->
76
+
77
+ #### ❌ Incorrect
78
+
79
+ ```ts
80
+ /* eslint @typescript-eslint/class-literal-property-style: ["error", "getters"] */
81
+
82
+ class Mx {
83
+ readonly myField1 = 1;
84
+ readonly myField2 = `hello world`;
85
+ private readonly myField3 = 'hello world';
86
+ }
87
+ ```
88
+
89
+ #### ✅ Correct
90
+
91
+ ```ts
92
+ /* eslint @typescript-eslint/class-literal-property-style: ["error", "getters"] */
93
+
94
+ class Mx {
95
+ // no readonly modifier
96
+ public myField1 = 'hello';
97
+
98
+ // not a literal
99
+ public readonly myField2 = [1, 2, 3];
100
+
101
+ public static get myField3() {
102
+ return 1;
103
+ }
104
+
105
+ private get ['myField4']() {
106
+ return 'hello world';
107
+ }
108
+ }
109
+ ```
110
+
111
+ ## When Not To Use It
112
+
113
+ When you have no strong preference, or do not wish to enforce a particular style
114
+ for how literal values are exposed by your classes.
@@ -0,0 +1,22 @@
1
+ ---
2
+ description: 'Require or disallow trailing commas.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/comma-dangle** for documentation.
8
+
9
+ ## Examples
10
+
11
+ This rule extends the base [`eslint/comma-dangle`](https://eslint.org/docs/rules/comma-dangle) rule.
12
+ It adds support for TypeScript syntax.
13
+
14
+ See the [ESLint documentation](https://eslint.org/docs/rules/comma-dangle) for more details on the `comma-dangle` rule.
15
+
16
+ ## How to Use
17
+
18
+ In addition to the options supported by the `comma-dangle` rule in ESLint core, the rule adds the following options:
19
+
20
+ - `"enums"` is for trailing comma in enum. (e.g. `enum Foo = {Bar,}`)
21
+ - `"generics"` is for trailing comma in generic. (e.g. `function foo<T,>() {}`)
22
+ - `"tuples"` is for trailing comma in tuple. (e.g. `type Foo = [string,]`)
@@ -0,0 +1,12 @@
1
+ ---
2
+ description: 'Enforce consistent spacing before and after commas.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/comma-spacing** for documentation.
8
+
9
+ ## Examples
10
+
11
+ This rule extends the base [`eslint/comma-spacing`](https://eslint.org/docs/rules/comma-spacing) rule.
12
+ It adds support for trailing comma in a types parameters list.
@@ -0,0 +1,73 @@
1
+ ---
2
+ description: 'Enforce specifying generic type arguments on type annotation or constructor name of a constructor call.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/consistent-generic-constructors** for documentation.
8
+
9
+ When constructing a generic class, you can specify the type arguments on either the left-hand side (as a type annotation) or the right-hand side (as part of the constructor call):
10
+
11
+ ```ts
12
+ // Left-hand side
13
+ const map: Map<string, number> = new Map();
14
+
15
+ // Right-hand side
16
+ const map = new Map<string, number>();
17
+ ```
18
+
19
+ This rule ensures that type arguments appear consistently on one side of the declaration.
20
+ Keeping to one side consistently improve code readability.
21
+
22
+ > The rule never reports when there are type parameters on both sides, or neither sides of the declaration.
23
+ > It also doesn't report if the names of the type annotation and the constructor don't match.
24
+
25
+ ## Options
26
+
27
+ - `constructor` _(default)_: type arguments that **only** appear on the type annotation are disallowed.
28
+ - `type-annotation`: type arguments that **only** appear on the constructor are disallowed.
29
+
30
+ ### `constructor`
31
+
32
+ <!--tabs-->
33
+
34
+ #### ❌ Incorrect
35
+
36
+ ```ts
37
+ const map: Map<string, number> = new Map();
38
+ const set: Set<string> = new Set();
39
+ ```
40
+
41
+ #### ✅ Correct
42
+
43
+ ```ts
44
+ const map = new Map<string, number>();
45
+ const map: Map<string, number> = new MyMap();
46
+ const set = new Set<string>();
47
+ const set = new Set();
48
+ const set: Set<string> = new Set<string>();
49
+ ```
50
+
51
+ ### `type-annotation`
52
+
53
+ <!--tabs-->
54
+
55
+ #### ❌ Incorrect
56
+
57
+ ```ts
58
+ const map = new Map<string, number>();
59
+ const set = new Set<string>();
60
+ ```
61
+
62
+ #### ✅ Correct
63
+
64
+ ```ts
65
+ const map: Map<string, number> = new Map();
66
+ const set: Set<string> = new Set();
67
+ const set = new Set();
68
+ const set: Set<string> = new Set<string>();
69
+ ```
70
+
71
+ ## When Not To Use It
72
+
73
+ You can turn this rule off if you don't want to enforce one kind of generic constructor style over the other.
@@ -0,0 +1,80 @@
1
+ ---
2
+ description: 'Require or disallow the `Record` type.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/consistent-indexed-object-style** for documentation.
8
+
9
+ TypeScript supports defining arbitrary object keys using an index signature. TypeScript also has a builtin type named `Record` to create an empty object defining only an index signature. For example, the following types are equal:
10
+
11
+ ```ts
12
+ interface Foo {
13
+ [key: string]: unknown;
14
+ }
15
+
16
+ type Foo = {
17
+ [key: string]: unknown;
18
+ };
19
+
20
+ type Foo = Record<string, unknown>;
21
+ ```
22
+
23
+ Keeping to one declaration form consistently improve code readability.
24
+
25
+ ## Options
26
+
27
+ - `"record"` _(default)_: only allow the `Record` type.
28
+ - `"index-signature"`: only allow index signatures.
29
+
30
+ ### `record`
31
+
32
+ <!--tabs-->
33
+
34
+ #### ❌ Incorrect
35
+
36
+ ```ts
37
+ /* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "record"] */
38
+
39
+ interface Foo {
40
+ [key: string]: unknown;
41
+ }
42
+
43
+ type Foo = {
44
+ [key: string]: unknown;
45
+ };
46
+ ```
47
+
48
+ #### ✅ Correct
49
+
50
+ ```ts
51
+ /* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "record"] */
52
+
53
+ type Foo = Record<string, unknown>;
54
+ ```
55
+
56
+ ### `index-signature`
57
+
58
+ <!--tabs-->
59
+
60
+ #### ❌ Incorrect
61
+
62
+ ```ts
63
+ /* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "index-signature"] */
64
+
65
+ type Foo = Record<string, unknown>;
66
+ ```
67
+
68
+ #### ✅ Correct
69
+
70
+ ```ts
71
+ /* eslint @typescript-eslint/consistent-indexed-object-style: ["error", "index-signature"] */
72
+
73
+ interface Foo {
74
+ [key: string]: unknown;
75
+ }
76
+
77
+ type Foo = {
78
+ [key: string]: unknown;
79
+ };
80
+ ```
@@ -0,0 +1,108 @@
1
+ ---
2
+ description: 'Enforce consistent usage of type assertions.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/consistent-type-assertions** for documentation.
8
+
9
+ TypeScript provides two syntaxes for "type assertions":
10
+
11
+ - Angle brackets: `<Type>value`
12
+ - As: `value as Type`
13
+
14
+ This rule aims to standardize the use of type assertion style across the codebase.
15
+ Keeping to one syntax consistently helps with code readability.
16
+
17
+ :::note
18
+ Type assertions are also commonly referred as "type casting" in TypeScript.
19
+ However, that term is technically slightly different to what is understood by type casting in other languages.
20
+ Type assertions are a way to say to the TypeScript compiler, _"I know better than you, it's actually this different type!"_.
21
+ :::
22
+
23
+ [`const` assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) are always allowed by this rule.
24
+ Examples of them include `let x = "hello" as const;` and `let x = <const>"hello";`.
25
+
26
+ ## Options
27
+
28
+ ### `assertionStyle`
29
+
30
+ This option defines the expected assertion style. Valid values for `assertionStyle` are:
31
+
32
+ - `as` will enforce that you always use `... as foo`.
33
+ - `angle-bracket` will enforce that you always use `<foo>...`
34
+ - `never` will enforce that you do not do any type assertions.
35
+
36
+ Most codebases will want to enforce not using `angle-bracket` style because it conflicts with JSX syntax, and is confusing when paired with generic syntax.
37
+
38
+ Some codebases like to go for an extra level of type safety, and ban assertions altogether via the `never` option.
39
+
40
+ ### `objectLiteralTypeAssertions`
41
+
42
+ Always prefer `const x: T = { ... };` to `const x = { ... } as T;` (or similar with angle brackets). The type assertion in the latter case is either unnecessary or will probably hide an error.
43
+
44
+ The compiler will warn for excess properties with this syntax, but not missing _required_ fields. For example: `const x: { foo: number } = {};` will fail to compile, but `const x = {} as { foo: number }` will succeed.
45
+
46
+ The const assertion `const x = { foo: 1 } as const`, introduced in TypeScript 3.4, is considered beneficial and is ignored by this option.
47
+
48
+ Assertions to `any` are also ignored by this option.
49
+
50
+ Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'never' }`:
51
+
52
+ <!--tabs-->
53
+
54
+ #### ❌ Incorrect
55
+
56
+ ```ts
57
+ const x = { ... } as T;
58
+
59
+ function foo() {
60
+ return { ... } as T;
61
+ }
62
+ ```
63
+
64
+ #### ✅ Correct
65
+
66
+ ```ts
67
+ const x: T = { ... };
68
+ const y = { ... } as any;
69
+ const z = { ... } as unknown;
70
+
71
+ function foo(): T {
72
+ return { ... };
73
+ }
74
+ ```
75
+
76
+ <!--/tabs-->
77
+
78
+ Examples of code for `{ assertionStyle: 'as', objectLiteralTypeAssertions: 'allow-as-parameter' }`:
79
+
80
+ <!--tabs-->
81
+
82
+ #### ❌ Incorrect
83
+
84
+ ```ts
85
+ const x = { ... } as T;
86
+
87
+ function foo() {
88
+ return { ... } as T;
89
+ }
90
+ ```
91
+
92
+ #### ✅ Correct
93
+
94
+ ```tsx
95
+ const x: T = { ... };
96
+ const y = { ... } as any;
97
+ const z = { ... } as unknown;
98
+ foo({ ... } as T);
99
+ new Clazz({ ... } as T);
100
+ function foo() { throw { bar: 5 } as Foo }
101
+ const foo = <Foo props={{ ... } as Bar}/>;
102
+ ```
103
+
104
+ <!--/tabs-->
105
+
106
+ ## When Not To Use It
107
+
108
+ If you do not want to enforce consistent type assertions.
@@ -0,0 +1,82 @@
1
+ ---
2
+ description: 'Enforce type definitions to consistently use either `interface` or `type`.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/consistent-type-definitions** for documentation.
8
+
9
+ TypeScript provides two common ways to define an object type: `interface` and `type`.
10
+
11
+ ```ts
12
+ // type alias
13
+ type T1 = {
14
+ a: string;
15
+ b: number;
16
+ };
17
+
18
+ // interface keyword
19
+ interface T2 {
20
+ a: string;
21
+ b: number;
22
+ }
23
+ ```
24
+
25
+ The two are generally very similar, and can often be used interchangeably.
26
+ Using the same type declaration style consistently helps with code readability.
27
+
28
+ ## Options
29
+
30
+ - `"interface"` _(default)_: enforce using `interface`s for object type definitions.
31
+ - `"type"`: enforce using `type`s for object type definitions.
32
+
33
+ ### `interface`
34
+
35
+ <!--tabs-->
36
+
37
+ #### ❌ Incorrect
38
+
39
+ ```ts
40
+ /* eslint @typescript-eslint/consistent-type-definitions: ["error", "interface"] */
41
+
42
+ type T = { x: number };
43
+ ```
44
+
45
+ #### ✅ Correct
46
+
47
+ ```ts
48
+ /* eslint @typescript-eslint/consistent-type-definitions: ["error", "interface"] */
49
+
50
+ type T = string;
51
+ type Foo = string | {};
52
+
53
+ interface T {
54
+ x: number;
55
+ }
56
+ ```
57
+
58
+ ### `type`
59
+
60
+ <!--tabs-->
61
+
62
+ #### ❌ Incorrect
63
+
64
+ ```ts
65
+ /* eslint @typescript-eslint/consistent-type-definitions: ["error", "type"] */
66
+
67
+ interface T {
68
+ x: number;
69
+ }
70
+ ```
71
+
72
+ #### ✅ Correct
73
+
74
+ ```ts
75
+ /* eslint @typescript-eslint/consistent-type-definitions: ["error", "type"] */
76
+
77
+ type T = { x: number };
78
+ ```
79
+
80
+ ## When Not To Use It
81
+
82
+ If you specifically want to use an interface or type literal for stylistic reasons, you can disable this rule.
@@ -0,0 +1,100 @@
1
+ ---
2
+ description: 'Enforce consistent usage of type exports.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/consistent-type-exports** for documentation.
8
+
9
+ TypeScript allows specifying a `type` keyword on exports to indicate that the export exists only in the type system, not at runtime.
10
+ This allows transpilers to drop exports without knowing the types of the dependencies.
11
+
12
+ > See [Blog > Consistent Type Exports and Imports: Why and How](/blog/consistent-type-imports-and-exports-why-and-how) for more details.
13
+
14
+ ## Examples
15
+
16
+ <!--tabs-->
17
+
18
+ ### ❌ Incorrect
19
+
20
+ ```ts
21
+ interface ButtonProps {
22
+ onClick: () => void;
23
+ }
24
+
25
+ class Button implements ButtonProps {
26
+ onClick = () => console.log('button!');
27
+ }
28
+
29
+ export { Button, ButtonProps };
30
+ ```
31
+
32
+ ### ✅ Correct
33
+
34
+ ```ts
35
+ interface ButtonProps {
36
+ onClick: () => void;
37
+ }
38
+
39
+ class Button implements ButtonProps {
40
+ onClick = () => console.log('button!');
41
+ }
42
+
43
+ export { Button };
44
+ export type { ButtonProps };
45
+ ```
46
+
47
+ ## Options
48
+
49
+ ### `fixMixedExportsWithInlineTypeSpecifier`
50
+
51
+ When this is set to true, the rule will autofix "mixed" export cases using TS 4.5's "inline type specifier".
52
+ If you are using a TypeScript version less than 4.5, then you will not be able to use this option.
53
+
54
+ For example the following code:
55
+
56
+ ```ts
57
+ const x = 1;
58
+ type T = number;
59
+
60
+ export { x, T };
61
+ ```
62
+
63
+ With `{fixMixedExportsWithInlineTypeSpecifier: true}` will be fixed to:
64
+
65
+ ```ts
66
+ const x = 1;
67
+ type T = number;
68
+
69
+ export { x, type T };
70
+ ```
71
+
72
+ With `{fixMixedExportsWithInlineTypeSpecifier: false}` will be fixed to:
73
+
74
+ ```ts
75
+ const x = 1;
76
+ type T = number;
77
+
78
+ export type { T };
79
+ export { x };
80
+ ```
81
+
82
+ <!--tabs-->
83
+
84
+ ### ❌ Incorrect
85
+
86
+ ```ts
87
+ export { Button } from 'some-library';
88
+ export type { ButtonProps } from 'some-library';
89
+ ```
90
+
91
+ ### ✅ Correct
92
+
93
+ ```ts
94
+ export { Button, type ButtonProps } from 'some-library';
95
+ ```
96
+
97
+ ## When Not To Use It
98
+
99
+ - If you specifically want to use both export kinds for stylistic reasons, you can disable this rule.
100
+ - If you use `--isolatedModules` the compiler would error if a type is not re-exported using `export type`. If you also don't wish to enforce one style over the other, you can disable this rule.
@@ -0,0 +1,105 @@
1
+ ---
2
+ description: 'Enforce consistent usage of type imports.'
3
+ ---
4
+
5
+ > 🛑 This file is source code, not the primary documentation location! 🛑
6
+ >
7
+ > See **https://typescript-eslint.io/rules/consistent-type-imports** for documentation.
8
+
9
+ TypeScript allows specifying a `type` keyword on imports to indicate that the export exists only in the type system, not at runtime.
10
+ This allows transpilers to drop imports without knowing the types of the dependencies.
11
+
12
+ > See [Blog > Consistent Type Exports and Imports: Why and How](/blog/consistent-type-imports-and-exports-why-and-how) for more details.
13
+
14
+ ## Options
15
+
16
+ ### `prefer`
17
+
18
+ This option defines the expected import kind for type-only imports. Valid values for `prefer` are:
19
+
20
+ - `type-imports` will enforce that you always use `import type Foo from '...'` except referenced by metadata of decorators. It is the default.
21
+ - `no-type-imports` will enforce that you always use `import Foo from '...'`.
22
+
23
+ Examples of **correct** code with `{prefer: 'type-imports'}`, and **incorrect** code with `{prefer: 'no-type-imports'}`.
24
+
25
+ ```ts
26
+ import type { Foo } from 'Foo';
27
+ import type Bar from 'Bar';
28
+ type T = Foo;
29
+ const x: Bar = 1;
30
+ ```
31
+
32
+ Examples of **incorrect** code with `{prefer: 'type-imports'}`, and **correct** code with `{prefer: 'no-type-imports'}`.
33
+
34
+ ```ts
35
+ import { Foo } from 'Foo';
36
+ import Bar from 'Bar';
37
+ type T = Foo;
38
+ const x: Bar = 1;
39
+ ```
40
+
41
+ ### `fixStyle`
42
+
43
+ This option defines the expected type modifier to be added when an import is detected as used only in the type position. Valid values for `fixStyle` are:
44
+
45
+ - `separate-type-imports` will add the type keyword after the import keyword `import type { A } from '...'`. It is the default.
46
+ - `inline-type-imports` will inline the type keyword `import { type A } from '...'` and is only available in TypeScript 4.5 and onwards. See [documentation here](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-5.html#type-modifiers-on-import-names 'TypeScript 4.5 documentation on type modifiers and import names').
47
+
48
+ <!--tabs-->
49
+
50
+ #### ❌ Incorrect
51
+
52
+ ```ts
53
+ import { Foo } from 'Foo';
54
+ import Bar from 'Bar';
55
+ type T = Foo;
56
+ const x: Bar = 1;
57
+ ```
58
+
59
+ #### ✅ With `separate-type-imports`
60
+
61
+ ```ts
62
+ import type { Foo } from 'Foo';
63
+ import type Bar from 'Bar';
64
+ type T = Foo;
65
+ const x: Bar = 1;
66
+ ```
67
+
68
+ #### ✅ With `inline-type-imports`
69
+
70
+ ```ts
71
+ import { type Foo } from 'Foo';
72
+ import type Bar from 'Bar';
73
+ type T = Foo;
74
+ const x: Bar = 1;
75
+ ```
76
+
77
+ <!--tabs-->
78
+
79
+ ### `disallowTypeAnnotations`
80
+
81
+ If `true`, type imports in type annotations (`import()`) are not allowed.
82
+ Default is `true`.
83
+
84
+ Examples of **incorrect** code with `{disallowTypeAnnotations: true}`:
85
+
86
+ ```ts
87
+ type T = import('Foo').Foo;
88
+ const x: import('Bar') = 1;
89
+ ```
90
+
91
+ ## Usage with `emitDecoratorMetadata`
92
+
93
+ The `emitDecoratorMetadata` compiler option changes the code the TypeScript emits. In short - it causes TypeScript to create references to value imports when they are used in a type-only location. If you are using `emitDecoratorMetadata` then our tooling will require additional information in order for the rule to work correctly.
94
+
95
+ If you are using [type-aware linting](https://typescript-eslint.io/linting/typed-linting), then you just need to ensure that the `tsconfig.json` you've configured for `parserOptions.project` has `emitDecoratorMetadata` turned on. Otherwise you can explicitly tell our tooling to analyze your code as if the compiler option was turned on [by setting `parserOptions.emitDecoratorMetadata` to `true`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionsemitdecoratormetadata).
96
+
97
+ ## When Not To Use It
98
+
99
+ - If you specifically want to use both import kinds for stylistic reasons, you can disable this rule.
100
+
101
+ ## Related To
102
+
103
+ - [`no-import-type-side-effects`](./no-import-type-side-effects.md)
104
+ - [`import/consistent-type-specifier-style`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/consistent-type-specifier-style.md)
105
+ - [`import/no-duplicates` with `{"prefer-inline": true}`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-duplicates.md#inline-type-imports)