@markuplint/rules 3.3.1 → 3.5.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 (88) hide show
  1. package/lib/attr-check.d.ts +9 -19
  2. package/lib/attr-duplication/index.d.ts +1 -1
  3. package/lib/attr-value-quotes/index.d.ts +2 -2
  4. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  5. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  6. package/lib/character-reference/index.d.ts +1 -1
  7. package/lib/class-naming/index.d.ts +1 -1
  8. package/lib/create-message.d.ts +3 -12
  9. package/lib/create-message.js +2 -2
  10. package/lib/deprecated-attr/index.d.ts +1 -1
  11. package/lib/deprecated-element/index.d.ts +1 -1
  12. package/lib/disallowed-element/index.d.ts +1 -1
  13. package/lib/doctype/index.d.ts +2 -2
  14. package/lib/end-tag/index.d.ts +1 -1
  15. package/lib/helpers.d.ts +18 -35
  16. package/lib/helpers.js +19 -5
  17. package/lib/id-duplication/index.d.ts +1 -1
  18. package/lib/index.d.ts +70 -3
  19. package/lib/index.js +2 -1
  20. package/lib/ineffective-attr/index.d.ts +1 -1
  21. package/lib/invalid-attr/index.d.ts +13 -17
  22. package/lib/label-has-control/index.d.ts +1 -1
  23. package/lib/landmark-roles/index.d.ts +3 -3
  24. package/lib/landmark-roles/index.js +6 -2
  25. package/lib/no-boolean-attr-value/index.d.ts +1 -1
  26. package/lib/no-default-value/index.d.ts +1 -1
  27. package/lib/no-empty-palpable-content/index.d.ts +3 -3
  28. package/lib/no-hard-code-id/index.d.ts +1 -1
  29. package/lib/no-refer-to-non-existent-id/index.d.ts +4 -7
  30. package/lib/no-refer-to-non-existent-id/index.js +4 -0
  31. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  32. package/lib/permitted-contents/choice.d.ts +2 -7
  33. package/lib/permitted-contents/choice.js +3 -1
  34. package/lib/permitted-contents/complex-branch.d.ts +2 -7
  35. package/lib/permitted-contents/complex-branch.js +4 -2
  36. package/lib/permitted-contents/content-model.d.ts +1 -1
  37. package/lib/permitted-contents/content-model.js +6 -2
  38. package/lib/permitted-contents/count-pattern.d.ts +3 -17
  39. package/lib/permitted-contents/count-pattern.js +10 -3
  40. package/lib/permitted-contents/debug.browser.d.ts +15 -15
  41. package/lib/permitted-contents/debug.d.ts +1 -1
  42. package/lib/permitted-contents/index.d.ts +1 -1
  43. package/lib/permitted-contents/index.js +3 -1
  44. package/lib/permitted-contents/matches-selector.d.ts +2 -8
  45. package/lib/permitted-contents/matches-selector.js +3 -1
  46. package/lib/permitted-contents/order.d.ts +2 -7
  47. package/lib/permitted-contents/order.js +4 -2
  48. package/lib/permitted-contents/recursive-branch.d.ts +2 -7
  49. package/lib/permitted-contents/recursive-branch.js +5 -3
  50. package/lib/permitted-contents/represent-transparent-nodes.d.ts +3 -7
  51. package/lib/permitted-contents/represent-transparent-nodes.js +3 -1
  52. package/lib/permitted-contents/start.d.ts +2 -6
  53. package/lib/permitted-contents/start.js +3 -1
  54. package/lib/permitted-contents/transparent.d.ts +2 -2
  55. package/lib/permitted-contents/transparent.js +5 -3
  56. package/lib/permitted-contents/types.d.ts +31 -30
  57. package/lib/permitted-contents/utils.d.ts +44 -80
  58. package/lib/permitted-contents/utils.js +21 -7
  59. package/lib/placeholder-label-option/index.d.ts +1 -1
  60. package/lib/placeholder-label-option/index.js +6 -2
  61. package/lib/require-accessible-name/index.d.ts +2 -2
  62. package/lib/require-datetime/index.d.ts +2 -2
  63. package/lib/require-datetime/types.d.ts +2 -2
  64. package/lib/require-datetime/utils.d.ts +1 -1
  65. package/lib/require-datetime/utils.js +3 -1
  66. package/lib/required-attr/index.d.ts +3 -3
  67. package/lib/required-attr/index.js +14 -11
  68. package/lib/required-element/index.d.ts +2 -2
  69. package/lib/required-element/index.js +2 -1
  70. package/lib/required-h1/index.d.ts +3 -3
  71. package/lib/required-h1/index.js +3 -2
  72. package/lib/use-list/index.d.ts +3 -3
  73. package/lib/use-list/index.js +3 -2
  74. package/lib/wai-aria/checkings/default-value.d.ts +3 -7
  75. package/lib/wai-aria/checkings/deprecated-props.d.ts +4 -8
  76. package/lib/wai-aria/checkings/disallowed-prop.d.ts +4 -8
  77. package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
  78. package/lib/wai-aria/checkings/implicit-props.d.ts +4 -8
  79. package/lib/wai-aria/checkings/interaction-in-hidden.js +3 -1
  80. package/lib/wai-aria/checkings/no-global-prop.d.ts +3 -7
  81. package/lib/wai-aria/checkings/presentational-children.js +3 -1
  82. package/lib/wai-aria/checkings/required-owned-elements.d.ts +3 -7
  83. package/lib/wai-aria/checkings/required-owned-elements.js +6 -4
  84. package/lib/wai-aria/checkings/required-prop.d.ts +6 -12
  85. package/lib/wai-aria/checkings/value.d.ts +6 -10
  86. package/lib/wai-aria/index.d.ts +1 -1
  87. package/lib/wai-aria/types.d.ts +10 -10
  88. package/package.json +9 -8
