@markuplint/rules 3.5.0 → 3.6.1
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 +1 -1
- package/lib/attr-check.js +19 -22
- package/lib/attr-duplication/index.d.ts +3 -1
- package/lib/attr-duplication/index.js +2 -1
- package/lib/attr-value-quotes/index.d.ts +2 -2
- package/lib/case-sensitive-attr-name/index.d.ts +1 -1
- package/lib/case-sensitive-tag-name/index.d.ts +1 -1
- package/lib/character-reference/index.d.ts +1 -1
- package/lib/class-naming/index.d.ts +1 -1
- package/lib/class-naming/index.js +2 -4
- package/lib/create-message.d.ts +12 -2
- package/lib/create-message.js +5 -4
- package/lib/deprecated-attr/index.d.ts +3 -1
- package/lib/deprecated-element/index.d.ts +3 -1
- package/lib/deprecated-element/index.js +2 -2
- package/lib/disallowed-element/index.d.ts +1 -1
- package/lib/doctype/index.d.ts +2 -2
- package/lib/end-tag/index.d.ts +1 -1
- package/lib/helpers.d.ts +0 -1
- package/lib/helpers.js +8 -9
- package/lib/id-duplication/index.d.ts +3 -1
- package/lib/index.d.ts +172 -67
- package/lib/ineffective-attr/index.d.ts +3 -1
- package/lib/ineffective-attr/index.js +2 -5
- package/lib/invalid-attr/index.d.ts +17 -13
- package/lib/invalid-attr/index.js +8 -8
- package/lib/label-has-control/index.d.ts +3 -1
- package/lib/landmark-roles/index.d.ts +3 -3
- package/lib/landmark-roles/index.js +1 -1
- package/lib/no-boolean-attr-value/index.d.ts +3 -1
- package/lib/no-default-value/index.d.ts +3 -1
- package/lib/no-empty-palpable-content/index.d.ts +3 -3
- package/lib/no-hard-code-id/index.d.ts +3 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
- package/lib/no-refer-to-non-existent-id/index.js +4 -14
- package/lib/no-use-event-handler-attr/index.d.ts +2 -2
- package/lib/permitted-contents/choice.d.ts +7 -1
- package/lib/permitted-contents/complex-branch.d.ts +7 -1
- package/lib/permitted-contents/content-model.js +1 -1
- package/lib/permitted-contents/count-pattern.d.ts +17 -2
- package/lib/permitted-contents/count-pattern.js +1 -1
- package/lib/permitted-contents/debug.browser.d.ts +15 -15
- package/lib/permitted-contents/debug.d.ts +1 -1
- package/lib/permitted-contents/index.d.ts +1 -1
- package/lib/permitted-contents/index.js +5 -10
- package/lib/permitted-contents/matches-selector.d.ts +6 -1
- package/lib/permitted-contents/matches-selector.js +1 -1
- package/lib/permitted-contents/order.d.ts +7 -1
- package/lib/permitted-contents/order.js +4 -4
- package/lib/permitted-contents/recursive-branch.d.ts +7 -1
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +7 -3
- package/lib/permitted-contents/represent-transparent-nodes.js +1 -1
- package/lib/permitted-contents/start.d.ts +6 -1
- package/lib/permitted-contents/start.js +1 -1
- package/lib/permitted-contents/types.d.ts +29 -29
- package/lib/permitted-contents/utils.d.ts +90 -41
- package/lib/permitted-contents/utils.js +3 -3
- package/lib/placeholder-label-option/index.d.ts +1 -1
- package/lib/placeholder-label-option/index.js +5 -4
- package/lib/require-accessible-name/index.d.ts +2 -2
- package/lib/require-datetime/index.d.ts +2 -2
- package/lib/require-datetime/types.d.ts +2 -2
- package/lib/require-datetime/utils.js +3 -2
- package/lib/required-attr/index.d.ts +3 -3
- package/lib/required-attr/index.js +4 -4
- package/lib/required-element/index.d.ts +2 -2
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/use-list/index.d.ts +2 -2
- package/lib/use-list/index.js +4 -3
- 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 +1 -1
- 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/no-global-prop.d.ts +7 -3
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +7 -3
- package/lib/wai-aria/checkings/required-owned-elements.js +1 -1
- package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
- package/lib/wai-aria/checkings/value.d.ts +15 -6
- package/lib/wai-aria/checkings/value.js +3 -1
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/types.d.ts +10 -10
- package/package.json +8 -8
|
@@ -1,51 +1,100 @@
|
|
|
1
1
|
import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types';
|
|
2
|
-
import type {
|
|
2
|
+
import type {
|
|
3
|
+
PermittedContentPattern,
|
|
4
|
+
PermittedContentChoice,
|
|
5
|
+
PermittedContentOneOrMore,
|
|
6
|
+
PermittedContentOptional,
|
|
7
|
+
PermittedContentRequire,
|
|
8
|
+
PermittedContentTransparent,
|
|
9
|
+
PermittedContentZeroOrMore,
|
|
10
|
+
Model,
|
|
11
|
+
} from '@markuplint/ml-spec';
|
|
3
12
|
import type { ReadonlyDeep } from 'type-fest';
|
|
4
13
|
export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];
|
|
5
14
|
export declare function isModel(model: ReadonlyDeep<Model | PermittedContentPattern[]>): model is ReadonlyDeep<Model>;
|
|
6
|
-
export declare function matches(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
15
|
+
export declare function matches(
|
|
16
|
+
selector: string,
|
|
17
|
+
node: ChildNode,
|
|
18
|
+
specs: Specs,
|
|
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;
|
|
12
58
|
};
|
|
13
|
-
export declare function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
59
|
+
export declare function mergeHints(
|
|
60
|
+
a: Readonly<Hints>,
|
|
61
|
+
b: Readonly<Hints>,
|
|
62
|
+
): Partial<{
|
|
63
|
+
missing:
|
|
64
|
+
| Partial<{
|
|
65
|
+
barelyMatchedElements?: number | undefined;
|
|
66
|
+
need?: string | undefined;
|
|
67
|
+
}>
|
|
68
|
+
| undefined;
|
|
69
|
+
max?: number | undefined;
|
|
70
|
+
not?:
|
|
71
|
+
| import('packages/@markuplint/ml-core/lib').DocumentType<
|
|
72
|
+
import('./types').TagRule[],
|
|
73
|
+
import('./types').Options
|
|
74
|
+
>
|
|
75
|
+
| import('packages/@markuplint/ml-core/lib/ml-dom/node/character-data').MLCharacterData<
|
|
76
|
+
import('./types').TagRule[],
|
|
77
|
+
import('./types').Options,
|
|
78
|
+
import('packages/@markuplint/ml-ast/lib').MLASTAbstractNode
|
|
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;
|
|
34
84
|
}>;
|
|
35
85
|
export declare function cleanObject<T extends Object>(object: T): Partial<T>;
|
|
36
86
|
export declare class Collection {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
export declare class UnsupportedError extends Error {
|
|
87
|
+
#private;
|
|
88
|
+
constructor(origin: readonly ChildNode[]);
|
|
89
|
+
get matched(): ChildNode[];
|
|
90
|
+
get matchedCount(): number;
|
|
91
|
+
get nodes(): ChildNode[];
|
|
92
|
+
get unmatched(): ChildNode[];
|
|
93
|
+
addMatched(nodes: ChildNode[]): boolean;
|
|
94
|
+
back(): void;
|
|
95
|
+
lock(): void;
|
|
96
|
+
max(max: number): void;
|
|
97
|
+
toString(highlightExtraNodes?: boolean): string;
|
|
50
98
|
}
|
|
99
|
+
export declare class UnsupportedError extends Error {}
|
|
51
100
|
export declare function modelLog(model: ReadonlyDeep<Model | PermittedContentPattern[]>, repeat: RepeatSign): string;
|
|
@@ -43,7 +43,7 @@ function matches(selector,
|
|
|
43
43
|
node, specs) {
|
|
44
44
|
const selectorResult = (0, selector_1.createSelector)(selector, specs).search(node);
|
|
45
45
|
const matched = selectorResult.filter((r) => r.matched);
|
|
46
|
-
if (matched.length) {
|
|
46
|
+
if (matched.length > 0) {
|
|
47
47
|
return {
|
|
48
48
|
matched: true,
|
|
49
49
|
};
|
|
@@ -64,9 +64,9 @@ function descendants(
|
|
|
64
64
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
65
65
|
selectorResult) {
|
|
66
66
|
let nodes = selectorResult.nodes.slice();
|
|
67
|
-
while (selectorResult.has.length) {
|
|
67
|
+
while (selectorResult.has.length > 0) {
|
|
68
68
|
for (const dep of selectorResult.has) {
|
|
69
|
-
if (
|
|
69
|
+
if (dep.has.length === 0) {
|
|
70
70
|
nodes = dep.nodes;
|
|
71
71
|
continue;
|
|
72
72
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: Readonly<import(
|
|
1
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
|
|
2
2
|
export default _default;
|
|
@@ -29,6 +29,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
29
29
|
function needPlaceholderLabelOption(
|
|
30
30
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
31
31
|
select) {
|
|
32
|
+
var _a;
|
|
32
33
|
const hasRequired = select.hasAttribute('required');
|
|
33
34
|
if (!hasRequired) {
|
|
34
35
|
return false;
|
|
@@ -37,7 +38,7 @@ select) {
|
|
|
37
38
|
if (hasMultiple) {
|
|
38
39
|
return false;
|
|
39
40
|
}
|
|
40
|
-
const size = select.getAttribute('size')
|
|
41
|
+
const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
|
|
41
42
|
if (size !== '1') {
|
|
42
43
|
return false;
|
|
43
44
|
}
|
|
@@ -58,7 +59,7 @@ select) {
|
|
|
58
59
|
function hasPlaceholderLabelOption(
|
|
59
60
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
60
61
|
select) {
|
|
61
|
-
var _a;
|
|
62
|
+
var _a, _b;
|
|
62
63
|
// > has a required attribute specified
|
|
63
64
|
if (!select.hasAttribute('required')) {
|
|
64
65
|
return false;
|
|
@@ -68,7 +69,7 @@ select) {
|
|
|
68
69
|
return false;
|
|
69
70
|
}
|
|
70
71
|
// > has a display size of 1
|
|
71
|
-
const size = select.getAttribute('size')
|
|
72
|
+
const size = (_a = select.getAttribute('size')) !== null && _a !== void 0 ? _a : '1';
|
|
72
73
|
if (size !== '1') {
|
|
73
74
|
return false;
|
|
74
75
|
}
|
|
@@ -79,7 +80,7 @@ select) {
|
|
|
79
80
|
return true;
|
|
80
81
|
}
|
|
81
82
|
// > that option element's parent node is the select element (and not an optgroup element)
|
|
82
|
-
if (((
|
|
83
|
+
if (((_b = firstOption.parentElement) === null || _b === void 0 ? void 0 : _b.localName) === 'optgroup') {
|
|
83
84
|
return false;
|
|
84
85
|
}
|
|
85
86
|
const value = firstOption.getAttribute('value');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
2
2
|
type Option = {
|
|
3
|
-
|
|
3
|
+
ariaVersion: ARIAVersion;
|
|
4
4
|
};
|
|
5
|
-
declare const _default: Readonly<import(
|
|
5
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Option>>;
|
|
6
6
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Lang } from './types';
|
|
2
2
|
type Options = {
|
|
3
|
-
|
|
3
|
+
langs?: Lang[];
|
|
4
4
|
};
|
|
5
|
-
declare const _default: Readonly<import(
|
|
5
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Options>>;
|
|
6
6
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type DateTimeKey = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'ms';
|
|
2
2
|
export type DateTimeData = Partial<Record<DateTimeKey, number>>;
|
|
3
3
|
export type DateTime = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
datetime: DateTimeData;
|
|
5
|
+
zone?: number;
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* @see https://github.com/wanasit/chrono#locales
|
|
@@ -13,6 +13,7 @@ const defaultLangs = ['en', 'ja', 'fr', 'nl', 'ru', 'de', 'pt', 'zh'];
|
|
|
13
13
|
* @returns
|
|
14
14
|
*/
|
|
15
15
|
function parseADatetime(content, langs, base) {
|
|
16
|
+
var _a;
|
|
16
17
|
const date = parseTryMultipleLangs(content, langs, base);
|
|
17
18
|
if (!date) {
|
|
18
19
|
return null;
|
|
@@ -31,7 +32,7 @@ function parseADatetime(content, langs, base) {
|
|
|
31
32
|
data.hour = date.get('hour');
|
|
32
33
|
}
|
|
33
34
|
if (date.isCertain('hour')) {
|
|
34
|
-
data.minute = date.get('minute')
|
|
35
|
+
data.minute = (_a = date.get('minute')) !== null && _a !== void 0 ? _a : 0;
|
|
35
36
|
}
|
|
36
37
|
if (date.isCertain('second')) {
|
|
37
38
|
data.second = date.get('second');
|
|
@@ -57,7 +58,7 @@ function getCandidateDatetimeString(content, langs = defaultLangs) {
|
|
|
57
58
|
if (!datetimeStr) {
|
|
58
59
|
return null;
|
|
59
60
|
}
|
|
60
|
-
if (date.zone) {
|
|
61
|
+
if (date.zone != null) {
|
|
61
62
|
const plusMinus = date.zone < 0 ? '-' : '+';
|
|
62
63
|
const hour = Math.floor(Math.abs(date.zone) / 60);
|
|
63
64
|
const minute = Math.abs(date.zone) % 60;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type RequiredAttributes = string | (string | Attr)[];
|
|
2
2
|
type Attr = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
name: string;
|
|
4
|
+
value: string | string[];
|
|
5
5
|
};
|
|
6
|
-
declare const _default: Readonly<import(
|
|
6
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<RequiredAttributes, undefined>>;
|
|
7
7
|
export default _default;
|
|
@@ -15,7 +15,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
15
15
|
const attributeSpecs = {};
|
|
16
16
|
if (attrSpec && el.elementType === 'html') {
|
|
17
17
|
for (const spec of attrSpec) {
|
|
18
|
-
if (spec.required || spec.requiredEither || spec.condition) {
|
|
18
|
+
if (spec.required != null || spec.requiredEither || spec.condition != null) {
|
|
19
19
|
attributeSpecs[spec.name] = {
|
|
20
20
|
...spec,
|
|
21
21
|
values: [],
|
|
@@ -54,7 +54,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
54
54
|
else if (spec.required === true) {
|
|
55
55
|
invalid = (0, helpers_1.attrMatches)(el, spec.condition) && didntHave;
|
|
56
56
|
}
|
|
57
|
-
else if (spec.required) {
|
|
57
|
+
else if (spec.required != null && spec.required !== false) {
|
|
58
58
|
const selector = typeof spec.required === 'string' ? spec.required : spec.required.join(',');
|
|
59
59
|
invalid = el.matches(selector) && didntHave;
|
|
60
60
|
}
|
|
@@ -66,14 +66,14 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
68
|
const value = el.getAttribute(spec.name);
|
|
69
|
-
if (spec.values.length && value) {
|
|
69
|
+
if (spec.values.length > 0 && value) {
|
|
70
70
|
const matched = spec.values.some(pattern => (0, helpers_1.match)(value, pattern));
|
|
71
71
|
if (!matched) {
|
|
72
72
|
const expects = spec.values.length === 1 ? t(spec.values) : t('either {0}', t(spec.values));
|
|
73
73
|
const message = t('{0} expects {1}', t('the "{0*}" {1}', spec.name, 'attribute'), expects);
|
|
74
74
|
const attrToken = el.getAttributeToken(spec.name);
|
|
75
75
|
const valueToken = (_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.valueNode;
|
|
76
|
-
const token = valueToken
|
|
76
|
+
const token = valueToken !== null && valueToken !== void 0 ? valueToken : attrToken[0];
|
|
77
77
|
if (token) {
|
|
78
78
|
report({
|
|
79
79
|
scope: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type Options = {
|
|
2
|
-
|
|
2
|
+
ignoreHasMutableContents: boolean;
|
|
3
3
|
};
|
|
4
|
-
declare const _default: Readonly<import(
|
|
4
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<string[], Options>>;
|
|
5
5
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface Options {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
'expected-once': boolean;
|
|
3
|
+
'in-document-fragment': boolean;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: Readonly<import(
|
|
5
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Options>>;
|
|
6
6
|
export default _default;
|
package/lib/use-list/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type Bullets = readonly string[];
|
|
2
2
|
type Options = {
|
|
3
|
-
|
|
3
|
+
spaceNeededBullets?: string[];
|
|
4
4
|
};
|
|
5
|
-
declare const _default: Readonly<import(
|
|
5
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Bullets, Options>>;
|
|
6
6
|
export default _default;
|
package/lib/use-list/index.js
CHANGED
|
@@ -1,7 +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
|
|
4
|
+
const shared_1 = require("@markuplint/shared");
|
|
5
5
|
exports.default = (0, ml_core_1.createRule)({
|
|
6
6
|
defaultValue: [
|
|
7
7
|
/**
|
|
@@ -57,7 +57,8 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
57
57
|
defaultSeverity: 'warning',
|
|
58
58
|
async verify({ document, report, t }) {
|
|
59
59
|
await document.walkOn('Text', textNode => {
|
|
60
|
-
|
|
60
|
+
var _a;
|
|
61
|
+
const text = (0, shared_1.decodeEntities)(textNode.raw.trim());
|
|
61
62
|
if (!text) {
|
|
62
63
|
// empty
|
|
63
64
|
return;
|
|
@@ -67,7 +68,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
67
68
|
return;
|
|
68
69
|
}
|
|
69
70
|
const bullets = textNode.rule.value;
|
|
70
|
-
const spaceNeededBullets = textNode.rule.options.spaceNeededBullets
|
|
71
|
+
const spaceNeededBullets = (_a = textNode.rule.options.spaceNeededBullets) !== null && _a !== void 0 ? _a : [];
|
|
71
72
|
if (isMayListItem(text, bullets, spaceNeededBullets)) {
|
|
72
73
|
report({
|
|
73
74
|
scope: textNode,
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingDefaultValue: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const checkingDefaultValue: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
}
|
|
10
|
+
>;
|
|
@@ -1,7 +1,11 @@
|
|
|
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 checkingDeprecatedProps: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const checkingDeprecatedProps: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role: ARIARole | null;
|
|
9
|
+
propSpecs: readonly ARIAProperty[];
|
|
10
|
+
}
|
|
11
|
+
>;
|
|
@@ -1,7 +1,11 @@
|
|
|
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
|
-
|
|
4
|
+
export declare const checkingDisallowedProp: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role: ARIARole | null;
|
|
9
|
+
propSpecs: readonly ARIAProperty[];
|
|
10
|
+
}
|
|
11
|
+
>;
|
|
@@ -13,7 +13,7 @@ const checkingDisallowedProp = ({ attr, role, propSpecs }) => t => {
|
|
|
13
13
|
const statesAndProp = role.ownedProperties.find(p => p.name === attr.name);
|
|
14
14
|
const propSpec = propSpecs.find(p => p.name === attr.name);
|
|
15
15
|
const elAriaSpec = (0, ml_spec_1.getARIA)(attr.ownerMLDocument.specs, attr.ownerElement.localName, attr.ownerElement.namespaceURI, attr.rule.options.version, attr.ownerElement.matches.bind(attr.ownerElement));
|
|
16
|
-
if ((elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) && ((_a = elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) === null || _a === void 0 ? void 0 : _a.without)) {
|
|
16
|
+
if ((elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) !== false && ((_a = elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) === null || _a === void 0 ? void 0 : _a.without)) {
|
|
17
17
|
for (const ignore of elAriaSpec.properties.without) {
|
|
18
18
|
if (ignore.name === attr.name) {
|
|
19
19
|
return {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, Attribute } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingImplicitProps: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
export declare const checkingImplicitProps: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
attrSpecs: readonly Attribute[] | null;
|
|
10
|
+
}
|
|
11
|
+
>;
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.checkingImplicitProps = void 0;
|
|
4
4
|
const helpers_1 = require("../../helpers");
|
|
5
5
|
const checkingImplicitProps = ({ attr, propSpecs, attrSpecs }) => t => {
|
|
6
|
+
var _a;
|
|
6
7
|
if (!attrSpecs) {
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
@@ -15,8 +16,8 @@ const checkingImplicitProps = ({ attr, propSpecs, attrSpecs }) => t => {
|
|
|
15
16
|
}
|
|
16
17
|
for (const equivalentHtmlAttr of propSpec.equivalentHtmlAttrs) {
|
|
17
18
|
const htmlAttrSpec = attrSpecs.find(a => a.name === equivalentHtmlAttr.htmlAttrName);
|
|
18
|
-
const isValid = (0, helpers_1.isValidAttr)(t, equivalentHtmlAttr.htmlAttrName, equivalentHtmlAttr.value
|
|
19
|
-
if (isValid && isValid.invalidType === 'non-existent') {
|
|
19
|
+
const isValid = (0, helpers_1.isValidAttr)(t, equivalentHtmlAttr.htmlAttrName, (_a = equivalentHtmlAttr.value) !== null && _a !== void 0 ? _a : '', false, attr.ownerElement, attrSpecs);
|
|
20
|
+
if (isValid !== false && isValid.invalidType === 'non-existent') {
|
|
20
21
|
continue;
|
|
21
22
|
}
|
|
22
23
|
const value = attr.value.trim().toLowerCase();
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { AttrChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingNoGlobalProp: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
export declare const checkingNoGlobalProp: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
propSpecs: readonly ARIAProperty[];
|
|
9
|
+
}
|
|
10
|
+
>;
|
|
@@ -6,6 +6,10 @@ import type { ARIARole } from '@markuplint/ml-spec';
|
|
|
6
6
|
*
|
|
7
7
|
* @see https://w3c.github.io/aria/#mustContain
|
|
8
8
|
*/
|
|
9
|
-
export declare const checkingRequiredOwnedElements: ElementChecker<
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
export declare const checkingRequiredOwnedElements: ElementChecker<
|
|
10
|
+
boolean,
|
|
11
|
+
Options,
|
|
12
|
+
{
|
|
13
|
+
role?: ARIARole | null;
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { Options } from '../types';
|
|
2
2
|
import type { ElementChecker } from '@markuplint/ml-core';
|
|
3
3
|
import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingRequiredProp: ElementChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
export declare const checkingRequiredProp: ElementChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role?:
|
|
9
|
+
| (ARIARole & {
|
|
10
|
+
isImplicit?: boolean;
|
|
11
|
+
})
|
|
12
|
+
| null;
|
|
13
|
+
propSpecs: readonly ARIAProperty[];
|
|
14
|
+
}
|
|
15
|
+
>;
|
|
@@ -1,13 +1,22 @@
|
|
|
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 checkingValue: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
export declare const checkingValue: AttrChecker<
|
|
5
|
+
boolean,
|
|
6
|
+
Options,
|
|
7
|
+
{
|
|
8
|
+
role?: ARIARole | null;
|
|
9
|
+
propSpecs: readonly ARIAProperty[];
|
|
10
|
+
booleanish?: boolean;
|
|
11
|
+
}
|
|
12
|
+
>;
|
|
9
13
|
/**
|
|
10
14
|
*
|
|
11
15
|
* @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
|
|
12
16
|
*/
|
|
13
|
-
export declare function checkAriaValue(
|
|
17
|
+
export declare function checkAriaValue(
|
|
18
|
+
type: string,
|
|
19
|
+
value: string,
|
|
20
|
+
tokenEnum: readonly string[],
|
|
21
|
+
booleanish?: boolean,
|
|
22
|
+
): boolean;
|
|
@@ -14,7 +14,9 @@ const checkingValue = ({ attr, role, propSpecs, booleanish }) => t => {
|
|
|
14
14
|
return {
|
|
15
15
|
scope: attr,
|
|
16
16
|
message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0}"', attr.value), 'disallowed'), t('the "{0*}" {1}', attr.name, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`)) +
|
|
17
|
-
('enum' in result && result.enum.length
|
|
17
|
+
('enum' in result && result.enum.length > 0
|
|
18
|
+
? t('. ') + t('Allowed values are: {0}', t(result.enum))
|
|
19
|
+
: ''),
|
|
18
20
|
};
|
|
19
21
|
};
|
|
20
22
|
exports.checkingValue = checkingValue;
|
package/lib/wai-aria/index.d.ts
CHANGED
package/lib/wai-aria/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
2
2
|
export type Options = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
3
|
+
checkingValue: boolean;
|
|
4
|
+
checkingDeprecatedProps: boolean;
|
|
5
|
+
permittedAriaRoles: boolean;
|
|
6
|
+
checkingRequiredOwnedElements: boolean;
|
|
7
|
+
checkingPresentationalChildren: boolean;
|
|
8
|
+
checkingInteractionInHidden: boolean;
|
|
9
|
+
disallowSetImplicitRole: boolean;
|
|
10
|
+
disallowSetImplicitProps: boolean;
|
|
11
|
+
disallowDefaultValue: boolean;
|
|
12
|
+
version: ARIAVersion;
|
|
13
13
|
};
|