@markuplint/rules 3.15.0 → 4.0.0-alpha.10

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 (178) hide show
  1. package/.eslintrc +5 -0
  2. package/LICENSE +1 -1
  3. package/lib/attr-check.d.ts +8 -19
  4. package/lib/attr-check.js +16 -21
  5. package/lib/attr-duplication/index.d.ts +1 -3
  6. package/lib/attr-duplication/index.js +6 -6
  7. package/lib/attr-value-quotes/index.d.ts +2 -2
  8. package/lib/attr-value-quotes/index.js +8 -10
  9. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  10. package/lib/case-sensitive-attr-name/index.js +12 -13
  11. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  12. package/lib/case-sensitive-tag-name/index.js +5 -4
  13. package/lib/character-reference/index.d.ts +1 -1
  14. package/lib/character-reference/index.js +13 -12
  15. package/lib/class-naming/index.d.ts +1 -1
  16. package/lib/class-naming/index.js +14 -13
  17. package/lib/create-message.d.ts +2 -12
  18. package/lib/create-message.js +26 -26
  19. package/lib/debug.js +2 -6
  20. package/lib/deprecated-attr/index.d.ts +1 -3
  21. package/lib/deprecated-attr/index.js +9 -9
  22. package/lib/deprecated-element/index.d.ts +1 -3
  23. package/lib/deprecated-element/index.js +7 -6
  24. package/lib/disallowed-element/index.d.ts +1 -1
  25. package/lib/disallowed-element/index.js +9 -8
  26. package/lib/doctype/index.d.ts +2 -2
  27. package/lib/doctype/index.js +5 -4
  28. package/lib/end-tag/index.d.ts +1 -1
  29. package/lib/end-tag/index.js +8 -8
  30. package/lib/helpers.d.ts +17 -35
  31. package/lib/helpers.js +25 -32
  32. package/lib/id-duplication/index.d.ts +1 -3
  33. package/lib/id-duplication/index.js +5 -4
  34. package/lib/index.d.ts +21 -17
  35. package/lib/index.js +63 -66
  36. package/lib/ineffective-attr/index.d.ts +1 -3
  37. package/lib/ineffective-attr/index.js +8 -7
  38. package/lib/invalid-attr/index.d.ts +31 -38
  39. package/lib/invalid-attr/index.js +33 -33
  40. package/lib/label-has-control/index.d.ts +1 -3
  41. package/lib/label-has-control/index.js +5 -4
  42. package/lib/landmark-roles/index.d.ts +3 -3
  43. package/lib/landmark-roles/index.js +16 -18
  44. package/lib/no-boolean-attr-value/index.d.ts +1 -3
  45. package/lib/no-boolean-attr-value/index.js +9 -9
  46. package/lib/no-default-value/index.d.ts +1 -3
  47. package/lib/no-default-value/index.js +12 -12
  48. package/lib/no-empty-palpable-content/index.d.ts +3 -3
  49. package/lib/no-empty-palpable-content/index.js +9 -8
  50. package/lib/no-hard-code-id/index.d.ts +1 -3
  51. package/lib/no-hard-code-id/index.js +5 -4
  52. package/lib/no-refer-to-non-existent-id/index.d.ts +1 -1
  53. package/lib/no-refer-to-non-existent-id/index.js +37 -38
  54. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  55. package/lib/no-use-event-handler-attr/index.js +7 -6
  56. package/lib/permitted-contents/choice.d.ts +2 -8
  57. package/lib/permitted-contents/choice.js +14 -19
  58. package/lib/permitted-contents/complex-branch.d.ts +2 -8
  59. package/lib/permitted-contents/complex-branch.js +10 -14
  60. package/lib/permitted-contents/content-model.d.ts +1 -1
  61. package/lib/permitted-contents/content-model.js +10 -11
  62. package/lib/permitted-contents/count-pattern.d.ts +3 -18
  63. package/lib/permitted-contents/count-pattern.js +19 -24
  64. package/lib/permitted-contents/debug.browser.d.ts +16 -16
  65. package/lib/permitted-contents/debug.browser.js +9 -12
  66. package/lib/permitted-contents/debug.d.ts +10 -3
  67. package/lib/permitted-contents/debug.js +12 -13
  68. package/lib/permitted-contents/index.d.ts +2 -2
  69. package/lib/permitted-contents/index.js +13 -13
  70. package/lib/permitted-contents/matches-selector.d.ts +2 -7
  71. package/lib/permitted-contents/matches-selector.js +13 -18
  72. package/lib/permitted-contents/order.d.ts +2 -8
  73. package/lib/permitted-contents/order.js +19 -24
  74. package/lib/permitted-contents/recursive-branch.d.ts +3 -9
  75. package/lib/permitted-contents/recursive-branch.js +9 -13
  76. package/lib/permitted-contents/represent-transparent-nodes.d.ts +4 -8
  77. package/lib/permitted-contents/represent-transparent-nodes.js +15 -20
  78. package/lib/permitted-contents/start.d.ts +2 -7
  79. package/lib/permitted-contents/start.js +13 -21
  80. package/lib/permitted-contents/transparent.d.ts +1 -1
  81. package/lib/permitted-contents/transparent.js +6 -11
  82. package/lib/permitted-contents/types.d.ts +29 -29
  83. package/lib/permitted-contents/types.js +1 -2
  84. package/lib/permitted-contents/utils.d.ts +42 -79
  85. package/lib/permitted-contents/utils.js +72 -82
  86. package/lib/placeholder-label-option/index.d.ts +1 -1
  87. package/lib/placeholder-label-option/index.js +12 -13
  88. package/lib/require-accessible-name/index.d.ts +2 -2
  89. package/lib/require-accessible-name/index.js +12 -15
  90. package/lib/require-datetime/index.d.ts +3 -3
  91. package/lib/require-datetime/index.js +14 -13
  92. package/lib/require-datetime/types.d.ts +2 -2
  93. package/lib/require-datetime/types.js +1 -2
  94. package/lib/require-datetime/utils.d.ts +1 -1
  95. package/lib/require-datetime/utils.js +5 -12
  96. package/lib/required-attr/index.d.ts +3 -3
  97. package/lib/required-attr/index.js +11 -11
  98. package/lib/required-element/index.d.ts +2 -2
  99. package/lib/required-element/index.js +7 -7
  100. package/lib/required-h1/index.d.ts +3 -3
  101. package/lib/required-h1/index.js +6 -6
  102. package/lib/use-list/index.d.ts +6 -2
  103. package/lib/use-list/index.js +27 -11
  104. package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
  105. package/lib/wai-aria/checkings/abstract-role.js +5 -10
  106. package/lib/wai-aria/checkings/default-value.d.ts +4 -8
  107. package/lib/wai-aria/checkings/default-value.js +2 -6
  108. package/lib/wai-aria/checkings/deprecated-props.d.ts +5 -9
  109. package/lib/wai-aria/checkings/deprecated-props.js +3 -8
  110. package/lib/wai-aria/checkings/disallowed-prop.d.ts +5 -9
  111. package/lib/wai-aria/checkings/disallowed-prop.js +7 -12
  112. package/lib/wai-aria/checkings/implicit-props.d.ts +5 -9
  113. package/lib/wai-aria/checkings/implicit-props.js +12 -17
  114. package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
  115. package/lib/wai-aria/checkings/implicit-role.js +4 -9
  116. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
  117. package/lib/wai-aria/checkings/interaction-in-hidden.js +4 -8
  118. package/lib/wai-aria/checkings/no-global-prop.d.ts +4 -8
  119. package/lib/wai-aria/checkings/no-global-prop.js +2 -7
  120. package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
  121. package/lib/wai-aria/checkings/non-existent-role.js +4 -9
  122. package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
  123. package/lib/wai-aria/checkings/permitted-roles.js +4 -9
  124. package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
  125. package/lib/wai-aria/checkings/presentational-children.js +5 -10
  126. package/lib/wai-aria/checkings/required-owned-elements.d.ts +4 -8
  127. package/lib/wai-aria/checkings/required-owned-elements.js +7 -11
  128. package/lib/wai-aria/checkings/required-prop.d.ts +7 -13
  129. package/lib/wai-aria/checkings/required-prop.js +2 -7
  130. package/lib/wai-aria/checkings/value.d.ts +7 -16
  131. package/lib/wai-aria/checkings/value.js +7 -13
  132. package/lib/wai-aria/index.d.ts +2 -2
  133. package/lib/wai-aria/index.js +41 -40
  134. package/lib/wai-aria/types.d.ts +10 -10
  135. package/lib/wai-aria/types.js +1 -2
  136. package/package.json +17 -13
  137. package/test/attr-check.spec.js +0 -77
  138. package/test/attr-duplication/index.spec.js +0 -159
  139. package/test/attr-value-quotes/index.spec.js +0 -133
  140. package/test/case-sensitive-attr-name/index.spec.js +0 -65
  141. package/test/case-sensitive-tag-name/index.spec.js +0 -80
  142. package/test/character-reference/index.spec.js +0 -72
  143. package/test/class-naming/index.spec.js +0 -470
  144. package/test/create-message.spec.js +0 -497
  145. package/test/deprecated-attr/index.spec.js +0 -48
  146. package/test/deprecated-element/index.spec.js +0 -35
  147. package/test/disallowed-element/index.spec.js +0 -90
  148. package/test/doctype/index.spec.js +0 -50
  149. package/test/end-tag/index.spec.js +0 -162
  150. package/test/id-duplication/index.spec.js +0 -47
  151. package/test/ineffective-attr/index.spec.js +0 -31
  152. package/test/invalid-attr/index.spec.js +0 -1631
  153. package/test/label-has-control/index.spec.js +0 -29
  154. package/test/landmark-roles/index.spec.js +0 -187
  155. package/test/no-boolean-attr-value/index.spec.js +0 -41
  156. package/test/no-default-value/index.spec.js +0 -74
  157. package/test/no-empty-palpable-content/index.spec.js +0 -115
  158. package/test/no-hard-code-id/index.spec.js +0 -100
  159. package/test/no-refer-to-non-existent-id/index.spec.js +0 -254
  160. package/test/no-use-event-handler-attr/index.spec.js +0 -57
  161. package/test/permitted-contents/choice.spec.js +0 -174
  162. package/test/permitted-contents/count-pattern.spec.js +0 -308
  163. package/test/permitted-contents/index.spec.js +0 -1395
  164. package/test/permitted-contents/matches-selector.spec.js +0 -59
  165. package/test/permitted-contents/order.spec.js +0 -351
  166. package/test/permitted-contents/recursive-branch.spec.js +0 -41
  167. package/test/permitted-contents/represent-transparent-nodes.spec.js +0 -24
  168. package/test/permitted-contents/start.spec.js +0 -67
  169. package/test/placeholder-label-option/index.spec.js +0 -113
  170. package/test/require-accessible-name/index.spec.js +0 -444
  171. package/test/require-datetime/index.spec.js +0 -54
  172. package/test/require-datetime/utils.spec.js +0 -52
  173. package/test/required-attr/index.spec.js +0 -414
  174. package/test/required-element/index.spec.js +0 -188
  175. package/test/required-h1/index.spec.js +0 -69
  176. package/test/use-list/index.spec.js +0 -109
  177. package/test/wai-aria/checkings/value.spec.js +0 -33
  178. package/test/wai-aria/index.spec.js +0 -1203
