@markuplint/rules 3.0.0-alpha.66 → 3.0.0-dev.176

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 (211) hide show
  1. package/README.md +10 -44
  2. package/lib/attr-check.d.ts +22 -10
  3. package/lib/attr-check.js +32 -23
  4. package/lib/attr-duplication/index.d.ts +3 -1
  5. package/lib/attr-duplication/index.js +3 -2
  6. package/lib/attr-value-quotes/index.d.ts +5 -5
  7. package/lib/attr-value-quotes/index.js +1 -1
  8. package/lib/case-sensitive-attr-name/index.d.ts +2 -2
  9. package/lib/case-sensitive-attr-name/index.js +3 -3
  10. package/lib/case-sensitive-tag-name/index.d.ts +2 -2
  11. package/lib/case-sensitive-tag-name/index.js +3 -3
  12. package/lib/character-reference/index.d.ts +1 -1
  13. package/lib/character-reference/index.js +1 -1
  14. package/lib/class-naming/index.d.ts +2 -2
  15. package/lib/class-naming/index.js +3 -5
  16. package/lib/create-message.d.ts +13 -2
  17. package/lib/create-message.js +9 -8
  18. package/lib/debug.d.ts +1 -1
  19. package/lib/debug.js +1 -1
  20. package/lib/deprecated-attr/index.d.ts +3 -1
  21. package/lib/deprecated-element/index.d.ts +3 -1
  22. package/lib/deprecated-element/index.js +4 -4
  23. package/lib/disallowed-element/index.d.ts +1 -1
  24. package/lib/doctype/index.d.ts +3 -3
  25. package/lib/doctype/index.js +2 -2
  26. package/lib/end-tag/index.d.ts +1 -1
  27. package/lib/end-tag/index.js +3 -18
  28. package/lib/helpers.d.ts +38 -47
  29. package/lib/helpers.js +42 -93
  30. package/lib/id-duplication/index.d.ts +3 -1
  31. package/lib/index.d.ts +242 -62
  32. package/lib/index.js +10 -1
  33. package/lib/ineffective-attr/index.d.ts +3 -1
  34. package/lib/ineffective-attr/index.js +3 -6
  35. package/lib/invalid-attr/index.d.ts +40 -12
  36. package/lib/invalid-attr/index.js +159 -28
  37. package/lib/label-has-control/index.d.ts +4 -0
  38. package/lib/label-has-control/index.js +28 -0
  39. package/lib/landmark-roles/index.d.ts +6 -6
  40. package/lib/landmark-roles/index.js +10 -6
  41. package/lib/no-boolean-attr-value/index.d.ts +3 -1
  42. package/lib/no-boolean-attr-value/index.js +1 -1
  43. package/lib/no-default-value/index.d.ts +3 -1
  44. package/lib/no-default-value/index.js +1 -1
  45. package/lib/no-empty-palpable-content/index.d.ts +6 -0
  46. package/lib/no-empty-palpable-content/index.js +42 -0
  47. package/lib/no-hard-code-id/index.d.ts +3 -1
  48. package/lib/no-hard-code-id/index.js +1 -1
  49. package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
  50. package/lib/no-refer-to-non-existent-id/index.js +65 -5
  51. package/lib/no-use-event-handler-attr/index.d.ts +3 -3
  52. package/lib/no-use-event-handler-attr/index.js +6 -6
  53. package/lib/permitted-contents/choice.d.ts +10 -0
  54. package/lib/permitted-contents/choice.js +72 -0
  55. package/lib/permitted-contents/complex-branch.d.ts +20 -0
  56. package/lib/permitted-contents/complex-branch.js +29 -0
  57. package/lib/permitted-contents/content-model.d.ts +2 -0
  58. package/lib/permitted-contents/content-model.js +53 -0
  59. package/lib/permitted-contents/count-pattern.d.ts +29 -0
  60. package/lib/permitted-contents/count-pattern.js +162 -0
  61. package/lib/permitted-contents/debug.browser.d.ts +30 -0
  62. package/lib/permitted-contents/debug.browser.js +14 -0
  63. package/lib/permitted-contents/debug.d.ts +3 -0
  64. package/lib/permitted-contents/debug.js +13 -0
  65. package/lib/permitted-contents/index.d.ts +2 -8
  66. package/lib/permitted-contents/index.js +76 -249
  67. package/lib/permitted-contents/matches-selector.d.ts +8 -0
  68. package/lib/permitted-contents/matches-selector.js +187 -0
  69. package/lib/permitted-contents/order.d.ts +20 -0
  70. package/lib/permitted-contents/order.js +99 -0
  71. package/lib/permitted-contents/recursive-branch.d.ts +11 -0
  72. package/lib/permitted-contents/recursive-branch.js +45 -0
  73. package/lib/permitted-contents/represent-transparent-nodes.d.ts +10 -0
  74. package/lib/permitted-contents/represent-transparent-nodes.js +78 -0
  75. package/lib/permitted-contents/start.d.ts +18 -0
  76. package/lib/permitted-contents/start.js +73 -0
  77. package/lib/permitted-contents/transparent.d.ts +2 -0
  78. package/lib/permitted-contents/transparent.js +31 -0
  79. package/lib/permitted-contents/types.d.ts +52 -0
  80. package/lib/permitted-contents/types.js +2 -0
  81. package/lib/permitted-contents/utils.d.ts +100 -0
  82. package/lib/permitted-contents/utils.js +302 -0
  83. package/lib/placeholder-label-option/index.d.ts +2 -0
  84. package/lib/placeholder-label-option/index.js +88 -0
  85. package/lib/require-accessible-name/index.d.ts +3 -3
  86. package/lib/require-accessible-name/index.js +12 -4
  87. package/lib/require-datetime/index.d.ts +6 -0
  88. package/lib/require-datetime/index.js +34 -0
  89. package/lib/require-datetime/types.d.ts +10 -0
  90. package/lib/require-datetime/types.js +2 -0
  91. package/lib/require-datetime/utils.d.ts +11 -0
  92. package/lib/require-datetime/utils.js +137 -0
  93. package/lib/required-attr/index.d.ts +5 -5
  94. package/lib/required-attr/index.js +20 -17
  95. package/lib/required-element/index.d.ts +3 -3
  96. package/lib/required-element/index.js +3 -2
  97. package/lib/required-h1/index.d.ts +3 -3
  98. package/lib/required-h1/index.js +4 -3
  99. package/lib/use-list/index.d.ts +4 -4
  100. package/lib/use-list/index.js +9 -7
  101. package/lib/wai-aria/checkings/_.d.ts +15 -0
  102. package/lib/wai-aria/checkings/_.js +27 -0
  103. package/lib/wai-aria/checkings/abstract-role.js +1 -1
  104. package/lib/wai-aria/checkings/default-value.d.ts +7 -3
  105. package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
  106. package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
  107. package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
  108. package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
  109. package/lib/wai-aria/checkings/implicit-props.js +3 -2
  110. package/lib/wai-aria/checkings/implicit-role.js +2 -2
  111. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +11 -0
  112. package/lib/wai-aria/checkings/interaction-in-hidden.js +49 -0
  113. package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
  114. package/lib/wai-aria/checkings/{non-existant-role.d.ts → non-existent-role.d.ts} +1 -1
  115. package/lib/wai-aria/checkings/{non-existant-role.js → non-existent-role.js} +4 -4
  116. package/lib/wai-aria/checkings/permitted-roles.js +1 -1
  117. package/lib/wai-aria/checkings/presentational-children.d.ts +29 -0
  118. package/lib/wai-aria/checkings/presentational-children.js +62 -0
  119. package/lib/wai-aria/checkings/{checking-required-owned-elements.d.ts → required-owned-elements.d.ts} +7 -3
  120. package/lib/wai-aria/checkings/required-owned-elements.js +103 -0
  121. package/lib/wai-aria/checkings/required-prop copy.d.ts +15 -0
  122. package/lib/wai-aria/checkings/required-prop copy.js +27 -0
  123. package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
  124. package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +15 -0
  125. package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
  126. package/lib/wai-aria/checkings/value.d.ts +19 -4
  127. package/lib/wai-aria/checkings/value.js +77 -5
  128. package/lib/wai-aria/index.d.ts +1 -1
  129. package/lib/wai-aria/index.js +27 -16
  130. package/lib/wai-aria/types.d.ts +11 -9
  131. package/lib/xxx/index.d.ts +2 -0
  132. package/lib/xxx/index.js +32 -0
  133. package/package.json +18 -12
  134. package/schema.json +12 -0
  135. package/test/attr-check.spec.js +77 -0
  136. package/test/attr-duplication/index.spec.js +159 -0
  137. package/test/attr-value-quotes/index.spec.js +133 -0
  138. package/test/case-sensitive-attr-name/index.spec.js +65 -0
  139. package/test/case-sensitive-tag-name/index.spec.js +80 -0
  140. package/test/character-reference/index.spec.js +57 -0
  141. package/test/class-naming/index.spec.js +470 -0
  142. package/test/create-message.spec.js +497 -0
  143. package/test/deprecated-attr/index.spec.js +48 -0
  144. package/test/deprecated-element/index.spec.js +48 -0
  145. package/test/disallowed-element/index.spec.js +90 -0
  146. package/test/doctype/index.spec.js +50 -0
  147. package/test/end-tag/index.spec.js +162 -0
  148. package/test/id-duplication/index.spec.js +47 -0
  149. package/test/ineffective-attr/index.spec.js +31 -0
  150. package/test/invalid-attr/index.spec.js +1632 -0
  151. package/test/label-has-control/index.spec.js +29 -0
  152. package/test/landmark-roles/index.spec.js +187 -0
  153. package/test/no-boolean-attr-value/index.spec.js +41 -0
  154. package/test/no-default-value/index.spec.js +74 -0
  155. package/test/no-empty-palpable-content/index.spec.js +115 -0
  156. package/test/no-hard-code-id/index.spec.js +100 -0
  157. package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
  158. package/test/no-use-event-handler-attr/index.spec.js +57 -0
  159. package/test/permitted-contents/choice.spec.js +174 -0
  160. package/test/permitted-contents/count-pattern.spec.js +308 -0
  161. package/test/permitted-contents/index.spec.js +1371 -0
  162. package/test/permitted-contents/matches-selector.spec.js +59 -0
  163. package/test/permitted-contents/order.spec.js +351 -0
  164. package/test/permitted-contents/recursive-branch.spec.js +41 -0
  165. package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
  166. package/test/permitted-contents/start.spec.js +67 -0
  167. package/test/placeholder-label-option/index.spec.js +113 -0
  168. package/test/require-accessible-name/index.spec.js +446 -0
  169. package/test/require-datetime/index.spec.js +54 -0
  170. package/test/require-datetime/utils.spec.js +52 -0
  171. package/test/required-attr/index.spec.js +414 -0
  172. package/test/required-element/index.spec.js +188 -0
  173. package/test/required-h1/index.spec.js +69 -0
  174. package/test/use-list/index.spec.js +109 -0
  175. package/test/wai-aria/checkings/value.spec.js +33 -0
  176. package/test/wai-aria/index.spec.js +1173 -0
  177. package/lib/__foo/index.d.ts +0 -2
  178. package/lib/__foo/index.js +0 -46
  179. package/lib/attr-equal-space-after/index.d.ts +0 -3
  180. package/lib/attr-equal-space-after/index.js +0 -90
  181. package/lib/attr-equal-space-before/index.d.ts +0 -3
  182. package/lib/attr-equal-space-before/index.js +0 -90
  183. package/lib/attr-spacing/index.d.ts +0 -6
  184. package/lib/attr-spacing/index.js +0 -100
  185. package/lib/helper/aria/get-aria.d.ts +0 -7
  186. package/lib/helper/aria/get-aria.js +0 -53
  187. package/lib/helper/aria/get-computed-role.d.ts +0 -10
  188. package/lib/helper/aria/get-computed-role.js +0 -24
  189. package/lib/helper/aria/get-implicit-role.d.ts +0 -7
  190. package/lib/helper/aria/get-implicit-role.js +0 -12
  191. package/lib/helper/aria/get-permitted-roles.d.ts +0 -14
  192. package/lib/helper/aria/get-permitted-roles.js +0 -26
  193. package/lib/helper/aria/resolve-version.d.ts +0 -2
  194. package/lib/helper/aria/resolve-version.js +0 -21
  195. package/lib/helper/spec/aria-spec.d.ts +0 -5
  196. package/lib/helper/spec/aria-spec.js +0 -12
  197. package/lib/helper/spec/get-role-spec.d.ts +0 -11
  198. package/lib/helper/spec/get-role-spec.js +0 -39
  199. package/lib/helper/spec/html-spec.d.ts +0 -2
  200. package/lib/helper/spec/html-spec.js +0 -14
  201. package/lib/indentation/index.d.ts +0 -7
  202. package/lib/indentation/index.js +0 -208
  203. package/lib/permitted-contents/array.combination.d.ts +0 -1
  204. package/lib/permitted-contents/array.combination.js +0 -33
  205. package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +0 -11
  206. package/lib/permitted-contents/permitted-content.spec-to-regexp.js +0 -230
  207. package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +0 -2
  208. package/lib/permitted-contents/unfold-content-models-to-tags.js +0 -8
  209. package/lib/wai-aria/checkings/checking-required-owned-elements.js +0 -63
  210. package/tsconfig.test.json +0 -3
  211. package/tsconfig.tsbuildinfo +0 -1
