@markuplint/rules 3.0.0-rc.1 → 3.0.0-rc.3
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 +8 -19
- package/lib/attr-duplication/index.d.ts +1 -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/create-message.d.ts +2 -12
- package/lib/deprecated-attr/index.d.ts +1 -1
- package/lib/deprecated-element/index.d.ts +1 -1
- 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 +17 -35
- package/lib/id-duplication/index.d.ts +1 -1
- package/lib/ineffective-attr/index.d.ts +1 -1
- package/lib/invalid-attr/index.d.ts +13 -17
- package/lib/invalid-attr/index.js +6 -6
- package/lib/label-has-control/index.d.ts +1 -1
- package/lib/landmark-roles/index.d.ts +3 -3
- package/lib/landmark-roles/index.js +2 -2
- package/lib/no-boolean-attr-value/index.d.ts +1 -1
- package/lib/no-default-value/index.d.ts +1 -1
- package/lib/no-empty-palpable-content/index.d.ts +3 -3
- package/lib/no-empty-palpable-content/index.js +2 -2
- package/lib/no-hard-code-id/index.d.ts +1 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +3 -6
- package/lib/no-refer-to-non-existent-id/index.js +1 -1
- package/lib/no-use-event-handler-attr/index.d.ts +2 -2
- package/lib/no-use-event-handler-attr/index.js +4 -4
- package/lib/permitted-contents/choice.d.ts +1 -7
- package/lib/permitted-contents/complex-branch.d.ts +1 -7
- package/lib/permitted-contents/count-pattern.d.ts +2 -17
- package/lib/permitted-contents/debug.d.ts +1 -1
- package/lib/permitted-contents/index.d.ts +1 -1
- package/lib/permitted-contents/index.js +4 -4
- package/lib/permitted-contents/matches-selector.d.ts +1 -7
- package/lib/permitted-contents/order.d.ts +1 -7
- package/lib/permitted-contents/recursive-branch.d.ts +1 -7
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +3 -7
- package/lib/permitted-contents/start.d.ts +1 -6
- package/lib/permitted-contents/start.js +1 -1
- package/lib/permitted-contents/types.d.ts +27 -31
- package/lib/permitted-contents/utils.d.ts +21 -35
- package/lib/require-accessible-name/index.d.ts +2 -2
- package/lib/require-accessible-name/index.js +4 -4
- package/lib/required-attr/index.d.ts +3 -3
- package/lib/required-element/index.d.ts +2 -2
- package/lib/required-element/index.js +1 -1
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/required-h1/index.js +2 -2
- package/lib/use-list/index.d.ts +2 -2
- package/lib/use-list/index.js +1 -1
- package/lib/wai-aria/checkings/abstract-role.js +1 -1
- package/lib/wai-aria/checkings/default-value.d.ts +3 -7
- package/lib/wai-aria/checkings/deprecated-props.d.ts +4 -8
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +4 -8
- package/lib/wai-aria/checkings/implicit-props.d.ts +4 -8
- package/lib/wai-aria/checkings/implicit-role.js +1 -1
- package/lib/wai-aria/checkings/no-global-prop.d.ts +3 -7
- package/lib/wai-aria/checkings/non-existent-role.js +1 -1
- package/lib/wai-aria/checkings/permitted-roles.js +1 -1
- package/lib/wai-aria/checkings/presentational-children.js +1 -1
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +3 -7
- package/lib/wai-aria/checkings/required-owned-elements.js +24 -10
- package/lib/wai-aria/checkings/required-prop.d.ts +6 -12
- package/lib/wai-aria/checkings/value.d.ts +5 -9
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/index.js +11 -11
- package/lib/wai-aria/types.d.ts +10 -10
- package/package.json +6 -6
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -3,47 +3,43 @@ import type { ContentModel, MLMLSpec } from '@markuplint/ml-spec';
|
|
|
3
3
|
export type Element = _Element<TagRule[], Options>;
|
|
4
4
|
export type ChildNode = _ChildNode<TagRule[], Options>;
|
|
5
5
|
export type Specs = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
cites: MLMLSpec['cites'];
|
|
7
|
+
def: MLMLSpec['def'];
|
|
8
|
+
specs: {
|
|
9
|
+
name: string;
|
|
10
|
+
contentModel: {
|
|
11
|
+
contents: MLMLSpec['specs'][0]['contentModel']['contents'];
|
|
12
|
+
};
|
|
13
|
+
}[];
|
|
14
14
|
};
|
|
15
15
|
export type ContentModelResult = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
type: MatchedReason | UnmatchedReason;
|
|
17
|
+
scope: ChildNode;
|
|
18
|
+
query: Result['query'];
|
|
19
|
+
hint: Result['hint'];
|
|
20
20
|
};
|
|
21
21
|
export type Result<T extends string = MatchedReason> = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
type: MatchedReason | UnmatchedReason | T;
|
|
23
|
+
matched: ChildNode[];
|
|
24
|
+
unmatched: ChildNode[];
|
|
25
|
+
zeroMatch: boolean;
|
|
26
|
+
query: string;
|
|
27
|
+
hint: {
|
|
28
|
+
max?: number;
|
|
29
|
+
not?: ChildNode;
|
|
30
|
+
transparent?: Element;
|
|
31
|
+
};
|
|
32
32
|
};
|
|
33
33
|
export type MatchedReason = 'MATCHED' | 'MATCHED_ZERO';
|
|
34
|
-
export type UnmatchedReason =
|
|
35
|
-
| 'VOID_ELEMENT'
|
|
36
|
-
| 'UNEXPECTED_EXTRA_NODE'
|
|
37
|
-
| 'TRANSPARENT_MODEL_DISALLOWS'
|
|
38
|
-
| MissingNodeReason;
|
|
34
|
+
export type UnmatchedReason = 'NOTHING' | 'UNEXPECTED_EXTRA_NODE' | 'TRANSPARENT_MODEL_DISALLOWS' | MissingNodeReason;
|
|
39
35
|
export type MissingNodeReason = 'MISSING_NODE_REQUIRED' | 'MISSING_NODE_ONE_OR_MORE';
|
|
40
36
|
export type TransparentModel = {
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
el: Element;
|
|
38
|
+
additionalCondition: string;
|
|
43
39
|
};
|
|
44
40
|
export type TagRule = {
|
|
45
|
-
|
|
41
|
+
tag: string;
|
|
46
42
|
} & ContentModel;
|
|
47
43
|
export type Options = {
|
|
48
|
-
|
|
44
|
+
ignoreHasMutableChildren: boolean;
|
|
49
45
|
};
|
|
@@ -1,29 +1,14 @@
|
|
|
1
1
|
import type { ChildNode, Element, 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
|
export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];
|
|
13
4
|
export declare function isModel(model: Model | PermittedContentPattern[]): model is Model;
|
|
14
|
-
export declare function matches(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
not?: undefined;
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
matched: boolean;
|
|
25
|
-
not: ChildNode | undefined;
|
|
26
|
-
};
|
|
5
|
+
export declare function matches(selector: string, node: ChildNode, specs: Specs): {
|
|
6
|
+
matched: boolean;
|
|
7
|
+
not?: undefined;
|
|
8
|
+
} | {
|
|
9
|
+
matched: boolean;
|
|
10
|
+
not: ChildNode | undefined;
|
|
11
|
+
};
|
|
27
12
|
export declare function isRequire(content: PermittedContentPattern): content is PermittedContentRequire;
|
|
28
13
|
export declare function isOptional(content: PermittedContentPattern): content is PermittedContentOptional;
|
|
29
14
|
export declare function isOneOrMore(content: PermittedContentPattern): content is PermittedContentOneOrMore;
|
|
@@ -31,16 +16,17 @@ export declare function isZeroOrMore(content: PermittedContentPattern): content
|
|
|
31
16
|
export declare function isChoice(content: PermittedContentPattern): content is PermittedContentChoice;
|
|
32
17
|
export declare function isTransparent(content: PermittedContentPattern): content is PermittedContentTransparent;
|
|
33
18
|
export declare class Collection {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
19
|
+
#private;
|
|
20
|
+
constructor(origin: readonly ChildNode[]);
|
|
21
|
+
get matched(): ChildNode[];
|
|
22
|
+
get matchedCount(): number;
|
|
23
|
+
get nodes(): ChildNode[];
|
|
24
|
+
get unmatched(): ChildNode[];
|
|
25
|
+
addMatched(nodes: ChildNode[]): boolean;
|
|
26
|
+
back(): void;
|
|
27
|
+
lock(): void;
|
|
28
|
+
max(max: number): void;
|
|
29
|
+
toString(highlightExtraNodes?: boolean): string;
|
|
30
|
+
}
|
|
31
|
+
export declare class UnsupportedError extends Error {
|
|
45
32
|
}
|
|
46
|
-
export declare class UnsupportedError extends Error {}
|
|
@@ -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: import(
|
|
5
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Option>;
|
|
6
6
|
export default _default;
|
|
@@ -16,18 +16,18 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
16
16
|
if ((0, helpers_1.accnameMayBeMutable)(el, document)) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
if (!(0, ml_spec_1.isExposed)(el, document.specs, el.rule.
|
|
19
|
+
if (!(0, ml_spec_1.isExposed)(el, document.specs, el.rule.options.ariaVersion)) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
const computed = (0, ml_core_1.getComputedRole)(document.specs, el, el.rule.
|
|
22
|
+
const computed = (0, ml_core_1.getComputedRole)(document.specs, el, el.rule.options.ariaVersion);
|
|
23
23
|
if (!computed.role) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const roleSpec = (0, ml_core_1.getRoleSpec)(document.specs, computed.role.name, el.namespaceURI, el.rule.
|
|
26
|
+
const roleSpec = (0, ml_core_1.getRoleSpec)(document.specs, computed.role.name, el.namespaceURI, el.rule.options.ariaVersion);
|
|
27
27
|
if (!roleSpec || !roleSpec.accessibleNameRequired) {
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
|
-
const hasAccessibleName = !!el.getAccessibleName(el.rule.
|
|
30
|
+
const hasAccessibleName = !!el.getAccessibleName(el.rule.options.ariaVersion).trim();
|
|
31
31
|
if (!hasAccessibleName) {
|
|
32
32
|
report({ scope: el, message: t('Require {0}', 'accessible name') });
|
|
33
33
|
}
|
|
@@ -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: import(
|
|
6
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<RequiredAttributes, null>;
|
|
7
7
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type Options = {
|
|
2
|
-
|
|
2
|
+
ignoreHasMutableContents: boolean;
|
|
3
3
|
};
|
|
4
|
-
declare const _default: import(
|
|
4
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<string[], Options>;
|
|
5
5
|
export default _default;
|
|
@@ -26,7 +26,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
26
26
|
if (el.rule.value === document.rule.value) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
if (el.rule.
|
|
29
|
+
if (el.rule.options.ignoreHasMutableContents && el.hasMutableChildren()) {
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
32
|
for (const query of el.rule.value) {
|
|
@@ -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: import(
|
|
5
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Options>;
|
|
6
6
|
export default _default;
|
package/lib/required-h1/index.js
CHANGED
|
@@ -11,7 +11,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
11
11
|
if (document.nodeList.length === 0) {
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
if (!document.rule.
|
|
14
|
+
if (!document.rule.options['in-document-fragment'] && document.isFragment) {
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
17
|
await document.walkOn('Element', node => {
|
|
@@ -28,7 +28,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
28
28
|
raw: document.nodeList[0].raw.slice(0, 1),
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
else if (document.rule.
|
|
31
|
+
else if (document.rule.options['expected-once'] && h1Stack.length > 1) {
|
|
32
32
|
const message = t('{0} is {1:c}', t('the "{0*}" {1}', 'h1', 'element'), 'duplicated');
|
|
33
33
|
report({
|
|
34
34
|
message,
|
package/lib/use-list/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type Bullets = string[];
|
|
2
2
|
type Options = {
|
|
3
|
-
|
|
3
|
+
spaceNeededBullets?: string[];
|
|
4
4
|
};
|
|
5
|
-
declare const _default: import(
|
|
5
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<Bullets, Options>;
|
|
6
6
|
export default _default;
|
package/lib/use-list/index.js
CHANGED
|
@@ -67,7 +67,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
const bullets = textNode.rule.value;
|
|
70
|
-
const spaceNeededBullets = textNode.rule.
|
|
70
|
+
const spaceNeededBullets = textNode.rule.options.spaceNeededBullets || [];
|
|
71
71
|
if (isMayListItem(text, bullets, spaceNeededBullets)) {
|
|
72
72
|
report({
|
|
73
73
|
scope: textNode,
|
|
@@ -4,7 +4,7 @@ exports.checkingAbstractRole = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const checkingAbstractRole = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
|
-
const { roles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.
|
|
7
|
+
const { roles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.options.version);
|
|
8
8
|
const tokens = (_a = attr.tokenList) === null || _a === void 0 ? void 0 : _a.allTokens();
|
|
9
9
|
if (!tokens) {
|
|
10
10
|
return;
|
|
@@ -1,10 +1,6 @@
|
|
|
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
|
-
|
|
7
|
-
{
|
|
8
|
-
propSpecs: ARIAProperty[];
|
|
9
|
-
}
|
|
10
|
-
>;
|
|
4
|
+
export declare const checkingDefaultValue: AttrChecker<boolean, Options, {
|
|
5
|
+
propSpecs: ARIAProperty[];
|
|
6
|
+
}>;
|
|
@@ -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 checkingDeprecatedProps: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
role: ARIARole | null;
|
|
9
|
-
propSpecs: ARIAProperty[];
|
|
10
|
-
}
|
|
11
|
-
>;
|
|
4
|
+
export declare const checkingDeprecatedProps: AttrChecker<boolean, Options, {
|
|
5
|
+
role: ARIARole | null;
|
|
6
|
+
propSpecs: ARIAProperty[];
|
|
7
|
+
}>;
|
|
@@ -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: ARIAProperty[];
|
|
10
|
-
}
|
|
11
|
-
>;
|
|
4
|
+
export declare const checkingDisallowedProp: AttrChecker<boolean, Options, {
|
|
5
|
+
role: ARIARole | null;
|
|
6
|
+
propSpecs: ARIAProperty[];
|
|
7
|
+
}>;
|
|
@@ -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, Attribute } from '@markuplint/ml-spec';
|
|
4
|
-
export declare const checkingImplicitProps: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
propSpecs: ARIAProperty[];
|
|
9
|
-
attrSpecs: Attribute[] | null;
|
|
10
|
-
}
|
|
11
|
-
>;
|
|
4
|
+
export declare const checkingImplicitProps: AttrChecker<boolean, Options, {
|
|
5
|
+
propSpecs: ARIAProperty[];
|
|
6
|
+
attrSpecs: Attribute[] | null;
|
|
7
|
+
}>;
|
|
@@ -4,7 +4,7 @@ exports.checkingImplicitRole = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const checkingImplicitRole = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
|
-
const implicitRole = (0, ml_spec_1.getImplicitRoleName)(attr.ownerElement, attr.rule.
|
|
7
|
+
const implicitRole = (0, ml_spec_1.getImplicitRoleName)(attr.ownerElement, attr.rule.options.version, attr.ownerMLDocument.specs);
|
|
8
8
|
const tokens = (_a = attr.tokenList) === null || _a === void 0 ? void 0 : _a.allTokens();
|
|
9
9
|
if (!tokens) {
|
|
10
10
|
return;
|
|
@@ -1,10 +1,6 @@
|
|
|
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
|
-
|
|
7
|
-
{
|
|
8
|
-
propSpecs: ARIAProperty[];
|
|
9
|
-
}
|
|
10
|
-
>;
|
|
4
|
+
export declare const checkingNoGlobalProp: AttrChecker<boolean, Options, {
|
|
5
|
+
propSpecs: ARIAProperty[];
|
|
6
|
+
}>;
|
|
@@ -4,7 +4,7 @@ exports.checkingNonExistentRole = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const checkingNonExistentRole = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
|
-
const { roles, graphicsRoles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.
|
|
7
|
+
const { roles, graphicsRoles } = (0, ml_spec_1.ariaSpecs)(attr.ownerMLDocument.specs, attr.rule.options.version);
|
|
8
8
|
const tokens = (_a = attr.tokenList) === null || _a === void 0 ? void 0 : _a.allTokens();
|
|
9
9
|
if (!tokens) {
|
|
10
10
|
return;
|
|
@@ -5,7 +5,7 @@ const ml_spec_1 = require("@markuplint/ml-spec");
|
|
|
5
5
|
const checkingPermittedRoles = ({ attr }) => t => {
|
|
6
6
|
var _a;
|
|
7
7
|
const el = attr.ownerElement;
|
|
8
|
-
const permittedRoles = (0, ml_spec_1.getPermittedRoles)(el, el.rule.
|
|
8
|
+
const permittedRoles = (0, ml_spec_1.getPermittedRoles)(el, el.rule.options.version, attr.ownerMLDocument.specs);
|
|
9
9
|
if (permittedRoles.length === 0) {
|
|
10
10
|
return {
|
|
11
11
|
scope: attr,
|
|
@@ -50,7 +50,7 @@ function getAncestorHasPresentationalChildren(el) {
|
|
|
50
50
|
var _a;
|
|
51
51
|
let current = el.parentElement;
|
|
52
52
|
while (current) {
|
|
53
|
-
const computed = (0, ml_spec_1.getComputedRole)(el.ownerMLDocument.specs, current, el.rule.
|
|
53
|
+
const computed = (0, ml_spec_1.getComputedRole)(el.ownerMLDocument.specs, current, el.rule.options.version);
|
|
54
54
|
if ((_a = computed.role) === null || _a === void 0 ? void 0 : _a.childrenPresentational) {
|
|
55
55
|
return computed;
|
|
56
56
|
}
|
|
@@ -6,10 +6,6 @@ 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
|
-
|
|
12
|
-
{
|
|
13
|
-
role?: ARIARole | null;
|
|
14
|
-
}
|
|
15
|
-
>;
|
|
9
|
+
export declare const checkingRequiredOwnedElements: ElementChecker<boolean, Options, {
|
|
10
|
+
role?: ARIARole | null;
|
|
11
|
+
}>;
|
|
@@ -28,18 +28,13 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
|
28
28
|
return;
|
|
29
29
|
}
|
|
30
30
|
// TODO: Needs to resolve `aria-own`
|
|
31
|
-
if (el.isEmpty()) {
|
|
32
|
-
return {
|
|
33
|
-
scope: el,
|
|
34
|
-
message: t('{0}. Or, {1}', t('require {0}', role.requiredOwnedElements.length === 1
|
|
35
|
-
? t('the "{0*}" {1}', role.requiredOwnedElements[0], 'role')
|
|
36
|
-
: t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`), t('require {0}', 'aria-busy="true"')),
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
31
|
const children = Array.from(el.childNodes).map(child => {
|
|
40
32
|
if (child.is(child.ELEMENT_NODE)) {
|
|
41
|
-
|
|
42
|
-
|
|
33
|
+
if (child.matches('[aria-busy="true" i]')) {
|
|
34
|
+
return [child, 'BUSY'];
|
|
35
|
+
}
|
|
36
|
+
const computedChild = (0, ml_spec_1.getComputedRole)(child.ownerMLDocument.specs, child, child.rule.options.version);
|
|
37
|
+
if (role.requiredOwnedElements.some(ownedRole => (0, ml_spec_1.isRequiredOwnedElement)(computedChild, ownedRole, child.ownerMLDocument.specs, child.rule.options.version))) {
|
|
43
38
|
return [child, 'REQUIRED'];
|
|
44
39
|
}
|
|
45
40
|
return [child, 'OTHER'];
|
|
@@ -49,6 +44,9 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
|
49
44
|
}
|
|
50
45
|
return [null, 'NO_ELEMENT'];
|
|
51
46
|
});
|
|
47
|
+
if (children.some(([, type]) => type === 'BUSY')) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
52
50
|
/**
|
|
53
51
|
* > Any element that will be owned by the element with this role.
|
|
54
52
|
* > For example, an element with the role list
|
|
@@ -77,6 +75,14 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
|
77
75
|
if (el.hasMutableChildren(true)) {
|
|
78
76
|
return;
|
|
79
77
|
}
|
|
78
|
+
if (mayBeBeforeCreated(el)) {
|
|
79
|
+
return {
|
|
80
|
+
scope: el,
|
|
81
|
+
message: t('{0}. Or, {1}', t('require {0}', role.requiredOwnedElements.length === 1
|
|
82
|
+
? t('the "{0*}" {1}', role.requiredOwnedElements[0], 'role')
|
|
83
|
+
: t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`), t('require {0}', 'aria-busy="true"')),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
80
86
|
return {
|
|
81
87
|
scope: el,
|
|
82
88
|
message: t('{0} expects {1}', t('the "{0*}" {1}', role.name, 'role'), role.requiredOwnedElements.length === 1
|
|
@@ -85,3 +91,11 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
|
|
|
85
91
|
};
|
|
86
92
|
};
|
|
87
93
|
exports.checkingRequiredOwnedElements = checkingRequiredOwnedElements;
|
|
94
|
+
function mayBeBeforeCreated(el) {
|
|
95
|
+
if (el.isEmpty()) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
return Array.from(el.children).every(child => {
|
|
99
|
+
return ['script', 'template'].includes(child.localName);
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -1,15 +1,9 @@
|
|
|
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
|
-
|
|
10
|
-
isImplicit?: boolean;
|
|
11
|
-
})
|
|
12
|
-
| null;
|
|
13
|
-
propSpecs: ARIAProperty[];
|
|
14
|
-
}
|
|
15
|
-
>;
|
|
4
|
+
export declare const checkingRequiredProp: ElementChecker<boolean, Options, {
|
|
5
|
+
role?: (ARIARole & {
|
|
6
|
+
isImplicit?: boolean;
|
|
7
|
+
}) | null;
|
|
8
|
+
propSpecs: ARIAProperty[];
|
|
9
|
+
}>;
|
|
@@ -1,15 +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 checkingValue: AttrChecker<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
propSpecs: ARIAProperty[];
|
|
10
|
-
booleanish?: boolean;
|
|
11
|
-
}
|
|
12
|
-
>;
|
|
4
|
+
export declare const checkingValue: AttrChecker<boolean, Options, {
|
|
5
|
+
role?: ARIARole | null;
|
|
6
|
+
propSpecs: ARIAProperty[];
|
|
7
|
+
booleanish?: boolean;
|
|
8
|
+
}>;
|
|
13
9
|
/**
|
|
14
10
|
*
|
|
15
11
|
* @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
|
package/lib/wai-aria/index.d.ts
CHANGED
package/lib/wai-aria/index.js
CHANGED
|
@@ -47,8 +47,8 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
47
47
|
}
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
const computed = (0, ml_core_1.getComputedRole)(document.specs, el, el.rule.
|
|
51
|
-
const { props: propSpecs } = (0, ml_core_1.ariaSpecs)(document.specs, el.rule.
|
|
50
|
+
const computed = (0, ml_core_1.getComputedRole)(document.specs, el, el.rule.options.version);
|
|
51
|
+
const { props: propSpecs } = (0, ml_core_1.ariaSpecs)(document.specs, el.rule.options.version);
|
|
52
52
|
if (roleAttr) {
|
|
53
53
|
if (report((0, non_existent_role_1.checkingNonExistentRole)({ attr: roleAttr }))) {
|
|
54
54
|
return;
|
|
@@ -57,39 +57,39 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
report((0, required_prop_1.checkingRequiredProp)({ el, role: computed.role, propSpecs }));
|
|
60
|
-
if (el.rule.
|
|
60
|
+
if (el.rule.options.disallowSetImplicitRole) {
|
|
61
61
|
report((0, implicit_role_1.checkingImplicitRole)({ attr: roleAttr }));
|
|
62
62
|
}
|
|
63
|
-
if (el.rule.
|
|
63
|
+
if (el.rule.options.permittedAriaRoles) {
|
|
64
64
|
report((0, permitted_roles_1.checkingPermittedRoles)({ attr: roleAttr }));
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
for (const attr of propAttrs) {
|
|
68
68
|
report((0, disallowed_prop_1.checkingDisallowedProp)({ attr, role: computed.role, propSpecs }));
|
|
69
|
-
if (el.rule.
|
|
69
|
+
if (el.rule.options.checkingDeprecatedProps) {
|
|
70
70
|
report((0, deprecated_props_1.checkingDeprecatedProps)({ attr, role: computed.role, propSpecs }));
|
|
71
71
|
}
|
|
72
|
-
if (el.rule.
|
|
72
|
+
if (el.rule.options.disallowSetImplicitProps) {
|
|
73
73
|
const attrSpecs = (0, ml_core_1.getAttrSpecs)(el, document.specs);
|
|
74
74
|
report((0, implicit_props_1.checkingImplicitProps)({ attr, propSpecs, attrSpecs }));
|
|
75
75
|
}
|
|
76
|
-
if (el.rule.
|
|
76
|
+
if (el.rule.options.checkingValue) {
|
|
77
77
|
report((0, value_1.checkingValue)({ attr, role: computed.role, propSpecs, booleanish: document.booleanish }));
|
|
78
78
|
}
|
|
79
|
-
if (el.rule.
|
|
79
|
+
if (el.rule.options.disallowDefaultValue) {
|
|
80
80
|
report((0, default_value_1.checkingDefaultValue)({ attr, propSpecs }));
|
|
81
81
|
}
|
|
82
82
|
if (!computed.role) {
|
|
83
83
|
report((0, no_global_prop_1.checkingNoGlobalProp)({ attr, propSpecs }));
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
if (el.rule.
|
|
86
|
+
if (el.rule.options.checkingRequiredOwnedElements) {
|
|
87
87
|
report((0, required_owned_elements_1.checkingRequiredOwnedElements)({ el, role: computed.role }));
|
|
88
88
|
}
|
|
89
|
-
if (el.rule.
|
|
89
|
+
if (el.rule.options.checkingPresentationalChildren) {
|
|
90
90
|
report((0, presentational_children_1.checkingPresentationalChildren)({ el }));
|
|
91
91
|
}
|
|
92
|
-
if (el.rule.
|
|
92
|
+
if (el.rule.options.checkingInteractionInHidden) {
|
|
93
93
|
report((0, interaction_in_hidden_1.checkingInteractionInHidden)({ el }));
|
|
94
94
|
}
|
|
95
95
|
});
|
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
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/rules",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.3",
|
|
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>",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"clean": "tsc --build --clean"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@markuplint/html-spec": "3.0.0-rc.
|
|
21
|
-
"@markuplint/ml-core": "3.0.0-rc.
|
|
22
|
-
"@markuplint/ml-spec": "3.0.0-rc.
|
|
23
|
-
"@markuplint/types": "3.0.0-rc.
|
|
20
|
+
"@markuplint/html-spec": "3.0.0-rc.3",
|
|
21
|
+
"@markuplint/ml-core": "3.0.0-rc.3",
|
|
22
|
+
"@markuplint/ml-spec": "3.0.0-rc.3",
|
|
23
|
+
"@markuplint/types": "3.0.0-rc.3",
|
|
24
24
|
"@ungap/structured-clone": "^1.0.1",
|
|
25
25
|
"debug": "^4.3.4",
|
|
26
26
|
"html-entities": "^2.3.3",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/debug": "^4.1.7"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "6cb4f1656d4cd7554891006181c1f79cea4d9bfa"
|
|
33
33
|
}
|