@@ -1,7 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule, getSpec } from '@markuplint/ml-core';
2
+ export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
5
6
  async verify({ document, report, t }) {
6
7
  await document.walkOn('Element', el => {
7
8
  if (!(el.namespaceURI === 'http://www.w3.org/1999/xhtml' ||
@@ -9,9 +10,9 @@ exports.default = (0, ml_core_1.createRule)({
9
10
  el.elementType !== 'html') {
10
11
  return;
11
12
  }
12
- const spec = (0, ml_core_1.getSpec)(el, document.specs.specs);
13
+ const spec = getSpec(el, document.specs.specs);
13
14
  if (spec && (spec.obsolete != null || spec.deprecated || spec.nonStandard)) {
14
- const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete != null ? 'obsolete' : 'non-standard');
15
+ const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete == null ? 'non-standard' : 'obsolete');
15
16
  report({
16
17
  scope: el,
17
18
  message,
@@ -1,2 +1,2 @@
1
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<string[], undefined>>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<string[], undefined>>;
2
2
  export default _default;
@@ -1,18 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule } from '@markuplint/ml-core';
2
+ export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
5
6
  defaultValue: [],
6
7
  async verify({ document, report, t }) {
7
8
  for (const query of document.rule.value) {
8
9
  const elements = document.querySelectorAll(query);
9
- elements.forEach(el => {
10
+ for (const el of elements) {
10
11
  const message = t('{0} is disallowed', t('the "{0*}" {1}', query, 'element'));
11
12
  report({
12
13
  scope: el,
13
14
  message,
14
15
  });
15
- });
16
+ }
16
17
  }
17
18
  await document.walkOn('Element', el => {
18
19
  if (el.rule.value === document.rule.value) {
@@ -20,13 +21,13 @@ exports.default = (0, ml_core_1.createRule)({
20
21
  }
21
22
  for (const query of el.rule.value) {
22
23
  const elements = el.querySelectorAll(query);
23
- elements.forEach(el => {
24
+ for (const el of elements) {
24
25
  const message = t('{0} is disallowed', t('the "{0*}" {1}', query, 'element'));
25
26
  report({
26
27
  scope: el,
27
28
  message,
28
29
  });
29
- });
30
+ }
30
31
  }
31
32
  });
32
33
  },
@@ -1,5 +1,5 @@
1
1
  type Option = {
2
- denyObsoleteType: boolean;
2
+ denyObsoleteType: boolean;
3
3
  };
4
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<'always', Option>>;
4
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<"always", Option>>;
5
5
  export default _default;
@@ -1,7 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule } from '@markuplint/ml-core';
2
+ export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
5
6
  defaultValue: 'always',
6
7
  defaultOptions: {
7
8
  denyObsoleteType: true,
@@ -1,2 +1,2 @@
1
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
2
2
  export default _default;
@@ -1,25 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const ml_spec_1 = require("@markuplint/ml-spec");
5
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule } from '@markuplint/ml-core';
2
+ import { isVoidElement } from '@markuplint/ml-spec';
3
+ export default createRule({
4
+ meta: {
5
+ category: 'style',
6
+ },
6
7
  defaultSeverity: 'warning',
7
8
  async verify({ document, report, t }) {
8
9
  if (document.endTag === 'never') {
9
10
  return;
10
11
  }
11
12
  await document.walkOn('Element', el => {
12
- var _a;
13
13
  if (el.isOmitted) {
14
14
  return;
15
15
  }
16
- if ((0, ml_spec_1.isVoidElement)(el)) {
16
+ if (isVoidElement(el)) {
17
17
  return;
18
18
  }
19
19
  if (el.closeTag != null) {
20
20
  return;
21
21
  }
22
- if ((document.endTag === 'xml' || el.isForeignElement) && ((_a = el.selfClosingSolidus) === null || _a === void 0 ? void 0 : _a.raw)) {
22
+ if ((document.endTag === 'xml' || el.isForeignElement) && el.selfClosingSolidus?.raw) {
23
23
  return;
24
24
  }
25
25
  report({
package/lib/helpers.d.ts CHANGED
@@ -1,13 +1,10 @@
1
- import type { Log } from './debug';
1
+ import type { Log } from './debug.js';
2
2
  import type { Translator } from '@markuplint/i18n';
3
3
  import type { PlainData } from '@markuplint/ml-config';
4
4
  import type { Element, RuleConfigValue, Document } from '@markuplint/ml-core';
5
5
  import type { Attribute } from '@markuplint/ml-spec';
6
6
  import type { WritableDeep } from 'type-fest';
7
- export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(
8
- node: Element<T, O>,
9
- condition: Attribute['condition'],
10
- ): boolean;
7
+ export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(node: Element<T, O>, condition: Attribute['condition']): boolean;
11
8
  export declare function match(needle: string, pattern: string): boolean;
12
9
  /**
13
10
  * PotentialCustomElementName
@@ -25,38 +22,23 @@ export declare function match(needle: string, pattern: string): boolean;
25
22
  * Originally, it is not possible to define a name including ASCII upper alphas in the custom element, but it is not treated as illegal by the HTML parser.
26
23
  */
27
24
  export declare const rePCENChar: string;
28
- export declare function isValidAttr(
29
- t: Translator,
30
- name: string,
31
- value: string,
32
- isDynamicValue: boolean,
33
- node: Element<any, any>,
34
- attrSpecs: readonly Attribute[],
35
- log?: Log,
36
- ):
37
- | false
38
- | {
39
- invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
40
- message: string;
41
- loc?:
42
- | {
43
- raw: string;
44
- line: number;
45
- col: number;
46
- }
47
- | undefined;
48
- };
25
+ export declare function isValidAttr(t: Translator, name: string, value: string, isDynamicValue: boolean, node: Element<any, any>, attrSpecs: readonly Attribute[], log?: Log): false | {
26
+ invalidType: "non-existent" | "invalid-value" | "disallowed-attr";
27
+ message: string;
28
+ loc?: {
29
+ raw: string;
30
+ line: number;
31
+ col: number;
32
+ } | undefined;
33
+ };
49
34
  export declare function toNormalizedValue(value: string, spec: Attribute): string;
50
35
  export declare function accnameMayBeMutable(el: Element<any, any>, document: Document<any, any>): boolean;
51
- export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(
52
- el: Element<V, O>,
53
- document: Document<V, O>,
54
- ): Element<V, O> | null;
36
+ export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(el: Element<V, O>, document: Document<V, O>): Element<V, O> | null;
55
37
  export declare class Collection<T> {
56
- #private;
57
- constructor(...items: readonly (T | null | undefined)[]);
58
- [Symbol.iterator](): Iterator<T>;
59
- add(...items: readonly (T | null | undefined)[]): void;
60
- toArray(): readonly T[];
38
+ #private;
39
+ constructor(...items: readonly (T | null | undefined)[]);
40
+ [Symbol.iterator](): Iterator<T>;
41
+ add(...items: readonly (T | null | undefined)[]): void;
42
+ toArray(): readonly T[];
61
43
  }
62
44
  export declare function deepCopy<T>(value: T): WritableDeep<T>;
package/lib/helpers.js CHANGED
@@ -1,12 +1,13 @@
1
- "use strict";
1
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
2
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
3
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
4
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
5
+ };
2
6
  var _Collection_items;
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.deepCopy = exports.Collection = exports.getOwnedLabel = exports.accnameMayBeMutable = exports.toNormalizedValue = exports.isValidAttr = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
5
- const tslib_1 = require("tslib");
6
7
  // @ts-ignore
7
- const structured_clone_1 = tslib_1.__importDefault(require("@ungap/structured-clone"));
8
- const attr_check_1 = require("./attr-check");
9
- function attrMatches(
8
+ import structuredClone from '@ungap/structured-clone';
9
+ import { attrCheck } from './attr-check.js';
10
+ export function attrMatches(
10
11
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
11
12
  node, condition) {
12
13
  if (condition == null) {
@@ -15,9 +16,8 @@ node, condition) {
15
16
  const condSelector = typeof condition === 'string' ? condition : condition.join(',');
16
17
  return node.matches(condSelector);
17
18
  }
18
- exports.attrMatches = attrMatches;
19
- function match(needle, pattern) {
20
- const matches = pattern.match(/^\/(.*)\/(i|g|m)*$/);
19
+ export function match(needle, pattern) {
20
+ const matches = pattern.match(/^\/(.*)\/([gim])*$/);
21
21
  if (matches && matches[1]) {
22
22
  const re = matches[1];
23
23
  const flag = matches[2];
@@ -25,7 +25,6 @@ function match(needle, pattern) {
25
25
  }
26
26
  return needle === pattern;
27
27
  }
28
- exports.match = match;
29
28
  /**
30
29
  * PotentialCustomElementName
31
30
  *
@@ -41,7 +40,7 @@ exports.match = match;
41
40
  * ASCII-case-insensitively.
42
41
  * Originally, it is not possible to define a name including ASCII upper alphas in the custom element, but it is not treated as illegal by the HTML parser.
43
42
  */
44
- exports.rePCENChar = [
43
+ export const rePCENChar = [
45
44
  '\\-',
46
45
  '\\.',
47
46
  '[0-9]',
@@ -61,7 +60,7 @@ exports.rePCENChar = [
61
60
  '[\uFDF0-\uFFFD]',
62
61
  '[\uD800-\uDBFF][\uDC00-\uDFFF]',
63
62
  ].join('|');
64
- function isValidAttr(t, name, value, isDynamicValue,
63
+ export function isValidAttr(t, name, value, isDynamicValue,
65
64
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
66
65
  node, attrSpecs,
67
66
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
@@ -69,7 +68,7 @@ log) {
69
68
  let invalid = false;
70
69
  const spec = attrSpecs.find(s => s.name.toLowerCase() === name.toLowerCase());
71
70
  log && log('Spec of the %s attr: %o', name, spec);
72
- invalid = (0, attr_check_1.attrCheck)(t, name, value, false, spec);
71
+ invalid = attrCheck(t, name, value, false, spec);
73
72
  if (invalid === false &&
74
73
  spec &&
75
74
  spec.condition != null &&
@@ -85,15 +84,14 @@ log) {
85
84
  }
86
85
  return invalid;
87
86
  }
88
- exports.isValidAttr = isValidAttr;
89
- function toNormalizedValue(value, spec) {
87
+ export function toNormalizedValue(value, spec) {
90
88
  let normalized = value;
91
89
  if (!spec.caseSensitive) {
92
90
  normalized = normalized.toLowerCase();
93
91
  }
94
92
  if (typeof spec.type === 'string') {
95
93
  if (spec.type[0] === '<') {
96
- normalized = normalized.toLowerCase().trim().replace(/\s+/g, ' ');
94
+ normalized = normalized.toLowerCase().trim().replaceAll(/\s+/g, ' ');
97
95
  }
98
96
  }
99
97
  else {
@@ -105,17 +103,16 @@ function toNormalizedValue(value, spec) {
105
103
  normalized = normalized.trim();
106
104
  }
107
105
  if (spec.type.separator === 'space') {
108
- normalized = normalized.replace(/\s+/g, ' ');
106
+ normalized = normalized.replaceAll(/\s+/g, ' ');
109
107
  }
110
108
  if (spec.type.separator === 'comma') {
111
- normalized = normalized.replace(/\s*,\s*/g, ',');
109
+ normalized = normalized.replaceAll(/\s*,\s*/g, ',');
112
110
  }
113
111
  }
114
112
  }
115
113
  return normalized;
116
114
  }
117
- exports.toNormalizedValue = toNormalizedValue;
118
- function accnameMayBeMutable(
115
+ export function accnameMayBeMutable(
119
116
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
120
117
  el,
121
118
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
@@ -129,9 +126,8 @@ document) {
129
126
  }
130
127
  return false;
131
128
  }
132
- exports.accnameMayBeMutable = accnameMayBeMutable;
133
129
  const labelable = ['button', 'input:not([type=hidden])', 'meter', 'output', 'progress', 'select', 'textarea'];
134
- function getOwnedLabel(
130
+ export function getOwnedLabel(
135
131
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
136
132
  el,
137
133
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
@@ -148,29 +144,26 @@ document) {
148
144
  }
149
145
  return ownedLabel;
150
146
  }
151
- exports.getOwnedLabel = getOwnedLabel;
152
- class Collection {
147
+ export class Collection {
153
148
  constructor(...items) {
154
149
  _Collection_items.set(this, new Set());
155
150
  this.add(...items);
156
151
  }
157
152
  [(_Collection_items = new WeakMap(), Symbol.iterator)]() {
158
- return tslib_1.__classPrivateFieldGet(this, _Collection_items, "f").values();
153
+ return __classPrivateFieldGet(this, _Collection_items, "f").values();
159
154
  }
160
155
  add(...items) {
161
156
  for (const item of items) {
162
157
  if (item == null) {
163
158
  continue;
164
159
  }
165
- tslib_1.__classPrivateFieldGet(this, _Collection_items, "f").add(item);
160
+ __classPrivateFieldGet(this, _Collection_items, "f").add(item);
166
161
  }
167
162
  }
168
163
  toArray() {
169
- return Object.freeze(Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_items, "f")));
164
+ return Object.freeze([...__classPrivateFieldGet(this, _Collection_items, "f")]);
170
165
  }
171
166
  }
172
- exports.Collection = Collection;
173
- function deepCopy(value) {
174
- return (0, structured_clone_1.default)(value);
167
+ export function deepCopy(value) {
168
+ return structuredClone(value);
175
169
  }
176
- exports.deepCopy = deepCopy;
@@ -1,4 +1,2 @@
1
- declare const _default: Readonly<
2
- import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
- >;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
4
2
  export default _default;
@@ -1,7 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule } from '@markuplint/ml-core';
2
+ export default createRule({
3
+ meta: {
4
+ category: 'validation',
5
+ },
5
6
  async verify({ document, report, t }) {
6
7
  const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'value'), t('the "{0*}" {1}', 'id', 'attribute')), 'duplicated');
7
8
  const idStack = [];
package/lib/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  declare const rules: {
2
2
  readonly 'attr-duplication': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
3
- readonly 'attr-value-quotes': Readonly<import("@markuplint/ml-core").RuleSeed<import("./attr-value-quotes").Type, undefined>>;
4
- readonly 'case-sensitive-attr-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-attr-name").Value, undefined>>;
5
- readonly 'case-sensitive-tag-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-tag-name").Value, undefined>>;
3
+ readonly 'attr-value-quotes': Readonly<import("@markuplint/ml-core").RuleSeed<import("./attr-value-quotes/index.js").Type, undefined>>;
4
+ readonly 'case-sensitive-attr-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-attr-name/index.js").Value, undefined>>;
5
+ readonly 'case-sensitive-tag-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-tag-name/index.js").Value, undefined>>;
6
6
  readonly 'character-reference': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
7
- readonly 'class-naming': Readonly<import("@markuplint/ml-core").RuleSeed<import("./class-naming").Value, undefined>>;
7
+ readonly 'class-naming': Readonly<import("@markuplint/ml-core").RuleSeed<import("./class-naming/index.js").Value, undefined>>;
8
8
  readonly 'deprecated-attr': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
9
9
  readonly 'deprecated-element': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
10
10
  readonly 'disallowed-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], undefined>>;
@@ -20,15 +20,15 @@ declare const rules: {
20
20
  } | {
21
21
  pattern: string;
22
22
  } | {
23
- type: import("packages/@markuplint/ml-spec/lib").AttributeType;
23
+ type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
24
24
  }> | (string | {
25
25
  name: string;
26
- value: import("packages/@markuplint/ml-spec/lib").AttributeType | ({
26
+ value: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType | ({
27
27
  enum: [string, ...string[]];
28
28
  } | {
29
29
  pattern: string;
30
30
  } | {
31
- type: import("packages/@markuplint/ml-spec/lib").AttributeType;
31
+ type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
32
32
  });
33
33
  })[] | undefined;
34
34
  disallowAttrs?: Record<string, {
@@ -36,15 +36,15 @@ declare const rules: {
36
36
  } | {
37
37
  pattern: string;
38
38
  } | {
39
- type: import("packages/@markuplint/ml-spec/lib").AttributeType;
39
+ type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
40
40
  }> | (string | {
41
41
  name: string;
42
- value: import("packages/@markuplint/ml-spec/lib").AttributeType | ({
42
+ value: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType | ({
43
43
  enum: [string, ...string[]];
44
44
  } | {
45
45
  pattern: string;
46
46
  } | {
47
- type: import("packages/@markuplint/ml-spec/lib").AttributeType;
47
+ type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
48
48
  });
49
49
  })[] | undefined;
50
50
  ignoreAttrNamePrefix?: string | string[] | undefined;
@@ -54,7 +54,7 @@ declare const rules: {
54
54
  } | {
55
55
  pattern: string;
56
56
  } | {
57
- type: import("packages/@markuplint/ml-spec/lib").AttributeType;
57
+ type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
58
58
  }) | {
59
59
  disallowed: true;
60
60
  }> | undefined;
@@ -72,19 +72,19 @@ declare const rules: {
72
72
  }>>;
73
73
  readonly 'no-hard-code-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
74
74
  readonly 'no-refer-to-non-existent-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
75
- ariaVersion: "1.3" | "1.2" | "1.1";
75
+ ariaVersion: "1.2" | "1.1" | "1.3";
76
76
  fragmentRefersNameAttr: boolean;
77
77
  }>>;
78
78
  readonly 'no-use-event-handler-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
79
79
  ignore?: string | string[] | undefined;
80
80
  }>>;
81
- readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types").TagRule[], import("./permitted-contents/types").Options>>;
81
+ readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types.js").TagRule[], import("./permitted-contents/types.js").Options>>;
82
82
  readonly 'placeholder-label-option': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
83
83
  readonly 'require-accessible-name': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
84
- ariaVersion: "1.3" | "1.2" | "1.1";
84
+ ariaVersion: "1.2" | "1.1" | "1.3";
85
85
  }>>;
86
86
  readonly 'require-datetime': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
87
- langs?: import("./require-datetime/types").Lang[] | undefined;
87
+ langs?: import("./require-datetime/types.js").Lang[] | undefined;
88
88
  }>>;
89
89
  readonly 'required-attr': Readonly<import("@markuplint/ml-core").RuleSeed<string | (string | {
90
90
  name: string;
@@ -93,10 +93,14 @@ declare const rules: {
93
93
  readonly 'required-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], {
94
94
  ignoreHasMutableContents: boolean;
95
95
  }>>;
96
- readonly 'required-h1': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./required-h1").Options>>;
96
+ readonly 'required-h1': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./required-h1/index.js").Options>>;
97
97
  readonly 'use-list': Readonly<import("@markuplint/ml-core").RuleSeed<readonly string[], {
98
98
  spaceNeededBullets?: string[] | undefined;
99
+ noPrev?: boolean | undefined;
100
+ prevElement?: boolean | undefined;
101
+ prevComment?: boolean | undefined;
102
+ prevCodeBlock?: boolean | undefined;
99
103
  }>>;
100
- readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types").Options>>;
104
+ readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types.js").Options>>;
101
105
  };
102
106
  export default rules;
package/lib/index.js CHANGED
@@ -1,68 +1,65 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const attr_duplication_1 = tslib_1.__importDefault(require("./attr-duplication"));
5
- const attr_value_quotes_1 = tslib_1.__importDefault(require("./attr-value-quotes"));
6
- const case_sensitive_attr_name_1 = tslib_1.__importDefault(require("./case-sensitive-attr-name"));
7
- const case_sensitive_tag_name_1 = tslib_1.__importDefault(require("./case-sensitive-tag-name"));
8
- const character_reference_1 = tslib_1.__importDefault(require("./character-reference"));
9
- const class_naming_1 = tslib_1.__importDefault(require("./class-naming"));
10
- const deprecated_attr_1 = tslib_1.__importDefault(require("./deprecated-attr"));
11
- const deprecated_element_1 = tslib_1.__importDefault(require("./deprecated-element"));
12
- const disallowed_element_1 = tslib_1.__importDefault(require("./disallowed-element"));
13
- const doctype_1 = tslib_1.__importDefault(require("./doctype"));
14
- const end_tag_1 = tslib_1.__importDefault(require("./end-tag"));
15
- const id_duplication_1 = tslib_1.__importDefault(require("./id-duplication"));
16
- const ineffective_attr_1 = tslib_1.__importDefault(require("./ineffective-attr"));
17
- const invalid_attr_1 = tslib_1.__importDefault(require("./invalid-attr"));
18
- const label_has_control_1 = tslib_1.__importDefault(require("./label-has-control"));
19
- const landmark_roles_1 = tslib_1.__importDefault(require("./landmark-roles"));
20
- const no_boolean_attr_value_1 = tslib_1.__importDefault(require("./no-boolean-attr-value"));
21
- const no_default_value_1 = tslib_1.__importDefault(require("./no-default-value"));
22
- const no_empty_palpable_content_1 = tslib_1.__importDefault(require("./no-empty-palpable-content"));
23
- const no_hard_code_id_1 = tslib_1.__importDefault(require("./no-hard-code-id"));
24
- const no_refer_to_non_existent_id_1 = tslib_1.__importDefault(require("./no-refer-to-non-existent-id"));
25
- const no_use_event_handler_attr_1 = tslib_1.__importDefault(require("./no-use-event-handler-attr"));
26
- const permitted_contents_1 = tslib_1.__importDefault(require("./permitted-contents"));
27
- const placeholder_label_option_1 = tslib_1.__importDefault(require("./placeholder-label-option"));
28
- const require_accessible_name_1 = tslib_1.__importDefault(require("./require-accessible-name"));
29
- const require_datetime_1 = tslib_1.__importDefault(require("./require-datetime"));
30
- const required_attr_1 = tslib_1.__importDefault(require("./required-attr"));
31
- const required_element_1 = tslib_1.__importDefault(require("./required-element"));
32
- const required_h1_1 = tslib_1.__importDefault(require("./required-h1"));
33
- const use_list_1 = tslib_1.__importDefault(require("./use-list"));
34
- const wai_aria_1 = tslib_1.__importDefault(require("./wai-aria"));
1
+ import AttrDuplication from './attr-duplication/index.js';
2
+ import AttrValueQuotes from './attr-value-quotes/index.js';
3
+ import CaseSensitiveAttrName from './case-sensitive-attr-name/index.js';
4
+ import CaseSensitiveTagName from './case-sensitive-tag-name/index.js';
5
+ import CharacterReference from './character-reference/index.js';
6
+ import ClassNaming from './class-naming/index.js';
7
+ import DeprecatedAttr from './deprecated-attr/index.js';
8
+ import DeprecatedElement from './deprecated-element/index.js';
9
+ import DisallowedElement from './disallowed-element/index.js';
10
+ import Doctype from './doctype/index.js';
11
+ import EndTag from './end-tag/index.js';
12
+ import IdDuplication from './id-duplication/index.js';
13
+ import IneffectiveAttr from './ineffective-attr/index.js';
14
+ import InvalidAttr from './invalid-attr/index.js';
15
+ import LabelHasControl from './label-has-control/index.js';
16
+ import LandmarkRoles from './landmark-roles/index.js';
17
+ import NoBooleanAttrValue from './no-boolean-attr-value/index.js';
18
+ import NoDefaultValue from './no-default-value/index.js';
19
+ import NoEmptyPalpableContent from './no-empty-palpable-content/index.js';
20
+ import NoHardCodeId from './no-hard-code-id/index.js';
21
+ import NoReferToNonExistentId from './no-refer-to-non-existent-id/index.js';
22
+ import NoUseEventHandlerAttr from './no-use-event-handler-attr/index.js';
23
+ import PermittedContents from './permitted-contents/index.js';
24
+ import PlaceholderLabelOption from './placeholder-label-option/index.js';
25
+ import RequireAccessibleName from './require-accessible-name/index.js';
26
+ import RequireDatetime from './require-datetime/index.js';
27
+ import RequiredAttr from './required-attr/index.js';
28
+ import RequiredElement from './required-element/index.js';
29
+ import RequiredH1 from './required-h1/index.js';
30
+ import UseList from './use-list/index.js';
31
+ import WaiAria from './wai-aria/index.js';
35
32
  const rules = {
36
- 'attr-duplication': attr_duplication_1.default,
37
- 'attr-value-quotes': attr_value_quotes_1.default,
38
- 'case-sensitive-attr-name': case_sensitive_attr_name_1.default,
39
- 'case-sensitive-tag-name': case_sensitive_tag_name_1.default,
40
- 'character-reference': character_reference_1.default,
41
- 'class-naming': class_naming_1.default,
42
- 'deprecated-attr': deprecated_attr_1.default,
43
- 'deprecated-element': deprecated_element_1.default,
44
- 'disallowed-element': disallowed_element_1.default,
45
- doctype: doctype_1.default,
46
- 'end-tag': end_tag_1.default,
47
- 'id-duplication': id_duplication_1.default,
48
- 'ineffective-attr': ineffective_attr_1.default,
49
- 'invalid-attr': invalid_attr_1.default,
50
- 'label-has-control': label_has_control_1.default,
51
- 'landmark-roles': landmark_roles_1.default,
52
- 'no-boolean-attr-value': no_boolean_attr_value_1.default,
53
- 'no-default-value': no_default_value_1.default,
54
- 'no-empty-palpable-content': no_empty_palpable_content_1.default,
55
- 'no-hard-code-id': no_hard_code_id_1.default,
56
- 'no-refer-to-non-existent-id': no_refer_to_non_existent_id_1.default,
57
- 'no-use-event-handler-attr': no_use_event_handler_attr_1.default,
58
- 'permitted-contents': permitted_contents_1.default,
59
- 'placeholder-label-option': placeholder_label_option_1.default,
60
- 'require-accessible-name': require_accessible_name_1.default,
61
- 'require-datetime': require_datetime_1.default,
62
- 'required-attr': required_attr_1.default,
63
- 'required-element': required_element_1.default,
64
- 'required-h1': required_h1_1.default,
65
- 'use-list': use_list_1.default,
66
- 'wai-aria': wai_aria_1.default,
33
+ 'attr-duplication': AttrDuplication,
34
+ 'attr-value-quotes': AttrValueQuotes,
35
+ 'case-sensitive-attr-name': CaseSensitiveAttrName,
36
+ 'case-sensitive-tag-name': CaseSensitiveTagName,
37
+ 'character-reference': CharacterReference,
38
+ 'class-naming': ClassNaming,
39
+ 'deprecated-attr': DeprecatedAttr,
40
+ 'deprecated-element': DeprecatedElement,
41
+ 'disallowed-element': DisallowedElement,
42
+ doctype: Doctype,
43
+ 'end-tag': EndTag,
44
+ 'id-duplication': IdDuplication,
45
+ 'ineffective-attr': IneffectiveAttr,
46
+ 'invalid-attr': InvalidAttr,
47
+ 'label-has-control': LabelHasControl,
48
+ 'landmark-roles': LandmarkRoles,
49
+ 'no-boolean-attr-value': NoBooleanAttrValue,
50
+ 'no-default-value': NoDefaultValue,
51
+ 'no-empty-palpable-content': NoEmptyPalpableContent,
52
+ 'no-hard-code-id': NoHardCodeId,
53
+ 'no-refer-to-non-existent-id': NoReferToNonExistentId,
54
+ 'no-use-event-handler-attr': NoUseEventHandlerAttr,
55
+ 'permitted-contents': PermittedContents,
56
+ 'placeholder-label-option': PlaceholderLabelOption,
57
+ 'require-accessible-name': RequireAccessibleName,
58
+ 'require-datetime': RequireDatetime,
59
+ 'required-attr': RequiredAttr,
60
+ 'required-element': RequiredElement,
61
+ 'required-h1': RequiredH1,
62
+ 'use-list': UseList,
63
+ 'wai-aria': WaiAria,
67
64
  };
68
- exports.default = rules;
65
+ export default rules;
@@ -1,4 +1,2 @@
1
- declare const _default: Readonly<
2
- import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
- >;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
4
2
  export default _default;