@markuplint/types 4.8.1 → 5.0.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/ARCHITECTURE.ja.md +256 -0
  2. package/ARCHITECTURE.md +256 -0
  3. package/CHANGELOG.md +18 -2
  4. package/README.md +37 -2
  5. package/SKILL.md +100 -0
  6. package/docs/check-pipeline.ja.md +494 -0
  7. package/docs/check-pipeline.md +494 -0
  8. package/docs/token-system.ja.md +584 -0
  9. package/docs/token-system.md +584 -0
  10. package/docs/type-system.ja.md +556 -0
  11. package/docs/type-system.md +556 -0
  12. package/docs/validators.ja.md +524 -0
  13. package/docs/validators.md +524 -0
  14. package/lib/check-base.d.ts +81 -1
  15. package/lib/check-base.js +87 -0
  16. package/lib/check-multi-types.d.ts +12 -1
  17. package/lib/check-multi-types.js +11 -0
  18. package/lib/check.d.ts +13 -0
  19. package/lib/check.js +13 -0
  20. package/lib/css-defs.d.ts +8 -0
  21. package/lib/css-defs.js +8 -0
  22. package/lib/css-overrides.d.ts +7 -0
  23. package/lib/css-overrides.js +7 -0
  24. package/lib/css-syntax.d.ts +11 -0
  25. package/lib/css-syntax.js +12 -1
  26. package/lib/css-tokenizers.d.ts +6 -0
  27. package/lib/css-tokenizers.js +6 -0
  28. package/lib/debug.d.ts +3 -0
  29. package/lib/debug.js +3 -0
  30. package/lib/defs.d.ts +8 -0
  31. package/lib/defs.js +26 -0
  32. package/lib/directive.d.ts +14 -0
  33. package/lib/directive.js +14 -0
  34. package/lib/enum.d.ts +11 -0
  35. package/lib/enum.js +11 -0
  36. package/lib/get-candidate.d.ts +11 -0
  37. package/lib/get-candidate.js +11 -0
  38. package/lib/index.d.ts +10 -1
  39. package/lib/index.js +9 -1
  40. package/lib/keyword-type.d.ts +13 -0
  41. package/lib/keyword-type.js +13 -0
  42. package/lib/list.d.ts +13 -0
  43. package/lib/list.js +13 -0
  44. package/lib/match-result.d.ts +22 -1
  45. package/lib/match-result.js +21 -0
  46. package/lib/number.d.ts +12 -0
  47. package/lib/number.js +12 -0
  48. package/lib/pattern.d.ts +12 -0
  49. package/lib/pattern.js +33 -0
  50. package/lib/primitive/is-float.d.ts +4 -1
  51. package/lib/primitive/is-float.js +4 -1
  52. package/lib/primitive/is-int.d.ts +4 -1
  53. package/lib/primitive/is-int.js +4 -1
  54. package/lib/primitive/is-non-zero-uint.d.ts +3 -2
  55. package/lib/primitive/is-non-zero-uint.js +3 -2
  56. package/lib/primitive/is-quantity.d.ts +5 -3
  57. package/lib/primitive/is-quantity.js +5 -3
  58. package/lib/primitive/is-uint.d.ts +5 -1
  59. package/lib/primitive/is-uint.js +5 -1
  60. package/lib/primitive/range.d.ts +5 -4
  61. package/lib/primitive/range.js +5 -4
  62. package/lib/primitive/split-unit.d.ts +3 -2
  63. package/lib/primitive/split-unit.js +3 -2
  64. package/lib/rfc/is-bcp-47.d.ts +2 -0
  65. package/lib/rfc/is-bcp-47.js +4 -2
  66. package/lib/token/token-collection.d.ts +108 -3
  67. package/lib/token/token-collection.js +110 -3
  68. package/lib/token/token.d.ts +66 -2
  69. package/lib/token/token.js +89 -21
  70. package/lib/token/types.d.ts +9 -0
  71. package/lib/types.d.ts +108 -1
  72. package/lib/types.schema.d.ts +4 -1
  73. package/lib/w3c/check-serialized-permissions-policy.d.ts +2 -0
  74. package/lib/w3c/check-serialized-permissions-policy.js +2 -0
  75. package/lib/whatwg/check-autocomplete.d.ts +10 -0
  76. package/lib/whatwg/check-autocomplete.js +214 -159
  77. package/lib/whatwg/check-datetime/date-string.d.ts +2 -0
  78. package/lib/whatwg/check-datetime/date-string.js +2 -0
  79. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +13 -0
  80. package/lib/whatwg/check-datetime/datetime-tokens.js +14 -1
  81. package/lib/whatwg/check-datetime/duration-string.d.ts +7 -0
  82. package/lib/whatwg/check-datetime/duration-string.js +7 -0
  83. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +2 -0
  84. package/lib/whatwg/check-datetime/global-date-and-time-string.js +2 -0
  85. package/lib/whatwg/check-datetime/index.d.ts +5 -0
  86. package/lib/whatwg/check-datetime/index.js +5 -0
  87. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +4 -0
  88. package/lib/whatwg/check-datetime/local-date-and-time-string.js +4 -0
  89. package/lib/whatwg/check-datetime/month-string.d.ts +2 -0
  90. package/lib/whatwg/check-datetime/month-string.js +2 -0
  91. package/lib/whatwg/check-datetime/time-string.d.ts +2 -0
  92. package/lib/whatwg/check-datetime/time-string.js +2 -0
  93. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +8 -0
  94. package/lib/whatwg/check-datetime/time-zone-offset-string.js +8 -0
  95. package/lib/whatwg/check-datetime/week-string.d.ts +2 -0
  96. package/lib/whatwg/check-datetime/week-string.js +2 -0
  97. package/lib/whatwg/check-datetime/year-string.d.ts +2 -0
  98. package/lib/whatwg/check-datetime/year-string.js +2 -0
  99. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +2 -0
  100. package/lib/whatwg/check-datetime/yearless-date-string.js +2 -0
  101. package/lib/whatwg/check-link-type.d.ts +108 -1
  102. package/lib/whatwg/check-link-type.js +17 -7
  103. package/lib/whatwg/check-mime-type.d.ts +4 -1
  104. package/lib/whatwg/check-mime-type.js +6 -3
  105. package/lib/whatwg/is-abs-url.d.ts +2 -0
  106. package/lib/whatwg/is-abs-url.js +3 -4
  107. package/lib/whatwg/is-browser-context-name.d.ts +2 -2
  108. package/lib/whatwg/is-browser-context-name.js +2 -2
  109. package/lib/whatwg/is-custom-element-name.d.ts +1 -1
  110. package/lib/whatwg/is-custom-element-name.js +1 -1
  111. package/lib/whatwg/is-itemprop-name.d.ts +1 -0
  112. package/lib/whatwg/is-itemprop-name.js +1 -0
  113. package/lib/whatwg/is-navigable-target-name.d.ts +2 -0
  114. package/lib/whatwg/is-navigable-target-name.js +2 -0
  115. package/package.json +8 -6
  116. package/types.schema.json +10 -1
