@markuplint/rules 3.0.0-dev.25 → 3.0.0-dev.290

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 (135) hide show
  1. package/lib/attr-check.d.ts +3 -2
  2. package/lib/attr-check.js +42 -38
  3. package/lib/attr-duplication/index.d.ts +1 -1
  4. package/lib/attr-duplication/index.js +3 -5
  5. package/lib/attr-value-quotes/index.d.ts +1 -1
  6. package/lib/attr-value-quotes/index.js +5 -9
  7. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  8. package/lib/case-sensitive-attr-name/index.js +9 -13
  9. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  10. package/lib/case-sensitive-tag-name/index.js +2 -4
  11. package/lib/character-reference/index.d.ts +1 -1
  12. package/lib/character-reference/index.js +7 -9
  13. package/lib/class-naming/index.d.ts +1 -1
  14. package/lib/class-naming/index.js +9 -13
  15. package/lib/create-message.d.ts +3 -2
  16. package/lib/create-message.js +15 -17
  17. package/lib/debug.js +2 -6
  18. package/lib/deprecated-attr/index.d.ts +1 -1
  19. package/lib/deprecated-attr/index.js +6 -9
  20. package/lib/deprecated-element/index.d.ts +1 -1
  21. package/lib/deprecated-element/index.js +5 -7
  22. package/lib/disallowed-element/index.d.ts +1 -1
  23. package/lib/disallowed-element/index.js +2 -4
  24. package/lib/doctype/index.d.ts +1 -1
  25. package/lib/doctype/index.js +2 -4
  26. package/lib/end-tag/index.d.ts +1 -1
  27. package/lib/end-tag/index.js +5 -8
  28. package/lib/helpers.d.ts +10 -13
  29. package/lib/helpers.js +39 -37
  30. package/lib/id-duplication/index.d.ts +1 -1
  31. package/lib/id-duplication/index.js +2 -4
  32. package/lib/index.d.ts +102 -3
  33. package/lib/index.js +64 -62
  34. package/lib/ineffective-attr/index.d.ts +1 -1
  35. package/lib/ineffective-attr/index.js +5 -10
  36. package/lib/invalid-attr/index.d.ts +25 -5
  37. package/lib/invalid-attr/index.js +166 -43
  38. package/lib/label-has-control/index.d.ts +1 -1
  39. package/lib/label-has-control/index.js +2 -4
  40. package/lib/landmark-roles/index.d.ts +1 -1
  41. package/lib/landmark-roles/index.js +10 -9
  42. package/lib/no-boolean-attr-value/index.d.ts +1 -1
  43. package/lib/no-boolean-attr-value/index.js +6 -9
  44. package/lib/no-default-value/index.d.ts +1 -1
  45. package/lib/no-default-value/index.js +9 -12
  46. package/lib/no-empty-palpable-content/index.d.ts +1 -1
  47. package/lib/no-empty-palpable-content/index.js +13 -7
  48. package/lib/no-hard-code-id/index.d.ts +1 -1
  49. package/lib/no-hard-code-id/index.js +2 -4
  50. package/lib/no-refer-to-non-existent-id/index.d.ts +4 -4
  51. package/lib/no-refer-to-non-existent-id/index.js +79 -23
  52. package/lib/no-use-event-handler-attr/index.d.ts +1 -1
  53. package/lib/no-use-event-handler-attr/index.js +4 -6
  54. package/lib/permitted-contents/choice.d.ts +3 -2
  55. package/lib/permitted-contents/choice.js +54 -14
  56. package/lib/permitted-contents/complex-branch.d.ts +3 -2
  57. package/lib/permitted-contents/complex-branch.js +12 -14
  58. package/lib/permitted-contents/content-model.d.ts +2 -2
  59. package/lib/permitted-contents/content-model.js +11 -11
  60. package/lib/permitted-contents/count-pattern.d.ts +3 -2
  61. package/lib/permitted-contents/count-pattern.js +76 -74
  62. package/lib/permitted-contents/debug.browser.js +9 -12
  63. package/lib/permitted-contents/debug.d.ts +8 -1
  64. package/lib/permitted-contents/debug.js +12 -13
  65. package/lib/permitted-contents/index.d.ts +2 -2
  66. package/lib/permitted-contents/index.js +18 -24
  67. package/lib/permitted-contents/matches-selector.d.ts +2 -2
  68. package/lib/permitted-contents/matches-selector.js +17 -20
  69. package/lib/permitted-contents/order.d.ts +3 -2
  70. package/lib/permitted-contents/order.js +33 -28
  71. package/lib/permitted-contents/recursive-branch.d.ts +4 -3
  72. package/lib/permitted-contents/recursive-branch.js +11 -13
  73. package/lib/permitted-contents/represent-transparent-nodes.d.ts +1 -1
  74. package/lib/permitted-contents/represent-transparent-nodes.js +18 -21
  75. package/lib/permitted-contents/start.d.ts +3 -2
  76. package/lib/permitted-contents/start.js +16 -22
  77. package/lib/permitted-contents/transparent.d.ts +2 -2
  78. package/lib/permitted-contents/transparent.js +6 -9
  79. package/lib/permitted-contents/types.d.ts +20 -13
  80. package/lib/permitted-contents/types.js +1 -2
  81. package/lib/permitted-contents/utils.d.ts +27 -8
  82. package/lib/permitted-contents/utils.js +164 -65
  83. package/lib/placeholder-label-option/index.d.ts +2 -0
  84. package/lib/placeholder-label-option/index.js +84 -0
  85. package/lib/require-accessible-name/index.d.ts +1 -1
  86. package/lib/require-accessible-name/index.js +10 -13
  87. package/lib/require-datetime/index.d.ts +6 -0
  88. package/lib/require-datetime/index.js +32 -0
  89. package/lib/require-datetime/types.d.ts +10 -0
  90. package/lib/require-datetime/types.js +1 -0
  91. package/lib/require-datetime/utils.d.ts +11 -0
  92. package/lib/require-datetime/utils.js +130 -0
  93. package/lib/required-attr/index.d.ts +2 -2
  94. package/lib/required-attr/index.js +24 -24
  95. package/lib/required-element/index.d.ts +1 -1
  96. package/lib/required-element/index.js +3 -5
  97. package/lib/required-h1/index.d.ts +1 -1
  98. package/lib/required-h1/index.js +4 -6
  99. package/lib/use-list/index.d.ts +2 -2
  100. package/lib/use-list/index.js +7 -9
  101. package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
  102. package/lib/wai-aria/checkings/abstract-role.js +5 -10
  103. package/lib/wai-aria/checkings/default-value.d.ts +2 -2
  104. package/lib/wai-aria/checkings/default-value.js +2 -6
  105. package/lib/wai-aria/checkings/deprecated-props.d.ts +2 -2
  106. package/lib/wai-aria/checkings/deprecated-props.js +3 -8
  107. package/lib/wai-aria/checkings/disallowed-prop.d.ts +2 -2
  108. package/lib/wai-aria/checkings/disallowed-prop.js +27 -8
  109. package/lib/wai-aria/checkings/implicit-props.d.ts +3 -3
  110. package/lib/wai-aria/checkings/implicit-props.js +7 -11
  111. package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
  112. package/lib/wai-aria/checkings/implicit-role.js +4 -9
  113. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
  114. package/lib/wai-aria/checkings/interaction-in-hidden.js +7 -9
  115. package/lib/wai-aria/checkings/no-global-prop.d.ts +2 -2
  116. package/lib/wai-aria/checkings/no-global-prop.js +2 -7
  117. package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
  118. package/lib/wai-aria/checkings/non-existent-role.js +4 -9
  119. package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
  120. package/lib/wai-aria/checkings/permitted-roles.js +4 -9
  121. package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
  122. package/lib/wai-aria/checkings/presentational-children.js +7 -10
  123. package/lib/wai-aria/checkings/required-owned-elements.d.ts +1 -1
  124. package/lib/wai-aria/checkings/required-owned-elements.js +10 -12
  125. package/lib/wai-aria/checkings/required-prop.d.ts +2 -2
  126. package/lib/wai-aria/checkings/required-prop.js +2 -7
  127. package/lib/wai-aria/checkings/value.d.ts +3 -3
  128. package/lib/wai-aria/checkings/value.js +7 -11
  129. package/lib/wai-aria/index.d.ts +2 -2
  130. package/lib/wai-aria/index.js +38 -39
  131. package/lib/wai-aria/types.js +1 -2
  132. package/package.json +21 -14
  133. package/schema.json +6 -0
  134. package/tsconfig.test.json +0 -3
  135. package/tsconfig.tsbuildinfo +0 -1
