@alexlit/lint-kit 173.2.2 → 174.0.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.
Files changed (418) hide show
  1. package/package.json +1 -1
  2. package/packages/config-eslint/package.json +5 -5
  3. package/packages/config-stylelint/package.json +2 -2
  4. package/scripts/i.sh +2 -1
  5. package/packages/config-stylelint/node_modules/ansi-regex/index.d.ts +0 -33
  6. package/packages/config-stylelint/node_modules/ansi-regex/index.js +0 -14
  7. package/packages/config-stylelint/node_modules/ansi-regex/license +0 -9
  8. package/packages/config-stylelint/node_modules/ansi-regex/package.json +0 -61
  9. package/packages/config-stylelint/node_modules/ansi-regex/readme.md +0 -66
  10. package/packages/config-stylelint/node_modules/balanced-match/CODE_OF_CONDUCT.md +0 -128
  11. package/packages/config-stylelint/node_modules/balanced-match/LICENSE.md +0 -21
  12. package/packages/config-stylelint/node_modules/balanced-match/README.md +0 -95
  13. package/packages/config-stylelint/node_modules/balanced-match/index.js +0 -75
  14. package/packages/config-stylelint/node_modules/balanced-match/package.json +0 -55
  15. package/packages/config-stylelint/node_modules/file-entry-cache/LICENSE +0 -19
  16. package/packages/config-stylelint/node_modules/file-entry-cache/README.md +0 -630
  17. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.cjs +0 -559
  18. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.d.cts +0 -304
  19. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.d.ts +0 -304
  20. package/packages/config-stylelint/node_modules/file-entry-cache/dist/index.js +0 -525
  21. package/packages/config-stylelint/node_modules/file-entry-cache/package.json +0 -62
  22. package/packages/config-stylelint/node_modules/flat-cache/LICENSE +0 -19
  23. package/packages/config-stylelint/node_modules/flat-cache/README.md +0 -235
  24. package/packages/config-stylelint/node_modules/flat-cache/dist/index.cjs +0 -495
  25. package/packages/config-stylelint/node_modules/flat-cache/dist/index.d.cts +0 -255
  26. package/packages/config-stylelint/node_modules/flat-cache/dist/index.d.ts +0 -255
  27. package/packages/config-stylelint/node_modules/flat-cache/dist/index.js +0 -455
  28. package/packages/config-stylelint/node_modules/flat-cache/package.json +0 -87
  29. package/packages/config-stylelint/node_modules/globby/ignore.js +0 -337
  30. package/packages/config-stylelint/node_modules/globby/index.d.ts +0 -394
  31. package/packages/config-stylelint/node_modules/globby/index.js +0 -468
  32. package/packages/config-stylelint/node_modules/globby/license +0 -9
  33. package/packages/config-stylelint/node_modules/globby/package.json +0 -94
  34. package/packages/config-stylelint/node_modules/globby/readme.md +0 -388
  35. package/packages/config-stylelint/node_modules/globby/utilities.js +0 -299
  36. package/packages/config-stylelint/node_modules/meow/build/dependencies.js +0 -9521
  37. package/packages/config-stylelint/node_modules/meow/build/index.d.ts +0 -2432
  38. package/packages/config-stylelint/node_modules/meow/build/index.js +0 -95
  39. package/packages/config-stylelint/node_modules/meow/build/licenses.md +0 -1254
  40. package/packages/config-stylelint/node_modules/meow/build/options.js +0 -97
  41. package/packages/config-stylelint/node_modules/meow/build/parser.js +0 -81
  42. package/packages/config-stylelint/node_modules/meow/build/utils.js +0 -7
  43. package/packages/config-stylelint/node_modules/meow/build/validate.js +0 -122
  44. package/packages/config-stylelint/node_modules/meow/license +0 -9
  45. package/packages/config-stylelint/node_modules/meow/package.json +0 -103
  46. package/packages/config-stylelint/node_modules/meow/readme.md +0 -314
  47. package/packages/config-stylelint/node_modules/postcss-safe-parser/LICENSE +0 -20
  48. package/packages/config-stylelint/node_modules/postcss-safe-parser/README.md +0 -25
  49. package/packages/config-stylelint/node_modules/postcss-safe-parser/lib/safe-parse.js +0 -12
  50. package/packages/config-stylelint/node_modules/postcss-safe-parser/lib/safe-parser.js +0 -100
  51. package/packages/config-stylelint/node_modules/postcss-safe-parser/package.json +0 -36
  52. package/packages/config-stylelint/node_modules/slash/index.d.ts +0 -23
  53. package/packages/config-stylelint/node_modules/slash/index.js +0 -9
  54. package/packages/config-stylelint/node_modules/slash/license +0 -9
  55. package/packages/config-stylelint/node_modules/slash/package.json +0 -39
  56. package/packages/config-stylelint/node_modules/slash/readme.md +0 -36
  57. package/packages/config-stylelint/node_modules/string-width/index.d.ts +0 -39
  58. package/packages/config-stylelint/node_modules/string-width/index.js +0 -89
  59. package/packages/config-stylelint/node_modules/string-width/license +0 -9
  60. package/packages/config-stylelint/node_modules/string-width/package.json +0 -65
  61. package/packages/config-stylelint/node_modules/string-width/readme.md +0 -66
  62. package/packages/config-stylelint/node_modules/strip-ansi/index.d.ts +0 -15
  63. package/packages/config-stylelint/node_modules/strip-ansi/index.js +0 -14
  64. package/packages/config-stylelint/node_modules/strip-ansi/license +0 -9
  65. package/packages/config-stylelint/node_modules/strip-ansi/package.json +0 -59
  66. package/packages/config-stylelint/node_modules/strip-ansi/readme.md +0 -37
  67. package/packages/config-stylelint/node_modules/stylelint/LICENSE +0 -20
  68. package/packages/config-stylelint/node_modules/stylelint/README.md +0 -108
  69. package/packages/config-stylelint/node_modules/stylelint/bin/stylelint.mjs +0 -7
  70. package/packages/config-stylelint/node_modules/stylelint/lib/assignDisabledRanges.mjs +0 -483
  71. package/packages/config-stylelint/node_modules/stylelint/lib/augmentConfig.mjs +0 -521
  72. package/packages/config-stylelint/node_modules/stylelint/lib/cli.mjs +0 -746
  73. package/packages/config-stylelint/node_modules/stylelint/lib/constants.mjs +0 -25
  74. package/packages/config-stylelint/node_modules/stylelint/lib/createPartialStylelintResult.mjs +0 -114
  75. package/packages/config-stylelint/node_modules/stylelint/lib/createPlugin.mjs +0 -9
  76. package/packages/config-stylelint/node_modules/stylelint/lib/createStylelint.mjs +0 -30
  77. package/packages/config-stylelint/node_modules/stylelint/lib/descriptionlessDisables.mjs +0 -51
  78. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/calcSeverityCounts.mjs +0 -21
  79. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/compactFormatter.mjs +0 -23
  80. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/index.mjs +0 -23
  81. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/jsonFormatter.mjs +0 -10
  82. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/preprocessWarnings.mjs +0 -74
  83. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/stringFormatter.mjs +0 -308
  84. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/tapFormatter.mjs +0 -85
  85. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/terminalLink.mjs +0 -21
  86. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/unixFormatter.mjs +0 -32
  87. package/packages/config-stylelint/node_modules/stylelint/lib/formatters/verboseFormatter.mjs +0 -175
  88. package/packages/config-stylelint/node_modules/stylelint/lib/getConfigForFile.mjs +0 -83
  89. package/packages/config-stylelint/node_modules/stylelint/lib/getPostcssResult.mjs +0 -130
  90. package/packages/config-stylelint/node_modules/stylelint/lib/index.mjs +0 -38
  91. package/packages/config-stylelint/node_modules/stylelint/lib/invalidScopeDisables.mjs +0 -41
  92. package/packages/config-stylelint/node_modules/stylelint/lib/isPathIgnored.mjs +0 -48
  93. package/packages/config-stylelint/node_modules/stylelint/lib/lintPostcssResult.mjs +0 -188
  94. package/packages/config-stylelint/node_modules/stylelint/lib/lintSource.mjs +0 -133
  95. package/packages/config-stylelint/node_modules/stylelint/lib/needlessDisables.mjs +0 -91
  96. package/packages/config-stylelint/node_modules/stylelint/lib/normalizeAllRuleSettings.mjs +0 -29
  97. package/packages/config-stylelint/node_modules/stylelint/lib/normalizeRuleSettings.mjs +0 -56
  98. package/packages/config-stylelint/node_modules/stylelint/lib/postcssPlugin.mjs +0 -50
  99. package/packages/config-stylelint/node_modules/stylelint/lib/prepareReturnValue.mjs +0 -63
  100. package/packages/config-stylelint/node_modules/stylelint/lib/printConfig.mjs +0 -44
  101. package/packages/config-stylelint/node_modules/stylelint/lib/reference/atKeywords.mjs +0 -83
  102. package/packages/config-stylelint/node_modules/stylelint/lib/reference/functions.mjs +0 -60
  103. package/packages/config-stylelint/node_modules/stylelint/lib/reference/keywords.mjs +0 -636
  104. package/packages/config-stylelint/node_modules/stylelint/lib/reference/mediaFeatures.mjs +0 -115
  105. package/packages/config-stylelint/node_modules/stylelint/lib/reference/mediaTypes.mjs +0 -14
  106. package/packages/config-stylelint/node_modules/stylelint/lib/reference/prefixes.mjs +0 -17
  107. package/packages/config-stylelint/node_modules/stylelint/lib/reference/properties.mjs +0 -804
  108. package/packages/config-stylelint/node_modules/stylelint/lib/reference/selectors.mjs +0 -469
  109. package/packages/config-stylelint/node_modules/stylelint/lib/reference/units.mjs +0 -82
  110. package/packages/config-stylelint/node_modules/stylelint/lib/reportDisables.mjs +0 -48
  111. package/packages/config-stylelint/node_modules/stylelint/lib/reportUnknownRuleNames.mjs +0 -76
  112. package/packages/config-stylelint/node_modules/stylelint/lib/resolveConfig.mjs +0 -43
  113. package/packages/config-stylelint/node_modules/stylelint/lib/rules/alpha-value-notation/index.mjs +0 -207
  114. package/packages/config-stylelint/node_modules/stylelint/lib/rules/annotation-no-unknown/index.mjs +0 -88
  115. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-allowed-list/index.mjs +0 -62
  116. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-descriptor-no-unknown/index.mjs +0 -108
  117. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-descriptor-value-no-unknown/index.mjs +0 -65
  118. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-disallowed-list/index.mjs +0 -62
  119. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-empty-line-before/index.mjs +0 -178
  120. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-deprecated/index.mjs +0 -86
  121. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-unknown/index.mjs +0 -80
  122. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-no-vendor-prefix/index.mjs +0 -67
  123. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-prelude-no-invalid/index.mjs +0 -76
  124. package/packages/config-stylelint/node_modules/stylelint/lib/rules/at-rule-property-required-list/index.mjs +0 -92
  125. package/packages/config-stylelint/node_modules/stylelint/lib/rules/block-no-empty/index.mjs +0 -116
  126. package/packages/config-stylelint/node_modules/stylelint/lib/rules/block-no-redundant-nested-style-rules/index.mjs +0 -52
  127. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-function-alias-notation/index.mjs +0 -85
  128. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-function-notation/index.mjs +0 -167
  129. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-hex-alpha/index.mjs +0 -75
  130. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-hex-length/index.mjs +0 -129
  131. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-named/colordUtils.mjs +0 -109
  132. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-named/index.mjs +0 -187
  133. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-no-hex/index.mjs +0 -69
  134. package/packages/config-stylelint/node_modules/stylelint/lib/rules/color-no-invalid-hex/index.mjs +0 -73
  135. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-empty-line-before/index.mjs +0 -131
  136. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-no-empty/index.mjs +0 -50
  137. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-pattern/index.mjs +0 -51
  138. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-whitespace-inside/index.mjs +0 -149
  139. package/packages/config-stylelint/node_modules/stylelint/lib/rules/comment-word-disallowed-list/index.mjs +0 -63
  140. package/packages/config-stylelint/node_modules/stylelint/lib/rules/container-name-pattern/index.mjs +0 -107
  141. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-media-pattern/index.mjs +0 -64
  142. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-empty-line-before/index.mjs +0 -156
  143. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-no-missing-var-function/index.mjs +0 -148
  144. package/packages/config-stylelint/node_modules/stylelint/lib/rules/custom-property-pattern/index.mjs +0 -102
  145. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-duplicate-custom-properties/index.mjs +0 -82
  146. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-duplicate-properties/index.mjs +0 -301
  147. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-redundant-longhand-properties/index.mjs +0 -411
  148. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-no-shorthand-property-overrides/index.mjs +0 -74
  149. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-block-single-line-max-declarations/index.mjs +0 -62
  150. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-empty-line-before/index.mjs +0 -160
  151. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-no-important/index.mjs +0 -51
  152. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-max-values/index.mjs +0 -75
  153. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-unit-allowed-list/index.mjs +0 -108
  154. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-unit-disallowed-list/index.mjs +0 -91
  155. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-allowed-list/index.mjs +0 -66
  156. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-disallowed-list/index.mjs +0 -66
  157. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-keyword-no-deprecated/index.mjs +0 -200
  158. package/packages/config-stylelint/node_modules/stylelint/lib/rules/declaration-property-value-no-unknown/index.mjs +0 -250
  159. package/packages/config-stylelint/node_modules/stylelint/lib/rules/display-notation/index.mjs +0 -226
  160. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-name-quotes/index.mjs +0 -242
  161. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-no-duplicate-names/index.mjs +0 -121
  162. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-family-no-missing-generic-family-keyword/index.mjs +0 -121
  163. package/packages/config-stylelint/node_modules/stylelint/lib/rules/font-weight-notation/index.mjs +0 -212
  164. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-allowed-list/index.mjs +0 -112
  165. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-calc-no-unspaced-operator/index.mjs +0 -591
  166. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-disallowed-list/index.mjs +0 -71
  167. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-linear-gradient-no-nonstandard-direction/index.mjs +0 -145
  168. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-name-case/index.mjs +0 -120
  169. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-no-unknown/index.mjs +0 -101
  170. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-no-scheme-relative/index.mjs +0 -66
  171. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-quotes/index.mjs +0 -231
  172. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-scheme-allowed-list/index.mjs +0 -70
  173. package/packages/config-stylelint/node_modules/stylelint/lib/rules/function-url-scheme-disallowed-list/index.mjs +0 -70
  174. package/packages/config-stylelint/node_modules/stylelint/lib/rules/hue-degree-notation/index.mjs +0 -122
  175. package/packages/config-stylelint/node_modules/stylelint/lib/rules/import-notation/index.mjs +0 -99
  176. package/packages/config-stylelint/node_modules/stylelint/lib/rules/index.mjs +0 -448
  177. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-block-no-duplicate-selectors/index.mjs +0 -68
  178. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-declaration-no-important/index.mjs +0 -54
  179. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframe-selector-notation/index.mjs +0 -191
  180. package/packages/config-stylelint/node_modules/stylelint/lib/rules/keyframes-name-pattern/index.mjs +0 -63
  181. package/packages/config-stylelint/node_modules/stylelint/lib/rules/layer-name-pattern/index.mjs +0 -91
  182. package/packages/config-stylelint/node_modules/stylelint/lib/rules/length-zero-no-unit/index.mjs +0 -216
  183. package/packages/config-stylelint/node_modules/stylelint/lib/rules/lightness-notation/index.mjs +0 -167
  184. package/packages/config-stylelint/node_modules/stylelint/lib/rules/max-nesting-depth/index.mjs +0 -195
  185. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-allowed-list/index.mjs +0 -67
  186. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-disallowed-list/index.mjs +0 -67
  187. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-no-unknown/index.mjs +0 -79
  188. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-no-vendor-prefix/index.mjs +0 -77
  189. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-unit-allowed-list/index.mjs +0 -108
  190. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-value-allowed-list/index.mjs +0 -100
  191. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-name-value-no-unknown/index.mjs +0 -277
  192. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-feature-range-notation/index.mjs +0 -174
  193. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-query-no-invalid/index.mjs +0 -193
  194. package/packages/config-stylelint/node_modules/stylelint/lib/rules/media-type-no-deprecated/index.mjs +0 -87
  195. package/packages/config-stylelint/node_modules/stylelint/lib/rules/named-grid-areas-no-invalid/index.mjs +0 -116
  196. package/packages/config-stylelint/node_modules/stylelint/lib/rules/named-grid-areas-no-invalid/utils/findNotContiguousOrRectangular.mjs +0 -57
  197. package/packages/config-stylelint/node_modules/stylelint/lib/rules/nesting-selector-no-missing-scoping-root/index.mjs +0 -166
  198. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-descending-specificity/index.mjs +0 -196
  199. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-duplicate-at-import-rules/index.mjs +0 -156
  200. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-duplicate-selectors/index.mjs +0 -219
  201. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-empty-source/index.mjs +0 -61
  202. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-double-slash-comments/index.mjs +0 -77
  203. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-position-at-import-rule/index.mjs +0 -76
  204. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-invalid-position-declaration/index.mjs +0 -86
  205. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-irregular-whitespace/index.mjs +0 -232
  206. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-animations/index.mjs +0 -71
  207. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-custom-media/index.mjs +0 -75
  208. package/packages/config-stylelint/node_modules/stylelint/lib/rules/no-unknown-custom-properties/index.mjs +0 -72
  209. package/packages/config-stylelint/node_modules/stylelint/lib/rules/number-max-precision/index.mjs +0 -209
  210. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-allowed-list/index.mjs +0 -58
  211. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-disallowed-list/index.mjs +0 -58
  212. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-deprecated/index.mjs +0 -143
  213. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-unknown/index.mjs +0 -129
  214. package/packages/config-stylelint/node_modules/stylelint/lib/rules/property-no-vendor-prefix/index.mjs +0 -100
  215. package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-empty-line-before/index.mjs +0 -156
  216. package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-nesting-at-rule-required-list/index.mjs +0 -85
  217. package/packages/config-stylelint/node_modules/stylelint/lib/rules/rule-selector-property-disallowed-list/index.mjs +0 -119
  218. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-anb-no-unmatchable/index.mjs +0 -123
  219. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-name-disallowed-list/index.mjs +0 -72
  220. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-operator-allowed-list/index.mjs +0 -75
  221. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-operator-disallowed-list/index.mjs +0 -75
  222. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-attribute-quotes/index.mjs +0 -112
  223. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-class-pattern/index.mjs +0 -70
  224. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-combinator-allowed-list/index.mjs +0 -81
  225. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-combinator-disallowed-list/index.mjs +0 -81
  226. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-disallowed-list/index.mjs +0 -115
  227. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-id-pattern/index.mjs +0 -65
  228. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-attribute/index.mjs +0 -91
  229. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-class/index.mjs +0 -74
  230. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-combinators/index.mjs +0 -76
  231. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-compound-selectors/index.mjs +0 -122
  232. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-id/index.mjs +0 -106
  233. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-pseudo-class/index.mjs +0 -84
  234. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-specificity/index.mjs +0 -146
  235. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-type/index.mjs +0 -218
  236. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-max-universal/index.mjs +0 -94
  237. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-nested-pattern/index.mjs +0 -95
  238. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-no-qualifying-type/index.mjs +0 -328
  239. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-no-vendor-prefix/index.mjs +0 -94
  240. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-not-notation/index.mjs +0 -220
  241. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-allowed-list/index.mjs +0 -89
  242. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-disallowed-list/index.mjs +0 -89
  243. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-class-no-unknown/index.mjs +0 -179
  244. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-allowed-list/index.mjs +0 -78
  245. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-colon-notation/index.mjs +0 -97
  246. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-disallowed-list/index.mjs +0 -77
  247. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-pseudo-element-no-unknown/index.mjs +0 -96
  248. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-type-case/index.mjs +0 -118
  249. package/packages/config-stylelint/node_modules/stylelint/lib/rules/selector-type-no-unknown/index.mjs +0 -148
  250. package/packages/config-stylelint/node_modules/stylelint/lib/rules/shorthand-property-no-redundant-values/index.mjs +0 -357
  251. package/packages/config-stylelint/node_modules/stylelint/lib/rules/string-no-newline/index.mjs +0 -120
  252. package/packages/config-stylelint/node_modules/stylelint/lib/rules/syntax-string-no-invalid/index.mjs +0 -81
  253. package/packages/config-stylelint/node_modules/stylelint/lib/rules/time-min-milliseconds/index.mjs +0 -162
  254. package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-allowed-list/index.mjs +0 -114
  255. package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-disallowed-list/index.mjs +0 -212
  256. package/packages/config-stylelint/node_modules/stylelint/lib/rules/unit-no-unknown/index.mjs +0 -208
  257. package/packages/config-stylelint/node_modules/stylelint/lib/rules/value-keyword-case/index.mjs +0 -249
  258. package/packages/config-stylelint/node_modules/stylelint/lib/rules/value-no-vendor-prefix/index.mjs +0 -92
  259. package/packages/config-stylelint/node_modules/stylelint/lib/standalone.mjs +0 -379
  260. package/packages/config-stylelint/node_modules/stylelint/lib/timing.mjs +0 -134
  261. package/packages/config-stylelint/node_modules/stylelint/lib/unscopedDisables.mjs +0 -66
  262. package/packages/config-stylelint/node_modules/stylelint/lib/utils/FileCache.mjs +0 -115
  263. package/packages/config-stylelint/node_modules/stylelint/lib/utils/addEmptyLineBefore.mjs +0 -21
  264. package/packages/config-stylelint/node_modules/stylelint/lib/utils/addSemicolonForEditInfo.mjs +0 -35
  265. package/packages/config-stylelint/node_modules/stylelint/lib/utils/appendRuleName.mjs +0 -13
  266. package/packages/config-stylelint/node_modules/stylelint/lib/utils/arrayEqual.mjs +0 -14
  267. package/packages/config-stylelint/node_modules/stylelint/lib/utils/beforeBlockString.mjs +0 -28
  268. package/packages/config-stylelint/node_modules/stylelint/lib/utils/blockString.mjs +0 -19
  269. package/packages/config-stylelint/node_modules/stylelint/lib/utils/blurInterpolation.mjs +0 -8
  270. package/packages/config-stylelint/node_modules/stylelint/lib/utils/checkAgainstRule.mjs +0 -70
  271. package/packages/config-stylelint/node_modules/stylelint/lib/utils/checkInvalidCLIOptions.mjs +0 -105
  272. package/packages/config-stylelint/node_modules/stylelint/lib/utils/configurationComment.mjs +0 -74
  273. package/packages/config-stylelint/node_modules/stylelint/lib/utils/containsString.mjs +0 -52
  274. package/packages/config-stylelint/node_modules/stylelint/lib/utils/createMapWithSet.mjs +0 -19
  275. package/packages/config-stylelint/node_modules/stylelint/lib/utils/dynamicImport.mjs +0 -13
  276. package/packages/config-stylelint/node_modules/stylelint/lib/utils/eachDeclarationBlock.mjs +0 -59
  277. package/packages/config-stylelint/node_modules/stylelint/lib/utils/eachNodeUpToRoot.mjs +0 -22
  278. package/packages/config-stylelint/node_modules/stylelint/lib/utils/emitWarning.mjs +0 -83
  279. package/packages/config-stylelint/node_modules/stylelint/lib/utils/errors.mjs +0 -55
  280. package/packages/config-stylelint/node_modules/stylelint/lib/utils/filterFilePaths.mjs +0 -17
  281. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findAnimationName.mjs +0 -74
  282. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findAtRuleContext.mjs +0 -27
  283. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findFontFamily.mjs +0 -148
  284. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findMediaFeatureNames.mjs +0 -151
  285. package/packages/config-stylelint/node_modules/stylelint/lib/utils/findNodeUpToRoot.mjs +0 -25
  286. package/packages/config-stylelint/node_modules/stylelint/lib/utils/fixEmptyLinesBefore.mjs +0 -26
  287. package/packages/config-stylelint/node_modules/stylelint/lib/utils/functionArgumentsSearch.mjs +0 -45
  288. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getAtRuleParams.mjs +0 -7
  289. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getDeclarationValue.mjs +0 -9
  290. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getDimension.mjs +0 -62
  291. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFileIgnorer.mjs +0 -41
  292. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFormatter.mjs +0 -43
  293. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getFormatterOptionsText.mjs +0 -12
  294. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getImportantPosition.mjs +0 -15
  295. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getLexer.mjs +0 -15
  296. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getModulePath.mjs +0 -35
  297. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getNextNonSharedLineCommentNode.mjs +0 -34
  298. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getPreviousNonSharedLineCommentNode.mjs +0 -36
  299. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getRelativePath.mjs +0 -12
  300. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getRuleSelector.mjs +0 -9
  301. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getSchemeFromUrl.mjs +0 -36
  302. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getSelectorSourceIndex.mjs +0 -12
  303. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getStrippedSelectorSource.mjs +0 -47
  304. package/packages/config-stylelint/node_modules/stylelint/lib/utils/getStylelintRule.mjs +0 -22
  305. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasANPlusBNotationPseudoClasses.mjs +0 -20
  306. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasBlock.mjs +0 -9
  307. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasColorFunction.mjs +0 -13
  308. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasDimension.mjs +0 -11
  309. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasEmptyLine.mjs +0 -13
  310. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasInterpolation.mjs +0 -24
  311. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasLessInterpolation.mjs +0 -11
  312. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasNamedColor.mjs +0 -15
  313. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasPrefix.mjs +0 -13
  314. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasPsvInterpolation.mjs +0 -11
  315. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasScssInterpolation.mjs +0 -11
  316. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasTplInterpolation.mjs +0 -11
  317. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hasValidHex.mjs +0 -11
  318. package/packages/config-stylelint/node_modules/stylelint/lib/utils/hash.mjs +0 -10
  319. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterBlock.mjs +0 -15
  320. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterComment.mjs +0 -15
  321. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterSingleLineComment.mjs +0 -19
  322. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAfterStandardPropertyDeclaration.mjs +0 -19
  323. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isAutoprefixable.mjs +0 -364
  324. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isBlocklessAtRuleAfterBlocklessAtRule.mjs +0 -21
  325. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isBlocklessAtRuleAfterSameNameBlocklessAtRule.mjs +0 -21
  326. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isContextFunctionalPseudoClass.mjs +0 -24
  327. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCounterIncrementCustomIdentValue.mjs +0 -19
  328. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCounterResetCustomIdentValue.mjs +0 -19
  329. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomElement.mjs +0 -34
  330. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomFunction.mjs +0 -9
  331. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomMediaQuery.mjs +0 -8
  332. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomProperty.mjs +0 -8
  333. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isCustomSelector.mjs +0 -9
  334. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isDescriptorDeclaration.mjs +0 -22
  335. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isFirstNested.mjs +0 -83
  336. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isFirstNodeOfRoot.mjs +0 -17
  337. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isHexColor.mjs +0 -9
  338. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isInDocument.mjs +0 -32
  339. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isKeyframeRule.mjs +0 -17
  340. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isKeyframeSelector.mjs +0 -29
  341. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isMathFunction.mjs +0 -11
  342. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isNonNegativeInteger.mjs +0 -6
  343. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isNumbery.mjs +0 -9
  344. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isOnlyWhitespace.mjs +0 -17
  345. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isPathNotFoundError.mjs +0 -9
  346. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isScssVariable.mjs +0 -19
  347. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isSharedLineComment.mjs +0 -53
  348. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isSingleLineString.mjs +0 -10
  349. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxAtRule.mjs +0 -32
  350. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxColorFunction.mjs +0 -24
  351. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxCombinator.mjs +0 -32
  352. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxComment.mjs +0 -13
  353. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxDeclaration.mjs +0 -57
  354. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxFunction.mjs +0 -28
  355. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxHexColor.mjs +0 -14
  356. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxKeyframesName.mjs +0 -15
  357. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxProperty.mjs +0 -32
  358. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxRule.mjs +0 -24
  359. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxSelector.mjs +0 -56
  360. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxTypeSelector.mjs +0 -56
  361. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxUrl.mjs +0 -49
  362. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isStandardSyntaxValue.mjs +0 -51
  363. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUnicodeRangeDescriptor.mjs +0 -24
  364. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUnicodeSupported.mjs +0 -26
  365. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isUrlFunction.mjs +0 -9
  366. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidFontSize.mjs +0 -38
  367. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidHex.mjs +0 -11
  368. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isValidIdentifier.mjs +0 -39
  369. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isVarFunction.mjs +0 -9
  370. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isVariable.mjs +0 -9
  371. package/packages/config-stylelint/node_modules/stylelint/lib/utils/isWhitespace.mjs +0 -9
  372. package/packages/config-stylelint/node_modules/stylelint/lib/utils/matchesStringOrRegExp.mjs +0 -97
  373. package/packages/config-stylelint/node_modules/stylelint/lib/utils/mergeSyntaxDefinitions.mjs +0 -137
  374. package/packages/config-stylelint/node_modules/stylelint/lib/utils/narrowFixRange.mjs +0 -68
  375. package/packages/config-stylelint/node_modules/stylelint/lib/utils/nodeContextLookup.mjs +0 -41
  376. package/packages/config-stylelint/node_modules/stylelint/lib/utils/nodeFieldIndices.mjs +0 -119
  377. package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeFilePath.mjs +0 -26
  378. package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeFixMode.mjs +0 -22
  379. package/packages/config-stylelint/node_modules/stylelint/lib/utils/normalizeSelector.mjs +0 -84
  380. package/packages/config-stylelint/node_modules/stylelint/lib/utils/optionsMatches.mjs +0 -20
  381. package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseCustomMediaQuery.mjs +0 -15
  382. package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseMediaQuery.mjs +0 -15
  383. package/packages/config-stylelint/node_modules/stylelint/lib/utils/parseSelector.mjs +0 -26
  384. package/packages/config-stylelint/node_modules/stylelint/lib/utils/pluralize.mjs +0 -10
  385. package/packages/config-stylelint/node_modules/stylelint/lib/utils/putIfAbsent.mjs +0 -20
  386. package/packages/config-stylelint/node_modules/stylelint/lib/utils/rangesOverlap.mjs +0 -19
  387. package/packages/config-stylelint/node_modules/stylelint/lib/utils/rawNodeString.mjs +0 -18
  388. package/packages/config-stylelint/node_modules/stylelint/lib/utils/regexes.mjs +0 -27
  389. package/packages/config-stylelint/node_modules/stylelint/lib/utils/removeEmptyLinesBefore.mjs +0 -13
  390. package/packages/config-stylelint/node_modules/stylelint/lib/utils/report.mjs +0 -321
  391. package/packages/config-stylelint/node_modules/stylelint/lib/utils/reportCommentProblem.mjs +0 -39
  392. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveFilePath.mjs +0 -38
  393. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveNestedSelectorsForRule.mjs +0 -90
  394. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveOptionValue.mjs +0 -30
  395. package/packages/config-stylelint/node_modules/stylelint/lib/utils/resolveSilent.mjs +0 -147
  396. package/packages/config-stylelint/node_modules/stylelint/lib/utils/ruleMessages.mjs +0 -18
  397. package/packages/config-stylelint/node_modules/stylelint/lib/utils/setAtRuleParams.mjs +0 -18
  398. package/packages/config-stylelint/node_modules/stylelint/lib/utils/setDeclarationValue.mjs +0 -18
  399. package/packages/config-stylelint/node_modules/stylelint/lib/utils/suppressionsService.mjs +0 -317
  400. package/packages/config-stylelint/node_modules/stylelint/lib/utils/toPath.mjs +0 -23
  401. package/packages/config-stylelint/node_modules/stylelint/lib/utils/typeGuards.mjs +0 -90
  402. package/packages/config-stylelint/node_modules/stylelint/lib/utils/uniteSets.mjs +0 -9
  403. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateObjectWithArrayProps.mjs +0 -29
  404. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateObjectWithProps.mjs +0 -28
  405. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateOptions.mjs +0 -176
  406. package/packages/config-stylelint/node_modules/stylelint/lib/utils/validateTypes.mjs +0 -150
  407. package/packages/config-stylelint/node_modules/stylelint/lib/utils/vendor.mjs +0 -43
  408. package/packages/config-stylelint/node_modules/stylelint/lib/validateDisableSettings.mjs +0 -67
  409. package/packages/config-stylelint/node_modules/stylelint/lib/writeOutputFile.mjs +0 -15
  410. package/packages/config-stylelint/node_modules/stylelint/package.json +0 -212
  411. package/packages/config-stylelint/node_modules/stylelint/types/stylelint/index.d.ts +0 -1570
  412. package/packages/config-stylelint/node_modules/unicorn-magic/default.d.ts +0 -13
  413. package/packages/config-stylelint/node_modules/unicorn-magic/default.js +0 -14
  414. package/packages/config-stylelint/node_modules/unicorn-magic/license +0 -9
  415. package/packages/config-stylelint/node_modules/unicorn-magic/node.d.ts +0 -125
  416. package/packages/config-stylelint/node_modules/unicorn-magic/node.js +0 -49
  417. package/packages/config-stylelint/node_modules/unicorn-magic/package.json +0 -68
  418. package/packages/config-stylelint/node_modules/unicorn-magic/readme.md +0 -31
