@markuplint/rules 3.4.0 → 3.6.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 +3 -2
  2. package/lib/attr-check.js +19 -22
  3. package/lib/attr-duplication/index.d.ts +3 -1
  4. package/lib/attr-duplication/index.js +2 -1
  5. package/lib/attr-value-quotes/index.d.ts +1 -1
  6. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  7. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  8. package/lib/character-reference/index.d.ts +1 -1
  9. package/lib/class-naming/index.d.ts +1 -1
  10. package/lib/class-naming/index.js +2 -4
  11. package/lib/create-message.d.ts +2 -1
  12. package/lib/create-message.js +5 -4
  13. package/lib/deprecated-attr/index.d.ts +3 -1
  14. package/lib/deprecated-element/index.d.ts +3 -1
  15. package/lib/deprecated-element/index.js +2 -2
  16. package/lib/disallowed-element/index.d.ts +1 -1
  17. package/lib/doctype/index.d.ts +1 -1
  18. package/lib/end-tag/index.d.ts +1 -1
  19. package/lib/helpers.d.ts +18 -36
  20. package/lib/helpers.js +27 -14
  21. package/lib/id-duplication/index.d.ts +3 -1
  22. package/lib/index.d.ts +175 -3
  23. package/lib/index.js +2 -1
  24. package/lib/ineffective-attr/index.d.ts +3 -1
  25. package/lib/ineffective-attr/index.js +2 -5
  26. package/lib/invalid-attr/index.d.ts +1 -1
  27. package/lib/invalid-attr/index.js +8 -8
  28. package/lib/label-has-control/index.d.ts +3 -1
  29. package/lib/landmark-roles/index.d.ts +1 -1
  30. package/lib/landmark-roles/index.js +7 -3
  31. package/lib/no-boolean-attr-value/index.d.ts +3 -1
  32. package/lib/no-default-value/index.d.ts +3 -1
  33. package/lib/no-empty-palpable-content/index.d.ts +1 -1
  34. package/lib/no-hard-code-id/index.d.ts +3 -1
  35. package/lib/no-refer-to-non-existent-id/index.d.ts +8 -6
  36. package/lib/no-refer-to-non-existent-id/index.js +4 -14
  37. package/lib/no-use-event-handler-attr/index.d.ts +1 -1
  38. package/lib/permitted-contents/choice.d.ts +3 -2
  39. package/lib/permitted-contents/choice.js +3 -1
  40. package/lib/permitted-contents/complex-branch.d.ts +3 -2
  41. package/lib/permitted-contents/complex-branch.js +4 -2
  42. package/lib/permitted-contents/content-model.d.ts +1 -1
  43. package/lib/permitted-contents/content-model.js +7 -3
  44. package/lib/permitted-contents/count-pattern.d.ts +5 -4
  45. package/lib/permitted-contents/count-pattern.js +9 -3
  46. package/lib/permitted-contents/index.d.ts +1 -1
  47. package/lib/permitted-contents/index.js +8 -11
  48. package/lib/permitted-contents/matches-selector.d.ts +1 -2
  49. package/lib/permitted-contents/matches-selector.js +4 -2
  50. package/lib/permitted-contents/order.d.ts +3 -2
  51. package/lib/permitted-contents/order.js +7 -5
  52. package/lib/permitted-contents/recursive-branch.d.ts +2 -1
  53. package/lib/permitted-contents/recursive-branch.js +5 -3
  54. package/lib/permitted-contents/represent-transparent-nodes.js +4 -2
  55. package/lib/permitted-contents/start.d.ts +2 -1
  56. package/lib/permitted-contents/start.js +4 -2
  57. package/lib/permitted-contents/transparent.d.ts +2 -2
  58. package/lib/permitted-contents/transparent.js +3 -1
  59. package/lib/permitted-contents/types.d.ts +10 -9
  60. package/lib/permitted-contents/utils.d.ts +44 -80
  61. package/lib/permitted-contents/utils.js +23 -9
  62. package/lib/placeholder-label-option/index.d.ts +1 -1
  63. package/lib/placeholder-label-option/index.js +11 -6
  64. package/lib/require-accessible-name/index.d.ts +1 -1
  65. package/lib/require-datetime/index.d.ts +1 -1
  66. package/lib/require-datetime/utils.d.ts +1 -1
  67. package/lib/require-datetime/utils.js +3 -2
  68. package/lib/required-attr/index.d.ts +1 -1
  69. package/lib/required-attr/index.js +5 -5
  70. package/lib/required-element/index.d.ts +1 -1
  71. package/lib/required-h1/index.d.ts +1 -1
  72. package/lib/use-list/index.d.ts +2 -2
  73. package/lib/use-list/index.js +4 -3
  74. package/lib/wai-aria/checkings/default-value.d.ts +1 -1
  75. package/lib/wai-aria/checkings/deprecated-props.d.ts +1 -1
  76. package/lib/wai-aria/checkings/disallowed-prop.d.ts +4 -8
  77. package/lib/wai-aria/checkings/disallowed-prop.js +1 -1
  78. package/lib/wai-aria/checkings/implicit-props.d.ts +2 -2
  79. package/lib/wai-aria/checkings/implicit-props.js +3 -2
  80. package/lib/wai-aria/checkings/interaction-in-hidden.js +3 -1
  81. package/lib/wai-aria/checkings/no-global-prop.d.ts +1 -1
  82. package/lib/wai-aria/checkings/presentational-children.js +3 -1
  83. package/lib/wai-aria/checkings/required-owned-elements.js +5 -3
  84. package/lib/wai-aria/checkings/required-prop.d.ts +1 -1
  85. package/lib/wai-aria/checkings/value.d.ts +7 -2
  86. package/lib/wai-aria/checkings/value.js +3 -1
  87. package/lib/wai-aria/index.d.ts +1 -1
  88. package/package.json +10 -9
