@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.
- package/README.md +10 -44
- package/lib/attr-check.d.ts +22 -10
- package/lib/attr-check.js +32 -23
- package/lib/attr-duplication/index.d.ts +3 -1
- package/lib/attr-duplication/index.js +3 -2
- package/lib/attr-value-quotes/index.d.ts +5 -5
- package/lib/attr-value-quotes/index.js +1 -1
- package/lib/case-sensitive-attr-name/index.d.ts +2 -2
- package/lib/case-sensitive-attr-name/index.js +3 -3
- package/lib/case-sensitive-tag-name/index.d.ts +2 -2
- package/lib/case-sensitive-tag-name/index.js +3 -3
- package/lib/character-reference/index.d.ts +1 -1
- package/lib/character-reference/index.js +1 -1
- package/lib/class-naming/index.d.ts +2 -2
- package/lib/class-naming/index.js +3 -5
- package/lib/create-message.d.ts +13 -2
- package/lib/create-message.js +9 -8
- package/lib/debug.d.ts +1 -1
- package/lib/debug.js +1 -1
- package/lib/deprecated-attr/index.d.ts +3 -1
- package/lib/deprecated-element/index.d.ts +3 -1
- package/lib/deprecated-element/index.js +4 -4
- package/lib/disallowed-element/index.d.ts +1 -1
- package/lib/doctype/index.d.ts +3 -3
- package/lib/doctype/index.js +2 -2
- package/lib/end-tag/index.d.ts +1 -1
- package/lib/end-tag/index.js +3 -18
- package/lib/helpers.d.ts +38 -47
- package/lib/helpers.js +42 -93
- package/lib/id-duplication/index.d.ts +3 -1
- package/lib/index.d.ts +242 -62
- package/lib/index.js +10 -1
- package/lib/ineffective-attr/index.d.ts +3 -1
- package/lib/ineffective-attr/index.js +3 -6
- package/lib/invalid-attr/index.d.ts +40 -12
- package/lib/invalid-attr/index.js +159 -28
- package/lib/label-has-control/index.d.ts +4 -0
- package/lib/label-has-control/index.js +28 -0
- package/lib/landmark-roles/index.d.ts +6 -6
- package/lib/landmark-roles/index.js +10 -6
- package/lib/no-boolean-attr-value/index.d.ts +3 -1
- package/lib/no-boolean-attr-value/index.js +1 -1
- package/lib/no-default-value/index.d.ts +3 -1
- package/lib/no-default-value/index.js +1 -1
- package/lib/no-empty-palpable-content/index.d.ts +6 -0
- package/lib/no-empty-palpable-content/index.js +42 -0
- package/lib/no-hard-code-id/index.d.ts +3 -1
- package/lib/no-hard-code-id/index.js +1 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
- package/lib/no-refer-to-non-existent-id/index.js +65 -5
- package/lib/no-use-event-handler-attr/index.d.ts +3 -3
- package/lib/no-use-event-handler-attr/index.js +6 -6
- package/lib/permitted-contents/choice.d.ts +10 -0
- package/lib/permitted-contents/choice.js +72 -0
- package/lib/permitted-contents/complex-branch.d.ts +20 -0
- package/lib/permitted-contents/complex-branch.js +29 -0
- package/lib/permitted-contents/content-model.d.ts +2 -0
- package/lib/permitted-contents/content-model.js +53 -0
- package/lib/permitted-contents/count-pattern.d.ts +29 -0
- package/lib/permitted-contents/count-pattern.js +162 -0
- package/lib/permitted-contents/debug.browser.d.ts +30 -0
- package/lib/permitted-contents/debug.browser.js +14 -0
- package/lib/permitted-contents/debug.d.ts +3 -0
- package/lib/permitted-contents/debug.js +13 -0
- package/lib/permitted-contents/index.d.ts +2 -8
- package/lib/permitted-contents/index.js +76 -249
- package/lib/permitted-contents/matches-selector.d.ts +8 -0
- package/lib/permitted-contents/matches-selector.js +187 -0
- package/lib/permitted-contents/order.d.ts +20 -0
- package/lib/permitted-contents/order.js +99 -0
- package/lib/permitted-contents/recursive-branch.d.ts +11 -0
- package/lib/permitted-contents/recursive-branch.js +45 -0
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +10 -0
- package/lib/permitted-contents/represent-transparent-nodes.js +78 -0
- package/lib/permitted-contents/start.d.ts +18 -0
- package/lib/permitted-contents/start.js +73 -0
- package/lib/permitted-contents/transparent.d.ts +2 -0
- package/lib/permitted-contents/transparent.js +31 -0
- package/lib/permitted-contents/types.d.ts +52 -0
- package/lib/permitted-contents/types.js +2 -0
- package/lib/permitted-contents/utils.d.ts +100 -0
- package/lib/permitted-contents/utils.js +302 -0
- package/lib/placeholder-label-option/index.d.ts +2 -0
- package/lib/placeholder-label-option/index.js +88 -0
- package/lib/require-accessible-name/index.d.ts +3 -3
- package/lib/require-accessible-name/index.js +12 -4
- package/lib/require-datetime/index.d.ts +6 -0
- package/lib/require-datetime/index.js +34 -0
- package/lib/require-datetime/types.d.ts +10 -0
- package/lib/require-datetime/types.js +2 -0
- package/lib/require-datetime/utils.d.ts +11 -0
- package/lib/require-datetime/utils.js +137 -0
- package/lib/required-attr/index.d.ts +5 -5
- package/lib/required-attr/index.js +20 -17
- package/lib/required-element/index.d.ts +3 -3
- package/lib/required-element/index.js +3 -2
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/required-h1/index.js +4 -3
- package/lib/use-list/index.d.ts +4 -4
- package/lib/use-list/index.js +9 -7
- package/lib/wai-aria/checkings/_.d.ts +15 -0
- package/lib/wai-aria/checkings/_.js +27 -0
- package/lib/wai-aria/checkings/abstract-role.js +1 -1
- package/lib/wai-aria/checkings/default-value.d.ts +7 -3
- package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
- package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
- package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
- package/lib/wai-aria/checkings/implicit-props.js +3 -2
- package/lib/wai-aria/checkings/implicit-role.js +2 -2
- package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +11 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.js +49 -0
- package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
- package/lib/wai-aria/checkings/{non-existant-role.d.ts → non-existent-role.d.ts} +1 -1
- package/lib/wai-aria/checkings/{non-existant-role.js → non-existent-role.js} +4 -4
- package/lib/wai-aria/checkings/permitted-roles.js +1 -1
- package/lib/wai-aria/checkings/presentational-children.d.ts +29 -0
- package/lib/wai-aria/checkings/presentational-children.js +62 -0
- package/lib/wai-aria/checkings/{checking-required-owned-elements.d.ts → required-owned-elements.d.ts} +7 -3
- package/lib/wai-aria/checkings/required-owned-elements.js +103 -0
- package/lib/wai-aria/checkings/required-prop copy.d.ts +15 -0
- package/lib/wai-aria/checkings/required-prop copy.js +27 -0
- package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
- package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +15 -0
- package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
- package/lib/wai-aria/checkings/value.d.ts +19 -4
- package/lib/wai-aria/checkings/value.js +77 -5
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/index.js +27 -16
- package/lib/wai-aria/types.d.ts +11 -9
- package/lib/xxx/index.d.ts +2 -0
- package/lib/xxx/index.js +32 -0
- package/package.json +18 -12
- package/schema.json +12 -0
- package/test/attr-check.spec.js +77 -0
- package/test/attr-duplication/index.spec.js +159 -0
- package/test/attr-value-quotes/index.spec.js +133 -0
- package/test/case-sensitive-attr-name/index.spec.js +65 -0
- package/test/case-sensitive-tag-name/index.spec.js +80 -0
- package/test/character-reference/index.spec.js +57 -0
- package/test/class-naming/index.spec.js +470 -0
- package/test/create-message.spec.js +497 -0
- package/test/deprecated-attr/index.spec.js +48 -0
- package/test/deprecated-element/index.spec.js +48 -0
- package/test/disallowed-element/index.spec.js +90 -0
- package/test/doctype/index.spec.js +50 -0
- package/test/end-tag/index.spec.js +162 -0
- package/test/id-duplication/index.spec.js +47 -0
- package/test/ineffective-attr/index.spec.js +31 -0
- package/test/invalid-attr/index.spec.js +1632 -0
- package/test/label-has-control/index.spec.js +29 -0
- package/test/landmark-roles/index.spec.js +187 -0
- package/test/no-boolean-attr-value/index.spec.js +41 -0
- package/test/no-default-value/index.spec.js +74 -0
- package/test/no-empty-palpable-content/index.spec.js +115 -0
- package/test/no-hard-code-id/index.spec.js +100 -0
- package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
- package/test/no-use-event-handler-attr/index.spec.js +57 -0
- package/test/permitted-contents/choice.spec.js +174 -0
- package/test/permitted-contents/count-pattern.spec.js +308 -0
- package/test/permitted-contents/index.spec.js +1371 -0
- package/test/permitted-contents/matches-selector.spec.js +59 -0
- package/test/permitted-contents/order.spec.js +351 -0
- package/test/permitted-contents/recursive-branch.spec.js +41 -0
- package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
- package/test/permitted-contents/start.spec.js +67 -0
- package/test/placeholder-label-option/index.spec.js +113 -0
- package/test/require-accessible-name/index.spec.js +446 -0
- package/test/require-datetime/index.spec.js +54 -0
- package/test/require-datetime/utils.spec.js +52 -0
- package/test/required-attr/index.spec.js +414 -0
- package/test/required-element/index.spec.js +188 -0
- package/test/required-h1/index.spec.js +69 -0
- package/test/use-list/index.spec.js +109 -0
- package/test/wai-aria/checkings/value.spec.js +33 -0
- package/test/wai-aria/index.spec.js +1173 -0
- package/lib/__foo/index.d.ts +0 -2
- package/lib/__foo/index.js +0 -46
- package/lib/attr-equal-space-after/index.d.ts +0 -3
- package/lib/attr-equal-space-after/index.js +0 -90
- package/lib/attr-equal-space-before/index.d.ts +0 -3
- package/lib/attr-equal-space-before/index.js +0 -90
- package/lib/attr-spacing/index.d.ts +0 -6
- package/lib/attr-spacing/index.js +0 -100
- package/lib/helper/aria/get-aria.d.ts +0 -7
- package/lib/helper/aria/get-aria.js +0 -53
- package/lib/helper/aria/get-computed-role.d.ts +0 -10
- package/lib/helper/aria/get-computed-role.js +0 -24
- package/lib/helper/aria/get-implicit-role.d.ts +0 -7
- package/lib/helper/aria/get-implicit-role.js +0 -12
- package/lib/helper/aria/get-permitted-roles.d.ts +0 -14
- package/lib/helper/aria/get-permitted-roles.js +0 -26
- package/lib/helper/aria/resolve-version.d.ts +0 -2
- package/lib/helper/aria/resolve-version.js +0 -21
- package/lib/helper/spec/aria-spec.d.ts +0 -5
- package/lib/helper/spec/aria-spec.js +0 -12
- package/lib/helper/spec/get-role-spec.d.ts +0 -11
- package/lib/helper/spec/get-role-spec.js +0 -39
- package/lib/helper/spec/html-spec.d.ts +0 -2
- package/lib/helper/spec/html-spec.js +0 -14
- package/lib/indentation/index.d.ts +0 -7
- package/lib/indentation/index.js +0 -208
- package/lib/permitted-contents/array.combination.d.ts +0 -1
- package/lib/permitted-contents/array.combination.js +0 -33
- package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +0 -11
- package/lib/permitted-contents/permitted-content.spec-to-regexp.js +0 -230
- package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +0 -2
- package/lib/permitted-contents/unfold-content-models-to-tags.js +0 -8
- package/lib/wai-aria/checkings/checking-required-owned-elements.js +0 -63
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
package/lib/__foo/index.d.ts
DELETED
package/lib/__foo/index.js
DELETED
|
@@ -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,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,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,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,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,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,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;
|