@@ -2,6 +2,8 @@ import { log } from '../../debug.js';
2
2
  import { TokenCollection } from '../../token/index.js';
3
3
  import { datetimeTokenCheck } from './datetime-tokens.js';
4
4
  /**
5
+ * Validates a time string in the format `HH:MM[:SS[.sss]]`.
6
+ *
5
7
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#times
6
8
  */
7
9
  export const checkTimeString = () => function checkTimeString(value) {
@@ -1,7 +1,15 @@
1
1
  import type { Token } from '../../token/index.js';
2
2
  import type { CustomSyntaxChecker } from '../../types.js';
3
3
  /**
4
+ * Validates a time-zone offset string (`Z`, `+HH:MM`, or `-HH:MM`).
5
+ *
4
6
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
5
7
  */
6
8
  export declare const checkTimeZoneOffsetString: CustomSyntaxChecker;
9
+ /**
10
+ * Parses and validates a time-zone offset string (e.g., `Z`, `+09:00`, `-05:30`).
11
+ *
12
+ * @param zone - The time-zone string or token to validate
13
+ * @returns The validation result
14
+ */
7
15
  export declare function parseTimeZone(zone: string | Readonly<Token>): import("../../types.js").Result;
@@ -3,12 +3,20 @@ import { matched, unmatched } from '../../match-result.js';
3
3
  import { TokenCollection } from '../../token/index.js';
4
4
  import { datetimeTokenCheck } from './datetime-tokens.js';
5
5
  /**
6
+ * Validates a time-zone offset string (`Z`, `+HH:MM`, or `-HH:MM`).
7
+ *
6
8
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#time-zones
7
9
  */
8
10
  export const checkTimeZoneOffsetString = () => function checkTimeZoneOffsetString(value) {
9
11
  log('CHECK: time-zone-offset-string');
10
12
  return parseTimeZone(value);
11
13
  };
14
+ /**
15
+ * Parses and validates a time-zone offset string (e.g., `Z`, `+09:00`, `-05:30`).
16
+ *
17
+ * @param zone - The time-zone string or token to validate
18
+ * @returns The validation result
19
+ */
12
20
  export function parseTimeZone(zone) {
13
21
  const value = typeof zone === 'string' ? zone : zone.value;
14
22
  const zoneTokens = TokenCollection.fromPatterns(zone, [
@@ -1,5 +1,7 @@
1
1
  import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
+ * Validates a week string in the format `YYYY-Www`.
4
+ *
3
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#weeks
4
6
  */
5
7
  export declare const checkWeekString: CustomSyntaxChecker;
@@ -2,6 +2,8 @@ import { log } from '../../debug.js';
2
2
  import { TokenCollection } from '../../token/index.js';
3
3
  import { datetimeTokenCheck } from './datetime-tokens.js';
4
4
  /**
5
+ * Validates a week string in the format `YYYY-Www`.
6
+ *
5
7
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#weeks
6
8
  */
7
9
  export const checkWeekString = () => function checkWeekString(value) {
@@ -1,5 +1,7 @@
1
1
  import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
+ * Validates a year string (four or more digits, greater than zero).
4
+ *
3
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html
4
6
  */
5
7
  export declare const checkYearString: CustomSyntaxChecker;
@@ -2,6 +2,8 @@ import { log } from '../../debug.js';
2
2
  import { TokenCollection } from '../../token/index.js';
3
3
  import { datetimeTokenCheck } from './datetime-tokens.js';
4
4
  /**
5
+ * Validates a year string (four or more digits, greater than zero).
6
+ *
5
7
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html
6
8
  */
7
9
  export const checkYearString = () => function checkYearString(value) {
@@ -1,5 +1,7 @@
1
1
  import type { CustomSyntaxChecker } from '../../types.js';
2
2
  /**
3
+ * Validates a yearless date string in the format `MM-DD`.
4
+ *
3
5
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#yearless-dates
4
6
  */
5
7
  export declare const checkYearlessDateString: CustomSyntaxChecker;
@@ -2,6 +2,8 @@ import { log } from '../../debug.js';
2
2
  import { TokenCollection } from '../../token/index.js';
3
3
  import { datetimeTokenCheck } from './datetime-tokens.js';
4
4
  /**
5
+ * Validates a yearless date string in the format `MM-DD`.
6
+ *
5
7
  * @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#yearless-dates
6
8
  */
7
9
  export const checkYearlessDateString = () => function checkYearlessDateString(value) {
@@ -1,6 +1,113 @@
1
1
  import type { CustomSyntaxChecker } from '../types.js';
2
2
  /**
3
- * Link Type
3
+ * A WHATWG-defined link type keyword with per-element context and body-ok flag.
4
+ *
5
+ * @see https://html.spec.whatwg.org/multipage/links.html#linkTypes
6
+ */
7
+ export type DefLinkTypeWhatwg = {
8
+ readonly keyword: string;
9
+ readonly link: string;
10
+ readonly a: string;
11
+ readonly form: string;
12
+ readonly bodyOk: string;
13
+ };
14
+ /**
15
+ * A Microformats-registered link type keyword with per-element context flags.
16
+ *
17
+ * @see https://microformats.org/wiki/existing-rel-values
18
+ */
19
+ export type DefLinkTypeMicroformats = {
20
+ readonly keyword: string;
21
+ readonly link: boolean;
22
+ readonly a: boolean;
23
+ };
24
+ /**
25
+ * A dropped, rejected, or non-HTML link type keyword from the Microformats registry.
26
+ *
27
+ * @see https://microformats.org/wiki/existing-rel-values
28
+ */
29
+ export type DefLinkTypeMicroformatsDropped = {
30
+ readonly keyword: string;
31
+ };
32
+ /**
33
+ * @see https://html.spec.whatwg.org/multipage/links.html#linkTypes
34
+ *
35
+ * Scraping:
36
+ * ```js
37
+ * JSON.stringify(document.querySelectorAll('#table-link-relations tbody tr').values().toArray().map((el) => {
38
+ * const keyword = el.querySelector('td').textContent.trim();
39
+ * const link = el.querySelector('td:nth-child(2)').textContent.trim();
40
+ * const a = el.querySelector('td[colspan="3"]:nth-child(2)')?.textContent.trim() ?? el.querySelector('td[colspan="2"]:nth-child(2)')?.textContent.trim() ?? el.querySelector('td:nth-child(3)')?.textContent.trim();
41
+ * const form = el.querySelector('td[colspan="3"]:nth-child(2)')?.textContent.trim() ?? el.querySelector('td[colspan="2"]:nth-child(3)')?.textContent.trim() ?? el.querySelector('td[colspan="2"]:nth-child(2) + td')?.textContent.trim() ?? el.querySelector('td:nth-child(4)')?.textContent.trim();
42
+ * const bodyOk = el.querySelector('td[colspan="3"]:nth-child(2) + td')?.textContent.trim() ?? el.querySelector('td[colspan="2"]:nth-child(3) + td')?.textContent.trim() ?? el.querySelector('td[colspan="2"]:nth-child(2) + td + td')?.textContent.trim() ?? el.querySelector('td:nth-child(5)')?.textContent.trim();
43
+ * return { keyword, link, a, form, bodyOk }
44
+ * }));
45
+ * ```
46
+ */
47
+ export declare const DEF_LINK_TYPE_WHATWG: DefLinkTypeWhatwg[];
48
+ /**
49
+ * @see https://microformats.org/wiki/existing-rel-values#non_HTML_rel_values
50
+ *
51
+ * Scraping:
52
+ * ```js
53
+ * JSON.stringify($("h2:has('#non_HTML_rel_values') ~ table").eq(0).find('tr:has(td)').toArray().map((el) => {
54
+ * const $tr = $(el);
55
+ * const keyword = $tr.find('td')[0].textContent.trim();
56
+ * return { keyword, link: true, a: true }
57
+ * }));
58
+ */
59
+ export declare const DEF_LINK_TYPE_MICROFORMATS_NON_HTML_REL_VALUES: DefLinkTypeMicroformatsDropped[];
60
+ /**
61
+ * @see https://microformats.org/wiki/existing-rel-values#dropped
62
+ *
63
+ * Scraping:
64
+ * ```js
65
+ * JSON.stringify($("h2:has('#dropped') ~ table").eq(0).find('tr:has(td)').toArray().map((el) => {
66
+ * const $tr = $(el);
67
+ * const keyword = $tr.find('td')[0].textContent.split(' ')[0]?.trim();
68
+ * return { keyword }
69
+ * }));
70
+ */
71
+ export declare const DEF_LINK_TYPE_MICROFORMATS_DROPPED: DefLinkTypeMicroformatsDropped[];
72
+ /**
73
+ * @see https://microformats.org/wiki/existing-rel-values#dropped_without_prejudice
74
+ *
75
+ * Scraping:
76
+ * ```js
77
+ * JSON.stringify($("h2:has('#dropped_without_prejudice') ~ table").eq(0).find('tr:has(td)').toArray().map((el) => {
78
+ * const $tr = $(el);
79
+ * const keyword = $tr.find('td')[0].textContent.split(' ')[0]?.trim();
80
+ * return { keyword }
81
+ * }));
82
+ * ```
83
+ */
84
+ export declare const DEF_LINK_TYPE_MICROFORMATS_DROPPED_WITHOUT_PREJUDICE: DefLinkTypeMicroformatsDropped[];
85
+ /**
86
+ * @see https://microformats.org/wiki/existing-rel-values#rejected
87
+ *
88
+ * Scraping:
89
+ * ```js
90
+ * JSON.stringify($("h2:has('#rejected') ~ table").eq(0).find('tr:has(td)').toArray().map((el) => {
91
+ * const $tr = $(el);
92
+ * const keyword = $tr.find('td')[0].textContent.split(' ')[0]?.trim();
93
+ * return { keyword }
94
+ * }));
95
+ * ```
96
+ */
97
+ export declare const DEF_LINK_TYPE_MICROFORMATS_REJECTED: DefLinkTypeMicroformatsDropped[];
98
+ /**
99
+ * Combined list of all allowed Microformats link type keywords,
100
+ * excluding any that overlap with WHATWG standard keywords.
101
+ *
102
+ * @see https://microformats.org/wiki/existing-rel-values
103
+ */
104
+ export declare const ALLOWED_LINK_TYPE_MICROFORMATS: DefLinkTypeMicroformats[];
105
+ /**
106
+ * Validates a link type attribute value against WHATWG and Microformats registries.
107
+ *
108
+ * Filters allowed keywords based on the element context (link, body link, a/area, or form).
109
+ * Rejects dropped, non-HTML, and rejected link types from the Microformats wiki.
110
+ *
4
111
  * @see https://html.spec.whatwg.org/multipage/links.html#linkTypes
5
112
  */
6
113
  export declare const checkLinkType: CustomSyntaxChecker<{
@@ -15,7 +15,7 @@ import { TokenCollection } from '../token/token-collection.js';
15
15
  * }));
16
16
  * ```
17
17
  */
18
- const DEF_LINK_TYPE_WHATWG = [
18
+ export const DEF_LINK_TYPE_WHATWG = [
19
19
  { keyword: 'alternate', link: 'Hyperlink', a: 'Hyperlink', form: 'not allowed', bodyOk: '·' },
20
20
  { keyword: 'canonical', link: 'Hyperlink', a: 'not allowed', form: 'not allowed', bodyOk: '·' },
21
21
  { keyword: 'author', link: 'Hyperlink', a: 'Hyperlink', form: 'not allowed', bodyOk: '·' },
@@ -353,7 +353,7 @@ const DEF_LINK_TYPE_MICROFORMATS_DUBLIN_CORE = [
353
353
  * return { keyword, link: true, a: true }
354
354
  * }));
355
355
  */
356
- const DEF_LINK_TYPE_MICROFORMATS_NON_HTML_REL_VALUES = [
356
+ export const DEF_LINK_TYPE_MICROFORMATS_NON_HTML_REL_VALUES = [
357
357
  { keyword: 'self' },
358
358
  { keyword: 'http://gdata.youtube.com/schemas/2007#in-reply-to' },
359
359
  { keyword: 'collection' },
@@ -394,7 +394,7 @@ const DEF_LINK_TYPE_MICROFORMATS_NON_HTML_REL_VALUES = [
394
394
  * return { keyword }
395
395
  * }));
396
396
  */
397
- const DEF_LINK_TYPE_MICROFORMATS_DROPPED = [
397
+ export const DEF_LINK_TYPE_MICROFORMATS_DROPPED = [
398
398
  { keyword: 'banner' },
399
399
  { keyword: 'begin' },
400
400
  { keyword: 'biblioentry' }, // cspell:disable-line
@@ -430,7 +430,7 @@ const DEF_LINK_TYPE_MICROFORMATS_DROPPED = [
430
430
  * }));
431
431
  * ```
432
432
  */
433
- const DEF_LINK_TYPE_MICROFORMATS_DROPPED_WITHOUT_PREJUDICE = [
433
+ export const DEF_LINK_TYPE_MICROFORMATS_DROPPED_WITHOUT_PREJUDICE = [
434
434
  { keyword: 'first' },
435
435
  { keyword: 'index' },
436
436
  { keyword: 'last' },
@@ -448,11 +448,17 @@ const DEF_LINK_TYPE_MICROFORMATS_DROPPED_WITHOUT_PREJUDICE = [
448
448
  * }));
449
449
  * ```
450
450
  */
451
- const DEF_LINK_TYPE_MICROFORMATS_REJECTED = [
451
+ export const DEF_LINK_TYPE_MICROFORMATS_REJECTED = [
452
452
  { keyword: 'logo' },
453
453
  { keyword: 'pavatar' }, // cspell:disable-line
454
454
  ];
455
- const ALLOWED_LINK_TYPE_MICROFORMATS = [
455
+ /**
456
+ * Combined list of all allowed Microformats link type keywords,
457
+ * excluding any that overlap with WHATWG standard keywords.
458
+ *
459
+ * @see https://microformats.org/wiki/existing-rel-values
460
+ */
461
+ export const ALLOWED_LINK_TYPE_MICROFORMATS = [
456
462
  ...DEF_LINK_TYPE_MICROFORMATS_FORMATS,
457
463
  ...DEF_LINK_TYPE_MICROFORMATS_PROPOSALS,
458
464
  ...DEF_LINK_TYPE_MICROFORMATS_HTML5_LINK_TYPE_EXTENSIONS,
@@ -461,7 +467,11 @@ const ALLOWED_LINK_TYPE_MICROFORMATS = [
461
467
  ...DEF_LINK_TYPE_MICROFORMATS_DUBLIN_CORE,
462
468
  ].filter(def => !DEF_LINK_TYPE_WHATWG.some(whatwg => whatwg.keyword === def.keyword));
463
469
  /**
464
- * Link Type
470
+ * Validates a link type attribute value against WHATWG and Microformats registries.
471
+ *
472
+ * Filters allowed keywords based on the element context (link, body link, a/area, or form).
473
+ * Rejects dropped, non-HTML, and rejected link types from the Microformats wiki.
474
+ *
465
475
  * @see https://html.spec.whatwg.org/multipage/links.html#linkTypes
466
476
  */
467
477
  export const checkLinkType = options => value => {
@@ -1,6 +1,9 @@
1
1
  import type { CustomSyntaxChecker } from '../types.js';
2
2
  /**
3
- * MIME Type
3
+ * Validates a MIME type string according to the WHATWG MIME Sniffing specification.
4
+ *
5
+ * Optionally restricts to MIME types with no parameters.
6
+ *
4
7
  * @see https://mimesniff.spec.whatwg.org/#valid-mime-type
5
8
  */
6
9
  export declare const checkMIMEType: CustomSyntaxChecker<{
@@ -1,5 +1,5 @@
1
- // @ts-ignore
2
- import MIMEType from 'whatwg-mimetype';
1
+ // @ts-ignore -- whatwg-mimetype v5 has no type definitions
2
+ import { MIMEType } from 'whatwg-mimetype';
3
3
  import { matched, unmatched } from '../match-result.js';
4
4
  import { Token } from '../token/index.js';
5
5
  const expects = (withoutParameters) => [
@@ -9,7 +9,10 @@ const expects = (withoutParameters) => [
9
9
  },
10
10
  ];
11
11
  /**
12
- * MIME Type
12
+ * Validates a MIME type string according to the WHATWG MIME Sniffing specification.
13
+ *
14
+ * Optionally restricts to MIME types with no parameters.
15
+ *
13
16
  * @see https://mimesniff.spec.whatwg.org/#valid-mime-type
14
17
  */
15
18
  export const checkMIMEType = options => value => {
@@ -1,5 +1,7 @@
1
1
  import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
+ * Checks whether a string is a valid absolute URL.
4
+ *
3
5
  * @see https://url.spec.whatwg.org/#syntax-url-absolute
4
6
  *
5
7
  * > An absolute-URL string must be one of the following:
@@ -1,4 +1,6 @@
1
1
  /**
2
+ * Checks whether a string is a valid absolute URL.
3
+ *
2
4
  * @see https://url.spec.whatwg.org/#syntax-url-absolute
3
5
  *
4
6
  * > An absolute-URL string must be one of the following:
@@ -17,10 +19,7 @@ export const isAbsURL = () => {
17
19
  new URL(value);
18
20
  }
19
21
  catch (error) {
20
- if (error &&
21
- typeof error === 'object' &&
22
- 'code' in error && // @ts-ignore
23
- error.code === 'ERR_INVALID_URL') {
22
+ if (error instanceof TypeError) {
24
23
  return false;
25
24
  }
26
25
  throw error;
@@ -1,5 +1,6 @@
1
1
  import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
+ * Checks whether a string is a valid browsing context name.
3
4
  *
4
5
  * @see https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name
5
6
  *
@@ -7,7 +8,6 @@ import type { FormattedPrimitiveTypeCreator } from '../types.js';
7
8
  * > that does not start with a U+005F LOW LINE character.
8
9
  * > (Names starting with an underscore are reserved for special keywords.)
9
10
  *
10
- * @deprecated
11
- *
11
+ * @deprecated Use {@link isNavigableTargetName} instead.
12
12
  */
13
13
  export declare const isBrowserContextName: FormattedPrimitiveTypeCreator;
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * Checks whether a string is a valid browsing context name.
2
3
  *
3
4
  * @see https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name
4
5
  *
@@ -6,8 +7,7 @@
6
7
  * > that does not start with a U+005F LOW LINE character.
7
8
  * > (Names starting with an underscore are reserved for special keywords.)
8
9
  *
9
- * @deprecated
10
- *
10
+ * @deprecated Use {@link isNavigableTargetName} instead.
11
11
  */
12
12
  export const isBrowserContextName = () => {
13
13
  return value => {
@@ -1,6 +1,6 @@
1
1
  import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
- * valid name of custom element
3
+ * Checks whether a string is a valid custom element name.
4
4
  *
5
5
  * > PotentialCustomElementName ::=
6
6
  * > [a-z] (PCENChar)* '-' (PCENChar)*
@@ -11,7 +11,7 @@ const onlyPCENChar =
11
11
  // eslint-disable-next-line no-misleading-character-class
12
12
  /^[-.\d_a-z\u00B7\u00C0-\u00D6[\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*$/u;
13
13
  /**
14
- * valid name of custom element
14
+ * Checks whether a string is a valid custom element name.
15
15
  *
16
16
  * > PotentialCustomElementName ::=
17
17
  * > [a-z] (PCENChar)* '-' (PCENChar)*
@@ -1,5 +1,6 @@
1
1
  import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
+ * Checks whether a string is a valid itemprop property name.
3
4
  *
4
5
  * @see https://html.spec.whatwg.org/multipage/microdata.html#defined-property-name
5
6
  *
@@ -1,4 +1,5 @@
1
1
  /**
2
+ * Checks whether a string is a valid itemprop property name.
2
3
  *
3
4
  * @see https://html.spec.whatwg.org/multipage/microdata.html#defined-property-name
4
5
  *
@@ -1,5 +1,7 @@
1
1
  import type { FormattedPrimitiveTypeCreator } from '../types.js';
2
2
  /**
3
+ * Checks whether a string is a valid navigable target name.
4
+ *
3
5
  * @see https://html.spec.whatwg.org/multipage/document-sequences.html#valid-navigable-target-name
4
6
  *
5
7
  * > A valid navigable target name is any string with at least one character
@@ -5,6 +5,8 @@
5
5
  */
6
6
  const TAB_OR_NEWLINE = /[\t\n\r]/;
7
7
  /**
8
+ * Checks whether a string is a valid navigable target name.
9
+ *
8
10
  * @see https://html.spec.whatwg.org/multipage/document-sequences.html#valid-navigable-target-name
9
11
  *
10
12
  * > A valid navigable target name is any string with at least one character
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@markuplint/types",
3
- "version": "4.8.1",
3
+ "version": "5.0.0-alpha.0",
4
4
  "description": "Type declaration and value checker",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
7
7
  "license": "MIT",
8
+ "engines": {
9
+ "node": ">=22"
10
+ },
8
11
  "type": "module",
9
12
  "exports": {
10
13
  ".": {
@@ -29,16 +32,15 @@
29
32
  "schema:prettier": "npx prettier --write \"./src/types.schema.ts\" \"./types.schema.json\" --log-level warn"
30
33
  },
31
34
  "dependencies": {
32
- "@markuplint/shared": "4.4.12",
35
+ "@markuplint/shared": "5.0.0-alpha.0",
33
36
  "@types/css-tree": "2.3.11",
34
37
  "@types/debug": "4.1.12",
35
- "@types/whatwg-mimetype": "3.0.2",
36
38
  "bcp-47": "2.1.0",
37
39
  "css-tree": "3.1.0",
38
40
  "debug": "4.4.3",
39
41
  "leven": "4.1.0",
40
- "type-fest": "4.41.0",
41
- "whatwg-mimetype": "4.0.0"
42
+ "type-fest": "5.4.4",
43
+ "whatwg-mimetype": "5.0.0"
42
44
  },
43
- "gitHead": "6213ea30269ef404f030e67bbcc7fc7443ec1060"
45
+ "gitHead": "13dcfc84ec83d87360c720e253383b60767e1b56"
44
46
  }
package/types.schema.json CHANGED
@@ -1274,13 +1274,22 @@
1274
1274
  "ref": { "type": "string" }
1275
1275
  }
1276
1276
  },
1277
+ "pattern": {
1278
+ "type": "object",
1279
+ "required": ["pattern"],
1280
+ "additionalProperties": false,
1281
+ "properties": {
1282
+ "pattern": { "type": "string" }
1283
+ }
1284
+ },
1277
1285
  "type": {
1278
1286
  "oneOf": [
1279
1287
  { "$ref": "#/definitions/keyword-defined-type" },
1280
1288
  { "$ref": "#/definitions/list" },
1281
1289
  { "$ref": "#/definitions/enum" },
1282
1290
  { "$ref": "#/definitions/number" },
1283
- { "$ref": "#/definitions/directive" }
1291
+ { "$ref": "#/definitions/directive" },
1292
+ { "$ref": "#/definitions/pattern" }
1284
1293
  ]
1285
1294
  }
1286
1295
  },