@@ -1,14 +1,15 @@
1
1
  import type { Translator } from '@markuplint/i18n';
2
2
  import type { Attribute as AttrSpec, AttributeType } from '@markuplint/ml-spec';
3
+ import type { ReadonlyDeep } from 'type-fest';
3
4
  type Invalid = {
4
- invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
5
- message: string;
6
- loc?: Loc;
5
+ invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
6
+ message: string;
7
+ loc?: Loc;
7
8
  };
8
9
  type Loc = {
9
- raw: string;
10
- line: number;
11
- col: number;
10
+ raw: string;
11
+ line: number;
12
+ col: number;
12
13
  };
13
14
  /**
14
15
  * Use in rules `invalid-attr` and `wai-aria`
@@ -18,17 +19,6 @@ type Loc = {
18
19
  * @param isCustomRule
19
20
  * @param spec
20
21
  */
21
- export declare function attrCheck(
22
- t: Translator,
23
- name: string,
24
- value: string,
25
- isCustomRule: boolean,
26
- spec?: AttrSpec,
27
- ): Invalid | false;
28
- export declare function valueCheck(
29
- t: Translator,
30
- name: string,
31
- value: string,
32
- type: AttributeType,
33
- ): string | [string, Loc] | false;
22
+ export declare function attrCheck(t: Translator, name: string, value: string, isCustomRule: boolean, spec?: AttrSpec): Invalid | false;
23
+ export declare function valueCheck(t: Translator, name: string, value: string, type: ReadonlyDeep<AttributeType>): string | [string, Loc] | false;
34
24
  export {};
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,7 +1,7 @@
1
1
  export type Type = 'double' | 'single';
2
2
  export type Quote = '"' | "'";
3
3
  export type QuoteMap = {
4
- [P in Type]: Quote;
4
+ [P in Type]: Quote;
5
5
  };
6
- declare const _default: import('@markuplint/ml-core').RuleSeed<Type, null>;
6
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<Type, undefined>>;
7
7
  export default _default;
@@ -1,3 +1,3 @@
1
1
  export type Value = 'lower' | 'upper';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<Value, null>;
