@markuplint/rules 3.6.1 → 3.8.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/lib/attr-check.d.ts +19 -8
- package/lib/helpers.d.ts +35 -17
- package/lib/index.d.ts +99 -172
- package/lib/invalid-attr/index.d.ts +28 -5
- package/lib/invalid-attr/index.js +139 -20
- package/lib/no-refer-to-non-existent-id/index.d.ts +1 -2
- package/lib/no-refer-to-non-existent-id/index.js +2 -1
- package/lib/permitted-contents/utils.d.ts +41 -90
- package/lib/require-accessible-name/index.js +1 -1
- package/lib/required-attr/index.d.ts +1 -1
- package/lib/required-attr/index.js +1 -1
- package/lib/wai-aria/checkings/_.d.ts +9 -0
- package/lib/wai-aria/checkings/_.js +27 -0
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +4 -8
- package/lib/wai-aria/checkings/required-prop copy.d.ts +9 -0
- package/lib/wai-aria/checkings/required-prop copy.js +27 -0
- package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +9 -0
- package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
- package/lib/wai-aria/index.js +2 -1
- package/package.json +6 -6
package/lib/attr-check.d.ts
CHANGED
|
@@ -2,14 +2,14 @@ import type { Translator } from '@markuplint/i18n';
|
|
|
2
2
|
import type { Attribute as AttrSpec, AttributeType } from '@markuplint/ml-spec';
|
|
3
3
|
import type { ReadonlyDeep } from 'type-fest';
|
|
4
4
|
type Invalid = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
|
|
6
|
+
message: string;
|
|
7
|
+
loc?: Loc;
|
|
8
8
|
};
|
|
9
9
|
type Loc = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
raw: string;
|
|
11
|
+
line: number;
|
|
12
|
+
col: number;
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Use in rules `invalid-attr` and `wai-aria`
|
|
@@ -19,6 +19,17 @@ type Loc = {
|
|
|
19
19
|
* @param isCustomRule
|
|
20
20
|
* @param spec
|
|
21
21
|
*/
|
|
22
|
-
export declare function attrCheck(
|
|
23
|
-
|
|
22
|
+
export declare function attrCheck(
|
|
23
|
+
t: Translator,
|
|
24
|
+
name: string,
|
|
25
|
+
value: string,
|
|
26
|
+
isCustomRule: boolean,
|
|
27
|
+
spec?: AttrSpec,
|
|
28
|
+
): Invalid | false;
|
|
29
|
+
export declare function valueCheck(
|
|
30
|
+
t: Translator,
|
|
31
|
+
name: string,
|
|
32
|
+
value: string,
|
|
33
|
+
type: ReadonlyDeep<AttributeType>,
|
|
34
|
+
): [string, Loc] | false;
|
|
24
35
|
export {};
|
package/lib/helpers.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ import type { Translator } from '@markuplint/i18n';
|
|
|
3
3
|
import type { PlainData } from '@markuplint/ml-config';
|
|
4
4
|
import type { Element, RuleConfigValue, Document } from '@markuplint/ml-core';
|
|
5
5
|
import type { Attribute } from '@markuplint/ml-spec';
|
|
6
|
-
export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(
|
|
6
|
+
export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(
|
|
7
|
+
node: Element<T, O>,
|
|
8
|
+
condition: Attribute['condition'],
|
|
9
|
+
): boolean;
|
|
7
10
|
export declare function match(needle: string, pattern: string): boolean;
|
|
8
11
|
/**
|
|
9
12
|
* PotentialCustomElementName
|
|
@@ -21,27 +24,42 @@ export declare function match(needle: string, pattern: string): boolean;
|
|
|
21
24
|
* Originally, it is not possible to define a name including ASCII upper alphas in the custom element, but it is not treated as illegal by the HTML parser.
|
|
22
25
|
*/
|
|
23
26
|
export declare const rePCENChar: string;
|
|
24
|
-
export declare function isValidAttr(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
export declare function isValidAttr(
|
|
28
|
+
t: Translator,
|
|
29
|
+
name: string,
|
|
30
|
+
value: string,
|
|
31
|
+
isDynamicValue: boolean,
|
|
32
|
+
node: Element<any, any>,
|
|
33
|
+
attrSpecs: readonly Attribute[],
|
|
34
|
+
log?: Log,
|
|
35
|
+
):
|
|
36
|
+
| false
|
|
37
|
+
| {
|
|
38
|
+
invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
|
|
39
|
+
message: string;
|
|
40
|
+
loc?:
|
|
41
|
+
| {
|
|
42
|
+
raw: string;
|
|
43
|
+
line: number;
|
|
44
|
+
col: number;
|
|
45
|
+
}
|
|
46
|
+
| undefined;
|
|
47
|
+
};
|
|
33
48
|
export declare function toNormalizedValue(value: string, spec: Attribute): string;
|
|
34
49
|
export declare function accnameMayBeMutable(el: Element<any, any>, document: Document<any, any>): boolean;
|
|
35
|
-
export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(
|
|
50
|
+
export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(
|
|
51
|
+
el: Element<V, O>,
|
|
52
|
+
document: Document<V, O>,
|
|
53
|
+
): Element<V, O> | null;
|
|
36
54
|
export declare class Collection<T> {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
55
|
+
#private;
|
|
56
|
+
constructor(...items: readonly (T | null | undefined)[]);
|
|
57
|
+
[Symbol.iterator](): Iterator<T>;
|
|
58
|
+
add(...items: readonly (T | null | undefined)[]): void;
|
|
59
|
+
toArray(): readonly T[];
|
|
42
60
|
}
|
|
43
61
|
type Writeable<T> = {
|
|
44
|
-
|
|
62
|
+
-readonly [P in keyof T]: T[P];
|
|
45
63
|
};
|
|
46
64
|
export declare function deepCopy<T>(value: T): Writeable<T>;
|
|
47
65
|
export {};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,175 +1,102 @@
|
|
|
1
1
|
declare const rules: {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
102
|
-
>;
|
|
103
|
-
readonly 'no-refer-to-non-existent-id': Readonly<
|
|
104
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
105
|
-
import('@markuplint/ml-core').RuleConfigValue,
|
|
106
|
-
{
|
|
107
|
-
ariaVersion: import('packages/@markuplint/ml-spec/lib').ARIAVersion;
|
|
108
|
-
fragmentRefersNameAttr: boolean;
|
|
109
|
-
}
|
|
110
|
-
>
|
|
111
|
-
>;
|
|
112
|
-
readonly 'no-use-event-handler-attr': Readonly<
|
|
113
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
114
|
-
boolean,
|
|
115
|
-
{
|
|
116
|
-
ignore?: string | string[] | undefined;
|
|
117
|
-
}
|
|
118
|
-
>
|
|
119
|
-
>;
|
|
120
|
-
readonly 'permitted-contents': Readonly<
|
|
121
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
122
|
-
import('./permitted-contents/types').TagRule[],
|
|
123
|
-
import('./permitted-contents/types').Options
|
|
124
|
-
>
|
|
125
|
-
>;
|
|
126
|
-
readonly 'placeholder-label-option': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
|
|
127
|
-
readonly 'require-accessible-name': Readonly<
|
|
128
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
129
|
-
boolean,
|
|
130
|
-
{
|
|
131
|
-
ariaVersion: import('packages/@markuplint/ml-spec/lib').ARIAVersion;
|
|
132
|
-
}
|
|
133
|
-
>
|
|
134
|
-
>;
|
|
135
|
-
readonly 'require-datetime': Readonly<
|
|
136
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
137
|
-
boolean,
|
|
138
|
-
{
|
|
139
|
-
langs?: import('./require-datetime/types').Lang[] | undefined;
|
|
140
|
-
}
|
|
141
|
-
>
|
|
142
|
-
>;
|
|
143
|
-
readonly 'required-attr': Readonly<
|
|
144
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
145
|
-
| string
|
|
146
|
-
| (
|
|
147
|
-
| string
|
|
148
|
-
| {
|
|
149
|
-
name: string;
|
|
150
|
-
value: string | string[];
|
|
151
|
-
}
|
|
152
|
-
)[],
|
|
153
|
-
undefined
|
|
154
|
-
>
|
|
155
|
-
>;
|
|
156
|
-
readonly 'required-element': Readonly<
|
|
157
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
158
|
-
string[],
|
|
159
|
-
{
|
|
160
|
-
ignoreHasMutableContents: boolean;
|
|
161
|
-
}
|
|
162
|
-
>
|
|
163
|
-
>;
|
|
164
|
-
readonly 'required-h1': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, import('./required-h1').Options>>;
|
|
165
|
-
readonly 'use-list': Readonly<
|
|
166
|
-
import('@markuplint/ml-core').RuleSeed<
|
|
167
|
-
readonly string[],
|
|
168
|
-
{
|
|
169
|
-
spaceNeededBullets?: string[] | undefined;
|
|
170
|
-
}
|
|
171
|
-
>
|
|
172
|
-
>;
|
|
173
|
-
readonly 'wai-aria': Readonly<import('@markuplint/ml-core').RuleSeed<boolean, import('./wai-aria/types').Options>>;
|
|
2
|
+
readonly 'attr-duplication': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
3
|
+
readonly 'attr-value-quotes': Readonly<import("@markuplint/ml-core").RuleSeed<import("./attr-value-quotes").Type, undefined>>;
|
|
4
|
+
readonly 'case-sensitive-attr-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-attr-name").Value, undefined>>;
|
|
5
|
+
readonly 'case-sensitive-tag-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-tag-name").Value, undefined>>;
|
|
6
|
+
readonly 'character-reference': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
7
|
+
readonly 'class-naming': Readonly<import("@markuplint/ml-core").RuleSeed<import("./class-naming").Value, undefined>>;
|
|
8
|
+
readonly 'deprecated-attr': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
9
|
+
readonly 'deprecated-element': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
10
|
+
readonly 'disallowed-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], undefined>>;
|
|
11
|
+
readonly doctype: Readonly<import("@markuplint/ml-core").RuleSeed<"always", {
|
|
12
|
+
denyObsoleteType: boolean;
|
|
13
|
+
}>>;
|
|
14
|
+
readonly 'end-tag': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
|
|
15
|
+
readonly 'id-duplication': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
16
|
+
readonly 'ineffective-attr': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
17
|
+
readonly 'invalid-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
18
|
+
allowAttrs?: Record<string, {
|
|
19
|
+
enum: [string, ...string[]];
|
|
20
|
+
} | {
|
|
21
|
+
pattern: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
24
|
+
}> | (string | {
|
|
25
|
+
name: string;
|
|
26
|
+
value: import("packages/@markuplint/ml-spec/src").AttributeType | ({
|
|
27
|
+
enum: [string, ...string[]];
|
|
28
|
+
} | {
|
|
29
|
+
pattern: string;
|
|
30
|
+
} | {
|
|
31
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
32
|
+
});
|
|
33
|
+
})[] | undefined;
|
|
34
|
+
disallowAttrs?: Record<string, {
|
|
35
|
+
enum: [string, ...string[]];
|
|
36
|
+
} | {
|
|
37
|
+
pattern: string;
|
|
38
|
+
} | {
|
|
39
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
40
|
+
}> | (string | {
|
|
41
|
+
name: string;
|
|
42
|
+
value: import("packages/@markuplint/ml-spec/src").AttributeType | ({
|
|
43
|
+
enum: [string, ...string[]];
|
|
44
|
+
} | {
|
|
45
|
+
pattern: string;
|
|
46
|
+
} | {
|
|
47
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
48
|
+
});
|
|
49
|
+
})[] | undefined;
|
|
50
|
+
ignoreAttrNamePrefix?: string | string[] | undefined;
|
|
51
|
+
allowToAddPropertiesForPretender?: boolean | undefined;
|
|
52
|
+
attrs?: Record<string, ({
|
|
53
|
+
enum: [string, ...string[]];
|
|
54
|
+
} | {
|
|
55
|
+
pattern: string;
|
|
56
|
+
} | {
|
|
57
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
58
|
+
}) | {
|
|
59
|
+
disallowed: true;
|
|
60
|
+
}> | undefined;
|
|
61
|
+
}>>;
|
|
62
|
+
readonly 'label-has-control': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
63
|
+
readonly 'landmark-roles': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
64
|
+
ignoreRoles: (("banner" | "main" | "complementary" | "contentinfo") | "form" | "navigation" | "region")[];
|
|
65
|
+
labelEachArea: boolean;
|
|
66
|
+
}>>;
|
|
67
|
+
readonly 'no-boolean-attr-value': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
68
|
+
readonly 'no-default-value': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
69
|
+
readonly 'no-empty-palpable-content': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
70
|
+
extendsExposableElements?: boolean | undefined;
|
|
71
|
+
ignoreIfAriaBusy?: boolean | undefined;
|
|
72
|
+
}>>;
|
|
73
|
+
readonly 'no-hard-code-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
74
|
+
readonly 'no-refer-to-non-existent-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
|
|
75
|
+
ariaVersion: "1.1" | "1.2" | "1.3";
|
|
76
|
+
fragmentRefersNameAttr: boolean;
|
|
77
|
+
}>>;
|
|
78
|
+
readonly 'no-use-event-handler-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
79
|
+
ignore?: string | string[] | undefined;
|
|
80
|
+
}>>;
|
|
81
|
+
readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types").TagRule[], import("./permitted-contents/types").Options>>;
|
|
82
|
+
readonly 'placeholder-label-option': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
|
|
83
|
+
readonly 'require-accessible-name': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
84
|
+
ariaVersion: "1.1" | "1.2" | "1.3";
|
|
85
|
+
}>>;
|
|
86
|
+
readonly 'require-datetime': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
87
|
+
langs?: import("./require-datetime/types").Lang[] | undefined;
|
|
88
|
+
}>>;
|
|
89
|
+
readonly 'required-attr': Readonly<import("@markuplint/ml-core").RuleSeed<string | (string | {
|
|
90
|
+
name: string;
|
|
91
|
+
value?: string | string[] | undefined;
|
|
92
|
+
})[], undefined>>;
|
|
93
|
+
readonly 'required-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], {
|
|
94
|
+
ignoreHasMutableContents: boolean;
|
|
95
|
+
}>>;
|
|
96
|
+
readonly 'required-h1': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./required-h1").Options>>;
|
|
97
|
+
readonly 'use-list': Readonly<import("@markuplint/ml-core").RuleSeed<readonly string[], {
|
|
98
|
+
spaceNeededBullets?: string[] | undefined;
|
|
99
|
+
}>>;
|
|
100
|
+
readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types").Options>>;
|
|
174
101
|
};
|
|
175
102
|
export default rules;
|
|
@@ -1,10 +1,36 @@
|
|
|
1
1
|
import type { AttributeType } from '@markuplint/ml-spec';
|
|
2
2
|
type Option = {
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @since 3.7.0
|
|
5
|
+
*/
|
|
6
|
+
allowAttrs?: (string | Attr)[] | Record<string, ValueRule>;
|
|
7
|
+
/**
|
|
8
|
+
* @since 3.7.0
|
|
9
|
+
*/
|
|
10
|
+
disallowAttrs?: (string | Attr)[] | Record<string, ValueRule>;
|
|
4
11
|
ignoreAttrNamePrefix?: string | string[];
|
|
5
12
|
allowToAddPropertiesForPretender?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Since version 3.7.0. Use `allowAttrs` or `disallowAttrs` instead.
|
|
15
|
+
* This option (`attr`) is now considered ambiguous and may lead to confusion.
|
|
16
|
+
* Please use the more explicit `allowAttrs` or `disallowAttrs` option
|
|
17
|
+
* to specify allowed attributes for the `invalid-attr` rule.
|
|
18
|
+
* @see {@link Option.allowAttrs}
|
|
19
|
+
* @see {@link Option.disallowAttrs}
|
|
20
|
+
*/
|
|
21
|
+
attrs?: Record<
|
|
22
|
+
string,
|
|
23
|
+
| ValueRule
|
|
24
|
+
| {
|
|
25
|
+
disallowed: true;
|
|
26
|
+
}
|
|
27
|
+
>;
|
|
6
28
|
};
|
|
7
|
-
type
|
|
29
|
+
type Attr = {
|
|
30
|
+
name: string;
|
|
31
|
+
value: AttributeType | ValueRule;
|
|
32
|
+
};
|
|
33
|
+
type ValueRule =
|
|
8
34
|
| {
|
|
9
35
|
enum: [string, ...string[]];
|
|
10
36
|
}
|
|
@@ -13,9 +39,6 @@ type Rule =
|
|
|
13
39
|
}
|
|
14
40
|
| {
|
|
15
41
|
type: AttributeType;
|
|
16
|
-
}
|
|
17
|
-
| {
|
|
18
|
-
disallowed: true;
|
|
19
42
|
};
|
|
20
43
|
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Option>>;
|
|
21
44
|
export default _default;
|
|
@@ -9,7 +9,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
9
9
|
defaultOptions: {},
|
|
10
10
|
async verify({ document, report, t }) {
|
|
11
11
|
await document.walkOn('Attr', attr => {
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
12
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
13
13
|
// Default
|
|
14
14
|
const allowToAddPropertiesForPretender = (_a = attr.rule.options.allowToAddPropertiesForPretender) !== null && _a !== void 0 ? _a : true;
|
|
15
15
|
if (attr.isDirective) {
|
|
@@ -42,33 +42,126 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
let invalid = false;
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
const allowAttrs = {};
|
|
46
|
+
const disallowAttrs = {};
|
|
47
|
+
if (attr.rule.options.allowAttrs) {
|
|
48
|
+
if (Array.isArray(attr.rule.options.allowAttrs)) {
|
|
49
|
+
for (const allowAttr of attr.rule.options.allowAttrs) {
|
|
50
|
+
if (typeof allowAttr === 'string') {
|
|
51
|
+
allowAttrs[allowAttr] = { type: 'Any' };
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
if (isValueRule(allowAttr.value)) {
|
|
55
|
+
allowAttrs[allowAttr.name] = allowAttr.value;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
allowAttrs[allowAttr.name] = { type: allowAttr.value };
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
for (const [attrName, valueRule] of Object.entries(attr.rule.options.allowAttrs)) {
|
|
63
|
+
allowAttrs[attrName] = valueRule;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (attr.rule.options.disallowAttrs) {
|
|
68
|
+
if (Array.isArray(attr.rule.options.disallowAttrs)) {
|
|
69
|
+
for (const disallowAttr of attr.rule.options.disallowAttrs) {
|
|
70
|
+
if (typeof disallowAttr === 'string') {
|
|
71
|
+
disallowAttrs[disallowAttr] = { type: 'Any' };
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (isValueRule(disallowAttr.value)) {
|
|
75
|
+
disallowAttrs[disallowAttr.name] = disallowAttr.value;
|
|
76
|
+
continue;
|
|
77
|
+
}
|
|
78
|
+
disallowAttrs[disallowAttr.name] = { type: disallowAttr.value };
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
for (const [attrName, valueRule] of Object.entries(attr.rule.options.disallowAttrs)) {
|
|
83
|
+
disallowAttrs[attrName] = valueRule;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (attr.rule.options.attrs) {
|
|
88
|
+
for (const [attrName, valueRule] of Object.entries(attr.rule.options.attrs)) {
|
|
89
|
+
if ('disallowed' in valueRule) {
|
|
90
|
+
disallowAttrs[attrName] = { type: 'Any' };
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
allowAttrs[attrName] = valueRule;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const allowValue = (_b = allowAttrs[name]) !== null && _b !== void 0 ? _b : null;
|
|
98
|
+
const disallowValue = (_c = disallowAttrs[name]) !== null && _c !== void 0 ? _c : null;
|
|
99
|
+
if (allowValue) {
|
|
100
|
+
if ('enum' in allowValue) {
|
|
48
101
|
invalid = (0, attr_check_1.attrCheck)(t, name.toLowerCase(), value, true, {
|
|
49
102
|
name,
|
|
50
103
|
type: {
|
|
51
|
-
enum:
|
|
104
|
+
enum: allowValue.enum,
|
|
52
105
|
},
|
|
53
106
|
description: '',
|
|
54
107
|
});
|
|
55
108
|
}
|
|
56
|
-
else if ('pattern' in
|
|
57
|
-
if (!(0, helpers_1.match)(value,
|
|
109
|
+
else if ('pattern' in allowValue) {
|
|
110
|
+
if (!(0, helpers_1.match)(value, allowValue.pattern)) {
|
|
111
|
+
invalid = {
|
|
112
|
+
invalidType: 'invalid-value',
|
|
113
|
+
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), allowValue.pattern),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
else if ('type' in allowValue) {
|
|
118
|
+
invalid = (0, attr_check_1.attrCheck)(t, name, value, true, { name, type: allowValue.type, description: '' });
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else if (disallowValue) {
|
|
122
|
+
if ('enum' in disallowValue) {
|
|
123
|
+
const checkResult = (0, attr_check_1.attrCheck)(t, name.toLowerCase(), value, true, {
|
|
124
|
+
name,
|
|
125
|
+
type: {
|
|
126
|
+
enum: disallowValue.enum,
|
|
127
|
+
},
|
|
128
|
+
description: '',
|
|
129
|
+
});
|
|
130
|
+
if (checkResult === false) {
|
|
58
131
|
invalid = {
|
|
59
132
|
invalidType: 'invalid-value',
|
|
60
|
-
message: t('{0} is
|
|
133
|
+
message: t('{0} is disallowed to accept the following values: {1}', t('the "{0*}" {1}', name, 'attribute'), t(disallowValue.enum)),
|
|
61
134
|
};
|
|
62
135
|
}
|
|
63
136
|
}
|
|
64
|
-
else if ('
|
|
65
|
-
|
|
137
|
+
else if ('pattern' in disallowValue) {
|
|
138
|
+
if ((0, helpers_1.match)(value, disallowValue.pattern)) {
|
|
139
|
+
invalid = {
|
|
140
|
+
invalidType: 'invalid-value',
|
|
141
|
+
message: t('{0} is matched with the below disallowed patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), disallowValue.pattern),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
66
144
|
}
|
|
67
|
-
else if ('
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
145
|
+
else if ('type' in disallowValue) {
|
|
146
|
+
if (disallowValue.type === 'Any') {
|
|
147
|
+
invalid = {
|
|
148
|
+
invalidType: 'non-existent',
|
|
149
|
+
message: t('{0} is disallowed', t('the "{0*}" {1}', name, 'attribute')),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
const checkResult = (0, attr_check_1.attrCheck)(t, name, value, true, {
|
|
154
|
+
name,
|
|
155
|
+
type: disallowValue.type,
|
|
156
|
+
description: '',
|
|
157
|
+
});
|
|
158
|
+
if (checkResult === false) {
|
|
159
|
+
invalid = {
|
|
160
|
+
invalidType: 'invalid-value',
|
|
161
|
+
message: t('{0} is disallowed', t('{0} of {1}', t('the {0}', 'type'), t('the "{0*}" {1}', name, 'attribute'))),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
}
|
|
72
165
|
}
|
|
73
166
|
}
|
|
74
167
|
else if (attr.ownerElement.elementType === 'html' && attrSpecs) {
|
|
@@ -91,16 +184,16 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
91
184
|
report({
|
|
92
185
|
scope: attr,
|
|
93
186
|
message: invalid.message,
|
|
94
|
-
line: ((
|
|
187
|
+
line: ((_d = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startLine) !== null && _d !== void 0 ? _d : 0) + ((_f = (_e = invalid.loc) === null || _e === void 0 ? void 0 : _e.line) !== null && _f !== void 0 ? _f : 0),
|
|
95
188
|
col: invalid.loc && invalid.loc.line > 0
|
|
96
|
-
? ((
|
|
97
|
-
: ((
|
|
98
|
-
raw: (
|
|
189
|
+
? ((_g = invalid.loc) === null || _g === void 0 ? void 0 : _g.col) + 1
|
|
190
|
+
: ((_h = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startCol) !== null && _h !== void 0 ? _h : 0) + ((_k = (_j = invalid.loc) === null || _j === void 0 ? void 0 : _j.col) !== null && _k !== void 0 ? _k : 0),
|
|
191
|
+
raw: (_m = (_l = invalid.loc) === null || _l === void 0 ? void 0 : _l.raw) !== null && _m !== void 0 ? _m : value,
|
|
99
192
|
});
|
|
100
193
|
break;
|
|
101
194
|
}
|
|
102
195
|
case 'non-existent': {
|
|
103
|
-
if (allowToAddPropertiesForPretender && ((
|
|
196
|
+
if (allowToAddPropertiesForPretender && ((_o = attr.ownerElement.pretenderContext) === null || _o === void 0 ? void 0 : _o.type) === 'origin') {
|
|
104
197
|
return;
|
|
105
198
|
}
|
|
106
199
|
const spec = (0, ml_core_1.getSpec)(attr.ownerElement, document.specs.specs);
|
|
@@ -120,3 +213,29 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
120
213
|
});
|
|
121
214
|
},
|
|
122
215
|
});
|
|
216
|
+
function isValueRule(
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
218
|
+
value) {
|
|
219
|
+
if (typeof value === 'string') {
|
|
220
|
+
return false;
|
|
221
|
+
}
|
|
222
|
+
if ('enum' in value) {
|
|
223
|
+
if (Object.keys(value).length > 1) {
|
|
224
|
+
return false;
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
if ('token' in value) {
|
|
229
|
+
return false;
|
|
230
|
+
}
|
|
231
|
+
if ('pattern' in value) {
|
|
232
|
+
return true;
|
|
233
|
+
}
|
|
234
|
+
if (value.type === 'integer' || value.type === 'float') {
|
|
235
|
+
return false;
|
|
236
|
+
}
|
|
237
|
+
if (Object.keys(value).length > 1) {
|
|
238
|
+
return false;
|
|
239
|
+
}
|
|
240
|
+
return true;
|
|
241
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
2
1
|
declare const _default: Readonly<
|
|
3
2
|
import('@markuplint/ml-core').RuleSeed<
|
|
4
3
|
import('@markuplint/ml-core').RuleConfigValue,
|
|
5
4
|
{
|
|
6
|
-
ariaVersion:
|
|
5
|
+
ariaVersion: '1.1' | '1.2' | '1.3';
|
|
7
6
|
fragmentRefersNameAttr: boolean;
|
|
8
7
|
}
|
|
9
8
|
>
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
4
5
|
const shared_1 = require("@markuplint/shared");
|
|
5
6
|
const HYPERLINK_SELECTOR = 'a[href], area[href]';
|
|
6
7
|
exports.default = (0, ml_core_1.createRule)({
|
|
7
8
|
defaultOptions: {
|
|
8
|
-
ariaVersion:
|
|
9
|
+
ariaVersion: ml_spec_1.ARIA_RECOMMENDED_VERSION,
|
|
9
10
|
fragmentRefersNameAttr: false,
|
|
10
11
|
},
|
|
11
12
|
async verify({ document, report, t }) {
|
|
@@ -1,100 +1,51 @@
|
|
|
1
1
|
import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types';
|
|
2
|
-
import type {
|
|
3
|
-
PermittedContentPattern,
|
|
4
|
-
PermittedContentChoice,
|
|
5
|
-
PermittedContentOneOrMore,
|
|
6
|
-
PermittedContentOptional,
|
|
7
|
-
PermittedContentRequire,
|
|
8
|
-
PermittedContentTransparent,
|
|
9
|
-
PermittedContentZeroOrMore,
|
|
10
|
-
Model,
|
|
11
|
-
} from '@markuplint/ml-spec';
|
|
2
|
+
import type { PermittedContentPattern, PermittedContentChoice, PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentTransparent, PermittedContentZeroOrMore, Model } from '@markuplint/ml-spec';
|
|
12
3
|
import type { ReadonlyDeep } from 'type-fest';
|
|
13
4
|
export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];
|
|
14
5
|
export declare function isModel(model: ReadonlyDeep<Model | PermittedContentPattern[]>): model is ReadonlyDeep<Model>;
|
|
15
|
-
export declare function matches(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
matched: boolean;
|
|
22
|
-
not?: undefined;
|
|
23
|
-
}
|
|
24
|
-
| {
|
|
25
|
-
matched: boolean;
|
|
26
|
-
not: ChildNode | undefined;
|
|
27
|
-
};
|
|
28
|
-
export declare function isRequire(
|
|
29
|
-
content: ReadonlyDeep<PermittedContentPattern>,
|
|
30
|
-
): content is ReadonlyDeep<PermittedContentRequire>;
|
|
31
|
-
export declare function isOptional(
|
|
32
|
-
content: ReadonlyDeep<PermittedContentPattern>,
|
|
33
|
-
): content is ReadonlyDeep<PermittedContentOptional>;
|
|
34
|
-
export declare function isOneOrMore(
|
|
35
|
-
content: ReadonlyDeep<PermittedContentPattern>,
|
|
36
|
-
): content is ReadonlyDeep<PermittedContentOneOrMore>;
|
|
37
|
-
export declare function isZeroOrMore(
|
|
38
|
-
content: ReadonlyDeep<PermittedContentPattern>,
|
|
39
|
-
): content is ReadonlyDeep<PermittedContentZeroOrMore>;
|
|
40
|
-
export declare function isChoice(
|
|
41
|
-
content: ReadonlyDeep<PermittedContentPattern>,
|
|
42
|
-
): content is ReadonlyDeep<PermittedContentChoice>;
|
|
43
|
-
export declare function isTransparent(
|
|
44
|
-
content: ReadonlyDeep<PermittedContentPattern>,
|
|
45
|
-
): content is ReadonlyDeep<PermittedContentTransparent>;
|
|
46
|
-
export declare function normalizeModel(
|
|
47
|
-
pattern:
|
|
48
|
-
| ReadonlyDeep<PermittedContentRequire>
|
|
49
|
-
| ReadonlyDeep<PermittedContentOptional>
|
|
50
|
-
| ReadonlyDeep<PermittedContentOneOrMore>
|
|
51
|
-
| ReadonlyDeep<PermittedContentZeroOrMore>,
|
|
52
|
-
): {
|
|
53
|
-
model: ReadonlyDeep<PermittedContentPattern[] | Model>;
|
|
54
|
-
min: number;
|
|
55
|
-
max: number;
|
|
56
|
-
repeat: RepeatSign;
|
|
57
|
-
missingType: MissingNodeReason | undefined;
|
|
6
|
+
export declare function matches(selector: string, node: ChildNode, specs: Specs): {
|
|
7
|
+
matched: boolean;
|
|
8
|
+
not?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
matched: boolean;
|
|
11
|
+
not: ChildNode | undefined;
|
|
58
12
|
};
|
|
59
|
-
export declare function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
):
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
| import('packages/@markuplint/ml-core/lib').Element<import('./types').TagRule[], import('./types').Options>
|
|
81
|
-
| import('packages/@markuplint/ml-core/lib').Block<import('./types').TagRule[], import('./types').Options>
|
|
82
|
-
| undefined;
|
|
83
|
-
transparent?: Element | undefined;
|
|
13
|
+
export declare function isRequire(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentRequire>;
|
|
14
|
+
export declare function isOptional(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOptional>;
|
|
15
|
+
export declare function isOneOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOneOrMore>;
|
|
16
|
+
export declare function isZeroOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentZeroOrMore>;
|
|
17
|
+
export declare function isChoice(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentChoice>;
|
|
18
|
+
export declare function isTransparent(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentTransparent>;
|
|
19
|
+
export declare function normalizeModel(pattern: ReadonlyDeep<PermittedContentRequire> | ReadonlyDeep<PermittedContentOptional> | ReadonlyDeep<PermittedContentOneOrMore> | ReadonlyDeep<PermittedContentZeroOrMore>): {
|
|
20
|
+
model: ReadonlyDeep<PermittedContentPattern[] | Model>;
|
|
21
|
+
min: number;
|
|
22
|
+
max: number;
|
|
23
|
+
repeat: RepeatSign;
|
|
24
|
+
missingType: MissingNodeReason | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare function mergeHints(a: Readonly<Hints>, b: Readonly<Hints>): Partial<{
|
|
27
|
+
missing: Partial<{
|
|
28
|
+
barelyMatchedElements?: number | undefined;
|
|
29
|
+
need?: string | undefined;
|
|
30
|
+
}> | undefined;
|
|
31
|
+
max?: number | undefined;
|
|
32
|
+
not?: import("packages/@markuplint/ml-core/lib").DocumentType<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib/ml-dom/node/character-data").MLCharacterData<import("./types").TagRule[], import("./types").Options, import("packages/@markuplint/ml-ast/src").MLASTAbstractNode> | import("packages/@markuplint/ml-core/lib").Element<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib").Block<import("./types").TagRule[], import("./types").Options> | undefined;
|
|
33
|
+
transparent?: Element | undefined;
|
|
84
34
|
}>;
|
|
85
35
|
export declare function cleanObject<T extends Object>(object: T): Partial<T>;
|
|
86
36
|
export declare class Collection {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
37
|
+
#private;
|
|
38
|
+
constructor(origin: readonly ChildNode[]);
|
|
39
|
+
get matched(): ChildNode[];
|
|
40
|
+
get matchedCount(): number;
|
|
41
|
+
get nodes(): ChildNode[];
|
|
42
|
+
get unmatched(): ChildNode[];
|
|
43
|
+
addMatched(nodes: ChildNode[]): boolean;
|
|
44
|
+
back(): void;
|
|
45
|
+
lock(): void;
|
|
46
|
+
max(max: number): void;
|
|
47
|
+
toString(highlightExtraNodes?: boolean): string;
|
|
48
|
+
}
|
|
49
|
+
export declare class UnsupportedError extends Error {
|
|
98
50
|
}
|
|
99
|
-
export declare class UnsupportedError extends Error {}
|
|
100
51
|
export declare function modelLog(model: ReadonlyDeep<Model | PermittedContentPattern[]>, repeat: RepeatSign): string;
|
|
@@ -5,7 +5,7 @@ const ml_spec_1 = require("@markuplint/ml-spec");
|
|
|
5
5
|
const helpers_1 = require("../helpers");
|
|
6
6
|
exports.default = (0, ml_core_1.createRule)({
|
|
7
7
|
defaultOptions: {
|
|
8
|
-
ariaVersion:
|
|
8
|
+
ariaVersion: ml_spec_1.ARIA_RECOMMENDED_VERSION,
|
|
9
9
|
},
|
|
10
10
|
async verify({ document, report, t }) {
|
|
11
11
|
await document.walkOn('Element', el => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type RequiredAttributes = string | (string | Attr)[];
|
|
2
2
|
type Attr = {
|
|
3
3
|
name: string;
|
|
4
|
-
value
|
|
4
|
+
value?: string | string[];
|
|
5
5
|
};
|
|
6
6
|
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<RequiredAttributes, undefined>>;
|
|
7
7
|
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
export declare const checkingRequiredProp: ElementChecker<boolean, Options, {
|
|
5
|
+
role?: (ARIARole & {
|
|
6
|
+
isImplicit?: boolean;
|
|
7
|
+
}) | null;
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingRequiredProp = void 0;
|
|
4
|
+
const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!role) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (role.isImplicit) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const requiredProps = role.ownedProperties.filter(s => s.required).map(s => s.name);
|
|
13
|
+
for (const requiredProp of requiredProps) {
|
|
14
|
+
const has = el.attributes.some(attr => {
|
|
15
|
+
const attrName = attr.name.toLowerCase();
|
|
16
|
+
return attrName === requiredProp;
|
|
17
|
+
});
|
|
18
|
+
if (!has) {
|
|
19
|
+
const propSpec = propSpecs.find(p => p.name === requiredProp);
|
|
20
|
+
return {
|
|
21
|
+
scope: el,
|
|
22
|
+
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`)), t('the "{0*}" {1}', role.name, 'role')),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.checkingRequiredProp = checkingRequiredProp;
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingDisallowedProp: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
role: ARIARole | null;
|
|
9
|
-
propSpecs: readonly ARIAProperty[];
|
|
10
|
-
}
|
|
11
|
-
>;
|
|
4
|
+
export declare const checkingDisallowedProp: AttrChecker<boolean, Options, {
|
|
5
|
+
role: ARIARole | null;
|
|
6
|
+
propSpecs: readonly ARIAProperty[];
|
|
7
|
+
}>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
export declare const checkingRequiredProp: ElementChecker<boolean, Options, {
|
|
5
|
+
role?: (ARIARole & {
|
|
6
|
+
isImplicit?: boolean;
|
|
7
|
+
}) | null;
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingRequiredProp = void 0;
|
|
4
|
+
const checkingRequiredProp = ({ el, role, propSpecs }) => t => {
|
|
5
|
+
var _a;
|
|
6
|
+
if (!role) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (role.isImplicit) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const requiredProps = role.ownedProperties.filter(s => s.required).map(s => s.name);
|
|
13
|
+
for (const requiredProp of requiredProps) {
|
|
14
|
+
const has = el.attributes.some(attr => {
|
|
15
|
+
const attrName = attr.name.toLowerCase();
|
|
16
|
+
return attrName === requiredProp;
|
|
17
|
+
});
|
|
18
|
+
if (!has) {
|
|
19
|
+
const propSpec = propSpecs.find(p => p.name === requiredProp);
|
|
20
|
+
return {
|
|
21
|
+
scope: el,
|
|
22
|
+
message: t('{0:c} on {1}', t('Require {0}', t('the "{0*}" {1}', requiredProp, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`)), t('the "{0*}" {1}', role.name, 'role')),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
exports.checkingRequiredProp = checkingRequiredProp;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Options } from '../types';
|
|
2
|
+
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
|
+
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
+
export declare const checkingUnadoptedExplicitRoles: ElementChecker<boolean, Options, {
|
|
5
|
+
role?: (ARIARole & {
|
|
6
|
+
isImplicit?: boolean;
|
|
7
|
+
}) | null;
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkingUnadoptedExplicitRoles = void 0;
|
|
4
|
+
const checkingUnadoptedExplicitRoles = ({ el, role, propSpecs }) => t => {
|
|
5
|
+
if (!role) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
if (role.name) {
|
|
9
|
+
console.log(el.localName, role.name);
|
|
10
|
+
return {
|
|
11
|
+
scope: el,
|
|
12
|
+
message: '',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
return;
|
|
16
|
+
};
|
|
17
|
+
exports.checkingUnadoptedExplicitRoles = checkingUnadoptedExplicitRoles;
|
package/lib/wai-aria/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
4
5
|
const helpers_1 = require("../helpers");
|
|
5
6
|
const abstract_role_1 = require("./checkings/abstract-role");
|
|
6
7
|
const default_value_1 = require("./checkings/default-value");
|
|
@@ -27,7 +28,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
27
28
|
disallowSetImplicitRole: true,
|
|
28
29
|
disallowSetImplicitProps: true,
|
|
29
30
|
disallowDefaultValue: false,
|
|
30
|
-
version:
|
|
31
|
+
version: ml_spec_1.ARIA_RECOMMENDED_VERSION,
|
|
31
32
|
},
|
|
32
33
|
async verify({ document, report, t }) {
|
|
33
34
|
await document.walkOn('Element', el => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/rules",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Built-in rules of markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@markuplint/html-spec": "3.
|
|
24
|
-
"@markuplint/ml-core": "3.
|
|
25
|
-
"@markuplint/ml-spec": "3.
|
|
26
|
-
"@markuplint/selector": "3.
|
|
23
|
+
"@markuplint/html-spec": "3.7.0",
|
|
24
|
+
"@markuplint/ml-core": "3.8.0",
|
|
25
|
+
"@markuplint/ml-spec": "3.7.0",
|
|
26
|
+
"@markuplint/selector": "3.7.0",
|
|
27
27
|
"@markuplint/shared": "3.5.0",
|
|
28
28
|
"@markuplint/types": "3.5.1",
|
|
29
29
|
"@ungap/structured-clone": "^1.0.1",
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"@types/debug": "^4.1.7",
|
|
37
37
|
"type-fest": "^3.6.1"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "42b97b47d22b37437024e693a72a458e2963e261"
|
|
40
40
|
}
|