@@ -1,2 +0,0 @@
1
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, null>;
2
- export default _default;
@@ -1,46 +0,0 @@
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)({
5
- defaultValue: true,
6
- defaultOptions: null,
7
- async verify({ document, report, t }) {
8
- // Node
9
- await document.walk((node) => {
10
- const raw = node.raw.trim();
11
- if (/./i.test(raw)) {
12
- report({
13
- scope: node,
14
- message: t("It is {0}", "issue"),
15
- });
16
- }
17
- });
18
- // Element
19
- await document.walkOn("Element", (el) => {
20
- const raw = el.raw.trim();
21
- if (/./i.test(raw)) {
22
- report({
23
- scope: el,
24
- message: t("It is {0}", "issue"),
25
- });
26
- }
27
- });
28
- // Attribute
29
- await document.walkOn("Element", (el) => {
30
- for (const attr of el.attributes) {
31
- if (attr.attrType !== "html-attr") {
32
- continue;
33
- }
34
- if (/./i.test(attr.name.raw)) {
35
- report({
36
- scope: el,
37
- line: attr.name.startLine,
38
- col: attr.name.startCol,
39
- raw: attr.name.raw,
40
- message: t("It is {0}", "issue"),
41
- });
42
- }
43
- }
44
- });
45
- },
46
- });
@@ -1,3 +0,0 @@
1
- declare type Value = 'always' | 'never' | 'always-single-line' | 'never-single-line';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<Value, null>;
3
- export default _default;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const alwaysMsg = 'Always insert {0} after {1} of {2}';
5
- const neverMsg = 'Never insert {0} after {1} of {2}';
6
- exports.default = (0, ml_core_1.createRule)({
7
- defaultServerity: 'warning',
8
- defaultValue: 'never',
9
- async verify(context) {
10
- await context.document.walkOn('Element', node => {
11
- for (const attr of node.attributes) {
12
- if (attr.attrType === 'ps-attr' || !(attr.equal && attr.spacesAfterEqual && attr.spacesBeforeEqual)) {
13
- continue;
14
- }
15
- const hasSpace = !!attr.spacesAfterEqual.raw;
16
- const hasLineBreak = /\r?\n/.test(attr.spacesAfterEqual.raw);
17
- let isBad = false;
18
- let rawMessage;
19
- switch (node.rule.value) {
20
- case 'always': {
21
- isBad = !hasSpace;
22
- rawMessage = alwaysMsg;
23
- break;
24
- }
25
- case 'never': {
26
- isBad = hasSpace;
27
- rawMessage = neverMsg;
28
- break;
29
- }
30
- case 'always-single-line': {
31
- // or 'no-newline'
32
- isBad = !hasSpace || hasLineBreak;
33
- rawMessage = alwaysMsg;
34
- break;
35
- }
36
- case 'never-single-line': {
37
- isBad = hasSpace && !hasLineBreak;
38
- rawMessage = neverMsg;
39
- break;
40
- }
41
- }
42
- if (isBad) {
43
- context.report({
44
- scope: node,
45
- message: context.translate(rawMessage, 'space', 'equal sign', 'attribute'),
46
- line: attr.spacesBeforeEqual.startLine,
47
- col: attr.spacesBeforeEqual.startCol,
48
- raw: attr.spacesBeforeEqual.raw + attr.equal.raw + attr.spacesAfterEqual.raw,
49
- });
50
- }
51
- }
52
- });
53
- },
54
- async fix({ document }) {
55
- await document.walkOn('Element', node => {
56
- for (const attr of node.attributes) {
57
- if (attr.attrType === 'ps-attr' || !(attr.equal && attr.spacesAfterEqual && attr.spacesBeforeEqual)) {
58
- continue;
59
- }
60
- const hasSpace = !!attr.spacesAfterEqual.raw;
61
- const hasLineBreak = /\r?\n/.test(attr.spacesAfterEqual.raw);
62
- switch (node.rule.value) {
63
- case 'always': {
64
- if (!hasSpace) {
65
- attr.spacesAfterEqual.fix(' ');
66
- }
67
- break;
68
- }
69
- case 'never': {
70
- attr.spacesAfterEqual.fix('');
71
- break;
72
- }
73
- case 'always-single-line': {
74
- // or 'no-newline'
75
- if (!hasSpace || hasLineBreak) {
76
- attr.spacesAfterEqual.fix(' ');
77
- }
78
- break;
79
- }
80
- case 'never-single-line': {
81
- if (hasSpace && !hasLineBreak) {
82
- attr.spacesAfterEqual.fix('');
83
- }
84
- break;
85
- }
86
- }
87
- }
88
- });
89
- },
90
- });
@@ -1,3 +0,0 @@
1
- declare type Value = 'always' | 'never' | 'always-single-line' | 'never-single-line';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<Value, null>;
3
- export default _default;
@@ -1,90 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ml_core_1 = require("@markuplint/ml-core");
4
- const alwaysMsg = 'Always insert {0} before {1} of {2}';
5
- const neverMsg = 'Never insert {0} before {1} of {2}';
6
- exports.default = (0, ml_core_1.createRule)({
7
- defaultServerity: 'warning',
8
- defaultValue: 'never',
9
- async verify(context) {
10
- await context.document.walkOn('Element', node => {
11
- for (const attr of node.attributes) {
12
- if (attr.attrType === 'ps-attr' || !(attr.equal && attr.spacesAfterEqual && attr.spacesBeforeEqual)) {
13
- continue;
14
- }
15
- const hasSpace = !!attr.spacesBeforeEqual.raw;
16
- const hasLineBreak = /\r?\n/.test(attr.spacesBeforeEqual.raw);
17
- let isBad = false;
18
- let rawMessage;
19
- switch (node.rule.value) {
20
- case 'always': {
21
- isBad = !hasSpace;
22
- rawMessage = alwaysMsg;
23
- break;
24
- }
25
- case 'never': {
26
- isBad = hasSpace;
27
- rawMessage = neverMsg;
28
- break;
29
- }
30
- case 'always-single-line': {
31
- // or 'no-newline'
32
- isBad = !hasSpace || hasLineBreak;
33
- rawMessage = alwaysMsg;
34
- break;
35
- }
36
- case 'never-single-line': {
37
- isBad = hasSpace && !hasLineBreak;
38
- rawMessage = neverMsg;
39
- break;
40
- }
41
- }
42
- if (isBad) {
43
- context.report({
44
- scope: node,
45
- message: context.translate(rawMessage, 'space', 'equal sign', 'attribute'),
46
- line: attr.spacesBeforeEqual.startLine,
47
- col: attr.spacesBeforeEqual.startCol,
48
- raw: attr.spacesBeforeEqual.raw + attr.equal.raw + attr.spacesAfterEqual.raw,
49
- });
50
- }
51
- }
52
- });
53
- },
54
- async fix({ document }) {
55
- await document.walkOn('Element', node => {
56
- for (const attr of node.attributes) {
57
- if (attr.attrType === 'ps-attr' || !(attr.equal && attr.spacesAfterEqual && attr.spacesBeforeEqual)) {
58
- continue;
59
- }
60
- const hasSpace = !!attr.spacesBeforeEqual.raw;
61
- const hasLineBreak = /\r?\n/.test(attr.spacesBeforeEqual.raw);
62
- switch (node.rule.value) {
63
- case 'always': {
64
- if (!hasSpace) {
65
- attr.spacesBeforeEqual.fix(' ');
66
- }
67
- break;
68
- }
69
- case 'never': {
70
- attr.spacesBeforeEqual.fix('');
71
- break;
72
- }
73
- case 'always-single-line': {
74
- // or 'no-newline'
75
- if (!hasSpace || hasLineBreak) {
76
- attr.spacesBeforeEqual.fix(' ');
77
- }
78
- break;
79
- }
80
- case 'never-single-line': {
81
- if (hasSpace && !hasLineBreak) {
82
- attr.spacesBeforeEqual.fix('');
83
- }
84
- break;
85
- }
86
- }
87
- }
88
- });
89
- },
90
- });
@@ -1,6 +0,0 @@
1
- export interface AttrSpasingOptions {
2
- lineBreak?: 'either' | 'always' | 'never';
3
- width?: number | false;
4
- }
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, AttrSpasingOptions>;
6
- export default _default;
@@ -1,100 +0,0 @@
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)({
5
- defaultServerity: 'warning',
6
- defaultOptions: {
7
- lineBreak: 'either',
8
- width: 1,
9
- },
10
- async verify(context) {
11
- await context.document.walkOn('Element', node => {
12
- const attrs = node.attributes;
13
- for (const attr of attrs) {
14
- if (attr.attrType === 'ps-attr') {
15
- continue;
16
- }
17
- const hasSpace = !!attr.spacesBeforeName.raw;
18
- const hasLineBreak = /\r?\n/.test(attr.spacesBeforeName.raw);
19
- // console.log({ attr: `${attr.spacesBeforeName.raw}${attr.raw}`, hasSpace, hasLineBreak });
20
- if (!hasSpace) {
21
- context.report({
22
- scope: node,
23
- message: context.translate('Required {0}', 'space'),
24
- line: attr.spacesBeforeName.startLine,
25
- col: attr.spacesBeforeName.startCol,
26
- raw: attr.spacesBeforeName.raw,
27
- });
28
- }
29
- else {
30
- if (hasLineBreak) {
31
- if (node.rule.option.lineBreak === 'never') {
32
- context.report({
33
- scope: node,
34
- message: context.translate('Never {0}', 'break line'),
35
- line: attr.spacesBeforeName.startLine,
36
- col: attr.spacesBeforeName.startCol,
37
- raw: attr.spacesBeforeName.raw,
38
- });
39
- }
40
- }
41
- else {
42
- if (node.rule.option.lineBreak === 'always') {
43
- context.report({
44
- scope: node,
45
- message: context.translate('Insert {0}', 'line break'),
46
- line: attr.spacesBeforeName.startLine,
47
- col: attr.spacesBeforeName.startCol,
48
- raw: attr.spacesBeforeName.raw,
49
- });
50
- }
51
- if (node.rule.option.width && node.rule.option.width !== attr.spacesBeforeName.raw.length) {
52
- context.report({
53
- scope: node,
54
- message: context.translate('{0} should be {1}', 'Space', node.rule.option.width),
55
- line: attr.spacesBeforeName.startLine,
56
- col: attr.spacesBeforeName.startCol,
57
- raw: attr.spacesBeforeName.raw,
58
- });
59
- }
60
- }
61
- }
62
- }
63
- });
64
- },
65
- async fix({ document }) {
66
- await document.walkOn('Element', node => {
67
- const attrs = node.attributes;
68
- for (const attr of attrs) {
69
- if (attr.attrType === 'ps-attr') {
70
- continue;
71
- }
72
- const hasSpace = !!attr.spacesBeforeName.raw;
73
- const hasLineBreak = /\r?\n/.test(attr.spacesBeforeName.raw);
74
- const expectWidth = node.rule.option.width || 1;
75
- const expectSpaces = ' '.repeat(expectWidth);
76
- if (!hasSpace) {
77
- attr.spacesBeforeName.fix(expectSpaces);
78
- }
79
- else {
80
- if (hasLineBreak) {
81
- if (node.rule.option.lineBreak === 'never') {
82
- attr.spacesBeforeName.fix(expectSpaces);
83
- }
84
- }
85
- else {
86
- if (node.rule.option.lineBreak === 'always') {
87
- const indent = (0, ml_core_1.getIndent)(node);
88
- const expectIndent = indent ? indent.raw : '';
89
- attr.spacesBeforeName.fix(`\n${expectIndent}`);
90
- }
91
- else if (node.rule.option.width &&
92
- node.rule.option.width !== attr.spacesBeforeName.raw.length) {
93
- attr.spacesBeforeName.fix(expectSpaces);
94
- }
95
- }
96
- }
97
- }
98
- });
99
- },
100
- });
@@ -1,7 +0,0 @@
1
- import type { Element } from '@markuplint/ml-core';
2
- import type { ARIA, ARIAVersion, MLMLSpec } from '@markuplint/ml-spec';
3
- export declare function getARIA(
4
- specs: Readonly<MLMLSpec>,
5
- el: Element<any, any>,
6
- version: ARIAVersion,
7
- ): Omit<ARIA, ARIAVersion | 'conditions'> | null;
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getARIA = void 0;
4
- const html_spec_1 = require("../spec/html-spec");
5
- const resolve_version_1 = require("./resolve-version");
6
- const cache = new Map();
7
- function getARIA(specs, el, version) {
8
- var _a, _b, _c, _d, _e;
9
- const aria = getVersionResolvedARIA(specs, el, version);
10
- if (!aria) {
11
- return null;
12
- }
13
- const conditions = aria.conditions;
14
- if (!conditions) {
15
- return aria;
16
- }
17
- const conds = Object.keys(conditions);
18
- let { implicitRole, permittedRoles, implicitProperties, properties, namingProhibited } = aria;
19
- for (const cond of conds) {
20
- if (!el.matches(cond)) {
21
- continue;
22
- }
23
- const condARIA = conditions[cond];
24
- implicitRole = (_a = condARIA.implicitRole) !== null && _a !== void 0 ? _a : implicitRole;
25
- permittedRoles = (_b = condARIA.permittedRoles) !== null && _b !== void 0 ? _b : permittedRoles;
26
- implicitProperties = (_c = condARIA.implicitProperties) !== null && _c !== void 0 ? _c : implicitProperties;
27
- properties = (_d = condARIA.properties) !== null && _d !== void 0 ? _d : properties;
28
- namingProhibited = (_e = condARIA.namingProhibited) !== null && _e !== void 0 ? _e : namingProhibited;
29
- }
30
- return {
31
- implicitRole,
32
- permittedRoles,
33
- implicitProperties,
34
- properties,
35
- namingProhibited,
36
- };
37
- }
38
- exports.getARIA = getARIA;
39
- function getVersionResolvedARIA(specs, el, version) {
40
- var _a;
41
- let aria = cache.get(el.nameWithNS + version);
42
- if (aria !== undefined) {
43
- return aria;
44
- }
45
- const spec = (_a = (0, html_spec_1.htmlSpec)(specs, el.nameWithNS)) === null || _a === void 0 ? void 0 : _a.aria;
46
- if (!spec) {
47
- cache.set(el.nameWithNS + version, null);
48
- return null;
49
- }
50
- aria = (0, resolve_version_1.resolveVersion)(spec, version);
51
- cache.set(el.nameWithNS + version, aria);
52
- return aria;
53
- }
@@ -1,10 +0,0 @@
1
- import type { Element } from '@markuplint/ml-core';
2
- import type { ARIAVersion, MLMLSpec } from '@markuplint/ml-spec';
3
- export declare function getComputedRole(
4
- specs: Readonly<MLMLSpec>,
5
- el: Element<any, any>,
6
- version: ARIAVersion,
7
- ): {
8
- name: string;
9
- isImplicit: boolean;
10
- } | null;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getComputedRole = void 0;
4
- const get_implicit_role_1 = require("./get-implicit-role");
5
- function getComputedRole(specs, el, version) {
6
- const roleAttrTokens = el.getAttributeToken('role');
7
- const roleAttr = roleAttrTokens[0];
8
- if (roleAttr) {
9
- const roleName = roleAttr.value.trim().toLowerCase();
10
- return {
11
- name: roleName,
12
- isImplicit: false,
13
- };
14
- }
15
- const implicitRole = (0, get_implicit_role_1.getImplicitRole)(specs, el, version);
16
- if (implicitRole) {
17
- return {
18
- name: implicitRole,
19
- isImplicit: true,
20
- };
21
- }
22
- return null;
23
- }
24
- exports.getComputedRole = getComputedRole;
@@ -1,7 +0,0 @@
1
- import type { Element } from '@markuplint/ml-core';
2
- import type { ARIAVersion, MLMLSpec } from '@markuplint/ml-spec';
3
- export declare function getImplicitRole(
4
- specs: Readonly<MLMLSpec>,
5
- el: Element<any, any>,
6
- version: ARIAVersion,
7
- ): import('@markuplint/ml-spec').ImplicitRole;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImplicitRole = void 0;
4
- const get_aria_1 = require("./get-aria");
5
- function getImplicitRole(specs, el, version) {
6
- const aria = (0, get_aria_1.getARIA)(specs, el, version);
7
- if (!aria) {
8
- return false;
9
- }
10
- return aria.implicitRole;
11
- }
12
- exports.getImplicitRole = getImplicitRole;
@@ -1,14 +0,0 @@
1
- import type { Element } from '@markuplint/ml-core';
2
- import type { ARIAVersion, MLMLSpec } from '@markuplint/ml-spec';
3
- /**
4
- * Getting permitted ARIA roles.
5
- *
6
- * - If an array, it is role list.
7
- * - If `true`, this mean is "Any".
8
- * - If `false`, this mean is "No".
9
- */
10
- export declare function getPermittedRoles(
11
- specs: Readonly<MLMLSpec>,
12
- el: Element<any, any>,
13
- version: ARIAVersion,
14
- ): import('@markuplint/ml-spec').PermittedRoles;
@@ -1,26 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPermittedRoles = void 0;
4
- const get_aria_1 = require("./get-aria");
5
- /**
6
- * Getting permitted ARIA roles.
7
- *
8
- * - If an array, it is role list.
9
- * - If `true`, this mean is "Any".
10
- * - If `false`, this mean is "No".
11
- */
12
- function getPermittedRoles(specs, el, version) {
13
- const aria = (0, get_aria_1.getARIA)(specs, el, version);
14
- if (!aria) {
15
- return true;
16
- }
17
- const { implicitRole, permittedRoles } = aria;
18
- if (implicitRole && Array.isArray(permittedRoles)) {
19
- return [implicitRole, ...permittedRoles];
20
- }
21
- if (implicitRole && permittedRoles === false) {
22
- return [implicitRole];
23
- }
24
- return permittedRoles;
25
- }
26
- exports.getPermittedRoles = getPermittedRoles;
@@ -1,2 +0,0 @@
1
- import type { ARIA, ARIAVersion } from '@markuplint/ml-spec';
2
- export declare function resolveVersion(aria: ARIA, version: ARIAVersion): Omit<ARIA, ARIAVersion>;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveVersion = void 0;
4
- function resolveVersion(aria, version) {
5
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
6
- const implicitRole = (_b = (_a = aria[version]) === null || _a === void 0 ? void 0 : _a.implicitRole) !== null && _b !== void 0 ? _b : aria.implicitRole;
7
- const permittedRoles = (_d = (_c = aria[version]) === null || _c === void 0 ? void 0 : _c.permittedRoles) !== null && _d !== void 0 ? _d : aria.permittedRoles;
8
- const implicitProperties = (_f = (_e = aria[version]) === null || _e === void 0 ? void 0 : _e.implicitProperties) !== null && _f !== void 0 ? _f : aria.implicitProperties;
9
- const properties = (_h = (_g = aria[version]) === null || _g === void 0 ? void 0 : _g.properties) !== null && _h !== void 0 ? _h : aria.properties;
10
- const namingProhibited = version === '1.2' ? (_k = (_j = aria[version]) === null || _j === void 0 ? void 0 : _j.namingProhibited) !== null && _k !== void 0 ? _k : aria.namingProhibited : aria.namingProhibited;
11
- const conditions = (_m = (_l = aria[version]) === null || _l === void 0 ? void 0 : _l.conditions) !== null && _m !== void 0 ? _m : aria.conditions;
12
- return {
13
- implicitRole,
14
- permittedRoles,
15
- implicitProperties,
16
- properties,
17
- namingProhibited,
18
- conditions,
19
- };
20
- }
21
- exports.resolveVersion = resolveVersion;
@@ -1,5 +0,0 @@
1
- import type { MLMLSpec } from '@markuplint/ml-spec';
2
- export declare function ariaSpec(specs: Readonly<MLMLSpec>): {
3
- roles: import('@markuplint/ml-spec').ARIRRoleAttribute[];
4
- ariaAttrs: import('@markuplint/ml-spec').ARIAProperty[];
5
- };
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ariaSpec = void 0;
4
- function ariaSpec(specs) {
5
- const roles = specs.def['#roles'];
6
- const ariaAttrs = specs.def['#ariaAttrs'];
7
- return {
8
- roles,
9
- ariaAttrs,
10
- };
11
- }
12
- exports.ariaSpec = ariaSpec;
@@ -1,11 +0,0 @@
1
- import type { ARIRRoleAttribute, MLMLSpec } from '@markuplint/ml-spec';
2
- export declare function getRoleSpec(
3
- specs: Readonly<MLMLSpec>,
4
- roleName: string,
5
- ): {
6
- name: string;
7
- isAbstract: boolean;
8
- accessibleNameRequired: boolean;
9
- statesAndProps: import('@markuplint/ml-spec').ARIARoleOwnedPropOrState[];
10
- superClassRoles: ARIRRoleAttribute[];
11
- } | null;
@@ -1,39 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getRoleSpec = void 0;
4
- function getRoleSpec(specs, roleName) {
5
- const role = getRoleByName(specs, roleName);
6
- if (!role) {
7
- return null;
8
- }
9
- const superClassRoles = recursiveTraverseSuperClassRoles(specs, roleName);
10
- return {
11
- name: role.name,
12
- isAbstract: !!role.isAbstract,
13
- accessibleNameRequired: role.accessibleNameRequired,
14
- statesAndProps: role.ownedAttribute,
15
- superClassRoles,
16
- };
17
- }
18
- exports.getRoleSpec = getRoleSpec;
19
- function getRoleByName(specs, roleName) {
20
- const roles = specs.def['#roles'];
21
- const role = roles.find(r => r.name === roleName);
22
- return role;
23
- }
24
- function recursiveTraverseSuperClassRoles(specs, roleName) {
25
- const roles = [];
26
- const superClassRoles = getSuperClassRoles(specs, roleName);
27
- if (superClassRoles) {
28
- roles.push(...superClassRoles);
29
- for (const superClassRole of superClassRoles) {
30
- const ancestorRoles = recursiveTraverseSuperClassRoles(specs, superClassRole.name);
31
- roles.push(...ancestorRoles);
32
- }
33
- }
34
- return roles;
35
- }
36
- function getSuperClassRoles(specs, roleName) {
37
- const role = getRoleByName(specs, roleName);
38
- return ((role === null || role === void 0 ? void 0 : role.generalization.map(roleName => getRoleByName(specs, roleName)).filter((role) => !!role)) || null);
39
- }
@@ -1,2 +0,0 @@
1
- import type { ElementSpec, MLMLSpec } from '@markuplint/ml-spec';
2
- export declare function htmlSpec(specs: Readonly<MLMLSpec>, nameWithNS: string): ElementSpec | null;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.htmlSpec = void 0;
4
- const cache = new Map();
5
- function htmlSpec(specs, nameWithNS) {
6
- let spec = cache.get(nameWithNS);
7
- if (spec !== undefined) {
8
- return spec;
9
- }
10
- spec = specs.specs.find(spec => spec.name === nameWithNS) || null;
11
- cache.set(nameWithNS, spec);
12
- return spec;
13
- }
14
- exports.htmlSpec = htmlSpec;
@@ -1,7 +0,0 @@
1
- export declare type Value = 'tab' | number;
2
- export interface IndentationOptions {
3
- alignment?: boolean;
4
- 'indent-nested-nodes'?: boolean | 'always' | 'never';
5
- }
6
- declare const _default: import('@markuplint/ml-core').RuleSeed<Value, IndentationOptions>;
7
- export default _default;