@@ -1,87 +1,51 @@
1
1
  import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types';
2
- import type {
3
- PermittedContentPattern,
4
- PermittedContentChoice,
5
- PermittedContentOneOrMore,
6
- PermittedContentOptional,
7
- PermittedContentRequire,
8
- PermittedContentTransparent,
9
- PermittedContentZeroOrMore,
10
- Model,
11
- } from '@markuplint/ml-spec';
2
+ import type { PermittedContentPattern, PermittedContentChoice, PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentTransparent, PermittedContentZeroOrMore, Model } from '@markuplint/ml-spec';
3
+ import type { ReadonlyDeep } from 'type-fest';
12
4
  export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];
13
- export declare function isModel(model: Model | PermittedContentPattern[]): model is Model;
14
- export declare function matches(
15
- selector: string,
16
- node: ChildNode,
17
- specs: Specs,
18
- ):
19
- | {
20
- matched: boolean;
21
- not?: undefined;
22
- }
23
- | {
24
- matched: boolean;
25
- not: ChildNode | undefined;
26
- };
27
- export declare function isRequire(content: PermittedContentPattern): content is PermittedContentRequire;
28
- export declare function isOptional(content: PermittedContentPattern): content is PermittedContentOptional;
29
- export declare function isOneOrMore(content: PermittedContentPattern): content is PermittedContentOneOrMore;
30
- export declare function isZeroOrMore(content: PermittedContentPattern): content is PermittedContentZeroOrMore;
31
- export declare function isChoice(content: PermittedContentPattern): content is PermittedContentChoice;
32
- export declare function isTransparent(content: PermittedContentPattern): content is PermittedContentTransparent;
33
- export declare function normalizeModel(
34
- pattern:
35
- | PermittedContentRequire
36
- | PermittedContentOptional
37
- | PermittedContentOneOrMore
38
- | PermittedContentZeroOrMore,
39
- ): {
40
- model: PermittedContentPattern[] | Model;
41
- min: number;
42
- max: number;
43
- repeat: RepeatSign;
44
- missingType: MissingNodeReason | undefined;
5
+ export declare function isModel(model: ReadonlyDeep<Model | PermittedContentPattern[]>): model is ReadonlyDeep<Model>;
6
+ export declare function matches(selector: string, node: ChildNode, specs: Specs): {
7
+ matched: boolean;
8
+ not?: undefined;
9
+ } | {
10
+ matched: boolean;
11
+ not: ChildNode | undefined;
45
12
  };
46
- export declare function mergeHints(
47
- a: Hints,
48
- b: Hints,
49
- ): Partial<{
50
- missing:
51
- | Partial<{
52
- barelyMatchedElements?: number | undefined;
53
- need?: string | undefined;
54
- }>
55
- | undefined;
56
- max?: number | undefined;
57
- not?:
58
- | import('packages/@markuplint/ml-core/lib').DocumentType<
59
- import('./types').TagRule[],
60
- import('./types').Options
61
- >
62
- | import('packages/@markuplint/ml-core/lib/ml-dom/node/character-data').MLCharacterData<
63
- import('./types').TagRule[],
64
- import('./types').Options,
65
- import('packages/@markuplint/ml-ast/lib').MLASTAbstractNode
66
- >
67
- | import('packages/@markuplint/ml-core/lib').Element<import('./types').TagRule[], import('./types').Options>
68
- | import('packages/@markuplint/ml-core/lib').Block<import('./types').TagRule[], import('./types').Options>
69
- | undefined;
70
- transparent?: Element | undefined;
13
+ export declare function isRequire(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentRequire>;
14
+ export declare function isOptional(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOptional>;
15
+ export declare function isOneOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOneOrMore>;
16
+ export declare function isZeroOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentZeroOrMore>;
17
+ export declare function isChoice(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentChoice>;
18
+ export declare function isTransparent(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentTransparent>;
19
+ export declare function normalizeModel(pattern: ReadonlyDeep<PermittedContentRequire> | ReadonlyDeep<PermittedContentOptional> | ReadonlyDeep<PermittedContentOneOrMore> | ReadonlyDeep<PermittedContentZeroOrMore>): {
20
+ model: ReadonlyDeep<PermittedContentPattern[] | Model>;
21
+ min: number;
22
+ max: number;
23
+ repeat: RepeatSign;
24
+ missingType: MissingNodeReason | undefined;
25
+ };
26
+ export declare function mergeHints(a: Readonly<Hints>, b: Readonly<Hints>): Partial<{
27
+ missing: Partial<{
28
+ barelyMatchedElements?: number | undefined;
29
+ need?: string | undefined;
30
+ }> | undefined;
31
+ max?: number | undefined;
32
+ not?: import("packages/@markuplint/ml-core/lib").DocumentType<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib/ml-dom/node/character-data").MLCharacterData<import("./types").TagRule[], import("./types").Options, import("packages/@markuplint/ml-ast/lib").MLASTAbstractNode> | import("packages/@markuplint/ml-core/lib").Element<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib").Block<import("./types").TagRule[], import("./types").Options> | undefined;
33
+ transparent?: Element | undefined;
71
34
  }>;
72
35
  export declare function cleanObject<T extends Object>(object: T): Partial<T>;
73
36
  export declare class Collection {
74
- #private;
75
- constructor(origin: readonly ChildNode[]);
76
- get matched(): ChildNode[];
77
- get matchedCount(): number;
78
- get nodes(): ChildNode[];
79
- get unmatched(): ChildNode[];
80
- addMatched(nodes: ChildNode[]): boolean;
81
- back(): void;
82
- lock(): void;
83
- max(max: number): void;
84
- toString(highlightExtraNodes?: boolean): string;
37
+ #private;
38
+ constructor(origin: readonly ChildNode[]);
39
+ get matched(): ChildNode[];
40
+ get matchedCount(): number;
41
+ get nodes(): ChildNode[];
42
+ get unmatched(): ChildNode[];
43
+ addMatched(nodes: ChildNode[]): boolean;
44
+ back(): void;
45
+ lock(): void;
46
+ max(max: number): void;
47
+ toString(highlightExtraNodes?: boolean): string;
48
+ }
49
+ export declare class UnsupportedError extends Error {
85
50
  }
86
- export declare class UnsupportedError extends Error {}
87
- export declare function modelLog(model: Model | PermittedContentPattern[], repeat: RepeatSign): string;
51
+ export declare function modelLog(model: ReadonlyDeep<Model | PermittedContentPattern[]>, repeat: RepeatSign): string;
@@ -7,7 +7,9 @@ const selector_1 = require("@markuplint/selector");
7
7
  const debug_1 = require("./debug");
8
8
  const represent_transparent_nodes_1 = require("./represent-transparent-nodes");
9
9
  const getChildNodesWithoutWhitespacesCaches = new Map();
10
- function getChildNodesWithoutWhitespaces(el) {
10
+ function getChildNodesWithoutWhitespaces(
11
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
12
+ el) {
11
13
  let nodes = getChildNodesWithoutWhitespacesCaches.get(el);
12
14
  if (nodes) {
13
15
  return nodes;
@@ -36,10 +38,12 @@ function isModel(model) {
36
38
  return modelMode;
37
39
  }
38
40
  exports.isModel = isModel;
39
- function matches(selector, node, specs) {
41
+ function matches(selector,
42
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
43
+ node, specs) {
40
44
  const selectorResult = (0, selector_1.createSelector)(selector, specs).search(node);
41
45
  const matched = selectorResult.filter((r) => r.matched);
42
- if (matched.length) {
46
+ if (matched.length > 0) {
43
47
  return {
44
48
  matched: true,
45
49
  };
@@ -56,11 +60,13 @@ function matches(selector, node, specs) {
56
60
  };
57
61
  }
58
62
  exports.matches = matches;
59
- function descendants(selectorResult) {
63
+ function descendants(
64
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
65
+ selectorResult) {
60
66
  let nodes = selectorResult.nodes.slice();
61
- while (selectorResult.has.length) {
67
+ while (selectorResult.has.length > 0) {
62
68
  for (const dep of selectorResult.has) {
63
- if (!dep.has.length) {
69
+ if (dep.has.length === 0) {
64
70
  nodes = dep.nodes;
65
71
  continue;
66
72
  }
@@ -151,7 +157,11 @@ function normalizeModel(pattern) {
151
157
  };
152
158
  }
153
159
  exports.normalizeModel = normalizeModel;
154
- function mergeHints(a, b) {
160
+ function mergeHints(
161
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
162
+ a,
163
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
164
+ b) {
155
165
  const missing = [a.missing, b.missing].sort((a, b) => { var _a, _b; return ((_a = b === null || b === void 0 ? void 0 : b.barelyMatchedElements) !== null && _a !== void 0 ? _a : 0) - ((_b = a === null || a === void 0 ? void 0 : a.barelyMatchedElements) !== null && _b !== void 0 ? _b : 0); })[0];
156
166
  return cleanObject({
157
167
  ...a,
@@ -171,7 +181,9 @@ function cleanObject(object) {
171
181
  }
172
182
  exports.cleanObject = cleanObject;
173
183
  class Collection {
174
- constructor(origin) {
184
+ constructor(
185
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
186
+ origin) {
175
187
  _Collection_locked.set(this, new Set());
176
188
  _Collection_matched.set(this, new Set());
177
189
  _Collection_nodes.set(this, void 0);
@@ -191,7 +203,9 @@ class Collection {
191
203
  get unmatched() {
192
204
  return Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f")).filter(n => !tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").has(n));
193
205
  }
194
- addMatched(nodes) {
206
+ addMatched(
207
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
208
+ nodes) {
195
209
  const i = tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
196
210
  for (const node of nodes) {
197
211
  if (!tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f").has(node)) {
@@ -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;
@@ -26,7 +26,10 @@ exports.default = (0, ml_core_1.createRule)({
26
26
  * @param select
27
27
  * @returns
28
28
  */
29
- function needPlaceholderLabelOption(select) {
29
+ function needPlaceholderLabelOption(
30
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
31
+ select) {
32
+ var _a;
30
33
  const hasRequired = select.hasAttribute('required');
31
34
  if (!hasRequired) {
32
35
  return false;
@@ -35,7 +38,7 @@ function needPlaceholderLabelOption(select) {
35
38
  if (hasMultiple) {
36
39
  return false;
37
40
  }
38
- const size = select.getAttribute('size') || '1';
41
+ const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
39
42
  if (size !== '1') {
40
43
  return false;
41
44
  }
@@ -53,8 +56,10 @@ function needPlaceholderLabelOption(select) {
53
56
  * @param select
54
57
  * @returns
55
58
  */
56
- function hasPlaceholderLabelOption(select) {
57
- var _a;
59
+ function hasPlaceholderLabelOption(
60
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
61
+ select) {
62
+ var _a, _b;
58
63
  // > has a required attribute specified
59
64
  if (!select.hasAttribute('required')) {
60
65
  return false;
@@ -64,7 +69,7 @@ function hasPlaceholderLabelOption(select) {
64
69
  return false;
65
70
  }
66
71
  // > has a display size of 1
67
- const size = select.getAttribute('size') || '1';
72
+ const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
68
73
  if (size !== '1') {
69
74
  return false;
70
75
  }
@@ -75,7 +80,7 @@ function hasPlaceholderLabelOption(select) {
75
80
  return true;
76
81
  }
77
82
  // > that option element's parent node is the select element (and not an optgroup element)
78
- if (((_a = firstOption.parentElement) === null || _a === void 0 ? void 0 : _a.localName) === 'optgroup') {
83
+ if (((_b = firstOption.parentElement) === null || _b === void 0 ? void 0 : _b.localName) === 'optgroup') {
79
84
  return false;
80
85
  }
81
86
  const value = firstOption.getAttribute('value');
@@ -2,5 +2,5 @@ import type { ARIAVersion } from '@markuplint/ml-spec';
2
2
  type Option = {
3
3
  ariaVersion: ARIAVersion;
4
4
  };
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Option>;
5
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Option>>;
6
6
  export default _default;
@@ -2,5 +2,5 @@ import type { Lang } from './types';
2
2
  type Options = {
3
3
  langs?: Lang[];
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;
@@ -7,5 +7,5 @@ import type { DateTime, Lang } from './types';
7
7
  * @param base Reference date for a test
8
8
  * @returns
9
9
  */
10
- export declare function parseADatetime(content: string, langs: Lang[], base?: Date): DateTime | null;
10
+ export declare function parseADatetime(content: string, langs: readonly Lang[], base?: Readonly<Date>): DateTime | null;
11
11
  export declare function getCandidateDatetimeString(content: string, langs?: Lang[]): string | null;
@@ -13,6 +13,7 @@ const defaultLangs = ['en', 'ja', 'fr', 'nl', 'ru', 'de', 'pt', 'zh'];
13
13
  * @returns
14
14
  */
15
15
  function parseADatetime(content, langs, base) {
16
+ var _a;
16
17
  const date = parseTryMultipleLangs(content, langs, base);
17
18
  if (!date) {
18
19
  return null;
@@ -31,7 +32,7 @@ function parseADatetime(content, langs, base) {
31
32
  data.hour = date.get('hour');
32
33
  }
33
34
  if (date.isCertain('hour')) {
34
- data.minute = date.get('minute') || 0;
35
+ data.minute = (_a = date.get('minute')) !== null && _a !== void 0 ? _a : 0;
35
36
  }
36
37
  if (date.isCertain('second')) {
37
38
  data.second = date.get('second');
@@ -57,7 +58,7 @@ function getCandidateDatetimeString(content, langs = defaultLangs) {
57
58
  if (!datetimeStr) {
58
59
  return null;
59
60
  }
60
- if (date.zone) {
61
+ if (date.zone != null) {
61
62
  const plusMinus = date.zone < 0 ? '-' : '+';
62
63
  const hour = Math.floor(Math.abs(date.zone) / 60);
63
64
  const minute = Math.abs(date.zone) % 60;
@@ -3,5 +3,5 @@ type Attr = {
3
3
  name: string;
4
4
  value: string | string[];
5
5
  };
6
- declare const _default: import('@markuplint/ml-core').RuleSeed<RequiredAttributes, null>;
6
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<RequiredAttributes, undefined>>;
7
7
  export default _default;
@@ -15,7 +15,7 @@ exports.default = (0, ml_core_1.createRule)({
15
15
  const attributeSpecs = {};
16
16
  if (attrSpec && el.elementType === 'html') {
17
17
  for (const spec of attrSpec) {
18
- if (spec.required || spec.requiredEither || spec.condition) {
18
+ if (spec.required != null || spec.requiredEither || spec.condition != null) {
19
19
  attributeSpecs[spec.name] = {
20
20
  ...spec,
21
21
  values: [],
@@ -54,8 +54,8 @@ exports.default = (0, ml_core_1.createRule)({
54
54
  else if (spec.required === true) {
55
55
  invalid = (0, helpers_1.attrMatches)(el, spec.condition) && didntHave;
56
56
  }
57
- else if (spec.required) {
58
- const selector = Array.isArray(spec.required) ? spec.required.join(',') : spec.required;
57
+ else if (spec.required != null && spec.required !== false) {
58
+ const selector = typeof spec.required === 'string' ? spec.required : spec.required.join(',');
59
59
  invalid = el.matches(selector) && didntHave;
60
60
  }
61
61
  if (invalid) {
@@ -66,14 +66,14 @@ exports.default = (0, ml_core_1.createRule)({
66
66
  });
67
67
  }
68
68
  const value = el.getAttribute(spec.name);
69
- if (spec.values.length && value) {
69
+ if (spec.values.length > 0 && value) {
70
70
  const matched = spec.values.some(pattern => (0, helpers_1.match)(value, pattern));
71
71
  if (!matched) {
72
72
  const expects = spec.values.length === 1 ? t(spec.values) : t('either {0}', t(spec.values));
73
73
  const message = t('{0} expects {1}', t('the "{0*}" {1}', spec.name, 'attribute'), expects);
74
74
  const attrToken = el.getAttributeToken(spec.name);
75
75
  const valueToken = (_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.valueNode;
76
- const token = valueToken || attrToken[0];
76
+ const token = valueToken !== null && valueToken !== void 0 ? valueToken : attrToken[0];
77
77
  if (token) {
78
78
  report({
79
79
  scope: {
@@ -1,5 +1,5 @@
1
1
  type Options = {
2
2
  ignoreHasMutableContents: boolean;
3
3
  };
4
- declare const _default: import('@markuplint/ml-core').RuleSeed<string[], Options>;
4
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<string[], Options>>;
5
5
  export default _default;
@@ -2,5 +2,5 @@ export interface Options {
2
2
  'expected-once': boolean;
3
3
  'in-document-fragment': 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,6 +1,6 @@
1
- type Bullets = string[];
1
+ type Bullets = readonly string[];
2
2
  type Options = {
3
3
  spaceNeededBullets?: string[];
4
4
  };
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<Bullets, Options>;
5
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Bullets, Options>>;
6
6
  export default _default;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ml_core_1 = require("@markuplint/ml-core");
4
- const helpers_1 = require("../helpers");
4
+ const shared_1 = require("@markuplint/shared");
5
5
  exports.default = (0, ml_core_1.createRule)({
6
6
  defaultValue: [
7
7
  /**
@@ -57,7 +57,8 @@ exports.default = (0, ml_core_1.createRule)({
57
57
  defaultSeverity: 'warning',
58
58
  async verify({ document, report, t }) {
59
59
  await document.walkOn('Text', textNode => {
60
- const text = (0, helpers_1.decodeCharRef)(textNode.raw.trim());
60
+ var _a;
61
+ const text = (0, shared_1.decodeEntities)(textNode.raw.trim());
61
62
  if (!text) {
62
63
  // empty
63
64
  return;
@@ -67,7 +68,7 @@ exports.default = (0, ml_core_1.createRule)({
67
68
  return;
68
69
  }
69
70
  const bullets = textNode.rule.value;
70
- const spaceNeededBullets = textNode.rule.options.spaceNeededBullets || [];
71
+ const spaceNeededBullets = (_a = textNode.rule.options.spaceNeededBullets) !== null && _a !== void 0 ? _a : [];
71
72
  if (isMayListItem(text, bullets, spaceNeededBullets)) {
72
73
  report({
73
74
  scope: textNode,
@@ -5,6 +5,6 @@ export declare const checkingDefaultValue: AttrChecker<
5
5
  boolean,
6
6
  Options,
7
7
  {
8
- propSpecs: ARIAProperty[];
8
+ propSpecs: readonly ARIAProperty[];
9
9
  }
10
10
  >;
@@ -6,6 +6,6 @@ export declare const checkingDeprecatedProps: AttrChecker<
6
6
  Options,
7
7
  {
8
8
  role: ARIARole | null;
9
- propSpecs: ARIAProperty[];
9
+ propSpecs: readonly ARIAProperty[];
10
10
  }
11
11
  >;
@@ -1,11 +1,7 @@
1
1
  import type { Options } from '../types';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
4
- export declare const checkingDisallowedProp: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- role: ARIARole | null;
9
- propSpecs: ARIAProperty[];
10
- }
11
- >;
4
+ export declare const checkingDisallowedProp: AttrChecker<boolean, Options, {
5
+ role: ARIARole | null;
6
+ propSpecs: readonly ARIAProperty[];
7
+ }>;
@@ -13,7 +13,7 @@ const checkingDisallowedProp = ({ attr, role, propSpecs }) => t => {
13
13
  const statesAndProp = role.ownedProperties.find(p => p.name === attr.name);
14
14
  const propSpec = propSpecs.find(p => p.name === attr.name);
15
15
  const elAriaSpec = (0, ml_spec_1.getARIA)(attr.ownerMLDocument.specs, attr.ownerElement.localName, attr.ownerElement.namespaceURI, attr.rule.options.version, attr.ownerElement.matches.bind(attr.ownerElement));
16
- if ((elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) && ((_a = elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) === null || _a === void 0 ? void 0 : _a.without)) {
16
+ if ((elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) !== false && ((_a = elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) === null || _a === void 0 ? void 0 : _a.without)) {
17
17
  for (const ignore of elAriaSpec.properties.without) {
18
18
  if (ignore.name === attr.name) {
19
19
  return {
@@ -5,7 +5,7 @@ export declare const checkingImplicitProps: AttrChecker<
5
5
  boolean,
6
6
  Options,
7
7
  {
8
- propSpecs: ARIAProperty[];
9
- attrSpecs: Attribute[] | null;
8
+ propSpecs: readonly ARIAProperty[];
9
+ attrSpecs: readonly Attribute[] | null;
10
10
  }
11
11
  >;
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkingImplicitProps = void 0;
4
4
  const helpers_1 = require("../../helpers");
5
5
  const checkingImplicitProps = ({ attr, propSpecs, attrSpecs }) => t => {
6
+ var _a;
6
7
  if (!attrSpecs) {
7
8
  return;
8
9
  }
@@ -15,8 +16,8 @@ const checkingImplicitProps = ({ attr, propSpecs, attrSpecs }) => t => {
15
16
  }
16
17
  for (const equivalentHtmlAttr of propSpec.equivalentHtmlAttrs) {
17
18
  const htmlAttrSpec = attrSpecs.find(a => a.name === equivalentHtmlAttr.htmlAttrName);
18
- const isValid = (0, helpers_1.isValidAttr)(t, equivalentHtmlAttr.htmlAttrName, equivalentHtmlAttr.value || '', false, attr.ownerElement, attrSpecs);
19
- if (isValid && isValid.invalidType === 'non-existent') {
19
+ const isValid = (0, helpers_1.isValidAttr)(t, equivalentHtmlAttr.htmlAttrName, (_a = equivalentHtmlAttr.value) !== null && _a !== void 0 ? _a : '', false, attr.ownerElement, attrSpecs);
20
+ if (isValid !== false && isValid.invalidType === 'non-existent') {
20
21
  continue;
21
22
  }
22
23
  const value = attr.value.trim().toLowerCase();
@@ -34,7 +34,9 @@ const checkingInteractionInHidden = ({ el }) => t => {
34
34
  };
35
35
  };
36
36
  exports.checkingInteractionInHidden = checkingInteractionInHidden;
37
- function getClosestAriaHidden(el) {
37
+ function getClosestAriaHidden(
38
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
39
+ el) {
38
40
  let current = el;
39
41
  while (current) {
40
42
  const ariaHidden = current.getAttributeNode('aria-hidden');
@@ -5,6 +5,6 @@ export declare const checkingNoGlobalProp: AttrChecker<
5
5
  boolean,
6
6
  Options,
7
7
  {
8
- propSpecs: ARIAProperty[];
8
+ propSpecs: readonly ARIAProperty[];
9
9
  }
10
10
  >;
@@ -46,7 +46,9 @@ const checkingPresentationalChildren = ({ el }) => t => {
46
46
  };
47
47
  };
48
48
  exports.checkingPresentationalChildren = checkingPresentationalChildren;
49
- function getAncestorHasPresentationalChildren(el) {
49
+ function getAncestorHasPresentationalChildren(
50
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
51
+ el) {
50
52
  var _a;
51
53
  let current = el.parentElement;
52
54
  while (current) {
@@ -11,7 +11,7 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
11
11
  if (!role) {
12
12
  return;
13
13
  }
14
- if (!role.requiredOwnedElements.length) {
14
+ if (role.requiredOwnedElements.length === 0) {
15
15
  return;
16
16
  }
17
17
  /**
@@ -34,7 +34,7 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
34
34
  return [child, 'BUSY'];
35
35
  }
36
36
  const computedChild = (0, ml_spec_1.getComputedRole)(child.ownerMLDocument.specs, child, child.rule.options.version);
37
- if (role.requiredOwnedElements.some(ownedRole => (0, ml_spec_1.isRequiredOwnedElement)(computedChild, ownedRole, child.ownerMLDocument.specs, child.rule.options.version))) {
37
+ if (role.requiredOwnedElements.some(ownedRole => (0, ml_spec_1.isRequiredOwnedElement)(computedChild.el, computedChild.role, ownedRole, child.ownerMLDocument.specs, child.rule.options.version))) {
38
38
  return [child, 'REQUIRED'];
39
39
  }
40
40
  return [child, 'OTHER'];
@@ -91,7 +91,9 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
91
91
  };
92
92
  };
93
93
  exports.checkingRequiredOwnedElements = checkingRequiredOwnedElements;
94
- function mayBeBeforeCreated(el) {
94
+ function mayBeBeforeCreated(
95
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
96
+ el) {
95
97
  if (el.isEmpty()) {
96
98
  return true;
97
99
  }
@@ -10,6 +10,6 @@ export declare const checkingRequiredProp: ElementChecker<
10
10
  isImplicit?: boolean;
11
11
  })
12
12
  | null;
13
- propSpecs: ARIAProperty[];
13
+ propSpecs: readonly ARIAProperty[];
14
14
  }
15
15
  >;
@@ -6,7 +6,7 @@ export declare const checkingValue: AttrChecker<
6
6
  Options,
7
7
  {
8
8
  role?: ARIARole | null;
9
- propSpecs: ARIAProperty[];
9
+ propSpecs: readonly ARIAProperty[];
10
10
  booleanish?: boolean;
11
11
  }
12
12
  >;
@@ -14,4 +14,9 @@ export declare const checkingValue: AttrChecker<
14
14
  *
15
15
  * @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
16
16
  */
17
- export declare function checkAriaValue(type: string, value: string, tokenEnum: string[], booleanish?: boolean): boolean;
17
+ export declare function checkAriaValue(
18
+ type: string,
19
+ value: string,
20
+ tokenEnum: readonly string[],
21
+ booleanish?: boolean,
22
+ ): boolean;
@@ -14,7 +14,9 @@ const checkingValue = ({ attr, role, propSpecs, booleanish }) => t => {
14
14
  return {
15
15
  scope: attr,
16
16
  message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}"', attr.value), 'disallowed'), t('the "{0*}" {1}', attr.name, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`)) +
17
- ('enum' in result && result.enum.length ? t('. ') + t('Allowed values are: {0}', t(result.enum)) : ''),
17
+ ('enum' in result && result.enum.length > 0
18
+ ? t('. ') + t('Allowed values are: {0}', t(result.enum))
19
+ : ''),
18
20
  };
19
21
  };
20
22
  exports.checkingValue = checkingValue;
@@ -1,3 +1,3 @@
1
1
  import type { Options } from './types';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
2
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Options>>;
3
3
  export default _default;