@@ -1,2432 +0,0 @@
1
- /**
2
- Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
3
-
4
- @category Type
5
- */
6
- type Primitive =
7
- | null
8
- | undefined
9
- | string
10
- | number
11
- | boolean
12
- | symbol
13
- | bigint;
14
-
15
- /**
16
- Matches a JSON object.
17
-
18
- This type can be useful to enforce some input to be JSON-compatible or as a super-type to be extended from. Don't use this as a direct return type as the user would have to double-cast it: `jsonObject as unknown as CustomResponse`. Instead, you could extend your CustomResponse type from it to ensure your type only uses JSON-compatible types: `interface CustomResponse extends JsonObject { … }`.
19
-
20
- @category JSON
21
- */
22
- type JsonObject = {[Key in string]: JsonValue} & {[Key in string]?: JsonValue | undefined};
23
-
24
- /**
25
- Matches a JSON array.
26
-
27
- @category JSON
28
- */
29
- type JsonArray = JsonValue[] | readonly JsonValue[];
30
-
31
- /**
32
- Matches any valid JSON primitive value.
33
-
34
- @category JSON
35
- */
36
- type JsonPrimitive = string | number | boolean | null;
37
-
38
- /**
39
- Matches any valid JSON value.
40
-
41
- @see `Jsonify` if you need to transform a type to one that is assignable to `JsonValue`.
42
-
43
- @category JSON
44
- */
45
- type JsonValue = JsonPrimitive | JsonObject | JsonArray;
46
-
47
- /**
48
- Returns a boolean for whether the given type is `any`.
49
-
50
- @link https://stackoverflow.com/a/49928360/1490091
51
-
52
- Useful in type utilities, such as disallowing `any`s to be passed to a function.
53
-
54
- @example
55
- ```
56
- import type {IsAny} from 'type-fest';
57
-
58
- const typedObject = {a: 1, b: 2} as const;
59
- const anyObject: any = {a: 1, b: 2};
60
-
61
- function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
62
- return obj[key];
63
- }
64
-
65
- const typedA = get(typedObject, 'a');
66
- //=> 1
67
-
68
- const anyA = get(anyObject, 'a');
69
- //=> any
70
- ```
71
-
72
- @category Type Guard
73
- @category Utilities
74
- */
75
- type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
76
-
77
- /**
78
- Returns a boolean for whether the given key is an optional key of type.
79
-
80
- This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
81
-
82
- @example
83
- ```
84
- import type {IsOptionalKeyOf} from 'type-fest';
85
-
86
- interface User {
87
- name: string;
88
- surname: string;
89
-
90
- luckyNumber?: number;
91
- }
92
-
93
- interface Admin {
94
- name: string;
95
- surname?: string;
96
- }
97
-
98
- type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
99
- //=> true
100
-
101
- type T2 = IsOptionalKeyOf<User, 'name'>;
102
- //=> false
103
-
104
- type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
105
- //=> boolean
106
-
107
- type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
108
- //=> false
109
-
110
- type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
111
- //=> boolean
112
- ```
113
-
114
- @category Type Guard
115
- @category Utilities
116
- */
117
- type IsOptionalKeyOf<Type extends object, Key extends keyof Type> =
118
- IsAny<Type | Key> extends true ? never
119
- : Key extends keyof Type
120
- ? Type extends Record<Key, Type[Key]>
121
- ? false
122
- : true
123
- : false;
124
-
125
- /**
126
- Extract all optional keys from the given type.
127
-
128
- This is useful when you want to create a new type that contains different type values for the optional keys only.
129
-
130
- @example
131
- ```
132
- import type {OptionalKeysOf, Except} from 'type-fest';
133
-
134
- interface User {
135
- name: string;
136
- surname: string;
137
-
138
- luckyNumber?: number;
139
- }
140
-
141
- const REMOVE_FIELD = Symbol('remove field symbol');
142
- type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
143
- [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
144
- };
145
-
146
- const update1: UpdateOperation<User> = {
147
- name: 'Alice'
148
- };
149
-
150
- const update2: UpdateOperation<User> = {
151
- name: 'Bob',
152
- luckyNumber: REMOVE_FIELD
153
- };
154
- ```
155
-
156
- @category Utilities
157
- */
158
- type OptionalKeysOf<Type extends object> =
159
- Type extends unknown // For distributing `Type`
160
- ? (keyof {[Key in keyof Type as
161
- IsOptionalKeyOf<Type, Key> extends false
162
- ? never
163
- : Key
164
- ]: never
165
- }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
166
- : never; // Should never happen
167
-
168
- /**
169
- Extract all required keys from the given type.
170
-
171
- This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
172
-
173
- @example
174
- ```
175
- import type {RequiredKeysOf} from 'type-fest';
176
-
177
- declare function createValidation<Entity extends object, Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>>(field: Key, validator: (value: Entity[Key]) => boolean): ValidatorFn;
178
-
179
- interface User {
180
- name: string;
181
- surname: string;
182
-
183
- luckyNumber?: number;
184
- }
185
-
186
- const validator1 = createValidation<User>('name', value => value.length < 25);
187
- const validator2 = createValidation<User>('surname', value => value.length < 25);
188
- ```
189
-
190
- @category Utilities
191
- */
192
- type RequiredKeysOf<Type extends object> =
193
- Type extends unknown // For distributing `Type`
194
- ? Exclude<keyof Type, OptionalKeysOf<Type>>
195
- : never; // Should never happen
196
-
197
- /**
198
- Returns a boolean for whether the given type is `never`.
199
-
200
- @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
201
- @link https://stackoverflow.com/a/53984913/10292952
202
- @link https://www.zhenghao.io/posts/ts-never
203
-
204
- Useful in type utilities, such as checking if something does not occur.
205
-
206
- @example
207
- ```
208
- import type {IsNever, And} from 'type-fest';
209
-
210
- // https://github.com/andnp/SimplyTyped/blob/master/src/types/strings.ts
211
- type AreStringsEqual<A extends string, B extends string> =
212
- And<
213
- IsNever<Exclude<A, B>> extends true ? true : false,
214
- IsNever<Exclude<B, A>> extends true ? true : false
215
- >;
216
-
217
- type EndIfEqual<I extends string, O extends string> =
218
- AreStringsEqual<I, O> extends true
219
- ? never
220
- : void;
221
-
222
- function endIfEqual<I extends string, O extends string>(input: I, output: O): EndIfEqual<I, O> {
223
- if (input === output) {
224
- process.exit(0);
225
- }
226
- }
227
-
228
- endIfEqual('abc', 'abc');
229
- //=> never
230
-
231
- endIfEqual('abc', '123');
232
- //=> void
233
- ```
234
-
235
- @category Type Guard
236
- @category Utilities
237
- */
238
- type IsNever<T> = [T] extends [never] ? true : false;
239
-
240
- /**
241
- An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
242
-
243
- Use-cases:
244
- - You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
245
-
246
- Note:
247
- - Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
248
- - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
249
-
250
- @example
251
- ```
252
- import {If} from 'type-fest';
253
-
254
- type A = If<true, 'yes', 'no'>;
255
- //=> 'yes'
256
-
257
- type B = If<false, 'yes', 'no'>;
258
- //=> 'no'
259
-
260
- type C = If<boolean, 'yes', 'no'>;
261
- //=> 'yes' | 'no'
262
-
263
- type D = If<any, 'yes', 'no'>;
264
- //=> 'yes' | 'no'
265
-
266
- type E = If<never, 'yes', 'no'>;
267
- //=> 'no'
268
- ```
269
-
270
- @example
271
- ```
272
- import {If, IsAny, IsNever} from 'type-fest';
273
-
274
- type A = If<IsAny<unknown>, 'is any', 'not any'>;
275
- //=> 'not any'
276
-
277
- type B = If<IsNever<never>, 'is never', 'not never'>;
278
- //=> 'is never'
279
- ```
280
-
281
- @example
282
- ```
283
- import {If, IsEqual} from 'type-fest';
284
-
285
- type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
286
-
287
- type A = IfEqual<string, string, 'equal', 'not equal'>;
288
- //=> 'equal'
289
-
290
- type B = IfEqual<string, number, 'equal', 'not equal'>;
291
- //=> 'not equal'
292
- ```
293
-
294
- @category Type Guard
295
- @category Utilities
296
- */
297
- type If<Type extends boolean, IfBranch, ElseBranch> =
298
- IsNever<Type> extends true
299
- ? ElseBranch
300
- : Type extends true
301
- ? IfBranch
302
- : ElseBranch;
303
-
304
- /**
305
- Represents an array with `unknown` value.
306
-
307
- Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
308
-
309
- @example
310
- ```
311
- import type {UnknownArray} from 'type-fest';
312
-
313
- type IsArray<T> = T extends UnknownArray ? true : false;
314
-
315
- type A = IsArray<['foo']>;
316
- //=> true
317
-
318
- type B = IsArray<readonly number[]>;
319
- //=> true
320
-
321
- type C = IsArray<string>;
322
- //=> false
323
- ```
324
-
325
- @category Type
326
- @category Array
327
- */
328
- type UnknownArray = readonly unknown[];
329
-
330
- /**
331
- Returns a boolean for whether A is false.
332
-
333
- @example
334
- ```
335
- Not<true>;
336
- //=> false
337
-
338
- Not<false>;
339
- //=> true
340
- ```
341
- */
342
- type Not<A extends boolean> = A extends true
343
- ? false
344
- : A extends false
345
- ? true
346
- : never;
347
-
348
- /**
349
- An if-else-like type that resolves depending on whether the given type is `any` or `never`.
350
-
351
- @example
352
- ```
353
- // When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
354
- type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
355
- //=> 'VALID'
356
-
357
- // When `T` is `any` => Returns `IfAny` branch
358
- type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
359
- //=> 'IS_ANY'
360
-
361
- // When `T` is `never` => Returns `IfNever` branch
362
- type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
363
- //=> 'IS_NEVER'
364
- ```
365
- */
366
- type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> =
367
- If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
368
-
369
- /**
370
- Indicates the value of `exactOptionalPropertyTypes` compiler option.
371
- */
372
- type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?]
373
- ? false
374
- : true;
375
-
376
- /**
377
- Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
378
-
379
- @example
380
- ```
381
- type A = CollapseRestElement<[string, string, ...number[]]>;
382
- //=> [string, string, number]
383
-
384
- type B = CollapseRestElement<[...string[], number, number]>;
385
- //=> [string, number, number]
386
-
387
- type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
388
- //=> [string, string, number | bigint]
389
-
390
- type D = CollapseRestElement<[string, number]>;
391
- //=> [string, number]
392
- ```
393
-
394
- Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
395
-
396
- @example
397
- ```
398
- // `exactOptionalPropertyTypes` enabled
399
- type A = CollapseRestElement<[string?, string?, ...number[]]>;
400
- //=> [string, string, number]
401
-
402
- // `exactOptionalPropertyTypes` disabled
403
- type B = CollapseRestElement<[string?, string?, ...number[]]>;
404
- //=> [string | undefined, string | undefined, number]
405
- ```
406
- */
407
- type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
408
-
409
- type _CollapseRestElement<
410
- TArray extends UnknownArray,
411
- ForwardAccumulator extends UnknownArray = [],
412
- BackwardAccumulator extends UnknownArray = [],
413
- > =
414
- TArray extends UnknownArray // For distributing `TArray`
415
- ? keyof TArray & `${number}` extends never
416
- // Enters this branch, if `TArray` is empty (e.g., []),
417
- // or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
418
- ? TArray extends readonly [...infer Rest, infer Last]
419
- ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
420
- : TArray extends readonly []
421
- ? [...ForwardAccumulator, ...BackwardAccumulator]
422
- : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
423
- : TArray extends readonly [(infer First)?, ...infer Rest]
424
- ? _CollapseRestElement<
425
- Rest,
426
- [
427
- ...ForwardAccumulator,
428
- '0' extends OptionalKeysOf<TArray>
429
- ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
430
- : First,
431
- ],
432
- BackwardAccumulator
433
- >
434
- : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
435
- : never; // Should never happen
436
-
437
- type Whitespace =
438
- | '\u{9}' // '\t'
439
- | '\u{A}' // '\n'
440
- | '\u{B}' // '\v'
441
- | '\u{C}' // '\f'
442
- | '\u{D}' // '\r'
443
- | '\u{20}' // ' '
444
- | '\u{85}'
445
- | '\u{A0}'
446
- | '\u{1680}'
447
- | '\u{2000}'
448
- | '\u{2001}'
449
- | '\u{2002}'
450
- | '\u{2003}'
451
- | '\u{2004}'
452
- | '\u{2005}'
453
- | '\u{2006}'
454
- | '\u{2007}'
455
- | '\u{2008}'
456
- | '\u{2009}'
457
- | '\u{200A}'
458
- | '\u{2028}'
459
- | '\u{2029}'
460
- | '\u{202F}'
461
- | '\u{205F}'
462
- | '\u{3000}'
463
- | '\u{FEFF}';
464
-
465
- type WordSeparators = '-' | '_' | Whitespace;
466
-
467
- /**
468
- Remove spaces from the left side.
469
- */
470
- type TrimLeft<V extends string> = V extends `${Whitespace}${infer R}` ? TrimLeft<R> : V;
471
-
472
- /**
473
- Remove spaces from the right side.
474
- */
475
- type TrimRight<V extends string> = V extends `${infer R}${Whitespace}` ? TrimRight<R> : V;
476
-
477
- /**
478
- Remove leading and trailing spaces from a string.
479
-
480
- @example
481
- ```
482
- import type {Trim} from 'type-fest';
483
-
484
- Trim<' foo '>
485
- //=> 'foo'
486
- ```
487
-
488
- @category String
489
- @category Template literal
490
- */
491
- type Trim<V extends string> = TrimLeft<TrimRight<V>>;
492
-
493
- /**
494
- Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
495
-
496
- @example
497
- ```
498
- import type {Simplify} from 'type-fest';
499
-
500
- type PositionProps = {
501
- top: number;
502
- left: number;
503
- };
504
-
505
- type SizeProps = {
506
- width: number;
507
- height: number;
508
- };
509
-
510
- // In your editor, hovering over `Props` will show a flattened object with all the properties.
511
- type Props = Simplify<PositionProps & SizeProps>;
512
- ```
513
-
514
- Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
515
-
516
- If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
517
-
518
- @example
519
- ```
520
- import type {Simplify} from 'type-fest';
521
-
522
- interface SomeInterface {
523
- foo: number;
524
- bar?: string;
525
- baz: number | undefined;
526
- }
527
-
528
- type SomeType = {
529
- foo: number;
530
- bar?: string;
531
- baz: number | undefined;
532
- };
533
-
534
- const literal = {foo: 123, bar: 'hello', baz: 456};
535
- const someType: SomeType = literal;
536
- const someInterface: SomeInterface = literal;
537
-
538
- function fn(object: Record<string, unknown>): void {}
539
-
540
- fn(literal); // Good: literal object type is sealed
541
- fn(someType); // Good: type is sealed
542
- fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
543
- fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
544
- ```
545
-
546
- @link https://github.com/microsoft/TypeScript/issues/15300
547
- @see SimplifyDeep
548
- @category Object
549
- */
550
- type Simplify<T> = {[KeyType in keyof T]: T[KeyType]} & {};
551
-
552
- /**
553
- Omit any index signatures from the given object type, leaving only explicitly defined properties.
554
-
555
- This is the counterpart of `PickIndexSignature`.
556
-
557
- Use-cases:
558
- - Remove overly permissive signatures from third-party types.
559
-
560
- This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
561
-
562
- It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
563
-
564
- (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
565
-
566
- ```
567
- const indexed: Record<string, unknown> = {}; // Allowed
568
-
569
- const keyed: Record<'foo', unknown> = {}; // Error
570
- // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
571
- ```
572
-
573
- Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
574
-
575
- ```
576
- type Indexed = {} extends Record<string, unknown>
577
- ? '✅ `{}` is assignable to `Record<string, unknown>`'
578
- : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
579
- // => '✅ `{}` is assignable to `Record<string, unknown>`'
580
-
581
- type Keyed = {} extends Record<'foo' | 'bar', unknown>
582
- ? "✅ `{}` is assignable to `Record<'foo' | 'bar', unknown>`"
583
- : "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`";
584
- // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
585
- ```
586
-
587
- Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
588
-
589
- ```
590
- import type {OmitIndexSignature} from 'type-fest';
591
-
592
- type OmitIndexSignature<ObjectType> = {
593
- [KeyType in keyof ObjectType // Map each key of `ObjectType`...
594
- ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
595
- };
596
- ```
597
-
598
- ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
599
-
600
- ```
601
- import type {OmitIndexSignature} from 'type-fest';
602
-
603
- type OmitIndexSignature<ObjectType> = {
604
- [KeyType in keyof ObjectType
605
- // Is `{}` assignable to `Record<KeyType, unknown>`?
606
- as {} extends Record<KeyType, unknown>
607
- ? ... // ✅ `{}` is assignable to `Record<KeyType, unknown>`
608
- : ... // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
609
- ]: ObjectType[KeyType];
610
- };
611
- ```
612
-
613
- If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
614
-
615
- @example
616
- ```
617
- import type {OmitIndexSignature} from 'type-fest';
618
-
619
- interface Example {
620
- // These index signatures will be removed.
621
- [x: string]: any
622
- [x: number]: any
623
- [x: symbol]: any
624
- [x: `head-${string}`]: string
625
- [x: `${string}-tail`]: string
626
- [x: `head-${string}-tail`]: string
627
- [x: `${bigint}`]: string
628
- [x: `embedded-${number}`]: string
629
-
630
- // These explicitly defined keys will remain.
631
- foo: 'bar';
632
- qux?: 'baz';
633
- }
634
-
635
- type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
636
- // => { foo: 'bar'; qux?: 'baz' | undefined; }
637
- ```
638
-
639
- @see PickIndexSignature
640
- @category Object
641
- */
642
- type OmitIndexSignature<ObjectType> = {
643
- [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
644
- ? never
645
- : KeyType]: ObjectType[KeyType];
646
- };
647
-
648
- /**
649
- Pick only index signatures from the given object type, leaving out all explicitly defined properties.
650
-
651
- This is the counterpart of `OmitIndexSignature`.
652
-
653
- @example
654
- ```
655
- import type {PickIndexSignature} from 'type-fest';
656
-
657
- declare const symbolKey: unique symbol;
658
-
659
- type Example = {
660
- // These index signatures will remain.
661
- [x: string]: unknown;
662
- [x: number]: unknown;
663
- [x: symbol]: unknown;
664
- [x: `head-${string}`]: string;
665
- [x: `${string}-tail`]: string;
666
- [x: `head-${string}-tail`]: string;
667
- [x: `${bigint}`]: string;
668
- [x: `embedded-${number}`]: string;
669
-
670
- // These explicitly defined keys will be removed.
671
- ['kebab-case-key']: string;
672
- [symbolKey]: string;
673
- foo: 'bar';
674
- qux?: 'baz';
675
- };
676
-
677
- type ExampleIndexSignature = PickIndexSignature<Example>;
678
- // {
679
- // [x: string]: unknown;
680
- // [x: number]: unknown;
681
- // [x: symbol]: unknown;
682
- // [x: `head-${string}`]: string;
683
- // [x: `${string}-tail`]: string;
684
- // [x: `head-${string}-tail`]: string;
685
- // [x: `${bigint}`]: string;
686
- // [x: `embedded-${number}`]: string;
687
- // }
688
- ```
689
-
690
- @see OmitIndexSignature
691
- @category Object
692
- */
693
- type PickIndexSignature<ObjectType> = {
694
- [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
695
- ? KeyType
696
- : never]: ObjectType[KeyType];
697
- };
698
-
699
- // Merges two objects without worrying about index signatures.
700
- type SimpleMerge<Destination, Source> = {
701
- [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key];
702
- } & Source;
703
-
704
- /**
705
- Merge two types into a new type. Keys of the second type overrides keys of the first type.
706
-
707
- @example
708
- ```
709
- import type {Merge} from 'type-fest';
710
-
711
- interface Foo {
712
- [x: string]: unknown;
713
- [x: number]: unknown;
714
- foo: string;
715
- bar: symbol;
716
- }
717
-
718
- type Bar = {
719
- [x: number]: number;
720
- [x: symbol]: unknown;
721
- bar: Date;
722
- baz: boolean;
723
- };
724
-
725
- export type FooBar = Merge<Foo, Bar>;
726
- // => {
727
- // [x: string]: unknown;
728
- // [x: number]: number;
729
- // [x: symbol]: unknown;
730
- // foo: string;
731
- // bar: Date;
732
- // baz: boolean;
733
- // }
734
- ```
735
-
736
- @category Object
737
- */
738
- type Merge<Destination, Source> =
739
- Simplify<
740
- SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>>
741
- & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>
742
- >;
743
-
744
- /**
745
- Merges user specified options with default options.
746
-
747
- @example
748
- ```
749
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
750
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
751
- type SpecifiedOptions = {leavesOnly: true};
752
-
753
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
754
- //=> {maxRecursionDepth: 10; leavesOnly: true}
755
- ```
756
-
757
- @example
758
- ```
759
- // Complains if default values are not provided for optional options
760
-
761
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
762
- type DefaultPathsOptions = {maxRecursionDepth: 10};
763
- type SpecifiedOptions = {};
764
-
765
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
766
- // ~~~~~~~~~~~~~~~~~~~
767
- // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
768
- ```
769
-
770
- @example
771
- ```
772
- // Complains if an option's default type does not conform to the expected type
773
-
774
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
775
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
776
- type SpecifiedOptions = {};
777
-
778
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
779
- // ~~~~~~~~~~~~~~~~~~~
780
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
781
- ```
782
-
783
- @example
784
- ```
785
- // Complains if an option's specified type does not conform to the expected type
786
-
787
- type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
788
- type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
789
- type SpecifiedOptions = {leavesOnly: 'yes'};
790
-
791
- type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
792
- // ~~~~~~~~~~~~~~~~
793
- // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
794
- ```
795
- */
796
- type ApplyDefaultOptions<
797
- Options extends object,
798
- Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>,
799
- SpecifiedOptions extends Options,
800
- > =
801
- If<IsAny<SpecifiedOptions>, Defaults,
802
- If<IsNever<SpecifiedOptions>, Defaults,
803
- Simplify<Merge<Defaults, {
804
- [Key in keyof SpecifiedOptions
805
- as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key
806
- ]: SpecifiedOptions[Key]
807
- }> & Required<Options>>>>;
808
-
809
- /**
810
- Returns a boolean for whether either of two given types are true.
811
-
812
- Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
813
-
814
- @example
815
- ```
816
- import type {Or} from 'type-fest';
817
-
818
- type TT = Or<true, false>;
819
- //=> true
820
-
821
- type TF = Or<true, false>;
822
- //=> true
823
-
824
- type FT = Or<false, true>;
825
- //=> true
826
-
827
- type FF = Or<false, false>;
828
- //=> false
829
- ```
830
-
831
- Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
832
- For example, `And<false, boolean>` expands to `And<false, true> | And<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
833
- @example
834
- ```
835
- import type {And} from 'type-fest';
836
-
837
- type A = Or<false, boolean>;
838
- //=> boolean
839
-
840
- type B = Or<boolean, false>;
841
- //=> boolean
842
-
843
- type C = Or<true, boolean>;
844
- //=> true
845
-
846
- type D = Or<boolean, true>;
847
- //=> true
848
-
849
- type E = Or<boolean, boolean>;
850
- //=> boolean
851
- ```
852
-
853
- Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
854
-
855
- @example
856
- ```
857
- import type {Or} from 'type-fest';
858
-
859
- type A = Or<true, never>;
860
- //=> true
861
-
862
- type B = Or<never, true>;
863
- //=> true
864
-
865
- type C = Or<false, never>;
866
- //=> false
867
-
868
- type D = Or<never, false>;
869
- //=> false
870
-
871
- type E = Or<boolean, never>;
872
- //=> boolean
873
-
874
- type F = Or<never, boolean>;
875
- //=> boolean
876
-
877
- type G = Or<never, never>;
878
- //=> false
879
- ```
880
-
881
- @see {@link And}
882
- */
883
- type Or<A extends boolean, B extends boolean> =
884
- _Or<If<IsNever<A>, false, A>, If<IsNever<B>, false, B>>; // `never` is treated as `false`
885
-
886
- type _Or<A extends boolean, B extends boolean> = A extends true
887
- ? true
888
- : B extends true
889
- ? true
890
- : false;
891
-
892
- /**
893
- @see {@link AllExtend}
894
- */
895
- type AllExtendOptions = {
896
- /**
897
- Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
898
-
899
- - When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
900
- - When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
901
-
902
- @default true
903
-
904
- @example
905
- ```
906
- import type {AllExtend} from 'type-fest';
907
-
908
- type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
909
- //=> false
910
-
911
- type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
912
- //=> true
913
-
914
- type C = AllExtend<[never, never], never, {strictNever: true}>;
915
- //=> true
916
-
917
- type D = AllExtend<[never, never], never, {strictNever: false}>;
918
- //=> true
919
-
920
- type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
921
- //=> true
922
-
923
- type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
924
- //=> true
925
-
926
- type G = AllExtend<[never, 1], never, {strictNever: true}>;
927
- //=> false
928
-
929
- type H = AllExtend<[never, 1], never, {strictNever: false}>;
930
- //=> false
931
- ```
932
- */
933
- strictNever?: boolean;
934
- };
935
-
936
- type DefaultAllExtendOptions = {
937
- strictNever: true;
938
- };
939
-
940
- /**
941
- Returns a boolean for whether every element in an array type extends another type.
942
-
943
- @example
944
- ```
945
- import type {AllExtend} from 'type-fest';
946
-
947
- type A = AllExtend<[1, 2, 3], number>;
948
- //=> true
949
-
950
- type B = AllExtend<[1, 2, '3'], number>;
951
- //=> false
952
-
953
- type C = AllExtend<[number, number | string], number>;
954
- //=> boolean
955
-
956
- type D = AllExtend<[true, boolean, true], true>;
957
- //=> boolean
958
- ```
959
-
960
- Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
961
-
962
- ```
963
- import type {AllExtend} from 'type-fest';
964
-
965
- // `exactOptionalPropertyTypes` enabled
966
- type A = AllExtend<[1?, 2?, 3?], number>;
967
- //=> true
968
-
969
- // `exactOptionalPropertyTypes` disabled
970
- type B = AllExtend<[1?, 2?, 3?], number>;
971
- //=> false
972
-
973
- // `exactOptionalPropertyTypes` disabled
974
- type C = AllExtend<[1?, 2?, 3?], number | undefined>;
975
- //=> true
976
- ```
977
-
978
- @see {@link AllExtendOptions}
979
-
980
- @category Utilities
981
- @category Array
982
- */
983
- type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> =
984
- _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
985
-
986
- type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, If<IsAny<Type>, true,
987
- TArray extends readonly [infer First, ...infer Rest]
988
- ? IsNever<First> extends true
989
- ? Or<IsNever<Type>, Not<Options['strictNever']>> extends true
990
- // If target `Type` is also `never` OR `strictNever` is disabled, recurse further.
991
- ? _AllExtend<Rest, Type, Options>
992
- : false
993
- : First extends Type
994
- ? _AllExtend<Rest, Type, Options>
995
- : false
996
- : true
997
- >, false, false>;
998
-
999
- /**
1000
- Returns a boolean for whether the string is numeric.
1001
-
1002
- This type is a workaround for [Microsoft/TypeScript#46109](https://github.com/microsoft/TypeScript/issues/46109#issuecomment-930307987).
1003
- */
1004
- type IsNumeric<T extends string> = T extends `${number}`
1005
- ? Trim<T> extends T
1006
- ? true
1007
- : false
1008
- : false;
1009
-
1010
- /**
1011
- Allows creating a union type by combining primitive types and literal types without sacrificing auto-completion in IDEs for the literal type part of the union.
1012
-
1013
- Currently, when a union type of a primitive type is combined with literal types, TypeScript loses all information about the combined literals. Thus, when such type is used in an IDE with autocompletion, no suggestions are made for the declared literals.
1014
-
1015
- This type is a workaround for [Microsoft/TypeScript#29729](https://github.com/Microsoft/TypeScript/issues/29729). It will be removed as soon as it's not needed anymore.
1016
-
1017
- @example
1018
- ```
1019
- import type {LiteralUnion} from 'type-fest';
1020
-
1021
- // Before
1022
-
1023
- type Pet = 'dog' | 'cat' | string;
1024
-
1025
- const pet: Pet = '';
1026
- // Start typing in your TypeScript-enabled IDE.
1027
- // You **will not** get auto-completion for `dog` and `cat` literals.
1028
-
1029
- // After
1030
-
1031
- type Pet2 = LiteralUnion<'dog' | 'cat', string>;
1032
-
1033
- const pet: Pet2 = '';
1034
- // You **will** get auto-completion for `dog` and `cat` literals.
1035
- ```
1036
-
1037
- @category Type
1038
- */
1039
- type LiteralUnion<
1040
- LiteralType,
1041
- BaseType extends Primitive,
1042
- > = LiteralType | (BaseType & Record<never, never>);
1043
-
1044
- /**
1045
- Returns a boolean for whether the given string literal is lowercase.
1046
-
1047
- @example
1048
- ```
1049
- import type {IsLowercase} from 'type-fest';
1050
-
1051
- IsLowercase<'abc'>;
1052
- //=> true
1053
-
1054
- IsLowercase<'Abc'>;
1055
- //=> false
1056
-
1057
- IsLowercase<string>;
1058
- //=> boolean
1059
- ```
1060
- */
1061
- type IsLowercase<S extends string> = AllExtend<_IsLowercase<S>, true>;
1062
-
1063
- /**
1064
- Loops through each part in the string and returns a boolean array indicating whether each part is lowercase.
1065
- */
1066
- type _IsLowercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}`
1067
- ? _IsLowercase<Rest, [...Accumulator, IsLowercaseHelper<First>]>
1068
- : [...Accumulator, IsLowercaseHelper<S>];
1069
-
1070
- /**
1071
- Returns a boolean for whether an individual part of the string is lowercase.
1072
- */
1073
- type IsLowercaseHelper<S extends string> = S extends Lowercase<string>
1074
- ? true
1075
- : S extends Uppercase<string> | Capitalize<string> | `${string}${Uppercase<string>}${string}`
1076
- ? false
1077
- : boolean;
1078
-
1079
- /**
1080
- Returns a boolean for whether the given string literal is uppercase.
1081
-
1082
- @example
1083
- ```
1084
- import type {IsUppercase} from 'type-fest';
1085
-
1086
- IsUppercase<'ABC'>;
1087
- //=> true
1088
-
1089
- IsUppercase<'Abc'>;
1090
- //=> false
1091
-
1092
- IsUppercase<string>;
1093
- //=> boolean
1094
- ```
1095
- */
1096
- type IsUppercase<S extends string> = AllExtend<_IsUppercase<S>, true>;
1097
-
1098
- /**
1099
- Loops through each part in the string and returns a boolean array indicating whether each part is uppercase.
1100
- */
1101
- type _IsUppercase<S extends string, Accumulator extends boolean[] = []> = S extends `${infer First}${infer Rest}`
1102
- ? _IsUppercase<Rest, [...Accumulator, IsUppercaseHelper<First>]>
1103
- : [...Accumulator, IsUppercaseHelper<S>];
1104
-
1105
- /**
1106
- Returns a boolean for whether an individual part of the string is uppercase.
1107
- */
1108
- type IsUppercaseHelper<S extends string> = S extends Uppercase<string>
1109
- ? true
1110
- : S extends Lowercase<string> | Uncapitalize<string> | `${string}${Lowercase<string>}${string}`
1111
- ? false
1112
- : boolean;
1113
-
1114
- type SkipEmptyWord<Word extends string> = Word extends '' ? [] : [Word];
1115
-
1116
- type RemoveLastCharacter<
1117
- Sentence extends string,
1118
- Character extends string,
1119
- > = Sentence extends `${infer LeftSide}${Character}`
1120
- ? SkipEmptyWord<LeftSide>
1121
- : never;
1122
-
1123
- /**
1124
- Words options.
1125
-
1126
- @see {@link Words}
1127
- */
1128
- type WordsOptions = {
1129
- /**
1130
- Split on numeric sequence.
1131
-
1132
- @default true
1133
-
1134
- @example
1135
- ```
1136
- type Example1 = Words<'p2pNetwork', {splitOnNumbers: true}>;
1137
- //=> ["p", "2", "p", "Network"]
1138
-
1139
- type Example2 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1140
- //=> ["p2p", "Network"]
1141
- ```
1142
- */
1143
- splitOnNumbers?: boolean;
1144
- };
1145
-
1146
- type DefaultWordsOptions = {
1147
- splitOnNumbers: true;
1148
- };
1149
-
1150
- /**
1151
- Split a string (almost) like Lodash's `_.words()` function.
1152
-
1153
- - Split on each word that begins with a capital letter.
1154
- - Split on each {@link WordSeparators}.
1155
- - Split on numeric sequence.
1156
-
1157
- @example
1158
- ```
1159
- import type {Words} from 'type-fest';
1160
-
1161
- type Words0 = Words<'helloWorld'>;
1162
- //=> ['hello', 'World']
1163
-
1164
- type Words1 = Words<'helloWORLD'>;
1165
- //=> ['hello', 'WORLD']
1166
-
1167
- type Words2 = Words<'hello-world'>;
1168
- //=> ['hello', 'world']
1169
-
1170
- type Words3 = Words<'--hello the_world'>;
1171
- //=> ['hello', 'the', 'world']
1172
-
1173
- type Words4 = Words<'lifeIs42'>;
1174
- //=> ['life', 'Is', '42']
1175
-
1176
- type Words5 = Words<'p2pNetwork', {splitOnNumbers: false}>;
1177
- //=> ['p2p', 'Network']
1178
- ```
1179
-
1180
- @category Change case
1181
- @category Template literal
1182
- */
1183
- type Words<Sentence extends string, Options extends WordsOptions = {}> =
1184
- WordsImplementation<Sentence, ApplyDefaultOptions<WordsOptions, DefaultWordsOptions, Options>>;
1185
-
1186
- type WordsImplementation<
1187
- Sentence extends string,
1188
- Options extends Required<WordsOptions>,
1189
- LastCharacter extends string = '',
1190
- CurrentWord extends string = '',
1191
- > = Sentence extends `${infer FirstCharacter}${infer RemainingCharacters}`
1192
- ? FirstCharacter extends WordSeparators
1193
- // Skip word separator
1194
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options>]
1195
- : LastCharacter extends ''
1196
- // Fist char of word
1197
- ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>
1198
- // Case change: non-numeric to numeric
1199
- : [false, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
1200
- ? Options['splitOnNumbers'] extends true
1201
- // Split on number: push word
1202
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
1203
- // No split on number: concat word
1204
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1205
- // Case change: numeric to non-numeric
1206
- : [true, false] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
1207
- ? Options['splitOnNumbers'] extends true
1208
- // Split on number: push word
1209
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
1210
- // No split on number: concat word
1211
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1212
- // No case change: concat word
1213
- : [true, true] extends [IsNumeric<LastCharacter>, IsNumeric<FirstCharacter>]
1214
- ? WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1215
- // Case change: lower to upper, push word
1216
- : [true, true] extends [IsLowercase<LastCharacter>, IsUppercase<FirstCharacter>]
1217
- ? [...SkipEmptyWord<CurrentWord>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, FirstCharacter>]
1218
- // Case change: upper to lower, brings back the last character, push word
1219
- : [true, true] extends [IsUppercase<LastCharacter>, IsLowercase<FirstCharacter>]
1220
- ? [...RemoveLastCharacter<CurrentWord, LastCharacter>, ...WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${LastCharacter}${FirstCharacter}`>]
1221
- // No case change: concat word
1222
- : WordsImplementation<RemainingCharacters, Options, FirstCharacter, `${CurrentWord}${FirstCharacter}`>
1223
- : [...SkipEmptyWord<CurrentWord>];
1224
-
1225
- /**
1226
- CamelCase options.
1227
-
1228
- @see {@link CamelCase}
1229
- */
1230
- type CamelCaseOptions = {
1231
- /**
1232
- Whether to preserved consecutive uppercase letter.
1233
-
1234
- @default false
1235
- */
1236
- preserveConsecutiveUppercase?: boolean;
1237
- };
1238
-
1239
- type DefaultCamelCaseOptions = {
1240
- preserveConsecutiveUppercase: false;
1241
- };
1242
-
1243
- /**
1244
- Convert an array of words to camel-case.
1245
- */
1246
- type CamelCaseFromArray<
1247
- Words extends string[],
1248
- Options extends Required<CamelCaseOptions>,
1249
- OutputString extends string = '',
1250
- > = Words extends [
1251
- infer FirstWord extends string,
1252
- ...infer RemainingWords extends string[],
1253
- ]
1254
- ? Options['preserveConsecutiveUppercase'] extends true
1255
- ? `${Capitalize<FirstWord>}${CamelCaseFromArray<RemainingWords, Options>}`
1256
- : `${Capitalize<Lowercase<FirstWord>>}${CamelCaseFromArray<RemainingWords, Options>}`
1257
- : OutputString;
1258
-
1259
- /**
1260
- Convert a string literal to camel-case.
1261
-
1262
- This can be useful when, for example, converting some kebab-cased command-line flags or a snake-cased database result.
1263
-
1264
- By default, consecutive uppercase letter are preserved. See {@link CamelCaseOptions.preserveConsecutiveUppercase preserveConsecutiveUppercase} option to change this behaviour.
1265
-
1266
- @example
1267
- ```
1268
- import type {CamelCase} from 'type-fest';
1269
-
1270
- // Simple
1271
-
1272
- const someVariable: CamelCase<'foo-bar'> = 'fooBar';
1273
- const preserveConsecutiveUppercase: CamelCase<'foo-BAR-baz', {preserveConsecutiveUppercase: true}> = 'fooBARBaz';
1274
-
1275
- // Advanced
1276
-
1277
- type CamelCasedProperties<T> = {
1278
- [K in keyof T as CamelCase<K>]: T[K]
1279
- };
1280
-
1281
- interface RawOptions {
1282
- 'dry-run': boolean;
1283
- 'full_family_name': string;
1284
- foo: number;
1285
- BAR: string;
1286
- QUZ_QUX: number;
1287
- 'OTHER-FIELD': boolean;
1288
- }
1289
-
1290
- const dbResult: CamelCasedProperties<RawOptions> = {
1291
- dryRun: true,
1292
- fullFamilyName: 'bar.js',
1293
- foo: 123,
1294
- bar: 'foo',
1295
- quzQux: 6,
1296
- otherField: false
1297
- };
1298
- ```
1299
-
1300
- @category Change case
1301
- @category Template literal
1302
- */
1303
- type CamelCase<Type, Options extends CamelCaseOptions = {}> = Type extends string
1304
- ? string extends Type
1305
- ? Type
1306
- : Uncapitalize<CamelCaseFromArray<
1307
- Words<Type extends Uppercase<Type> ? Lowercase<Type> : Type>,
1308
- ApplyDefaultOptions<CamelCaseOptions, DefaultCamelCaseOptions, Options>
1309
- >>
1310
- : Type;
1311
-
1312
- /**
1313
- Convert object properties to camel case but not recursively.
1314
-
1315
- This can be useful when, for example, converting some API types from a different style.
1316
-
1317
- @see CamelCasedPropertiesDeep
1318
- @see CamelCase
1319
-
1320
- @example
1321
- ```
1322
- import type {CamelCasedProperties} from 'type-fest';
1323
-
1324
- interface User {
1325
- UserId: number;
1326
- UserName: string;
1327
- }
1328
-
1329
- const result: CamelCasedProperties<User> = {
1330
- userId: 1,
1331
- userName: 'Tom',
1332
- };
1333
-
1334
- const preserveConsecutiveUppercase: CamelCasedProperties<{fooBAR: string}, {preserveConsecutiveUppercase: true}> = {
1335
- fooBAR: 'string',
1336
- };
1337
- ```
1338
-
1339
- @category Change case
1340
- @category Template literal
1341
- @category Object
1342
- */
1343
- type CamelCasedProperties<Value, Options extends CamelCaseOptions = {}> = Value extends Function
1344
- ? Value
1345
- : Value extends Array<infer U>
1346
- ? Value
1347
- : {
1348
- [K in keyof Value as
1349
- CamelCase<K, ApplyDefaultOptions<CamelCaseOptions, DefaultCamelCaseOptions, Options>>
1350
- ]: Value[K];
1351
- };
1352
-
1353
- declare namespace PackageJson {
1354
- /**
1355
- A person who has been involved in creating or maintaining the package.
1356
- */
1357
- export type Person =
1358
- | string
1359
- | {
1360
- name: string;
1361
- url?: string;
1362
- email?: string;
1363
- };
1364
-
1365
- export type BugsLocation =
1366
- | string
1367
- | {
1368
- /**
1369
- The URL to the package's issue tracker.
1370
- */
1371
- url?: string;
1372
-
1373
- /**
1374
- The email address to which issues should be reported.
1375
- */
1376
- email?: string;
1377
- };
1378
-
1379
- export type DirectoryLocations = {
1380
- [directoryType: string]: JsonValue | undefined;
1381
-
1382
- /**
1383
- Location for executable scripts. Sugar to generate entries in the `bin` property by walking the folder.
1384
- */
1385
- bin?: string;
1386
-
1387
- /**
1388
- Location for Markdown files.
1389
- */
1390
- doc?: string;
1391
-
1392
- /**
1393
- Location for example scripts.
1394
- */
1395
- example?: string;
1396
-
1397
- /**
1398
- Location for the bulk of the library.
1399
- */
1400
- lib?: string;
1401
-
1402
- /**
1403
- Location for man pages. Sugar to generate a `man` array by walking the folder.
1404
- */
1405
- man?: string;
1406
-
1407
- /**
1408
- Location for test files.
1409
- */
1410
- test?: string;
1411
- };
1412
-
1413
- export type Scripts = {
1414
- /**
1415
- Run **before** the package is published (Also run on local `npm install` without any arguments).
1416
- */
1417
- prepublish?: string;
1418
-
1419
- /**
1420
- Run both **before** the package is packed and published, and on local `npm install` without any arguments. This is run **after** `prepublish`, but **before** `prepublishOnly`.
1421
- */
1422
- prepare?: string;
1423
-
1424
- /**
1425
- Run **before** the package is prepared and packed, **only** on `npm publish`.
1426
- */
1427
- prepublishOnly?: string;
1428
-
1429
- /**
1430
- Run **before** a tarball is packed (on `npm pack`, `npm publish`, and when installing git dependencies).
1431
- */
1432
- prepack?: string;
1433
-
1434
- /**
1435
- Run **after** the tarball has been generated and moved to its final destination.
1436
- */
1437
- postpack?: string;
1438
-
1439
- /**
1440
- Run **after** the package is published.
1441
- */
1442
- publish?: string;
1443
-
1444
- /**
1445
- Run **after** the package is published.
1446
- */
1447
- postpublish?: string;
1448
-
1449
- /**
1450
- Run **before** the package is installed.
1451
- */
1452
- preinstall?: string;
1453
-
1454
- /**
1455
- Run **after** the package is installed.
1456
- */
1457
- install?: string;
1458
-
1459
- /**
1460
- Run **after** the package is installed and after `install`.
1461
- */
1462
- postinstall?: string;
1463
-
1464
- /**
1465
- Run **before** the package is uninstalled and before `uninstall`.
1466
- */
1467
- preuninstall?: string;
1468
-
1469
- /**
1470
- Run **before** the package is uninstalled.
1471
- */
1472
- uninstall?: string;
1473
-
1474
- /**
1475
- Run **after** the package is uninstalled.
1476
- */
1477
- postuninstall?: string;
1478
-
1479
- /**
1480
- Run **before** bump the package version and before `version`.
1481
- */
1482
- preversion?: string;
1483
-
1484
- /**
1485
- Run **before** bump the package version.
1486
- */
1487
- version?: string;
1488
-
1489
- /**
1490
- Run **after** bump the package version.
1491
- */
1492
- postversion?: string;
1493
-
1494
- /**
1495
- Run with the `npm test` command, before `test`.
1496
- */
1497
- pretest?: string;
1498
-
1499
- /**
1500
- Run with the `npm test` command.
1501
- */
1502
- test?: string;
1503
-
1504
- /**
1505
- Run with the `npm test` command, after `test`.
1506
- */
1507
- posttest?: string;
1508
-
1509
- /**
1510
- Run with the `npm stop` command, before `stop`.
1511
- */
1512
- prestop?: string;
1513
-
1514
- /**
1515
- Run with the `npm stop` command.
1516
- */
1517
- stop?: string;
1518
-
1519
- /**
1520
- Run with the `npm stop` command, after `stop`.
1521
- */
1522
- poststop?: string;
1523
-
1524
- /**
1525
- Run with the `npm start` command, before `start`.
1526
- */
1527
- prestart?: string;
1528
-
1529
- /**
1530
- Run with the `npm start` command.
1531
- */
1532
- start?: string;
1533
-
1534
- /**
1535
- Run with the `npm start` command, after `start`.
1536
- */
1537
- poststart?: string;
1538
-
1539
- /**
1540
- Run with the `npm restart` command, before `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
1541
- */
1542
- prerestart?: string;
1543
-
1544
- /**
1545
- Run with the `npm restart` command. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
1546
- */
1547
- restart?: string;
1548
-
1549
- /**
1550
- Run with the `npm restart` command, after `restart`. Note: `npm restart` will run the `stop` and `start` scripts if no `restart` script is provided.
1551
- */
1552
- postrestart?: string;
1553
- } & Partial<Record<string, string>>;
1554
-
1555
- /**
1556
- Dependencies of the package. The version range is a string which has one or more space-separated descriptors. Dependencies can also be identified with a tarball or Git URL.
1557
- */
1558
- export type Dependency = Partial<Record<string, string>>;
1559
-
1560
- /**
1561
- A mapping of conditions and the paths to which they resolve.
1562
- */
1563
- type ExportConditions = {
1564
- [condition: string]: Exports;
1565
- };
1566
-
1567
- /**
1568
- Entry points of a module, optionally with conditions and subpath exports.
1569
- */
1570
- export type Exports =
1571
- | null
1572
- | string
1573
- | Array<string | ExportConditions>
1574
- | ExportConditions;
1575
-
1576
- /**
1577
- Import map entries of a module, optionally with conditions and subpath imports.
1578
- */
1579
- export type Imports = {
1580
- [key: `#${string}`]: Exports;
1581
- };
1582
-
1583
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
1584
- export interface NonStandardEntryPoints {
1585
- /**
1586
- An ECMAScript module ID that is the primary entry point to the program.
1587
- */
1588
- module?: string;
1589
-
1590
- /**
1591
- A module ID with untranspiled code that is the primary entry point to the program.
1592
- */
1593
- esnext?:
1594
- | string
1595
- | {
1596
- [moduleName: string]: string | undefined;
1597
- main?: string;
1598
- browser?: string;
1599
- };
1600
-
1601
- /**
1602
- A hint to JavaScript bundlers or component tools when packaging modules for client side use.
1603
- */
1604
- browser?:
1605
- | string
1606
- | Partial<Record<string, string | false>>;
1607
-
1608
- /**
1609
- Denote which files in your project are "pure" and therefore safe for Webpack to prune if unused.
1610
-
1611
- [Read more.](https://webpack.js.org/guides/tree-shaking/)
1612
- */
1613
- sideEffects?: boolean | string[];
1614
- }
1615
-
1616
- export type TypeScriptConfiguration = {
1617
- /**
1618
- Location of the bundled TypeScript declaration file.
1619
- */
1620
- types?: string;
1621
-
1622
- /**
1623
- Version selection map of TypeScript.
1624
- */
1625
- typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
1626
-
1627
- /**
1628
- Location of the bundled TypeScript declaration file. Alias of `types`.
1629
- */
1630
- typings?: string;
1631
- };
1632
-
1633
- /**
1634
- An alternative configuration for workspaces.
1635
- */
1636
- export type WorkspaceConfig = {
1637
- /**
1638
- An array of workspace pattern strings which contain the workspace packages.
1639
- */
1640
- packages?: WorkspacePattern[];
1641
-
1642
- /**
1643
- Designed to solve the problem of packages which break when their `node_modules` are moved to the root workspace directory - a process known as hoisting. For these packages, both within your workspace, and also some that have been installed via `node_modules`, it is important to have a mechanism for preventing the default Yarn workspace behavior. By adding workspace pattern strings here, Yarn will resume non-workspace behavior for any package which matches the defined patterns.
1644
-
1645
- [Supported](https://classic.yarnpkg.com/blog/2018/02/15/nohoist/) by Yarn.
1646
- [Not supported](https://github.com/npm/rfcs/issues/287) by npm.
1647
- */
1648
- nohoist?: WorkspacePattern[];
1649
- };
1650
-
1651
- /**
1652
- A workspace pattern points to a directory or group of directories which contain packages that should be included in the workspace installation process.
1653
-
1654
- The patterns are handled with [minimatch](https://github.com/isaacs/minimatch).
1655
-
1656
- @example
1657
- `docs` → Include the docs directory and install its dependencies.
1658
- `packages/*` → Include all nested directories within the packages directory, like `packages/cli` and `packages/core`.
1659
- */
1660
- type WorkspacePattern = string;
1661
-
1662
- export type YarnConfiguration = {
1663
- /**
1664
- If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as `yarn install --flat` on the command-line, set this to `true`.
1665
-
1666
- Note that if your `package.json` contains `"flat": true` and other packages depend on yours (e.g. you are building a library rather than an app), those other packages will also need `"flat": true` in their `package.json` or be installed with `yarn install --flat` on the command-line.
1667
- */
1668
- flat?: boolean;
1669
-
1670
- /**
1671
- Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the `yarn.lock` file.
1672
- */
1673
- resolutions?: Dependency;
1674
- };
1675
-
1676
- export type JSPMConfiguration = {
1677
- /**
1678
- JSPM configuration.
1679
- */
1680
- jspm?: PackageJson;
1681
- };
1682
-
1683
- /**
1684
- Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Containing standard npm properties.
1685
- */
1686
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions
1687
- export interface PackageJsonStandard {
1688
- /**
1689
- The name of the package.
1690
- */
1691
- name?: string;
1692
-
1693
- /**
1694
- Package version, parseable by [`node-semver`](https://github.com/npm/node-semver).
1695
- */
1696
- version?: string;
1697
-
1698
- /**
1699
- Package description, listed in `npm search`.
1700
- */
1701
- description?: string;
1702
-
1703
- /**
1704
- Keywords associated with package, listed in `npm search`.
1705
- */
1706
- keywords?: string[];
1707
-
1708
- /**
1709
- The URL to the package's homepage.
1710
- */
1711
- homepage?: LiteralUnion<'.', string>;
1712
-
1713
- /**
1714
- The URL to the package's issue tracker and/or the email address to which issues should be reported.
1715
- */
1716
- bugs?: BugsLocation;
1717
-
1718
- /**
1719
- The license for the package.
1720
- */
1721
- license?: string;
1722
-
1723
- /**
1724
- The licenses for the package.
1725
- */
1726
- licenses?: Array<{
1727
- type?: string;
1728
- url?: string;
1729
- }>;
1730
-
1731
- author?: Person;
1732
-
1733
- /**
1734
- A list of people who contributed to the package.
1735
- */
1736
- contributors?: Person[];
1737
-
1738
- /**
1739
- A list of people who maintain the package.
1740
- */
1741
- maintainers?: Person[];
1742
-
1743
- /**
1744
- The files included in the package.
1745
- */
1746
- files?: string[];
1747
-
1748
- /**
1749
- Resolution algorithm for importing ".js" files from the package's scope.
1750
-
1751
- [Read more.](https://nodejs.org/api/esm.html#esm_package_json_type_field)
1752
- */
1753
- type?: 'module' | 'commonjs';
1754
-
1755
- /**
1756
- The module ID that is the primary entry point to the program.
1757
- */
1758
- main?: string;
1759
-
1760
- /**
1761
- Subpath exports to define entry points of the package.
1762
-
1763
- [Read more.](https://nodejs.org/api/packages.html#subpath-exports)
1764
- */
1765
- exports?: Exports;
1766
-
1767
- /**
1768
- Subpath imports to define internal package import maps that only apply to import specifiers from within the package itself.
1769
-
1770
- [Read more.](https://nodejs.org/api/packages.html#subpath-imports)
1771
- */
1772
- imports?: Imports;
1773
-
1774
- /**
1775
- The executable files that should be installed into the `PATH`.
1776
- */
1777
- bin?:
1778
- | string
1779
- | Partial<Record<string, string>>;
1780
-
1781
- /**
1782
- Filenames to put in place for the `man` program to find.
1783
- */
1784
- man?: string | string[];
1785
-
1786
- /**
1787
- Indicates the structure of the package.
1788
- */
1789
- directories?: DirectoryLocations;
1790
-
1791
- /**
1792
- Location for the code repository.
1793
- */
1794
- repository?:
1795
- | string
1796
- | {
1797
- type: string;
1798
- url: string;
1799
-
1800
- /**
1801
- Relative path to package.json if it is placed in non-root directory (for example if it is part of a monorepo).
1802
-
1803
- [Read more.](https://github.com/npm/rfcs/blob/latest/implemented/0010-monorepo-subdirectory-declaration.md)
1804
- */
1805
- directory?: string;
1806
- };
1807
-
1808
- /**
1809
- Script commands that are run at various times in the lifecycle of the package. The key is the lifecycle event, and the value is the command to run at that point.
1810
- */
1811
- scripts?: Scripts;
1812
-
1813
- /**
1814
- Is used to set configuration parameters used in package scripts that persist across upgrades.
1815
- */
1816
- config?: JsonObject;
1817
-
1818
- /**
1819
- The dependencies of the package.
1820
- */
1821
- dependencies?: Dependency;
1822
-
1823
- /**
1824
- Additional tooling dependencies that are not required for the package to work. Usually test, build, or documentation tooling.
1825
- */
1826
- devDependencies?: Dependency;
1827
-
1828
- /**
1829
- Dependencies that are skipped if they fail to install.
1830
- */
1831
- optionalDependencies?: Dependency;
1832
-
1833
- /**
1834
- Dependencies that will usually be required by the package user directly or via another dependency.
1835
- */
1836
- peerDependencies?: Dependency;
1837
-
1838
- /**
1839
- Indicate peer dependencies that are optional.
1840
- */
1841
- peerDependenciesMeta?: Partial<Record<string, {optional: true}>>;
1842
-
1843
- /**
1844
- Package names that are bundled when the package is published.
1845
- */
1846
- bundledDependencies?: string[];
1847
-
1848
- /**
1849
- Alias of `bundledDependencies`.
1850
- */
1851
- bundleDependencies?: string[];
1852
-
1853
- /**
1854
- Engines that this package runs on.
1855
- */
1856
- engines?: {
1857
- [EngineName in 'npm' | 'node' | string]?: string;
1858
- };
1859
-
1860
- /**
1861
- @deprecated
1862
- */
1863
- engineStrict?: boolean;
1864
-
1865
- /**
1866
- Operating systems the module runs on.
1867
- */
1868
- os?: Array<LiteralUnion<
1869
- | 'aix'
1870
- | 'darwin'
1871
- | 'freebsd'
1872
- | 'linux'
1873
- | 'openbsd'
1874
- | 'sunos'
1875
- | 'win32'
1876
- | '!aix'
1877
- | '!darwin'
1878
- | '!freebsd'
1879
- | '!linux'
1880
- | '!openbsd'
1881
- | '!sunos'
1882
- | '!win32',
1883
- string
1884
- >>;
1885
-
1886
- /**
1887
- CPU architectures the module runs on.
1888
- */
1889
- cpu?: Array<LiteralUnion<
1890
- | 'arm'
1891
- | 'arm64'
1892
- | 'ia32'
1893
- | 'mips'
1894
- | 'mipsel'
1895
- | 'ppc'
1896
- | 'ppc64'
1897
- | 's390'
1898
- | 's390x'
1899
- | 'x32'
1900
- | 'x64'
1901
- | '!arm'
1902
- | '!arm64'
1903
- | '!ia32'
1904
- | '!mips'
1905
- | '!mipsel'
1906
- | '!ppc'
1907
- | '!ppc64'
1908
- | '!s390'
1909
- | '!s390x'
1910
- | '!x32'
1911
- | '!x64',
1912
- string
1913
- >>;
1914
-
1915
- /**
1916
- If set to `true`, a warning will be shown if package is installed locally. Useful if the package is primarily a command-line application that should be installed globally.
1917
-
1918
- @deprecated
1919
- */
1920
- preferGlobal?: boolean;
1921
-
1922
- /**
1923
- If set to `true`, then npm will refuse to publish it.
1924
- */
1925
- private?: boolean;
1926
-
1927
- /**
1928
- A set of config values that will be used at publish-time. It's especially handy to set the tag, registry or access, to ensure that a given package is not tagged with 'latest', published to the global public registry or that a scoped module is private by default.
1929
- */
1930
- publishConfig?: PublishConfig;
1931
-
1932
- /**
1933
- Describes and notifies consumers of a package's monetary support information.
1934
-
1935
- [Read more.](https://github.com/npm/rfcs/blob/main/implemented/0017-add-funding-support.md)
1936
- */
1937
- funding?: string | {
1938
- /**
1939
- The type of funding.
1940
- */
1941
- type?: LiteralUnion<
1942
- | 'github'
1943
- | 'opencollective'
1944
- | 'patreon'
1945
- | 'individual'
1946
- | 'foundation'
1947
- | 'corporation',
1948
- string
1949
- >;
1950
-
1951
- /**
1952
- The URL to the funding page.
1953
- */
1954
- url: string;
1955
- };
1956
-
1957
- /**
1958
- Used to configure [npm workspaces](https://docs.npmjs.com/cli/using-npm/workspaces) / [Yarn workspaces](https://classic.yarnpkg.com/docs/workspaces/).
1959
-
1960
- Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run your install command once in order to install all of them in a single pass.
1961
-
1962
- Please note that the top-level `private` property of `package.json` **must** be set to `true` in order to use workspaces.
1963
- */
1964
- workspaces?: WorkspacePattern[] | WorkspaceConfig;
1965
- }
1966
-
1967
- /**
1968
- Type for [`package.json` file used by the Node.js runtime](https://nodejs.org/api/packages.html#nodejs-packagejson-field-definitions).
1969
- */
1970
- export type NodeJsStandard = {
1971
- /**
1972
- Defines which package manager is expected to be used when working on the current project. It can set to any of the [supported package managers](https://nodejs.org/api/corepack.html#supported-package-managers), and will ensure that your teams use the exact same package manager versions without having to install anything else than Node.js.
1973
-
1974
- __This field is currently experimental and needs to be opted-in; check the [Corepack](https://nodejs.org/api/corepack.html) page for details about the procedure.__
1975
-
1976
- @example
1977
- ```json
1978
- {
1979
- "packageManager": "<package manager name>@<version>"
1980
- }
1981
- ```
1982
- */
1983
- packageManager?: string;
1984
- };
1985
-
1986
- export type PublishConfig = {
1987
- /**
1988
- Additional, less common properties from the [npm docs on `publishConfig`](https://docs.npmjs.com/cli/v7/configuring-npm/package-json#publishconfig).
1989
- */
1990
- [additionalProperties: string]: JsonValue | undefined;
1991
-
1992
- /**
1993
- When publishing scoped packages, the access level defaults to restricted. If you want your scoped package to be publicly viewable (and installable) set `--access=public`. The only valid values for access are public and restricted. Unscoped packages always have an access level of public.
1994
- */
1995
- access?: 'public' | 'restricted';
1996
-
1997
- /**
1998
- The base URL of the npm registry.
1999
-
2000
- Default: `'https://registry.npmjs.org/'`
2001
- */
2002
- registry?: string;
2003
-
2004
- /**
2005
- The tag to publish the package under.
2006
-
2007
- Default: `'latest'`
2008
- */
2009
- tag?: string;
2010
- };
2011
- }
2012
-
2013
- /**
2014
- Type for [npm's `package.json` file](https://docs.npmjs.com/creating-a-package-json-file). Also includes types for fields used by other popular projects, like TypeScript and Yarn.
2015
-
2016
- @category File
2017
- */
2018
- type PackageJson =
2019
- JsonObject &
2020
- PackageJson.NodeJsStandard &
2021
- PackageJson.PackageJsonStandard &
2022
- PackageJson.NonStandardEntryPoints &
2023
- PackageJson.TypeScriptConfiguration &
2024
- PackageJson.YarnConfiguration &
2025
- PackageJson.JSPMConfiguration;
2026
-
2027
- type FlagType = 'string' | 'boolean' | 'number';
2028
-
2029
- /**
2030
- Callback function to determine if a flag is required during runtime.
2031
-
2032
- @param flags - Contains the flags converted to camel-case excluding aliases.
2033
- @param input - Contains the non-flag arguments.
2034
-
2035
- @returns True if the flag is required, otherwise false.
2036
- */
2037
- type IsRequiredPredicate = (flags: Readonly<AnyFlags>, input: readonly string[]) => boolean;
2038
-
2039
- type Flag<PrimitiveType extends FlagType, Type, IsMultiple = false> = {
2040
- /**
2041
- Type of value. (Possible values: `string` `boolean` `number`)
2042
- */
2043
- readonly type?: PrimitiveType;
2044
-
2045
- /**
2046
- Limit valid values to a predefined set of choices.
2047
-
2048
- @example
2049
- ```
2050
- unicorn: {
2051
- isMultiple: true,
2052
- choices: ['rainbow', 'cat', 'unicorn']
2053
- }
2054
- ```
2055
- */
2056
- readonly choices?: Type extends unknown[] ? Type : Type[];
2057
-
2058
- /**
2059
- Default value when the flag is not specified.
2060
-
2061
- @example
2062
- ```
2063
- unicorn: {
2064
- type: 'boolean',
2065
- default: true
2066
- }
2067
- ```
2068
- */
2069
- readonly default?: Type;
2070
-
2071
- /**
2072
- A short flag alias.
2073
-
2074
- @example
2075
- ```
2076
- unicorn: {
2077
- shortFlag: 'u'
2078
- }
2079
- ```
2080
- */
2081
- readonly shortFlag?: string;
2082
-
2083
- /**
2084
- Other names for the flag.
2085
-
2086
- @example
2087
- ```
2088
- unicorn: {
2089
- aliases: ['unicorns', 'uni']
2090
- }
2091
- ```
2092
- */
2093
- readonly aliases?: string[];
2094
-
2095
- /**
2096
- Indicates a flag can be set multiple times. Values are turned into an array.
2097
-
2098
- Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).
2099
-
2100
- @default false
2101
- */
2102
- readonly isMultiple?: IsMultiple;
2103
-
2104
- /**
2105
- Determine if the flag is required.
2106
-
2107
- If it's only known at runtime whether the flag is required or not you can pass a Function instead of a boolean, which based on the given flags and other non-flag arguments should decide if the flag is required.
2108
-
2109
- - The first argument is the **flags** object, which contains the flags converted to camel-case excluding aliases.
2110
- - The second argument is the **input** string array, which contains the non-flag arguments.
2111
- - The function should return a `boolean`, true if the flag is required, otherwise false.
2112
-
2113
- @default false
2114
-
2115
- @example
2116
- ```
2117
- isRequired: (flags, input) => {
2118
- if (flags.otherFlag) {
2119
- return true;
2120
- }
2121
-
2122
- return false;
2123
- }
2124
- ```
2125
- */
2126
- readonly isRequired?: boolean | IsRequiredPredicate;
2127
- };
2128
-
2129
- type StringFlag = Flag<'string', string> | Flag<'string', string[], true>;
2130
- type BooleanFlag = Flag<'boolean', boolean> | Flag<'boolean', boolean[], true>;
2131
- type NumberFlag = Flag<'number', number> | Flag<'number', number[], true>;
2132
- type AnyFlag = StringFlag | BooleanFlag | NumberFlag;
2133
- type AnyFlags = Record<string, AnyFlag>;
2134
-
2135
- type Options<Flags extends AnyFlags> = {
2136
- /**
2137
- Pass in [`import.meta`](https://nodejs.org/dist/latest/docs/api/esm.html#esm_import_meta). This is used to find the correct package.json file.
2138
- */
2139
- readonly importMeta: ImportMeta;
2140
-
2141
- /**
2142
- Define argument flags.
2143
-
2144
- The key is the flag name in camel-case and the value is an object with any of:
2145
-
2146
- - `type`: Type of value. (Possible values: `string` `boolean` `number`)
2147
- - `choices`: Limit valid values to a predefined set of choices.
2148
- - `default`: Default value when the flag is not specified.
2149
- - `shortFlag`: A short flag alias.
2150
- - `aliases`: Other names for the flag.
2151
- - `isMultiple`: Indicates a flag can be set multiple times. Values are turned into an array. (Default: false)
2152
- - Multiple values are provided by specifying the flag multiple times, for example, `$ foo -u rainbow -u cat`. Space- or comma-separated values [currently *not* supported](https://github.com/sindresorhus/meow/issues/164).
2153
- - `isRequired`: Determine if the flag is required. (Default: false)
2154
- - If it's only known at runtime whether the flag is required or not, you can pass a `Function` instead of a `boolean`, which based on the given flags and other non-flag arguments, should decide if the flag is required. Two arguments are passed to the function:
2155
- - The first argument is the **flags** object, which contains the flags converted to camel-case excluding aliases.
2156
- - The second argument is the **input** string array, which contains the non-flag arguments.
2157
- - The function should return a `boolean`, true if the flag is required, otherwise false.
2158
-
2159
- Note that flags are always defined using a camel-case key (`myKey`), but will match arguments in kebab-case (`--my-key`).
2160
-
2161
- @example
2162
- ```
2163
- flags: {
2164
- unicorn: {
2165
- type: 'string',
2166
- choices: ['rainbow', 'cat', 'unicorn'],
2167
- default: ['rainbow', 'cat'],
2168
- shortFlag: 'u',
2169
- aliases: ['unicorns']
2170
- isMultiple: true,
2171
- isRequired: (flags, input) => {
2172
- if (flags.otherFlag) {
2173
- return true;
2174
- }
2175
-
2176
- return false;
2177
- }
2178
- }
2179
- }
2180
- ```
2181
- */
2182
- readonly flags?: Flags;
2183
-
2184
- /**
2185
- Description to show above the help text. Default: The package.json `"description"` property.
2186
-
2187
- Set it to `false` to disable it altogether.
2188
- */
2189
- readonly description?: string | false;
2190
-
2191
- /**
2192
- The help text you want shown.
2193
-
2194
- The input is reindented and starting/ending newlines are trimmed which means you can use a [template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) without having to care about using the correct amount of indent.
2195
-
2196
- The description will be shown above your help text automatically.
2197
-
2198
- Set it to `false` to disable it altogether.
2199
- */
2200
- readonly help?: string | false;
2201
-
2202
- /**
2203
- Set a custom version output. Default: The package.json `"version"` property.
2204
- */
2205
- readonly version?: string;
2206
-
2207
- /**
2208
- Automatically show the help text when the `--help` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own help text.
2209
-
2210
- This option is only considered when there is only one argument in `process.argv`.
2211
- */
2212
- readonly autoHelp?: boolean;
2213
-
2214
- /**
2215
- Automatically show the version text when the `--version` flag is present. Useful to set this value to `false` when a CLI manages child CLIs with their own version text.
2216
-
2217
- This option is only considered when there is only one argument in `process.argv`.
2218
- */
2219
- readonly autoVersion?: boolean;
2220
-
2221
- /**
2222
- `package.json` as an `Object`. Default: Closest `package.json` upwards.
2223
-
2224
- Note: Setting this stops `meow` from finding a package.json.
2225
-
2226
- _You most likely don't need this option._
2227
- */
2228
- readonly pkg?: Record<string, unknown>;
2229
-
2230
- /**
2231
- Custom arguments object.
2232
-
2233
- @default process.argv.slice(2)
2234
- */
2235
- readonly argv?: readonly string[];
2236
-
2237
- /**
2238
- Infer the argument type.
2239
-
2240
- By default, the argument `5` in `$ foo 5` becomes a string. Enabling this would infer it as a number.
2241
-
2242
- @default false
2243
- */
2244
- readonly inferType?: boolean;
2245
-
2246
- /**
2247
- Value of `boolean` flags not defined in `argv`.
2248
-
2249
- If set to `undefined`, the flags not defined in `argv` will be excluded from the result. The `default` value set in `boolean` flags take precedence over `booleanDefault`.
2250
-
2251
- _Note: If used in conjunction with `isMultiple`, the default flag value is set to `[]`._
2252
-
2253
- __Caution: Explicitly specifying `undefined` for `booleanDefault` has different meaning from omitting key itself.__
2254
-
2255
- @example
2256
- ```
2257
- import meow from 'meow';
2258
-
2259
- const cli = meow(`
2260
- Usage
2261
- $ foo
2262
-
2263
- Options
2264
- --rainbow, -r Include a rainbow
2265
- --unicorn, -u Include a unicorn
2266
- --no-sparkles Exclude sparkles
2267
-
2268
- Examples
2269
- $ foo
2270
- 🌈 unicorns✨🌈
2271
- `, {
2272
- importMeta: import.meta,
2273
- booleanDefault: undefined,
2274
- flags: {
2275
- rainbow: {
2276
- type: 'boolean',
2277
- default: true,
2278
- shortFlag: 'r'
2279
- },
2280
- unicorn: {
2281
- type: 'boolean',
2282
- default: false,
2283
- shortFlag: 'u'
2284
- },
2285
- cake: {
2286
- type: 'boolean',
2287
- shortFlag: 'c'
2288
- },
2289
- sparkles: {
2290
- type: 'boolean',
2291
- default: true
2292
- }
2293
- }
2294
- });
2295
-
2296
- //{
2297
- // flags: {
2298
- // rainbow: true,
2299
- // unicorn: false,
2300
- // sparkles: true
2301
- // },
2302
- // unnormalizedFlags: {
2303
- // rainbow: true,
2304
- // r: true,
2305
- // unicorn: false,
2306
- // u: false,
2307
- // sparkles: true
2308
- // },
2309
- // …
2310
- //}
2311
- ```
2312
- */
2313
- readonly booleanDefault?: boolean | undefined;
2314
-
2315
- /**
2316
- Whether to allow unknown flags or not.
2317
-
2318
- @default true
2319
- */
2320
- readonly allowUnknownFlags?: boolean;
2321
-
2322
- /**
2323
- The number of spaces to use for indenting the help text.
2324
-
2325
- @default 2
2326
- */
2327
- readonly helpIndent?: number;
2328
- };
2329
-
2330
- type TypedFlag<Flag extends AnyFlag> =
2331
- Flag extends {type: 'number'}
2332
- ? number
2333
- : Flag extends {type: 'string'}
2334
- ? string
2335
- : Flag extends {type: 'boolean'}
2336
- ? boolean
2337
- : unknown;
2338
-
2339
- type PossiblyOptionalFlag<Flag extends AnyFlag, FlagType> =
2340
- Flag extends {isRequired: true}
2341
- ? FlagType
2342
- : Flag extends {default: any}
2343
- ? FlagType
2344
- : FlagType | undefined;
2345
-
2346
- type TypedFlags<Flags extends AnyFlags> = {
2347
- [F in keyof Flags]: Flags[F] extends {isMultiple: true}
2348
- ? PossiblyOptionalFlag<Flags[F], Array<TypedFlag<Flags[F]>>>
2349
- : PossiblyOptionalFlag<Flags[F], TypedFlag<Flags[F]>>
2350
- };
2351
-
2352
- type Result<Flags extends AnyFlags> = {
2353
- /**
2354
- Non-flag arguments.
2355
- */
2356
- input: string[];
2357
-
2358
- /**
2359
- Flags converted to camelCase excluding aliases.
2360
- */
2361
- flags: CamelCasedProperties<TypedFlags<Flags>> & Record<string, unknown>;
2362
-
2363
- /**
2364
- Flags converted camelCase including aliases.
2365
- */
2366
- unnormalizedFlags: TypedFlags<Flags> & Record<string, unknown>;
2367
-
2368
- /**
2369
- The `package.json` object.
2370
- */
2371
- pkg: PackageJson;
2372
-
2373
- /**
2374
- The help text used with `--help`.
2375
- */
2376
- help: string;
2377
-
2378
- /**
2379
- Show the help text and exit with code.
2380
-
2381
- @param exitCode - The exit code to use. Default: `2`.
2382
- */
2383
- showHelp: (exitCode?: number) => never;
2384
-
2385
- /**
2386
- Show the version text and exit.
2387
- */
2388
- showVersion: () => void;
2389
- };
2390
- /**
2391
- @param helpMessage - Shortcut for the `help` option.
2392
-
2393
- @example
2394
- ```
2395
- #!/usr/bin/env node
2396
- import meow from 'meow';
2397
- import foo from './index.js';
2398
-
2399
- const cli = meow(`
2400
- Usage
2401
- $ foo <input>
2402
-
2403
- Options
2404
- --rainbow, -r Include a rainbow
2405
-
2406
- Examples
2407
- $ foo unicorns --rainbow
2408
- 🌈 unicorns 🌈
2409
- `, {
2410
- importMeta: import.meta, // This is required
2411
- flags: {
2412
- rainbow: {
2413
- type: 'boolean',
2414
- shortFlag: 'r'
2415
- }
2416
- }
2417
- });
2418
-
2419
- //{
2420
- // input: ['unicorns'],
2421
- // flags: {rainbow: true},
2422
- // ...
2423
- //}
2424
-
2425
- foo(cli.input.at(0), cli.flags);
2426
- ```
2427
- */
2428
- declare function meow<Flags extends AnyFlags>(helpMessage: string, options: Options<Flags>): Result<Flags>;
2429
- declare function meow<Flags extends AnyFlags>(options: Options<Flags>): Result<Flags>;
2430
-
2431
- export { meow as default };
2432
- export type { Flag, FlagType, IsRequiredPredicate, Options, Result, TypedFlags };