@markuplint/rules 3.7.0 → 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/index.d.ts +12 -12
- package/lib/invalid-attr/index.d.ts +38 -31
- 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/index.d.ts
CHANGED
|
@@ -20,32 +20,32 @@ declare const rules: {
|
|
|
20
20
|
} | {
|
|
21
21
|
pattern: string;
|
|
22
22
|
} | {
|
|
23
|
-
type: import("packages/@markuplint/ml-spec/
|
|
23
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
24
24
|
}> | (string | {
|
|
25
25
|
name: string;
|
|
26
|
-
value: ({
|
|
26
|
+
value: import("packages/@markuplint/ml-spec/src").AttributeType | ({
|
|
27
27
|
enum: [string, ...string[]];
|
|
28
28
|
} | {
|
|
29
29
|
pattern: string;
|
|
30
30
|
} | {
|
|
31
|
-
type: import("packages/@markuplint/ml-spec/
|
|
32
|
-
})
|
|
31
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
32
|
+
});
|
|
33
33
|
})[] | undefined;
|
|
34
34
|
disallowAttrs?: Record<string, {
|
|
35
35
|
enum: [string, ...string[]];
|
|
36
36
|
} | {
|
|
37
37
|
pattern: string;
|
|
38
38
|
} | {
|
|
39
|
-
type: import("packages/@markuplint/ml-spec/
|
|
39
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
40
40
|
}> | (string | {
|
|
41
41
|
name: string;
|
|
42
|
-
value: ({
|
|
42
|
+
value: import("packages/@markuplint/ml-spec/src").AttributeType | ({
|
|
43
43
|
enum: [string, ...string[]];
|
|
44
44
|
} | {
|
|
45
45
|
pattern: string;
|
|
46
46
|
} | {
|
|
47
|
-
type: import("packages/@markuplint/ml-spec/
|
|
48
|
-
})
|
|
47
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
48
|
+
});
|
|
49
49
|
})[] | undefined;
|
|
50
50
|
ignoreAttrNamePrefix?: string | string[] | undefined;
|
|
51
51
|
allowToAddPropertiesForPretender?: boolean | undefined;
|
|
@@ -54,7 +54,7 @@ declare const rules: {
|
|
|
54
54
|
} | {
|
|
55
55
|
pattern: string;
|
|
56
56
|
} | {
|
|
57
|
-
type: import("packages/@markuplint/ml-spec/
|
|
57
|
+
type: import("packages/@markuplint/ml-spec/src").AttributeType;
|
|
58
58
|
}) | {
|
|
59
59
|
disallowed: true;
|
|
60
60
|
}> | undefined;
|
|
@@ -72,7 +72,7 @@ declare const rules: {
|
|
|
72
72
|
}>>;
|
|
73
73
|
readonly 'no-hard-code-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
74
74
|
readonly 'no-refer-to-non-existent-id': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
|
|
75
|
-
ariaVersion:
|
|
75
|
+
ariaVersion: "1.1" | "1.2" | "1.3";
|
|
76
76
|
fragmentRefersNameAttr: boolean;
|
|
77
77
|
}>>;
|
|
78
78
|
readonly 'no-use-event-handler-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
@@ -81,14 +81,14 @@ declare const rules: {
|
|
|
81
81
|
readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types").TagRule[], import("./permitted-contents/types").Options>>;
|
|
82
82
|
readonly 'placeholder-label-option': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
|
|
83
83
|
readonly 'require-accessible-name': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
84
|
-
ariaVersion:
|
|
84
|
+
ariaVersion: "1.1" | "1.2" | "1.3";
|
|
85
85
|
}>>;
|
|
86
86
|
readonly 'require-datetime': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
87
87
|
langs?: import("./require-datetime/types").Lang[] | undefined;
|
|
88
88
|
}>>;
|
|
89
89
|
readonly 'required-attr': Readonly<import("@markuplint/ml-core").RuleSeed<string | (string | {
|
|
90
90
|
name: string;
|
|
91
|
-
value
|
|
91
|
+
value?: string | string[] | undefined;
|
|
92
92
|
})[], undefined>>;
|
|
93
93
|
readonly 'required-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], {
|
|
94
94
|
ignoreHasMutableContents: boolean;
|
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
import type { AttributeType } from '@markuplint/ml-spec';
|
|
2
2
|
type Option = {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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>;
|
|
11
|
+
ignoreAttrNamePrefix?: string | string[];
|
|
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
|
+
>;
|
|
24
28
|
};
|
|
25
29
|
type Attr = {
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
name: string;
|
|
31
|
+
value: AttributeType | ValueRule;
|
|
28
32
|
};
|
|
29
|
-
type ValueRule =
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
33
|
+
type ValueRule =
|
|
34
|
+
| {
|
|
35
|
+
enum: [string, ...string[]];
|
|
36
|
+
}
|
|
37
|
+
| {
|
|
38
|
+
pattern: string;
|
|
39
|
+
}
|
|
40
|
+
| {
|
|
41
|
+
type: AttributeType;
|
|
42
|
+
};
|
|
43
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Option>>;
|
|
37
44
|
export default _default;
|
|
@@ -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
|
}
|