2
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<Value, undefined>>;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  export type Value = 'lower' | 'upper';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<Value, null>;
2
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<Value, undefined>>;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  import type { RuleConfigValue } from '@markuplint/ml-config';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<RuleConfigValue, null>;
2
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<RuleConfigValue, undefined>>;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  export type Value = string | string[] | null;
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<Value, null>;
2
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<Value, undefined>>;
3
3
  export default _default;
@@ -1,15 +1,6 @@
1
1
  import type { Translator } from '@markuplint/i18n';
2
2
  import type { AttributeType } from '@markuplint/ml-spec';
3
3
  import type { UnmatchedResult } from '@markuplint/types';
4
- export declare function createMessageValueExpected(
5
- t: Translator,
6
- baseTarget: string,
7
- type: AttributeType,
8
- matches: UnmatchedResult,
9
- ): string;
10
- export declare function __createMessageValueExpected(
11
- t: Translator,
12
- baseTarget: string,
13
- expected: string | null,
14
- matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candidate' | 'ref' | 'extra'>,
15
- ): string;
4
+ import type { ReadonlyDeep } from 'type-fest';
5
+ export declare function createMessageValueExpected(t: Translator, baseTarget: string, type: ReadonlyDeep<AttributeType>, matches: UnmatchedResult): string;
6
+ export declare function __createMessageValueExpected(t: Translator, baseTarget: string, expected: string | null, matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candidate' | 'ref' | 'extra'>): string;
@@ -199,7 +199,7 @@ function __createMessageValueExpected(t, baseTarget, expected, matches) {
199
199
  }
200
200
  exports.__createMessageValueExpected = __createMessageValueExpected;
201
201
  function createExpectedObject(type, matches, t) {
202
- var _a;
202
+ var _a, _b;
203
203
  const expectedObject = [];
204
204
  if ((_a = matches.expects) === null || _a === void 0 ? void 0 : _a.length) {
205
205
  expectedObject.push(...matches.expects.map(expect => {
@@ -221,7 +221,7 @@ function createExpectedObject(type, matches, t) {
221
221
  ? null
222
222
  : 1 < expectedObject.length
223
223
  ? t('either {0}', t(expectedObject))
224
- : expectedObject[0];
224
+ : (_b = expectedObject[0]) !== null && _b !== void 0 ? _b : null;
225
225
  return expects;
226
226
  }
227
227
  function expectValueToWord(t, expect, type) {
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<string[], null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<string[], undefined>>;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
1
  type Option = {
2
- denyObsoleteType: boolean;
2
+ denyObsoleteType: boolean;
3
3
  };
4
- declare const _default: 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,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
2
2
  export default _default;
package/lib/helpers.d.ts CHANGED
@@ -1,11 +1,9 @@
1
1
  import type { Log } from './debug';
2
2
  import type { Translator } from '@markuplint/i18n';
3
+ import type { PlainData } from '@markuplint/ml-config';
3
4
  import type { Element, RuleConfigValue, Document } from '@markuplint/ml-core';
4
5
  import type { Attribute } from '@markuplint/ml-spec';
5
- export declare function attrMatches<T extends RuleConfigValue, R>(
6
- node: Element<T, R>,
7
- condition: Attribute['condition'],
8
- ): boolean;
6
+ export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(node: Element<T, O>, condition: Attribute['condition']): boolean;
9
7
  export declare function match(needle: string, pattern: string): boolean;
10
8
  /**
11
9
  * PotentialCustomElementName
@@ -23,43 +21,28 @@ export declare function match(needle: string, pattern: string): boolean;
23
21
  * 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.
24
22
  */
25
23
  export declare const rePCENChar: string;
26
- export declare function isValidAttr(
27
- t: Translator,
28
- name: string,
29
- value: string,
30
- isDynamicValue: boolean,
31
- node: Element<any, any>,
32
- attrSpecs: Attribute[],
33
- log?: Log,
34
- ):
35
- | false
36
- | {
37
- invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
38
- message: string;
39
- loc?:
40
- | {
41
- raw: string;
42
- line: number;
43
- col: number;
44
- }
45
- | undefined;
46
- };
24
+ export declare function isValidAttr(t: Translator, name: string, value: string, isDynamicValue: boolean, node: Element<any, any>, attrSpecs: readonly Attribute[], log?: Log): false | {
25
+ invalidType: "non-existent" | "invalid-value" | "disallowed-attr";
26
+ message: string;
27
+ loc?: {
28
+ raw: string;
29
+ line: number;
30
+ col: number;
31
+ } | undefined;
32
+ };
47
33
  export declare function toNormalizedValue(value: string, spec: Attribute): string;
48
34
  export declare function accnameMayBeMutable(el: Element<any, any>, document: Document<any, any>): boolean;
49
- export declare function getOwnedLabel<V extends RuleConfigValue, O>(
50
- el: Element<V, O>,
51
- document: Document<V, O>,
52
- ): Element<V, O> | null;
35
+ export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(el: Element<V, O>, document: Document<V, O>): Element<V, O> | null;
53
36
  export declare function decodeCharRef(characterReference: string): string;
54
37
  export declare class Collection<T> {
55
- #private;
56
- constructor(...items: (T | null | undefined)[]);
57
- [Symbol.iterator](): Iterator<T>;
58
- add(...items: (T | null | undefined)[]): void;
59
- 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[];
60
43
  }
61
44
  type Writeable<T> = {
62
- -readonly [P in keyof T]: T[P];
45
+ -readonly [P in keyof T]: T[P];
63
46
  };
64
47
  export declare function deepCopy<T>(value: T): Writeable<T>;
65
48
  export {};
package/lib/helpers.js CHANGED
@@ -7,11 +7,13 @@ const tslib_1 = require("tslib");
7
7
  const structured_clone_1 = tslib_1.__importDefault(require("@ungap/structured-clone"));
8
8
  const html_entities_1 = require("html-entities");
9
9
  const attr_check_1 = require("./attr-check");
10
- function attrMatches(node, condition) {
10
+ function attrMatches(
11
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
12
+ node, condition) {
11
13
  if (!condition) {
12
14
  return true;
13
15
  }
14
- const condSelector = Array.isArray(condition) ? condition.join(',') : condition;
16
+ const condSelector = typeof condition === 'string' ? condition : condition.join(',');
15
17
  return node.matches(condSelector);
16
18
  }
17
19
  exports.attrMatches = attrMatches;
@@ -60,7 +62,11 @@ exports.rePCENChar = [
60
62
  '[\uFDF0-\uFFFD]',
61
63
  '[\uD800-\uDBFF][\uDC00-\uDFFF]',
62
64
  ].join('|');
63
- function isValidAttr(t, name, value, isDynamicValue, node, attrSpecs, log) {
65
+ function isValidAttr(t, name, value, isDynamicValue,
66
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
67
+ node, attrSpecs,
68
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
69
+ log) {
64
70
  let invalid = false;
65
71
  const spec = attrSpecs.find(s => s.name.toLowerCase() === name.toLowerCase());
66
72
  log && log('Spec of the %s attr: %o', name, spec);
@@ -106,7 +112,11 @@ function toNormalizedValue(value, spec) {
106
112
  return normalized;
107
113
  }
108
114
  exports.toNormalizedValue = toNormalizedValue;
109
- function accnameMayBeMutable(el, document) {
115
+ function accnameMayBeMutable(
116
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
117
+ el,
118
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
119
+ document) {
110
120
  if (el.hasMutableAttributes() || el.hasMutableChildren(true)) {
111
121
  return true;
112
122
  }
@@ -118,7 +128,11 @@ function accnameMayBeMutable(el, document) {
118
128
  }
119
129
  exports.accnameMayBeMutable = accnameMayBeMutable;
120
130
  const labelable = ['button', 'input:not([type=hidden])', 'meter', 'output', 'progress', 'select', 'textarea'];
121
- function getOwnedLabel(el, document) {
131
+ function getOwnedLabel(
132
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
133
+ el,
134
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
135
+ document) {
122
136
  if (!labelable.some(cond => el.matches(cond))) {
123
137
  return null;
124
138
  }
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
package/lib/index.d.ts CHANGED
@@ -1,3 +1,70 @@
1
- import type { AnyRuleSeed } from '@markuplint/ml-core';
2
- declare const _default: Record<string, AnyRuleSeed>;
3
- export default _default;
1
+ declare const rules: {
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>>;
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>>;
8
+ readonly 'deprecated-attr': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
9
+ readonly 'deprecated-element': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
10
+ readonly 'disallowed-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], undefined>>;
11
+ readonly doctype: Readonly<import("@markuplint/ml-core").RuleSeed<"always", {
12
+ denyObsoleteType: boolean;
13
+ }>>;
14
+ readonly 'end-tag': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
15
+ readonly 'id-duplication': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
16
+ readonly 'ineffective-attr': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
17
+ readonly 'invalid-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
18
+ attrs?: Record<string, {
19
+ enum: [string, ...string[]];
20
+ } | {
21
+ pattern: string;
22
+ } | {
23
+ type: import("packages/@markuplint/ml-spec/lib").AttributeType;
24
+ } | {
25
+ disallowed: true;
26
+ }> | undefined;
27
+ ignoreAttrNamePrefix?: string | string[] | undefined;
28
+ allowToAddPropertiesForPretender?: boolean | undefined;
29
+ }>>;
30
+ readonly 'label-has-control': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
31
+ readonly 'landmark-roles': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
32
+ ignoreRoles: (("banner" | "main" | "complementary" | "contentinfo") | "form" | "navigation" | "region")[];
33
+ labelEachArea: boolean;
34
+ }>>;
35
+ readonly 'no-boolean-attr-value': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
36
+ readonly 'no-default-value': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
37
+ readonly 'no-empty-palpable-content': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
38
+ extendsExposableElements?: boolean | undefined;
39
+ ignoreIfAriaBusy?: boolean | undefined;
40
+ }>>;
41
+ readonly 'no-hard-code-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
42
+ readonly 'no-refer-to-non-existent-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
43
+ ariaVersion: import("packages/@markuplint/ml-spec/lib").ARIAVersion;
44
+ fragmentRefersNameAttr: boolean;
45
+ }>>;
46
+ readonly 'no-use-event-handler-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
47
+ ignore?: string | string[] | undefined;
48
+ }>>;
49
+ readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types").TagRule[], import("./permitted-contents/types").Options>>;
50
+ readonly 'placeholder-label-option': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
51
+ readonly 'require-accessible-name': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
52
+ ariaVersion: import("packages/@markuplint/ml-spec/lib").ARIAVersion;
53
+ }>>;
54
+ readonly 'require-datetime': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
55
+ langs?: import("./require-datetime/types").Lang[] | undefined;
56
+ }>>;
57
+ readonly 'required-attr': Readonly<import("@markuplint/ml-core").RuleSeed<string | (string | {
58
+ name: string;
59
+ value: string | string[];
60
+ })[], undefined>>;
61
+ readonly 'required-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], {
62
+ ignoreHasMutableContents: boolean;
63
+ }>>;
64
+ readonly 'required-h1': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./required-h1").Options>>;
65
+ readonly 'use-list': Readonly<import("@markuplint/ml-core").RuleSeed<readonly string[], {
66
+ spaceNeededBullets?: string[] | undefined;
67
+ }>>;
68
+ readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types").Options>>;
69
+ };
70
+ export default rules;
package/lib/index.js CHANGED
@@ -32,7 +32,7 @@ const required_element_1 = tslib_1.__importDefault(require("./required-element")
32
32
  const required_h1_1 = tslib_1.__importDefault(require("./required-h1"));
33
33
  const use_list_1 = tslib_1.__importDefault(require("./use-list"));
34
34
  const wai_aria_1 = tslib_1.__importDefault(require("./wai-aria"));
35
- exports.default = {
35
+ const rules = {
36
36
  'attr-duplication': attr_duplication_1.default,
37
37
  'attr-value-quotes': attr_value_quotes_1.default,
38
38
  'case-sensitive-attr-name': case_sensitive_attr_name_1.default,
@@ -65,3 +65,4 @@ exports.default = {
65
65
  'use-list': use_list_1.default,
66
66
  'wai-aria': wai_aria_1.default,
67
67
  };
68
+ exports.default = rules;
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,21 +1,17 @@
1
1
  import type { AttributeType } from '@markuplint/ml-spec';
2
2
  type Option = {
3
- attrs?: Record<string, Rule>;
4
- ignoreAttrNamePrefix?: string | string[];
5
- allowToAddPropertiesForPretender?: boolean;
3
+ attrs?: Record<string, Rule>;
4
+ ignoreAttrNamePrefix?: string | string[];
5
+ allowToAddPropertiesForPretender?: boolean;
6
6
  };
7
- type Rule =
8
- | {
9
- enum: [string, ...string[]];
10
- }
11
- | {
12
- pattern: string;
13
- }
14
- | {
15
- type: AttributeType;
16
- }
17
- | {
18
- disallowed: true;
19
- };
20
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Option>;
7
+ type Rule = {
8
+ enum: [string, ...string[]];
9
+ } | {
10
+ pattern: string;
11
+ } | {
12
+ type: AttributeType;
13
+ } | {
14
+ disallowed: true;
15
+ };
16
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Option>>;
21
17
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,8 +1,8 @@
1
1
  type Options = {
2
- ignoreRoles: Roles[];
3
- labelEachArea: boolean;
2
+ ignoreRoles: Roles[];
3
+ labelEachArea: boolean;
4
4
  };
5
5
  type TopLevelRoles = 'banner' | 'main' | 'complementary' | 'contentinfo';
6
6
  type Roles = TopLevelRoles | 'form' | 'navigation' | 'region';
7
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
7
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
8
8
  export default _default;
@@ -106,12 +106,16 @@ exports.default = (0, ml_core_1.createRule)({
106
106
  }
107
107
  },
108
108
  });
109
- function landmarkRoleElementUUIDList(roleset) {
109
+ function landmarkRoleElementUUIDList(
110
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
111
+ roleset) {
110
112
  return Object.values(roleset)
111
113
  .map(elements => elements.map(element => element.uuid))
112
114
  .flat();
113
115
  }
114
- function hasLabel(el) {
116
+ function hasLabel(
117
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
118
+ el) {
115
119
  const hasHeading = !!el.querySelectorAll('h1, h2, h3, h4, h5, h6').length;
116
120
  if (hasHeading && el.matches('[aria-labelledby]')) {
117
121
  return true;
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,6 +1,6 @@
1
1
  type Options = {
2
- extendsExposableElements?: boolean;
3
- ignoreIfAriaBusy?: boolean;
2
+ extendsExposableElements?: boolean;
3
+ ignoreIfAriaBusy?: boolean;
4
4
  };
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
5
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
6
6
  export default _default;
@@ -1,2 +1,2 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
2
2
  export default _default;
@@ -1,9 +1,6 @@
1
1
  import type { ARIAVersion } from '@markuplint/ml-spec';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<
3
- import('@markuplint/ml-core').RuleConfigValue,
4
- {
5
- ariaVersion: ARIAVersion;
6
- fragmentRefersNameAttr: boolean;
7
- }
8
- >;
2
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
3
+ ariaVersion: ARIAVersion;
4
+ fragmentRefersNameAttr: boolean;
5
+ }>>;
9
6
  export default _default;
@@ -12,6 +12,10 @@ exports.default = (0, ml_core_1.createRule)({
12
12
  const nameList = new Set();
13
13
  let hasDynamicId = false;
14
14
  let hasDynamicName = false;
15
+ const isMutable = document.nodeList.some(node => node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK));
16
+ if (isMutable) {
17
+ return;
18
+ }
15
19
  document.querySelectorAll('[id]').forEach(el => {
16
20
  const attr = el.getAttributeNode('id');
17
21
  if (!attr) {
@@ -1,5 +1,5 @@
1
1
  type Options = {
2
- ignore?: string | string[];
2
+ ignore?: string | string[];
3
3
  };
4
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
4
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
5
5
  export default _default;
@@ -1,9 +1,4 @@
1
1
  import type { ChildNode, Options, Result, Specs } from './types';
2
2
  import type { PermittedContentChoice } from '@markuplint/ml-spec';
3
- export declare function choice(
4
- pattern: PermittedContentChoice,
5
- elements: ChildNode[],
6
- specs: Specs,
7
- options: Options,
8
- depth: number,
9
- ): Result;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ export declare function choice(pattern: ReadonlyDeep<PermittedContentChoice>, elements: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
@@ -5,7 +5,9 @@ const debug_1 = require("./debug");
5
5
  const order_1 = require("./order");
6
6
  const utils_1 = require("./utils");
7
7
  const indexes = new WeakMap();
8
- function choice(pattern, elements, specs, options, depth) {
8
+ function choice(pattern,
9
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
10
+ elements, specs, options, depth) {
9
11
  const choiceLog = debug_1.cmLog.extend(`choice#${depth}`);
10
12
  const collection = new utils_1.Collection(elements);
11
13
  const unmatchedResults = [];
@@ -1,5 +1,6 @@
1
1
  import type { ChildNode, Options, Result, Specs } from './types';
2
2
  import type { PermittedContentPattern } from '@markuplint/ml-spec';
3
+ import type { ReadonlyDeep } from 'type-fest';
3
4
  /**
4
5
  * Check content condition
5
6
  *
@@ -10,10 +11,4 @@ import type { PermittedContentPattern } from '@markuplint/ml-spec';
10
11
  * @param depth
11
12
  * @returns
12
13
  */
13
- export declare function complexBranch(
14
- pattern: PermittedContentPattern,
15
- elements: ChildNode[],
16
- specs: Specs,
17
- options: Options,
18
- depth: number,
19
- ): Result;
14
+ export declare function complexBranch(pattern: ReadonlyDeep<PermittedContentPattern>, elements: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
@@ -15,12 +15,14 @@ const utils_1 = require("./utils");
15
15
  * @param depth
16
16
  * @returns
17
17
  */
18
- function complexBranch(pattern, elements, specs, options, depth) {
18
+ function complexBranch(pattern,
19
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
20
+ elements, specs, options, depth) {
19
21
  if ((0, utils_1.isChoice)(pattern)) {
20
22
  return (0, choice_1.choice)(pattern, elements, specs, options, depth);
21
23
  }
22
24
  if ((0, utils_1.isTransparent)(pattern)) {
23
- return (0, transparent_1.transparent)(elements, specs, options, depth);
25
+ return (0, transparent_1.transparent)(elements);
24
26
  }
25
27
  return (0, count_pattern_1.countPattern)(pattern, elements, specs, options, depth);
26
28
  }
@@ -1,2 +1,2 @@
1
1
  import type { ContentModelResult, Element, Options, TagRule } from './types';
2
- export declare function contentModel(el: Element, rules: TagRule[], options: Options): ContentModelResult[];
2
+ export declare function contentModel(el: Element, rules: readonly TagRule[], options: Options): ContentModelResult[];
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.contentModel = void 0;
4
4
  const ml_spec_1 = require("@markuplint/ml-spec");
5
5
  const start_1 = require("./start");
6
- function contentModel(el, rules, options) {
6
+ function contentModel(
7
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
+ el, rules, options) {
7
9
  const model = createModel(el, rules);
8
10
  if (model == null) {
9
11
  return [
@@ -19,7 +21,9 @@ function contentModel(el, rules, options) {
19
21
  return result;
20
22
  }
21
23
  exports.contentModel = contentModel;
22
- function createModel(el, rules) {
24
+ function createModel(
25
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
26
+ el, rules) {
23
27
  const specs = cachedSpecs(el.ownerMLDocument.specs, rules);
24
28
  const model = (0, ml_spec_1.getContentModel)(el, specs.specs);
25
29
  return model;