@@ -1,21 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const attr_check_1 = require("../attr-check");
5
- const debug_1 = require("../debug");
6
- const helpers_1 = require("../helpers");
7
- const log = debug_1.log.extend('invalid-attr');
8
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule, getAttrSpecs, getSpec } from '@markuplint/ml-core';
2
+ import { attrCheck } from '../attr-check.js';
3
+ import { log as ruleLog } from '../debug.js';
4
+ import { isValidAttr, match } from '../helpers.js';
5
+ const log = ruleLog.extend('invalid-attr');
6
+ export default createRule({
9
7
  defaultOptions: {},
10
8
  async verify({ document, report, t }) {
11
9
  await document.walkOn('Attr', attr => {
12
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
13
10
  // Default
14
- const allowToAddPropertiesForPretender = (_a = attr.rule.options.allowToAddPropertiesForPretender) !== null && _a !== void 0 ? _a : true;
11
+ const allowToAddPropertiesForPretender = attr.rule.options.allowToAddPropertiesForPretender ?? true;
15
12
  if (attr.isDirective) {
16
13
  return;
17
14
  }
18
- const attrSpecs = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
15
+ const attrSpecs = getAttrSpecs(attr.ownerElement, document.specs);
19
16
  const attrName = attr.nameNode;
20
17
  const name = attr.name;
21
18
  if (attr.ownerElement.elementType === 'html' && attr.candidate) {
@@ -24,16 +21,16 @@ exports.default = (0, ml_core_1.createRule)({
24
21
  t('Did you mean "{0}"?', attr.candidate);
25
22
  report({
26
23
  scope: attr,
27
- line: attrName === null || attrName === void 0 ? void 0 : attrName.startLine,
28
- col: attrName === null || attrName === void 0 ? void 0 : attrName.startCol,
29
- raw: attrName === null || attrName === void 0 ? void 0 : attrName.raw,
24
+ line: attrName?.startLine,
25
+ col: attrName?.startCol,
26
+ raw: attrName?.raw,
30
27
  message: message,
31
28
  });
32
29
  return;
33
30
  }
34
31
  const valueNode = attr.valueNode;
35
32
  const value = attr.value;
36
- if (attr.rule.options.ignoreAttrNamePrefix) {
33
+ if (attr.rule.options.ignoreAttrNamePrefix != null) {
37
34
  const ignoreAttrNamePrefixes = Array.isArray(attr.rule.options.ignoreAttrNamePrefix)
38
35
  ? attr.rule.options.ignoreAttrNamePrefix
39
36
  : [attr.rule.options.ignoreAttrNamePrefix];
@@ -42,41 +39,141 @@ exports.default = (0, ml_core_1.createRule)({
42
39
  }
43
40
  }
44
41
  let invalid = false;
45
- const customRule = attr.rule.options.attrs ? attr.rule.options.attrs[name] : null;
46
- if (customRule) {
47
- if ('enum' in customRule) {
48
- invalid = (0, attr_check_1.attrCheck)(t, name.toLowerCase(), value, true, {
42
+ const allowAttrs = {};
43
+ const disallowAttrs = {};
44
+ if (attr.rule.options.allowAttrs) {
45
+ if (Array.isArray(attr.rule.options.allowAttrs)) {
46
+ for (const allowAttr of attr.rule.options.allowAttrs) {
47
+ if (typeof allowAttr === 'string') {
48
+ allowAttrs[allowAttr] = { type: 'Any' };
49
+ continue;
50
+ }
51
+ if (isValueRule(allowAttr.value)) {
52
+ allowAttrs[allowAttr.name] = allowAttr.value;
53
+ continue;
54
+ }
55
+ allowAttrs[allowAttr.name] = { type: allowAttr.value };
56
+ }
57
+ }
58
+ else {
59
+ for (const [attrName, valueRule] of Object.entries(attr.rule.options.allowAttrs)) {
60
+ allowAttrs[attrName] = valueRule;
61
+ }
62
+ }
63
+ }
64
+ if (attr.rule.options.disallowAttrs) {
65
+ if (Array.isArray(attr.rule.options.disallowAttrs)) {
66
+ for (const disallowAttr of attr.rule.options.disallowAttrs) {
67
+ if (typeof disallowAttr === 'string') {
68
+ disallowAttrs[disallowAttr] = { type: 'Any' };
69
+ continue;
70
+ }
71
+ if (isValueRule(disallowAttr.value)) {
72
+ disallowAttrs[disallowAttr.name] = disallowAttr.value;
73
+ continue;
74
+ }
75
+ disallowAttrs[disallowAttr.name] = { type: disallowAttr.value };
76
+ }
77
+ }
78
+ else {
79
+ for (const [attrName, valueRule] of Object.entries(attr.rule.options.disallowAttrs)) {
80
+ disallowAttrs[attrName] = valueRule;
81
+ }
82
+ }
83
+ }
84
+ if (attr.rule.options.attrs) {
85
+ for (const [attrName, valueRule] of Object.entries(attr.rule.options.attrs)) {
86
+ if ('disallowed' in valueRule) {
87
+ disallowAttrs[attrName] = { type: 'Any' };
88
+ }
89
+ else {
90
+ allowAttrs[attrName] = valueRule;
91
+ }
92
+ }
93
+ }
94
+ const allowValue = allowAttrs[name] ?? null;
95
+ const disallowValue = disallowAttrs[name] ?? null;
96
+ if (allowValue) {
97
+ if ('enum' in allowValue) {
98
+ invalid = attrCheck(t, name.toLowerCase(), value, true, {
49
99
  name,
50
100
  type: {
51
- enum: customRule.enum,
101
+ enum: allowValue.enum,
52
102
  },
53
103
  description: '',
54
104
  });
55
105
  }
56
- else if ('pattern' in customRule) {
57
- if (!(0, helpers_1.match)(value, customRule.pattern)) {
106
+ else if ('pattern' in allowValue) {
107
+ if (!match(value, allowValue.pattern)) {
108
+ invalid = {
109
+ invalidType: 'invalid-value',
110
+ message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), allowValue.pattern),
111
+ };
112
+ }
113
+ }
114
+ else if ('type' in allowValue) {
115
+ invalid = attrCheck(t, name, value, true, { name, type: allowValue.type, description: '' });
116
+ }
117
+ }
118
+ else if (disallowValue) {
119
+ if ('enum' in disallowValue) {
120
+ const checkResult = attrCheck(t, name.toLowerCase(), value, true, {
121
+ name,
122
+ type: {
123
+ enum: disallowValue.enum,
124
+ },
125
+ description: '',
126
+ });
127
+ if (checkResult === false) {
58
128
  invalid = {
59
129
  invalidType: 'invalid-value',
60
- message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), customRule.pattern),
130
+ message: t('{0} is disallowed to accept the following values: {1}', t('the "{0*}" {1}', name, 'attribute'), t(disallowValue.enum)),
61
131
  };
62
132
  }
63
133
  }
64
- else if ('type' in customRule) {
65
- invalid = (0, attr_check_1.attrCheck)(t, name, value, true, { name, type: customRule.type, description: '' });
134
+ else if ('pattern' in disallowValue) {
135
+ if (match(value, disallowValue.pattern)) {
136
+ invalid = {
137
+ invalidType: 'invalid-value',
138
+ message: t('{0} is matched with the below disallowed patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), disallowValue.pattern),
139
+ };
140
+ }
66
141
  }
67
- else if ('disallowed' in customRule && customRule.disallowed) {
68
- invalid = {
69
- invalidType: 'non-existent',
70
- message: t('{0} is disallowed', t('the "{0*}" {1}', name, 'attribute')),
71
- };
142
+ else if ('type' in disallowValue) {
143
+ if (disallowValue.type === 'Any') {
144
+ invalid = {
145
+ invalidType: 'non-existent',
146
+ message: t('{0} is disallowed', t('the "{0*}" {1}', name, 'attribute')),
147
+ };
148
+ }
149
+ else {
150
+ const checkResult = attrCheck(t, name, value, true, {
151
+ name,
152
+ type: disallowValue.type,
153
+ description: '',
154
+ });
155
+ if (checkResult === false) {
156
+ invalid = {
157
+ invalidType: 'invalid-value',
158
+ message: t('{0} is disallowed', t('{0} of {1}', t('the {0}', 'type'), t('the "{0*}" {1}', name, 'attribute'))),
159
+ };
160
+ }
161
+ }
72
162
  }
73
163
  }
74
164
  else if (attr.ownerElement.elementType === 'html' && attrSpecs) {
75
165
  log('Checking %s[%s="%s"]', attr.nodeName, name, value);
76
- invalid = (0, helpers_1.isValidAttr)(t, name, value, attr.isDynamicValue || false, attr.ownerElement, attrSpecs, log);
166
+ invalid = isValidAttr(t, name, value, attr.isDynamicValue || false, attr.ownerElement, attrSpecs, log);
77
167
  }
78
- if (invalid) {
168
+ if (invalid !== false) {
79
169
  switch (invalid.invalidType) {
170
+ case 'disallowed-attr': {
171
+ report({
172
+ scope: attr,
173
+ message: invalid.message,
174
+ });
175
+ break;
176
+ }
80
177
  case 'invalid-value': {
81
178
  if (attr.isDynamicValue) {
82
179
  break;
@@ -84,28 +181,28 @@ exports.default = (0, ml_core_1.createRule)({
84
181
  report({
85
182
  scope: attr,
86
183
  message: invalid.message,
87
- line: ((_b = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startLine) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = invalid.loc) === null || _c === void 0 ? void 0 : _c.line) !== null && _d !== void 0 ? _d : 0),
88
- col: ((_e = invalid.loc) === null || _e === void 0 ? void 0 : _e.line)
89
- ? ((_f = invalid.loc) === null || _f === void 0 ? void 0 : _f.col) + 1
90
- : ((_g = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startCol) !== null && _g !== void 0 ? _g : 0) + ((_j = (_h = invalid.loc) === null || _h === void 0 ? void 0 : _h.col) !== null && _j !== void 0 ? _j : 0),
91
- raw: (_l = (_k = invalid.loc) === null || _k === void 0 ? void 0 : _k.raw) !== null && _l !== void 0 ? _l : value,
184
+ line: (valueNode?.startLine ?? 0) + (invalid.loc?.line ?? 0),
185
+ col: invalid.loc && invalid.loc.line > 0
186
+ ? invalid.loc?.col + 1
187
+ : (valueNode?.startCol ?? 0) + (invalid.loc?.col ?? 0),
188
+ raw: invalid.loc?.raw ?? value,
92
189
  });
93
190
  break;
94
191
  }
95
192
  case 'non-existent': {
96
- if (allowToAddPropertiesForPretender && ((_m = attr.ownerElement.pretenderContext) === null || _m === void 0 ? void 0 : _m.type) === 'origin') {
193
+ if (allowToAddPropertiesForPretender && attr.ownerElement.pretenderContext?.type === 'origin') {
97
194
  return;
98
195
  }
99
- const spec = (0, ml_core_1.getSpec)(attr.ownerElement, document.specs.specs);
100
- if (spec === null || spec === void 0 ? void 0 : spec.possibleToAddProperties) {
196
+ const spec = getSpec(attr.ownerElement, document.specs.specs);
197
+ if (spec?.possibleToAddProperties) {
101
198
  return;
102
199
  }
103
200
  report({
104
201
  scope: attr,
105
202
  message: invalid.message,
106
- line: attrName === null || attrName === void 0 ? void 0 : attrName.startLine,
107
- col: attrName === null || attrName === void 0 ? void 0 : attrName.startCol,
108
- raw: attrName === null || attrName === void 0 ? void 0 : attrName.raw,
203
+ line: attrName?.startLine,
204
+ col: attrName?.startCol,
205
+ raw: attrName?.raw,
109
206
  });
110
207
  }
111
208
  }
@@ -113,3 +210,29 @@ exports.default = (0, ml_core_1.createRule)({
113
210
  });
114
211
  },
115
212
  });
213
+ function isValueRule(
214
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
215
+ value) {
216
+ if (typeof value === 'string') {
217
+ return false;
218
+ }
219
+ if ('enum' in value) {
220
+ if (Object.keys(value).length > 1) {
221
+ return false;
222
+ }
223
+ return true;
224
+ }
225
+ if ('token' in value) {
226
+ return false;
227
+ }
228
+ if ('pattern' in value) {
229
+ return true;
230
+ }
231
+ if (value.type === 'integer' || value.type === 'float') {
232
+ return false;
233
+ }
234
+ if (Object.keys(value).length > 1) {
235
+ return false;
236
+ }
237
+ return true;
238
+ }
@@ -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,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
1
+ import { createRule } from '@markuplint/ml-core';
4
2
  const controlSelector = ["input:not([type='hidden' i])", 'select', 'textarea'].join(',');
5
- exports.default = (0, ml_core_1.createRule)({
3
+ export default createRule({
6
4
  defaultSeverity: 'warning',
7
5
  async verify({ document, report, t }) {
8
6
  await document.walkOn('Element', el => {
@@ -4,5 +4,5 @@ type Options = {
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;
@@ -1,6 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
1
+ import { createRule } from '@markuplint/ml-core';
4
2
  const selectors = {
5
3
  complementary: ['[role="complementary"]', 'aside'],
6
4
  contentinfo: ['[role="contentinfo"]'],
@@ -11,14 +9,13 @@ const selectors = {
11
9
  region: ['[role="region"]', 'section[aria-labelledby]', 'section[aria-label]', 'section[title]'],
12
10
  };
13
11
  const topLevelRoles = ['banner', 'main', 'complementary', 'contentinfo'];
14
- exports.default = (0, ml_core_1.createRule)({
12
+ export default createRule({
15
13
  defaultSeverity: 'warning',
16
14
  defaultOptions: {
17
15
  ignoreRoles: [],
18
16
  labelEachArea: true,
19
17
  },
20
18
  verify({ document, report, t }) {
21
- var _a;
22
19
  if (document.isFragment) {
23
20
  return;
24
21
  }
@@ -72,7 +69,7 @@ exports.default = (0, ml_core_1.createRule)({
72
69
  if (el.rule.disabled) {
73
70
  continue;
74
71
  }
75
- if ((_a = el.rule.options.ignoreRoles) === null || _a === void 0 ? void 0 : _a.includes(role)) {
72
+ if (el.rule.options.ignoreRoles?.includes(role)) {
76
73
  continue;
77
74
  }
78
75
  if (el.isDescendantByUUIDList(uuidList)) {
@@ -106,13 +103,17 @@ exports.default = (0, ml_core_1.createRule)({
106
103
  }
107
104
  },
108
105
  });
109
- function landmarkRoleElementUUIDList(roleset) {
106
+ function landmarkRoleElementUUIDList(
107
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
108
+ roleset) {
110
109
  return Object.values(roleset)
111
110
  .map(elements => elements.map(element => element.uuid))
112
111
  .flat();
113
112
  }
114
- function hasLabel(el) {
115
- const hasHeading = !!el.querySelectorAll('h1, h2, h3, h4, h5, h6').length;
113
+ function hasLabel(
114
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
115
+ el) {
116
+ const hasHeading = el.querySelectorAll('h1, h2, h3, h4, h5, h6').length > 0;
116
117
  if (hasHeading && el.matches('[aria-labelledby]')) {
117
118
  return true;
118
119
  }
@@ -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,12 +1,9 @@
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, getAttrSpecs } from '@markuplint/ml-core';
2
+ export default createRule({
5
3
  defaultSeverity: 'warning',
6
4
  async verify({ document, report, t }) {
7
5
  await document.walkOn('Attr', attr => {
8
- var _a, _b;
9
- const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
6
+ const attrSpec = getAttrSpecs(attr.ownerElement, document.specs);
10
7
  if (!attrSpec) {
11
8
  return;
12
9
  }
@@ -29,12 +26,12 @@ exports.default = (0, ml_core_1.createRule)({
29
26
  attr.valueNode,
30
27
  attr.endQuote,
31
28
  ];
32
- const extraRaw = extraTokens.reduce((raw, t) => { var _a; return raw + ((_a = t === null || t === void 0 ? void 0 : t.raw) !== null && _a !== void 0 ? _a : ''); }, '');
29
+ const extraRaw = extraTokens.reduce((raw, t) => raw + (t?.raw ?? ''), '');
33
30
  if (extraRaw) {
34
31
  report({
35
32
  scope: attr,
36
- line: (_a = attr.spacesBeforeEqual) === null || _a === void 0 ? void 0 : _a.startLine,
37
- col: (_b = attr.spacesBeforeEqual) === null || _b === void 0 ? void 0 : _b.startCol,
33
+ line: attr.spacesBeforeEqual?.startLine,
34
+ col: attr.spacesBeforeEqual?.startCol,
38
35
  raw: extraRaw,
39
36
  message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), t('a {0}', 'boolean attribute')) +
40
37
  t('. ') +
@@ -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,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const helpers_1 = require("../helpers");
5
- exports.default = (0, ml_core_1.createRule)({
1
+ import { createRule, getAttrSpecs } from '@markuplint/ml-core';
2
+ import { toNormalizedValue } from '../helpers.js';
3
+ export default createRule({
6
4
  defaultSeverity: 'warning',
7
5
  async verify({ document, report, t }) {
8
6
  await document.walkOn('Attr', attr => {
9
- var _a, _b, _c;
10
- const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
7
+ const attrSpec = getAttrSpecs(attr.ownerElement, document.specs);
11
8
  if (!attrSpec) {
12
9
  return;
13
10
  }
@@ -18,14 +15,14 @@ exports.default = (0, ml_core_1.createRule)({
18
15
  if (!spec.defaultValue) {
19
16
  return;
20
17
  }
21
- const normalizedValue = (0, helpers_1.toNormalizedValue)(attr.value, spec);
22
- const defaultValue = (0, helpers_1.toNormalizedValue)(spec.defaultValue, spec);
18
+ const normalizedValue = toNormalizedValue(attr.value, spec);
19
+ const defaultValue = toNormalizedValue(spec.defaultValue, spec);
23
20
  if (defaultValue === normalizedValue) {
24
21
  report({
25
22
  scope: attr,
26
- line: (_a = attr.valueNode) === null || _a === void 0 ? void 0 : _a.startLine,
27
- col: (_b = attr.valueNode) === null || _b === void 0 ? void 0 : _b.startCol,
28
- raw: (_c = attr.valueNode) === null || _c === void 0 ? void 0 : _c.raw,
23
+ line: attr.valueNode?.startLine,
24
+ col: attr.valueNode?.startCol,
25
+ raw: attr.valueNode?.raw,
29
26
  message: t('It is {0}', t('the {0}', 'default value')),
30
27
  });
31
28
  }
@@ -2,5 +2,5 @@ type Options = {
2
2
  extendsExposableElements?: boolean;
3
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,8 +1,6 @@
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 { isNothingContentModel, isPalpableElement } from '@markuplint/ml-spec';
3
+ export default createRule({
6
4
  defaultSeverity: 'warning',
7
5
  defaultOptions: {
8
6
  extendsExposableElements: true,
@@ -10,13 +8,21 @@ exports.default = (0, ml_core_1.createRule)({
10
8
  },
11
9
  async verify({ document, report, t }) {
12
10
  await document.walkOn('Element', el => {
13
- if (!(0, ml_spec_1.isPalpableElement)(el, el.ownerMLDocument.specs, {
11
+ /**
12
+ * Exception
13
+ *
14
+ * - The `textarea` element is possibly empty because a user inputs it.
15
+ */
16
+ if (el.localName === 'textarea') {
17
+ return;
18
+ }
19
+ if (!isPalpableElement(el, el.ownerMLDocument.specs, {
14
20
  extendsSvg: false,
15
21
  extendsExposableElements: el.rule.options.extendsExposableElements,
16
22
  })) {
17
23
  return;
18
24
  }
19
- if ((0, ml_spec_1.isNothingContentModel)(el)) {
25
+ if (isNothingContentModel(el)) {
20
26
  return;
21
27
  }
22
28
  if (el.rule.options.ignoreIfAriaBusy && el.getAttribute('aria-busy') === '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,7 +1,5 @@
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({
5
3
  defaultSeverity: 'warning',
6
4
  async verify({ document, report, t }) {
7
5
  if (!document.isFragment) {
@@ -1,5 +1,5 @@
1
- import type { ARIAVersion } from '@markuplint/ml-spec';
2
- declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
3
- ariaVersion: ARIAVersion;
4
- }>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
2
+ ariaVersion: "1.1" | "1.2" | "1.3";
3
+ fragmentRefersNameAttr: boolean;
4
+ }>>;
5
5
  export default _default;