@markuplint/rules 4.11.2 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -1
- package/SKILL.md +76 -0
- package/lib/attr-check.d.ts +41 -5
- package/lib/attr-check.js +29 -5
- package/lib/attr-duplication/index.d.ts +7 -0
- package/lib/attr-duplication/index.js +7 -0
- package/lib/attr-duplication/meta.d.ts +1 -0
- package/lib/attr-duplication/meta.js +1 -0
- package/lib/attr-value-quotes/index.d.ts +10 -0
- package/lib/attr-value-quotes/index.js +10 -0
- package/lib/attr-value-quotes/meta.d.ts +1 -0
- package/lib/attr-value-quotes/meta.js +1 -0
- package/lib/case-sensitive-attr-name/index.d.ts +9 -0
- package/lib/case-sensitive-attr-name/index.js +8 -0
- package/lib/case-sensitive-attr-name/meta.d.ts +1 -0
- package/lib/case-sensitive-attr-name/meta.js +1 -0
- package/lib/case-sensitive-tag-name/index.d.ts +9 -0
- package/lib/case-sensitive-tag-name/index.js +8 -0
- package/lib/case-sensitive-tag-name/meta.d.ts +1 -0
- package/lib/case-sensitive-tag-name/meta.js +1 -0
- package/lib/character-reference/index.d.ts +8 -0
- package/lib/character-reference/index.js +16 -0
- package/lib/character-reference/meta.d.ts +1 -0
- package/lib/character-reference/meta.js +1 -0
- package/lib/class-naming/index.d.ts +9 -0
- package/lib/class-naming/index.js +8 -0
- package/lib/class-naming/meta.d.ts +1 -0
- package/lib/class-naming/meta.js +1 -0
- package/lib/create-message.d.ts +27 -0
- package/lib/create-message.js +56 -1
- package/lib/debug.d.ts +9 -0
- package/lib/debug.js +5 -0
- package/lib/deprecated-attr/index.d.ts +6 -0
- package/lib/deprecated-attr/index.js +6 -0
- package/lib/deprecated-attr/meta.d.ts +1 -0
- package/lib/deprecated-attr/meta.js +1 -0
- package/lib/deprecated-element/index.d.ts +8 -0
- package/lib/deprecated-element/index.js +8 -0
- package/lib/deprecated-element/meta.d.ts +1 -0
- package/lib/deprecated-element/meta.js +1 -0
- package/lib/disallowed-element/index.d.ts +7 -0
- package/lib/disallowed-element/index.js +7 -0
- package/lib/disallowed-element/meta.d.ts +1 -0
- package/lib/disallowed-element/meta.js +1 -0
- package/lib/doctype/index.d.ts +10 -0
- package/lib/doctype/index.js +8 -0
- package/lib/doctype/meta.d.ts +1 -0
- package/lib/doctype/meta.js +1 -0
- package/lib/end-tag/index.d.ts +7 -0
- package/lib/end-tag/index.js +7 -0
- package/lib/end-tag/meta.d.ts +1 -0
- package/lib/end-tag/meta.js +1 -0
- package/lib/heading-levels/index.d.ts +6 -0
- package/lib/heading-levels/index.js +6 -0
- package/lib/heading-levels/meta.d.ts +1 -0
- package/lib/heading-levels/meta.js +1 -0
- package/lib/helpers.d.ts +104 -0
- package/lib/helpers.js +105 -2
- package/lib/id-duplication/index.d.ts +7 -0
- package/lib/id-duplication/index.js +7 -0
- package/lib/id-duplication/meta.d.ts +1 -0
- package/lib/id-duplication/meta.js +1 -0
- package/lib/index.d.ts +23 -10
- package/lib/index.js +12 -0
- package/lib/ineffective-attr/index.d.ts +7 -0
- package/lib/ineffective-attr/index.js +7 -0
- package/lib/ineffective-attr/meta.d.ts +1 -0
- package/lib/ineffective-attr/meta.js +1 -0
- package/lib/invalid-attr/index.d.ts +24 -0
- package/lib/invalid-attr/index.js +17 -0
- package/lib/invalid-attr/meta.d.ts +1 -0
- package/lib/invalid-attr/meta.js +1 -0
- package/lib/label-has-control/index.d.ts +7 -0
- package/lib/label-has-control/index.js +11 -0
- package/lib/label-has-control/meta.d.ts +1 -0
- package/lib/label-has-control/meta.js +1 -0
- package/lib/landmark-roles/index.d.ts +14 -0
- package/lib/landmark-roles/index.js +21 -0
- package/lib/landmark-roles/meta.d.ts +1 -0
- package/lib/landmark-roles/meta.js +1 -0
- package/lib/neighbor-popovers/index.d.ts +8 -0
- package/lib/neighbor-popovers/index.js +26 -2
- package/lib/neighbor-popovers/meta.d.ts +1 -0
- package/lib/neighbor-popovers/meta.js +1 -0
- package/lib/no-ambiguous-navigable-target-names/index.d.ts +8 -0
- package/lib/no-ambiguous-navigable-target-names/index.js +8 -0
- package/lib/no-ambiguous-navigable-target-names/meta.d.ts +1 -0
- package/lib/no-ambiguous-navigable-target-names/meta.js +1 -0
- package/lib/no-boolean-attr-value/index.d.ts +7 -0
- package/lib/no-boolean-attr-value/index.js +7 -0
- package/lib/no-boolean-attr-value/meta.d.ts +1 -0
- package/lib/no-boolean-attr-value/meta.js +1 -0
- package/lib/no-consecutive-br/index.d.ts +8 -0
- package/lib/no-consecutive-br/index.js +8 -0
- package/lib/no-consecutive-br/meta.d.ts +1 -0
- package/lib/no-consecutive-br/meta.js +1 -0
- package/lib/no-default-value/index.d.ts +7 -0
- package/lib/no-default-value/index.js +7 -0
- package/lib/no-default-value/meta.d.ts +1 -0
- package/lib/no-default-value/meta.js +1 -0
- package/lib/no-duplicate-dt/index.d.ts +6 -0
- package/lib/no-duplicate-dt/index.js +6 -0
- package/lib/no-duplicate-dt/meta.d.ts +1 -0
- package/lib/no-duplicate-dt/meta.js +1 -0
- package/lib/no-empty-palpable-content/index.d.ts +13 -0
- package/lib/no-empty-palpable-content/index.js +12 -0
- package/lib/no-empty-palpable-content/meta.d.ts +1 -0
- package/lib/no-empty-palpable-content/meta.js +1 -0
- package/lib/no-hard-code-id/index.d.ts +8 -0
- package/lib/no-hard-code-id/index.js +8 -0
- package/lib/no-hard-code-id/meta.d.ts +1 -0
- package/lib/no-hard-code-id/meta.js +1 -0
- package/lib/no-orphaned-end-tag/index.d.ts +7 -0
- package/lib/no-orphaned-end-tag/index.js +7 -0
- package/lib/no-orphaned-end-tag/meta.d.ts +1 -0
- package/lib/no-orphaned-end-tag/meta.js +1 -0
- package/lib/no-refer-to-non-existent-id/index.d.ts +8 -0
- package/lib/no-refer-to-non-existent-id/index.js +9 -0
- package/lib/no-refer-to-non-existent-id/meta.d.ts +1 -0
- package/lib/no-refer-to-non-existent-id/meta.js +1 -0
- package/lib/no-use-event-handler-attr/index.d.ts +10 -0
- package/lib/no-use-event-handler-attr/index.js +8 -0
- package/lib/no-use-event-handler-attr/meta.d.ts +1 -0
- package/lib/no-use-event-handler-attr/meta.js +1 -0
- package/lib/permitted-contents/choice.d.ts +17 -0
- package/lib/permitted-contents/choice.js +30 -0
- package/lib/permitted-contents/complex-branch.d.ts +11 -7
- package/lib/permitted-contents/complex-branch.js +11 -7
- package/lib/permitted-contents/content-model.d.ts +11 -0
- package/lib/permitted-contents/content-model.js +32 -0
- package/lib/permitted-contents/count-pattern.d.ts +13 -7
- package/lib/permitted-contents/count-pattern.js +23 -7
- package/lib/permitted-contents/debug.browser.d.ts +12 -0
- package/lib/permitted-contents/debug.browser.js +12 -0
- package/lib/permitted-contents/debug.d.ts +12 -0
- package/lib/permitted-contents/debug.js +12 -0
- package/lib/permitted-contents/index.d.ts +12 -0
- package/lib/permitted-contents/index.js +21 -0
- package/lib/permitted-contents/matches-selector.d.ts +19 -0
- package/lib/permitted-contents/matches-selector.js +33 -0
- package/lib/permitted-contents/meta.d.ts +1 -0
- package/lib/permitted-contents/meta.js +1 -0
- package/lib/permitted-contents/order.d.ts +14 -7
- package/lib/permitted-contents/order.js +14 -7
- package/lib/permitted-contents/recursive-branch.d.ts +17 -0
- package/lib/permitted-contents/recursive-branch.js +17 -0
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +29 -0
- package/lib/permitted-contents/represent-transparent-nodes.js +24 -0
- package/lib/permitted-contents/start.d.ts +12 -6
- package/lib/permitted-contents/start.js +12 -6
- package/lib/permitted-contents/transparent.d.ts +12 -0
- package/lib/permitted-contents/transparent.js +12 -0
- package/lib/permitted-contents/types.d.ts +67 -0
- package/lib/permitted-contents/utils.d.ts +160 -0
- package/lib/permitted-contents/utils.js +194 -0
- package/lib/placeholder-label-option/index.d.ts +7 -0
- package/lib/placeholder-label-option/index.js +19 -15
- package/lib/placeholder-label-option/meta.d.ts +1 -0
- package/lib/placeholder-label-option/meta.js +1 -0
- package/lib/require-accessible-name/index.d.ts +11 -0
- package/lib/require-accessible-name/index.js +7 -0
- package/lib/require-accessible-name/meta.d.ts +1 -0
- package/lib/require-accessible-name/meta.js +1 -0
- package/lib/require-datetime/index.d.ts +12 -0
- package/lib/require-datetime/index.js +8 -0
- package/lib/require-datetime/meta.d.ts +1 -0
- package/lib/require-datetime/meta.js +1 -0
- package/lib/require-datetime/types.d.ts +7 -0
- package/lib/require-datetime/utils.d.ts +18 -5
- package/lib/require-datetime/utils.js +53 -9
- package/lib/required-attr/index.d.ts +13 -0
- package/lib/required-attr/index.js +7 -0
- package/lib/required-attr/meta.d.ts +1 -0
- package/lib/required-attr/meta.js +1 -0
- package/lib/required-element/index.d.ts +14 -0
- package/lib/required-element/index.js +14 -2
- package/lib/required-element/meta.d.ts +1 -0
- package/lib/required-element/meta.js +1 -0
- package/lib/required-h1/index.d.ts +12 -0
- package/lib/required-h1/index.js +7 -0
- package/lib/required-h1/meta.d.ts +1 -0
- package/lib/required-h1/meta.js +1 -0
- package/lib/table-row-column-alignment/find-children.d.ts +10 -0
- package/lib/table-row-column-alignment/find-children.js +11 -0
- package/lib/table-row-column-alignment/grid.d.ts +60 -0
- package/lib/table-row-column-alignment/grid.js +85 -0
- package/lib/table-row-column-alignment/index.d.ts +8 -0
- package/lib/table-row-column-alignment/index.js +8 -0
- package/lib/table-row-column-alignment/meta.d.ts +1 -0
- package/lib/table-row-column-alignment/meta.js +1 -0
- package/lib/table-row-column-alignment/types.d.ts +10 -0
- package/lib/use-list/index.d.ts +16 -0
- package/lib/use-list/index.js +20 -0
- package/lib/use-list/meta.d.ts +1 -0
- package/lib/use-list/meta.js +1 -0
- package/lib/wai-aria/checkings/abstract-role.d.ts +9 -0
- package/lib/wai-aria/checkings/abstract-role.js +9 -0
- package/lib/wai-aria/checkings/default-value.d.ts +11 -0
- package/lib/wai-aria/checkings/default-value.js +11 -0
- package/lib/wai-aria/checkings/deprecated-props.d.ts +11 -0
- package/lib/wai-aria/checkings/deprecated-props.js +11 -0
- package/lib/wai-aria/checkings/deprecated-role.d.ts +10 -0
- package/lib/wai-aria/checkings/deprecated-role.js +10 -0
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +14 -0
- package/lib/wai-aria/checkings/disallowed-prop.js +14 -0
- package/lib/wai-aria/checkings/implicit-props.d.ts +13 -0
- package/lib/wai-aria/checkings/implicit-props.js +13 -0
- package/lib/wai-aria/checkings/implicit-role.d.ts +9 -0
- package/lib/wai-aria/checkings/implicit-role.js +9 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +9 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.js +15 -4
- package/lib/wai-aria/checkings/no-global-prop.d.ts +10 -0
- package/lib/wai-aria/checkings/no-global-prop.js +10 -0
- package/lib/wai-aria/checkings/non-existent-role.d.ts +10 -0
- package/lib/wai-aria/checkings/non-existent-role.js +10 -0
- package/lib/wai-aria/checkings/permitted-roles.d.ts +10 -0
- package/lib/wai-aria/checkings/permitted-roles.js +10 -0
- package/lib/wai-aria/checkings/presentational-children.d.ts +7 -1
- package/lib/wai-aria/checkings/presentational-children.js +14 -1
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +9 -1
- package/lib/wai-aria/checkings/required-owned-elements.js +16 -1
- package/lib/wai-aria/checkings/required-prop.d.ts +13 -0
- package/lib/wai-aria/checkings/required-prop.js +13 -0
- package/lib/wai-aria/checkings/value.d.ts +23 -0
- package/lib/wai-aria/checkings/value.js +32 -0
- package/lib/wai-aria/index.d.ts +10 -0
- package/lib/wai-aria/index.js +10 -0
- package/lib/wai-aria/meta.d.ts +1 -0
- package/lib/wai-aria/meta.js +1 -0
- package/lib/wai-aria/types.d.ts +17 -0
- package/package.json +11 -11
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @markuplint/rules
|
|
3
|
+
*
|
|
4
|
+
* Built-in rules for markuplint. This module exports a registry of all
|
|
5
|
+
* core lint rules that ship with markuplint, keyed by their rule name.
|
|
6
|
+
* Each rule implements the {@link AnyRuleSeed} interface and covers
|
|
7
|
+
* areas such as accessibility, HTML validity, naming conventions, and coding style.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Registry of all built-in markuplint rules, mapping rule names to their seed definitions.
|
|
11
|
+
* Used by the markuplint core to initialize rule instances during linting.
|
|
12
|
+
*/
|
|
1
13
|
declare const rules: {
|
|
2
14
|
readonly 'attr-duplication': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
3
15
|
readonly 'attr-value-quotes': Readonly<import("@markuplint/ml-core").RuleSeed<import("./attr-value-quotes/index.js").Type, undefined>>;
|
|
@@ -18,35 +30,35 @@ declare const rules: {
|
|
|
18
30
|
readonly 'invalid-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
19
31
|
allowAttrs?: (string | {
|
|
20
32
|
name: string;
|
|
21
|
-
value: import("
|
|
33
|
+
value: import("@markuplint/ml-spec").AttributeType | ({
|
|
22
34
|
enum: [string, ...string[]];
|
|
23
35
|
} | {
|
|
24
36
|
pattern: string;
|
|
25
37
|
} | {
|
|
26
|
-
type: import("
|
|
38
|
+
type: import("@markuplint/ml-spec").AttributeType;
|
|
27
39
|
});
|
|
28
40
|
})[] | Record<string, {
|
|
29
41
|
enum: [string, ...string[]];
|
|
30
42
|
} | {
|
|
31
43
|
pattern: string;
|
|
32
44
|
} | {
|
|
33
|
-
type: import("
|
|
45
|
+
type: import("@markuplint/ml-spec").AttributeType;
|
|
34
46
|
}>;
|
|
35
47
|
disallowAttrs?: (string | {
|
|
36
48
|
name: string;
|
|
37
|
-
value: import("
|
|
49
|
+
value: import("@markuplint/ml-spec").AttributeType | ({
|
|
38
50
|
enum: [string, ...string[]];
|
|
39
51
|
} | {
|
|
40
52
|
pattern: string;
|
|
41
53
|
} | {
|
|
42
|
-
type: import("
|
|
54
|
+
type: import("@markuplint/ml-spec").AttributeType;
|
|
43
55
|
});
|
|
44
56
|
})[] | Record<string, {
|
|
45
57
|
enum: [string, ...string[]];
|
|
46
58
|
} | {
|
|
47
59
|
pattern: string;
|
|
48
60
|
} | {
|
|
49
|
-
type: import("
|
|
61
|
+
type: import("@markuplint/ml-spec").AttributeType;
|
|
50
62
|
}>;
|
|
51
63
|
ignoreAttrNamePrefix?: string | string[];
|
|
52
64
|
allowToAddPropertiesForPretender?: boolean;
|
|
@@ -55,14 +67,14 @@ declare const rules: {
|
|
|
55
67
|
} | {
|
|
56
68
|
pattern: string;
|
|
57
69
|
} | {
|
|
58
|
-
type: import("
|
|
70
|
+
type: import("@markuplint/ml-spec").AttributeType;
|
|
59
71
|
}) | {
|
|
60
72
|
disallowed: true;
|
|
61
73
|
}>;
|
|
62
74
|
}>>;
|
|
63
75
|
readonly 'label-has-control': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
64
76
|
readonly 'landmark-roles': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
65
|
-
ignoreRoles: (
|
|
77
|
+
ignoreRoles: ("form" | ("main" | "banner" | "complementary" | "contentinfo") | "navigation" | "region")[];
|
|
66
78
|
labelEachArea: boolean;
|
|
67
79
|
}>>;
|
|
68
80
|
readonly 'neighbor-popovers': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
@@ -78,7 +90,7 @@ declare const rules: {
|
|
|
78
90
|
readonly 'no-hard-code-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
79
91
|
readonly 'no-orphaned-end-tag': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, null>>;
|
|
80
92
|
readonly 'no-refer-to-non-existent-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
|
|
81
|
-
ariaVersion: import("
|
|
93
|
+
ariaVersion: import("@markuplint/ml-spec").ARIAVersion;
|
|
82
94
|
fragmentRefersNameAttr: boolean;
|
|
83
95
|
}>>;
|
|
84
96
|
readonly 'no-use-event-handler-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
@@ -87,7 +99,7 @@ declare const rules: {
|
|
|
87
99
|
readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types.js").TagRule[], import("./permitted-contents/types.js").Options>>;
|
|
88
100
|
readonly 'placeholder-label-option': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
|
|
89
101
|
readonly 'require-accessible-name': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
90
|
-
ariaVersion: import("
|
|
102
|
+
ariaVersion: import("@markuplint/ml-spec").ARIAVersion;
|
|
91
103
|
}>>;
|
|
92
104
|
readonly 'require-datetime': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
93
105
|
langs?: import("./require-datetime/types.js").Lang[];
|
|
@@ -98,6 +110,7 @@ declare const rules: {
|
|
|
98
110
|
})[], undefined>>;
|
|
99
111
|
readonly 'required-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], {
|
|
100
112
|
ignoreHasMutableContents: boolean;
|
|
113
|
+
ignoreOmittedElements: boolean;
|
|
101
114
|
}>>;
|
|
102
115
|
readonly 'required-h1': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./required-h1/index.js").Options>>;
|
|
103
116
|
readonly 'table-row-column-alignment': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
|
package/lib/index.js
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module @markuplint/rules
|
|
3
|
+
*
|
|
4
|
+
* Built-in rules for markuplint. This module exports a registry of all
|
|
5
|
+
* core lint rules that ship with markuplint, keyed by their rule name.
|
|
6
|
+
* Each rule implements the {@link AnyRuleSeed} interface and covers
|
|
7
|
+
* areas such as accessibility, HTML validity, naming conventions, and coding style.
|
|
8
|
+
*/
|
|
1
9
|
import AttrDuplication from './attr-duplication/index.js';
|
|
2
10
|
import AttrValueQuotes from './attr-value-quotes/index.js';
|
|
3
11
|
import CaseSensitiveAttrName from './case-sensitive-attr-name/index.js';
|
|
@@ -36,6 +44,10 @@ import RequiredH1 from './required-h1/index.js';
|
|
|
36
44
|
import TableRowColumnAlignment from './table-row-column-alignment/index.js';
|
|
37
45
|
import UseList from './use-list/index.js';
|
|
38
46
|
import WaiAria from './wai-aria/index.js';
|
|
47
|
+
/**
|
|
48
|
+
* Registry of all built-in markuplint rules, mapping rule names to their seed definitions.
|
|
49
|
+
* Used by the markuplint core to initialize rule instances during linting.
|
|
50
|
+
*/
|
|
39
51
|
const rules = {
|
|
40
52
|
'attr-duplication': AttrDuplication,
|
|
41
53
|
'attr-value-quotes': AttrValueQuotes,
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that detects attributes that have no effect on their owner element.
|
|
3
|
+
*
|
|
4
|
+
* Checks each attribute's spec for ineffective conditions (CSS selectors)
|
|
5
|
+
* and reports when the owner element matches any of those conditions,
|
|
6
|
+
* meaning the attribute is present but has no practical effect.
|
|
7
|
+
*/
|
|
1
8
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
9
|
export default _default;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
2
|
import { toNoEmptyStringArrayFromStringOrArray } from '@markuplint/shared';
|
|
3
3
|
import meta from './meta.js';
|
|
4
|
+
/**
|
|
5
|
+
* Rule that detects attributes that have no effect on their owner element.
|
|
6
|
+
*
|
|
7
|
+
* Checks each attribute's spec for ineffective conditions (CSS selectors)
|
|
8
|
+
* and reports when the owner element matches any of those conditions,
|
|
9
|
+
* meaning the attribute is present but has no practical effect.
|
|
10
|
+
*/
|
|
4
11
|
export default createRule({
|
|
5
12
|
meta: meta,
|
|
6
13
|
defaultSeverity: 'warning',
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import type { AttributeType } from '@markuplint/ml-spec';
|
|
2
|
+
/**
|
|
3
|
+
* Configuration options for the `invalid-attr` rule.
|
|
4
|
+
*/
|
|
2
5
|
type Option = {
|
|
3
6
|
/**
|
|
4
7
|
* @since 3.7.0
|
|
@@ -8,7 +11,9 @@ type Option = {
|
|
|
8
11
|
* @since 3.7.0
|
|
9
12
|
*/
|
|
10
13
|
disallowAttrs?: (string | Attr)[] | Record<string, ValueRule>;
|
|
14
|
+
/** Attribute name prefix(es) to ignore during validation. */
|
|
11
15
|
ignoreAttrNamePrefix?: string | string[];
|
|
16
|
+
/** Whether to allow additional properties for pretender elements (defaults to `true`). */
|
|
12
17
|
allowToAddPropertiesForPretender?: boolean;
|
|
13
18
|
/**
|
|
14
19
|
* @deprecated Since version 3.7.0. Use `allowAttrs` or `disallowAttrs` instead.
|
|
@@ -22,10 +27,19 @@ type Option = {
|
|
|
22
27
|
disallowed: true;
|
|
23
28
|
}>;
|
|
24
29
|
};
|
|
30
|
+
/**
|
|
31
|
+
* Describes a single attribute with its name and expected value constraint.
|
|
32
|
+
*/
|
|
25
33
|
type Attr = {
|
|
34
|
+
/** The attribute name. */
|
|
26
35
|
name: string;
|
|
36
|
+
/** The expected attribute value type or validation rule. */
|
|
27
37
|
value: AttributeType | ValueRule;
|
|
28
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* A validation constraint for an attribute value, defined as either an
|
|
41
|
+
* enumerated list, a regex pattern, or a spec-based type.
|
|
42
|
+
*/
|
|
29
43
|
type ValueRule = {
|
|
30
44
|
enum: [string, ...string[]];
|
|
31
45
|
} | {
|
|
@@ -33,5 +47,15 @@ type ValueRule = {
|
|
|
33
47
|
} | {
|
|
34
48
|
type: AttributeType;
|
|
35
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Rule that validates attributes against the HTML spec, allowed lists,
|
|
52
|
+
* and disallowed lists.
|
|
53
|
+
*
|
|
54
|
+
* Checks each attribute for: existence in the spec, correct value type,
|
|
55
|
+
* allowed/disallowed overrides from configuration, and typo suggestions
|
|
56
|
+
* via candidate matching. Supports `allowAttrs`, `disallowAttrs`, and
|
|
57
|
+
* the deprecated `attrs` option. Non-existent attributes on elements that
|
|
58
|
+
* allow additional properties (pretenders) can be optionally permitted.
|
|
59
|
+
*/
|
|
36
60
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Option>>;
|
|
37
61
|
export default _default;
|
|
@@ -4,6 +4,16 @@ import { log as ruleLog } from '../debug.js';
|
|
|
4
4
|
import { isValidAttr, match } from '../helpers.js';
|
|
5
5
|
import meta from './meta.js';
|
|
6
6
|
const log = ruleLog.extend('invalid-attr');
|
|
7
|
+
/**
|
|
8
|
+
* Rule that validates attributes against the HTML spec, allowed lists,
|
|
9
|
+
* and disallowed lists.
|
|
10
|
+
*
|
|
11
|
+
* Checks each attribute for: existence in the spec, correct value type,
|
|
12
|
+
* allowed/disallowed overrides from configuration, and typo suggestions
|
|
13
|
+
* via candidate matching. Supports `allowAttrs`, `disallowAttrs`, and
|
|
14
|
+
* the deprecated `attrs` option. Non-existent attributes on elements that
|
|
15
|
+
* allow additional properties (pretenders) can be optionally permitted.
|
|
16
|
+
*/
|
|
7
17
|
export default createRule({
|
|
8
18
|
meta: meta,
|
|
9
19
|
defaultOptions: {},
|
|
@@ -216,6 +226,13 @@ export default createRule({
|
|
|
216
226
|
});
|
|
217
227
|
},
|
|
218
228
|
});
|
|
229
|
+
/**
|
|
230
|
+
* Determines whether the given value is a {@link ValueRule} (enum, pattern,
|
|
231
|
+
* or simple type constraint) as opposed to a raw {@link AttributeType}.
|
|
232
|
+
*
|
|
233
|
+
* @param value - The value to inspect.
|
|
234
|
+
* @returns `true` if the value is a {@link ValueRule}, `false` otherwise.
|
|
235
|
+
*/
|
|
219
236
|
function isValueRule(
|
|
220
237
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
221
238
|
value) {
|
package/lib/invalid-attr/meta.js
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that validates `<label>` elements are properly associated with form controls.
|
|
3
|
+
*
|
|
4
|
+
* Checks that each label either wraps a control or has a `for` attribute,
|
|
5
|
+
* and warns when a label contains more than one form control (only the first
|
|
6
|
+
* is associated per the HTML spec).
|
|
7
|
+
*/
|
|
1
8
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
9
|
export default _default;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { createRule } from '@markuplint/ml-core';
|
|
2
2
|
import meta from './meta.js';
|
|
3
|
+
/**
|
|
4
|
+
* CSS selector that matches form control elements eligible for label association.
|
|
5
|
+
* Excludes hidden inputs since they do not need labels.
|
|
6
|
+
*/
|
|
3
7
|
const controlSelector = ["input:not([type='hidden' i])", 'select', 'textarea'].join(',');
|
|
8
|
+
/**
|
|
9
|
+
* Rule that validates `<label>` elements are properly associated with form controls.
|
|
10
|
+
*
|
|
11
|
+
* Checks that each label either wraps a control or has a `for` attribute,
|
|
12
|
+
* and warns when a label contains more than one form control (only the first
|
|
13
|
+
* is associated per the HTML spec).
|
|
14
|
+
*/
|
|
4
15
|
export default createRule({
|
|
5
16
|
meta: meta,
|
|
6
17
|
defaultSeverity: 'warning',
|
|
@@ -1,8 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration options for the landmark-roles rule.
|
|
3
|
+
*/
|
|
1
4
|
type Options = {
|
|
5
|
+
/** Landmark roles to exclude from validation. */
|
|
2
6
|
ignoreRoles: Roles[];
|
|
7
|
+
/** Whether to require a unique accessible name when duplicate landmark roles exist. */
|
|
3
8
|
labelEachArea: boolean;
|
|
4
9
|
};
|
|
10
|
+
/** Landmark roles that should appear at the top level of the document. */
|
|
5
11
|
type TopLevelRoles = 'banner' | 'main' | 'complementary' | 'contentinfo';
|
|
12
|
+
/** All recognized ARIA landmark roles for this rule. */
|
|
6
13
|
type Roles = TopLevelRoles | 'form' | 'navigation' | 'region';
|
|
14
|
+
/**
|
|
15
|
+
* Rule that validates proper usage of ARIA landmark roles.
|
|
16
|
+
*
|
|
17
|
+
* Checks that `banner`, `main`, `complementary`, and `contentinfo` landmarks are
|
|
18
|
+
* top-level (not nested inside other landmarks), and that when duplicate landmarks
|
|
19
|
+
* of the same role exist, each has a unique accessible name.
|
|
20
|
+
*/
|
|
7
21
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
|
|
8
22
|
export default _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createRule } from '@markuplint/ml-core';
|
|
2
2
|
import meta from './meta.js';
|
|
3
|
+
/** CSS selectors used to identify elements with each landmark role. */
|
|
3
4
|
const selectors = {
|
|
4
5
|
complementary: ['[role="complementary"]', 'aside'],
|
|
5
6
|
contentinfo: ['[role="contentinfo"]'],
|
|
@@ -9,7 +10,15 @@ const selectors = {
|
|
|
9
10
|
navigation: ['[role="navigation"]', 'nav'],
|
|
10
11
|
region: ['[role="region"]', 'section[aria-labelledby]', 'section[aria-label]', 'section[title]'],
|
|
11
12
|
};
|
|
13
|
+
/** Roles that are required to be top-level landmarks per WAI-ARIA practices. */
|
|
12
14
|
const topLevelRoles = ['banner', 'main', 'complementary', 'contentinfo'];
|
|
15
|
+
/**
|
|
16
|
+
* Rule that validates proper usage of ARIA landmark roles.
|
|
17
|
+
*
|
|
18
|
+
* Checks that `banner`, `main`, `complementary`, and `contentinfo` landmarks are
|
|
19
|
+
* top-level (not nested inside other landmarks), and that when duplicate landmarks
|
|
20
|
+
* of the same role exist, each has a unique accessible name.
|
|
21
|
+
*/
|
|
13
22
|
export default createRule({
|
|
14
23
|
meta: meta,
|
|
15
24
|
defaultSeverity: 'warning',
|
|
@@ -105,11 +114,23 @@ export default createRule({
|
|
|
105
114
|
}
|
|
106
115
|
},
|
|
107
116
|
});
|
|
117
|
+
/**
|
|
118
|
+
* Collects all UUIDs of elements that have landmark roles.
|
|
119
|
+
*
|
|
120
|
+
* @param roleset - The mapping of roles to their matched elements.
|
|
121
|
+
* @returns A flat array of UUIDs for all landmark role elements.
|
|
122
|
+
*/
|
|
108
123
|
function landmarkRoleElementUUIDList(
|
|
109
124
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
110
125
|
roleset) {
|
|
111
126
|
return Object.values(roleset).flatMap(elements => elements.map(element => element.uuid));
|
|
112
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Checks whether an element has an accessible label via `aria-label` or `aria-labelledby`.
|
|
130
|
+
*
|
|
131
|
+
* @param el - The landmark element to check.
|
|
132
|
+
* @returns `true` if the element has an accessible name, `false` otherwise.
|
|
133
|
+
*/
|
|
113
134
|
function hasLabel(
|
|
114
135
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
115
136
|
el) {
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that detects perceptible content between a popover trigger and its target.
|
|
3
|
+
*
|
|
4
|
+
* When a `[popovertarget]` element or a `[commandfor]` element with a popover-related
|
|
5
|
+
* `command` attribute and its corresponding `[popover]` target exist in the DOM, any
|
|
6
|
+
* focusable elements, elements with accessible names, or non-whitespace text nodes
|
|
7
|
+
* between them are reported as violations.
|
|
8
|
+
*/
|
|
1
9
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
10
|
export default _default;
|
|
@@ -2,13 +2,37 @@ import { createRule } from '@markuplint/ml-core';
|
|
|
2
2
|
import { mayBeFocusable } from '@markuplint/ml-spec';
|
|
3
3
|
import meta from './meta.js';
|
|
4
4
|
// TODO: It will be received from config
|
|
5
|
+
/** The ARIA specification version used for accessible name computation. */
|
|
5
6
|
const ARIA_VERSION = '1.2';
|
|
7
|
+
/**
|
|
8
|
+
* Command values from the Invoker Commands API that relate to popover behavior.
|
|
9
|
+
* Comparison is case-insensitive per the HTML spec.
|
|
10
|
+
*/
|
|
11
|
+
const POPOVER_COMMANDS = new Set(['toggle-popover', 'show-popover', 'hide-popover']);
|
|
12
|
+
/**
|
|
13
|
+
* Rule that detects perceptible content between a popover trigger and its target.
|
|
14
|
+
*
|
|
15
|
+
* When a `[popovertarget]` element or a `[commandfor]` element with a popover-related
|
|
16
|
+
* `command` attribute and its corresponding `[popover]` target exist in the DOM, any
|
|
17
|
+
* focusable elements, elements with accessible names, or non-whitespace text nodes
|
|
18
|
+
* between them are reported as violations.
|
|
19
|
+
*/
|
|
6
20
|
export default createRule({
|
|
7
21
|
meta: meta,
|
|
8
22
|
verify({ document, report, t }) {
|
|
9
|
-
const triggers = document.querySelectorAll('[popovertarget]');
|
|
23
|
+
const triggers = document.querySelectorAll('[popovertarget], [commandfor]');
|
|
10
24
|
Triggers: for (const trigger of triggers) {
|
|
11
|
-
|
|
25
|
+
let targetId = null;
|
|
26
|
+
const popovertarget = trigger.getAttribute('popovertarget');
|
|
27
|
+
if (popovertarget) {
|
|
28
|
+
targetId = popovertarget;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const command = trigger.getAttribute('command');
|
|
32
|
+
if (command && POPOVER_COMMANDS.has(command.toLowerCase())) {
|
|
33
|
+
targetId = trigger.getAttribute('commandfor');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
12
36
|
if (!targetId) {
|
|
13
37
|
continue;
|
|
14
38
|
}
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that warns against ambiguous navigable target names.
|
|
3
|
+
*
|
|
4
|
+
* Detects attribute values (e.g., `target`) that look like browsing context
|
|
5
|
+
* keywords (such as `_blank`, `_self`) but are missing the leading underscore,
|
|
6
|
+
* which would make them navigable target names instead of keywords. Suggests
|
|
7
|
+
* adding the underscore prefix when applicable.
|
|
8
|
+
*/
|
|
1
9
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
|
|
2
10
|
export default _default;
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
2
|
import { valueCheck } from '../attr-check.js';
|
|
3
3
|
import meta from './meta.js';
|
|
4
|
+
/**
|
|
5
|
+
* Rule that warns against ambiguous navigable target names.
|
|
6
|
+
*
|
|
7
|
+
* Detects attribute values (e.g., `target`) that look like browsing context
|
|
8
|
+
* keywords (such as `_blank`, `_self`) but are missing the leading underscore,
|
|
9
|
+
* which would make them navigable target names instead of keywords. Suggests
|
|
10
|
+
* adding the underscore prefix when applicable.
|
|
11
|
+
*/
|
|
4
12
|
export default createRule({
|
|
5
13
|
meta: meta,
|
|
6
14
|
defaultSeverity: 'warning',
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that disallows explicit values on boolean attributes.
|
|
3
|
+
*
|
|
4
|
+
* Checks each attribute against the HTML spec and reports when a boolean
|
|
5
|
+
* attribute (e.g., `disabled`, `checked`) is written with an explicit value
|
|
6
|
+
* such as `disabled="disabled"` instead of the bare attribute name.
|
|
7
|
+
*/
|
|
1
8
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
9
|
export default _default;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
2
|
import meta from './meta.js';
|
|
3
|
+
/**
|
|
4
|
+
* Rule that disallows explicit values on boolean attributes.
|
|
5
|
+
*
|
|
6
|
+
* Checks each attribute against the HTML spec and reports when a boolean
|
|
7
|
+
* attribute (e.g., `disabled`, `checked`) is written with an explicit value
|
|
8
|
+
* such as `disabled="disabled"` instead of the bare attribute name.
|
|
9
|
+
*/
|
|
3
10
|
export default createRule({
|
|
4
11
|
meta: meta,
|
|
5
12
|
defaultSeverity: 'warning',
|
|
@@ -1,2 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that disallows consecutive `<br>` elements.
|
|
3
|
+
*
|
|
4
|
+
* Queries all `<br>` elements in the document and checks whether the next
|
|
5
|
+
* non-whitespace sibling is another `<br>`. Consecutive line breaks are
|
|
6
|
+
* typically a sign that a more semantic element (e.g., `<p>`) should be
|
|
7
|
+
* used instead, which is important for accessibility.
|
|
8
|
+
*/
|
|
1
9
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
10
|
export default _default;
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import { createRule } from '@markuplint/ml-core';
|
|
2
2
|
import meta from './meta.js';
|
|
3
|
+
/**
|
|
4
|
+
* Rule that disallows consecutive `<br>` elements.
|
|
5
|
+
*
|
|
6
|
+
* Queries all `<br>` elements in the document and checks whether the next
|
|
7
|
+
* non-whitespace sibling is another `<br>`. Consecutive line breaks are
|
|
8
|
+
* typically a sign that a more semantic element (e.g., `<p>`) should be
|
|
9
|
+
* used instead, which is important for accessibility.
|
|
10
|
+
*/
|
|
3
11
|
export default createRule({
|
|
4
12
|
meta: meta,
|
|
5
13
|
defaultSeverity: 'warning',
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that disallows explicitly setting an attribute to its default value.
|
|
3
|
+
*
|
|
4
|
+
* Looks up each attribute's default value from the spec and reports when
|
|
5
|
+
* the authored value matches the default, since the attribute can be
|
|
6
|
+
* omitted entirely for the same effect.
|
|
7
|
+
*/
|
|
1
8
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
9
|
export default _default;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
2
|
import { toNormalizedValue } from '../helpers.js';
|
|
3
3
|
import meta from './meta.js';
|
|
4
|
+
/**
|
|
5
|
+
* Rule that disallows explicitly setting an attribute to its default value.
|
|
6
|
+
*
|
|
7
|
+
* Looks up each attribute's default value from the spec and reports when
|
|
8
|
+
* the authored value matches the default, since the attribute can be
|
|
9
|
+
* omitted entirely for the same effect.
|
|
10
|
+
*/
|
|
4
11
|
export default createRule({
|
|
5
12
|
meta: meta,
|
|
6
13
|
defaultSeverity: 'warning',
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rule that validates there are no duplicate `<dt>` elements within a `<dl>`.
|
|
3
|
+
*
|
|
4
|
+
* Iterates through each definition list and checks that no two `<dt>` elements
|
|
5
|
+
* (direct children or wrapped in `<div>`) share the same text content.
|
|
6
|
+
*/
|
|
1
7
|
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
2
8
|
export default _default;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { createRule } from '@markuplint/ml-core';
|
|
2
2
|
import meta from './meta.js';
|
|
3
|
+
/**
|
|
4
|
+
* Rule that validates there are no duplicate `<dt>` elements within a `<dl>`.
|
|
5
|
+
*
|
|
6
|
+
* Iterates through each definition list and checks that no two `<dt>` elements
|
|
7
|
+
* (direct children or wrapped in `<div>`) share the same text content.
|
|
8
|
+
*/
|
|
3
9
|
export default createRule({
|
|
4
10
|
meta: meta,
|
|
5
11
|
verify({ document, report, t }) {
|