@markuplint/rules 3.12.0 → 4.0.0-alpha.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.js +14 -19
- package/lib/attr-duplication/index.js +3 -6
- package/lib/attr-value-quotes/index.js +5 -9
- package/lib/case-sensitive-attr-name/index.js +9 -13
- package/lib/case-sensitive-tag-name/index.js +2 -4
- package/lib/character-reference/index.js +6 -8
- package/lib/class-naming/index.js +9 -11
- package/lib/create-message.js +9 -16
- package/lib/debug.js +2 -6
- package/lib/deprecated-attr/index.js +6 -9
- package/lib/deprecated-element/index.js +3 -5
- package/lib/disallowed-element/index.js +2 -4
- package/lib/doctype/index.js +2 -4
- package/lib/end-tag/index.js +5 -8
- package/lib/helpers.d.ts +1 -1
- package/lib/helpers.js +17 -28
- package/lib/id-duplication/index.js +2 -4
- package/lib/index.d.ts +15 -15
- package/lib/index.js +63 -66
- package/lib/ineffective-attr/index.js +5 -7
- package/lib/invalid-attr/index.js +30 -33
- package/lib/label-has-control/index.js +2 -4
- package/lib/landmark-roles/index.js +3 -6
- package/lib/no-boolean-attr-value/index.js +6 -9
- package/lib/no-default-value/index.js +9 -12
- package/lib/no-empty-palpable-content/index.js +5 -7
- package/lib/no-hard-code-id/index.js +2 -4
- package/lib/no-refer-to-non-existent-id/index.js +26 -30
- package/lib/no-use-event-handler-attr/index.js +4 -6
- package/lib/permitted-contents/choice.d.ts +1 -1
- package/lib/permitted-contents/choice.js +13 -18
- package/lib/permitted-contents/complex-branch.d.ts +1 -1
- package/lib/permitted-contents/complex-branch.js +10 -14
- package/lib/permitted-contents/content-model.d.ts +1 -1
- package/lib/permitted-contents/content-model.js +5 -9
- package/lib/permitted-contents/count-pattern.d.ts +1 -1
- package/lib/permitted-contents/count-pattern.js +19 -24
- package/lib/permitted-contents/debug.browser.js +9 -12
- package/lib/permitted-contents/debug.d.ts +8 -1
- package/lib/permitted-contents/debug.js +12 -13
- package/lib/permitted-contents/index.d.ts +1 -1
- package/lib/permitted-contents/index.js +10 -13
- package/lib/permitted-contents/matches-selector.d.ts +1 -1
- package/lib/permitted-contents/matches-selector.js +12 -17
- package/lib/permitted-contents/order.d.ts +1 -1
- package/lib/permitted-contents/order.js +17 -22
- package/lib/permitted-contents/recursive-branch.d.ts +2 -2
- package/lib/permitted-contents/recursive-branch.js +9 -13
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +1 -1
- package/lib/permitted-contents/represent-transparent-nodes.js +15 -20
- package/lib/permitted-contents/start.d.ts +1 -1
- package/lib/permitted-contents/start.js +13 -21
- package/lib/permitted-contents/transparent.d.ts +1 -1
- package/lib/permitted-contents/transparent.js +4 -9
- package/lib/permitted-contents/types.js +1 -2
- package/lib/permitted-contents/utils.d.ts +1 -1
- package/lib/permitted-contents/utils.js +55 -74
- package/lib/placeholder-label-option/index.js +5 -9
- package/lib/require-accessible-name/index.js +10 -13
- package/lib/require-datetime/index.d.ts +1 -1
- package/lib/require-datetime/index.js +6 -8
- package/lib/require-datetime/types.js +1 -2
- package/lib/require-datetime/utils.d.ts +1 -1
- package/lib/require-datetime/utils.js +4 -11
- package/lib/required-attr/index.js +8 -11
- package/lib/required-element/index.js +3 -6
- package/lib/required-h1/index.js +3 -6
- package/lib/use-list/index.js +6 -10
- package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
- package/lib/wai-aria/checkings/abstract-role.js +5 -10
- package/lib/wai-aria/checkings/default-value.d.ts +1 -1
- package/lib/wai-aria/checkings/default-value.js +2 -6
- package/lib/wai-aria/checkings/deprecated-props.d.ts +1 -1
- package/lib/wai-aria/checkings/deprecated-props.js +3 -8
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +1 -1
- package/lib/wai-aria/checkings/disallowed-prop.js +7 -12
- package/lib/wai-aria/checkings/implicit-props.d.ts +1 -1
- package/lib/wai-aria/checkings/implicit-props.js +6 -11
- package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
- package/lib/wai-aria/checkings/implicit-role.js +4 -9
- package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
- package/lib/wai-aria/checkings/interaction-in-hidden.js +4 -8
- package/lib/wai-aria/checkings/no-global-prop.d.ts +1 -1
- package/lib/wai-aria/checkings/no-global-prop.js +2 -7
- package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
- package/lib/wai-aria/checkings/non-existent-role.js +4 -9
- package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
- package/lib/wai-aria/checkings/permitted-roles.js +4 -9
- package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
- package/lib/wai-aria/checkings/presentational-children.js +4 -9
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +1 -1
- package/lib/wai-aria/checkings/required-owned-elements.js +4 -8
- package/lib/wai-aria/checkings/required-prop.d.ts +1 -1
- package/lib/wai-aria/checkings/required-prop.js +2 -7
- package/lib/wai-aria/checkings/value.d.ts +1 -1
- package/lib/wai-aria/checkings/value.js +4 -10
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/index.js +38 -40
- package/lib/wai-aria/types.js +1 -2
- package/package.json +17 -12
- package/test/attr-check.spec.js +0 -77
- package/test/attr-duplication/index.spec.js +0 -159
- package/test/attr-value-quotes/index.spec.js +0 -133
- package/test/case-sensitive-attr-name/index.spec.js +0 -65
- package/test/case-sensitive-tag-name/index.spec.js +0 -80
- package/test/character-reference/index.spec.js +0 -72
- package/test/class-naming/index.spec.js +0 -470
- package/test/create-message.spec.js +0 -497
- package/test/deprecated-attr/index.spec.js +0 -48
- package/test/deprecated-element/index.spec.js +0 -35
- package/test/disallowed-element/index.spec.js +0 -90
- package/test/doctype/index.spec.js +0 -50
- package/test/end-tag/index.spec.js +0 -162
- package/test/id-duplication/index.spec.js +0 -47
- package/test/ineffective-attr/index.spec.js +0 -31
- package/test/invalid-attr/index.spec.js +0 -1641
- package/test/label-has-control/index.spec.js +0 -29
- package/test/landmark-roles/index.spec.js +0 -187
- package/test/no-boolean-attr-value/index.spec.js +0 -41
- package/test/no-default-value/index.spec.js +0 -74
- package/test/no-empty-palpable-content/index.spec.js +0 -115
- package/test/no-hard-code-id/index.spec.js +0 -100
- package/test/no-refer-to-non-existent-id/index.spec.js +0 -254
- package/test/no-use-event-handler-attr/index.spec.js +0 -57
- package/test/permitted-contents/choice.spec.js +0 -174
- package/test/permitted-contents/count-pattern.spec.js +0 -308
- package/test/permitted-contents/index.spec.js +0 -1395
- package/test/permitted-contents/matches-selector.spec.js +0 -59
- package/test/permitted-contents/order.spec.js +0 -351
- package/test/permitted-contents/recursive-branch.spec.js +0 -41
- package/test/permitted-contents/represent-transparent-nodes.spec.js +0 -24
- package/test/permitted-contents/start.spec.js +0 -67
- package/test/placeholder-label-option/index.spec.js +0 -113
- package/test/require-accessible-name/index.spec.js +0 -444
- package/test/require-datetime/index.spec.js +0 -54
- package/test/require-datetime/utils.spec.js +0 -52
- package/test/required-attr/index.spec.js +0 -414
- package/test/required-element/index.spec.js +0 -188
- package/test/required-h1/index.spec.js +0 -69
- package/test/use-list/index.spec.js +0 -109
- package/test/wai-aria/checkings/value.spec.js +0 -33
- package/test/wai-aria/index.spec.js +0 -1203
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
declare const rules: {
|
|
2
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>>;
|
|
3
|
+
readonly 'attr-value-quotes': Readonly<import("@markuplint/ml-core").RuleSeed<import("./attr-value-quotes/index.js").Type, undefined>>;
|
|
4
|
+
readonly 'case-sensitive-attr-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-attr-name/index.js").Value, undefined>>;
|
|
5
|
+
readonly 'case-sensitive-tag-name': Readonly<import("@markuplint/ml-core").RuleSeed<import("./case-sensitive-tag-name/index.js").Value, undefined>>;
|
|
6
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>>;
|
|
7
|
+
readonly 'class-naming': Readonly<import("@markuplint/ml-core").RuleSeed<import("./class-naming/index.js").Value, undefined>>;
|
|
8
8
|
readonly 'deprecated-attr': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
9
9
|
readonly 'deprecated-element': Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
10
10
|
readonly 'disallowed-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], undefined>>;
|
|
@@ -20,15 +20,15 @@ declare const rules: {
|
|
|
20
20
|
} | {
|
|
21
21
|
pattern: string;
|
|
22
22
|
} | {
|
|
23
|
-
type: import("packages/@markuplint/ml-spec/lib").AttributeType;
|
|
23
|
+
type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
|
|
24
24
|
}> | (string | {
|
|
25
25
|
name: string;
|
|
26
|
-
value: import("packages/@markuplint/ml-spec/lib").AttributeType | ({
|
|
26
|
+
value: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType | ({
|
|
27
27
|
enum: [string, ...string[]];
|
|
28
28
|
} | {
|
|
29
29
|
pattern: string;
|
|
30
30
|
} | {
|
|
31
|
-
type: import("packages/@markuplint/ml-spec/lib").AttributeType;
|
|
31
|
+
type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
|
|
32
32
|
});
|
|
33
33
|
})[] | undefined;
|
|
34
34
|
disallowAttrs?: Record<string, {
|
|
@@ -36,15 +36,15 @@ declare const rules: {
|
|
|
36
36
|
} | {
|
|
37
37
|
pattern: string;
|
|
38
38
|
} | {
|
|
39
|
-
type: import("packages/@markuplint/ml-spec/lib").AttributeType;
|
|
39
|
+
type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
|
|
40
40
|
}> | (string | {
|
|
41
41
|
name: string;
|
|
42
|
-
value: import("packages/@markuplint/ml-spec/lib").AttributeType | ({
|
|
42
|
+
value: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType | ({
|
|
43
43
|
enum: [string, ...string[]];
|
|
44
44
|
} | {
|
|
45
45
|
pattern: string;
|
|
46
46
|
} | {
|
|
47
|
-
type: import("packages/@markuplint/ml-spec/lib").AttributeType;
|
|
47
|
+
type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
|
|
48
48
|
});
|
|
49
49
|
})[] | undefined;
|
|
50
50
|
ignoreAttrNamePrefix?: string | string[] | undefined;
|
|
@@ -54,7 +54,7 @@ declare const rules: {
|
|
|
54
54
|
} | {
|
|
55
55
|
pattern: string;
|
|
56
56
|
} | {
|
|
57
|
-
type: import("packages/@markuplint/ml-spec/lib").AttributeType;
|
|
57
|
+
type: import("packages/@markuplint/ml-spec/lib/index.js").AttributeType;
|
|
58
58
|
}) | {
|
|
59
59
|
disallowed: true;
|
|
60
60
|
}> | undefined;
|
|
@@ -78,13 +78,13 @@ declare const rules: {
|
|
|
78
78
|
readonly 'no-use-event-handler-attr': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
79
79
|
ignore?: string | string[] | undefined;
|
|
80
80
|
}>>;
|
|
81
|
-
readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types").TagRule[], import("./permitted-contents/types").Options>>;
|
|
81
|
+
readonly 'permitted-contents': Readonly<import("@markuplint/ml-core").RuleSeed<import("./permitted-contents/types.js").TagRule[], import("./permitted-contents/types.js").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
84
|
ariaVersion: "1.1" | "1.2" | "1.3";
|
|
85
85
|
}>>;
|
|
86
86
|
readonly 'require-datetime': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, {
|
|
87
|
-
langs?: import("./require-datetime/types").Lang[] | undefined;
|
|
87
|
+
langs?: import("./require-datetime/types.js").Lang[] | undefined;
|
|
88
88
|
}>>;
|
|
89
89
|
readonly 'required-attr': Readonly<import("@markuplint/ml-core").RuleSeed<string | (string | {
|
|
90
90
|
name: string;
|
|
@@ -93,10 +93,10 @@ declare const rules: {
|
|
|
93
93
|
readonly 'required-element': Readonly<import("@markuplint/ml-core").RuleSeed<string[], {
|
|
94
94
|
ignoreHasMutableContents: boolean;
|
|
95
95
|
}>>;
|
|
96
|
-
readonly 'required-h1': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./required-h1").Options>>;
|
|
96
|
+
readonly 'required-h1': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./required-h1/index.js").Options>>;
|
|
97
97
|
readonly 'use-list': Readonly<import("@markuplint/ml-core").RuleSeed<readonly string[], {
|
|
98
98
|
spaceNeededBullets?: string[] | undefined;
|
|
99
99
|
}>>;
|
|
100
|
-
readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types").Options>>;
|
|
100
|
+
readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types.js").Options>>;
|
|
101
101
|
};
|
|
102
102
|
export default rules;
|
package/lib/index.js
CHANGED
|
@@ -1,68 +1,65 @@
|
|
|
1
|
-
|
|
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
|
-
const required_h1_1 = tslib_1.__importDefault(require("./required-h1"));
|
|
33
|
-
const use_list_1 = tslib_1.__importDefault(require("./use-list"));
|
|
34
|
-
const wai_aria_1 = tslib_1.__importDefault(require("./wai-aria"));
|
|
1
|
+
import AttrDuplication from './attr-duplication/index.js';
|
|
2
|
+
import AttrValueQuotes from './attr-value-quotes/index.js';
|
|
3
|
+
import CaseSensitiveAttrName from './case-sensitive-attr-name/index.js';
|
|
4
|
+
import CaseSensitiveTagName from './case-sensitive-tag-name/index.js';
|
|
5
|
+
import CharacterReference from './character-reference/index.js';
|
|
6
|
+
import ClassNaming from './class-naming/index.js';
|
|
7
|
+
import DeprecatedAttr from './deprecated-attr/index.js';
|
|
8
|
+
import DeprecatedElement from './deprecated-element/index.js';
|
|
9
|
+
import DisallowedElement from './disallowed-element/index.js';
|
|
10
|
+
import Doctype from './doctype/index.js';
|
|
11
|
+
import EndTag from './end-tag/index.js';
|
|
12
|
+
import IdDuplication from './id-duplication/index.js';
|
|
13
|
+
import IneffectiveAttr from './ineffective-attr/index.js';
|
|
14
|
+
import InvalidAttr from './invalid-attr/index.js';
|
|
15
|
+
import LabelHasControl from './label-has-control/index.js';
|
|
16
|
+
import LandmarkRoles from './landmark-roles/index.js';
|
|
17
|
+
import NoBooleanAttrValue from './no-boolean-attr-value/index.js';
|
|
18
|
+
import NoDefaultValue from './no-default-value/index.js';
|
|
19
|
+
import NoEmptyPalpableContent from './no-empty-palpable-content/index.js';
|
|
20
|
+
import NoHardCodeId from './no-hard-code-id/index.js';
|
|
21
|
+
import NoReferToNonExistentId from './no-refer-to-non-existent-id/index.js';
|
|
22
|
+
import NoUseEventHandlerAttr from './no-use-event-handler-attr/index.js';
|
|
23
|
+
import PermittedContents from './permitted-contents/index.js';
|
|
24
|
+
import PlaceholderLabelOption from './placeholder-label-option/index.js';
|
|
25
|
+
import RequireAccessibleName from './require-accessible-name/index.js';
|
|
26
|
+
import RequireDatetime from './require-datetime/index.js';
|
|
27
|
+
import RequiredAttr from './required-attr/index.js';
|
|
28
|
+
import RequiredElement from './required-element/index.js';
|
|
29
|
+
import RequiredH1 from './required-h1/index.js';
|
|
30
|
+
import UseList from './use-list/index.js';
|
|
31
|
+
import WaiAria from './wai-aria/index.js';
|
|
35
32
|
const rules = {
|
|
36
|
-
'attr-duplication':
|
|
37
|
-
'attr-value-quotes':
|
|
38
|
-
'case-sensitive-attr-name':
|
|
39
|
-
'case-sensitive-tag-name':
|
|
40
|
-
'character-reference':
|
|
41
|
-
'class-naming':
|
|
42
|
-
'deprecated-attr':
|
|
43
|
-
'deprecated-element':
|
|
44
|
-
'disallowed-element':
|
|
45
|
-
doctype:
|
|
46
|
-
'end-tag':
|
|
47
|
-
'id-duplication':
|
|
48
|
-
'ineffective-attr':
|
|
49
|
-
'invalid-attr':
|
|
50
|
-
'label-has-control':
|
|
51
|
-
'landmark-roles':
|
|
52
|
-
'no-boolean-attr-value':
|
|
53
|
-
'no-default-value':
|
|
54
|
-
'no-empty-palpable-content':
|
|
55
|
-
'no-hard-code-id':
|
|
56
|
-
'no-refer-to-non-existent-id':
|
|
57
|
-
'no-use-event-handler-attr':
|
|
58
|
-
'permitted-contents':
|
|
59
|
-
'placeholder-label-option':
|
|
60
|
-
'require-accessible-name':
|
|
61
|
-
'require-datetime':
|
|
62
|
-
'required-attr':
|
|
63
|
-
'required-element':
|
|
64
|
-
'required-h1':
|
|
65
|
-
'use-list':
|
|
66
|
-
'wai-aria':
|
|
33
|
+
'attr-duplication': AttrDuplication,
|
|
34
|
+
'attr-value-quotes': AttrValueQuotes,
|
|
35
|
+
'case-sensitive-attr-name': CaseSensitiveAttrName,
|
|
36
|
+
'case-sensitive-tag-name': CaseSensitiveTagName,
|
|
37
|
+
'character-reference': CharacterReference,
|
|
38
|
+
'class-naming': ClassNaming,
|
|
39
|
+
'deprecated-attr': DeprecatedAttr,
|
|
40
|
+
'deprecated-element': DeprecatedElement,
|
|
41
|
+
'disallowed-element': DisallowedElement,
|
|
42
|
+
doctype: Doctype,
|
|
43
|
+
'end-tag': EndTag,
|
|
44
|
+
'id-duplication': IdDuplication,
|
|
45
|
+
'ineffective-attr': IneffectiveAttr,
|
|
46
|
+
'invalid-attr': InvalidAttr,
|
|
47
|
+
'label-has-control': LabelHasControl,
|
|
48
|
+
'landmark-roles': LandmarkRoles,
|
|
49
|
+
'no-boolean-attr-value': NoBooleanAttrValue,
|
|
50
|
+
'no-default-value': NoDefaultValue,
|
|
51
|
+
'no-empty-palpable-content': NoEmptyPalpableContent,
|
|
52
|
+
'no-hard-code-id': NoHardCodeId,
|
|
53
|
+
'no-refer-to-non-existent-id': NoReferToNonExistentId,
|
|
54
|
+
'no-use-event-handler-attr': NoUseEventHandlerAttr,
|
|
55
|
+
'permitted-contents': PermittedContents,
|
|
56
|
+
'placeholder-label-option': PlaceholderLabelOption,
|
|
57
|
+
'require-accessible-name': RequireAccessibleName,
|
|
58
|
+
'require-datetime': RequireDatetime,
|
|
59
|
+
'required-attr': RequiredAttr,
|
|
60
|
+
'required-element': RequiredElement,
|
|
61
|
+
'required-h1': RequiredH1,
|
|
62
|
+
'use-list': UseList,
|
|
63
|
+
'wai-aria': WaiAria,
|
|
67
64
|
};
|
|
68
|
-
|
|
65
|
+
export default rules;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const shared_1 = require("@markuplint/shared");
|
|
5
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
|
+
import { toNoEmptyStringArrayFromStringOrArray } from '@markuplint/shared';
|
|
3
|
+
export default createRule({
|
|
6
4
|
defaultSeverity: 'warning',
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
await document.walkOn('Attr', attr => {
|
|
9
|
-
const attrSpec =
|
|
7
|
+
const attrSpec = getAttrSpecs(attr.ownerElement, document.specs);
|
|
10
8
|
if (!attrSpec) {
|
|
11
9
|
return;
|
|
12
10
|
}
|
|
@@ -15,7 +13,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
15
13
|
if (!spec) {
|
|
16
14
|
return;
|
|
17
15
|
}
|
|
18
|
-
const ineffectiveConditions =
|
|
16
|
+
const ineffectiveConditions = toNoEmptyStringArrayFromStringOrArray(spec.ineffective);
|
|
19
17
|
if (ineffectiveConditions.some(selector => attr.ownerElement.matches(selector))) {
|
|
20
18
|
report({
|
|
21
19
|
scope: attr,
|
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const log = debug_1.log.extend('invalid-attr');
|
|
8
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs, getSpec } from '@markuplint/ml-core';
|
|
2
|
+
import { attrCheck } from '../attr-check.js';
|
|
3
|
+
import { log as ruleLog } from '../debug.js';
|
|
4
|
+
import { isValidAttr, match } from '../helpers.js';
|
|
5
|
+
const log = ruleLog.extend('invalid-attr');
|
|
6
|
+
export default createRule({
|
|
9
7
|
defaultOptions: {},
|
|
10
8
|
async verify({ document, report, t }) {
|
|
11
9
|
await document.walkOn('Attr', attr => {
|
|
12
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
13
10
|
// Default
|
|
14
|
-
const allowToAddPropertiesForPretender =
|
|
11
|
+
const allowToAddPropertiesForPretender = attr.rule.options.allowToAddPropertiesForPretender ?? true;
|
|
15
12
|
if (attr.isDirective) {
|
|
16
13
|
return;
|
|
17
14
|
}
|
|
18
|
-
const attrSpecs =
|
|
15
|
+
const attrSpecs = getAttrSpecs(attr.ownerElement, document.specs);
|
|
19
16
|
const attrName = attr.nameNode;
|
|
20
17
|
const name = attr.name;
|
|
21
18
|
if (attr.ownerElement.elementType === 'html' && attr.candidate) {
|
|
@@ -24,9 +21,9 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
24
21
|
t('Did you mean "{0}"?', attr.candidate);
|
|
25
22
|
report({
|
|
26
23
|
scope: attr,
|
|
27
|
-
line: attrName
|
|
28
|
-
col: attrName
|
|
29
|
-
raw: attrName
|
|
24
|
+
line: attrName?.startLine,
|
|
25
|
+
col: attrName?.startCol,
|
|
26
|
+
raw: attrName?.raw,
|
|
30
27
|
message: message,
|
|
31
28
|
});
|
|
32
29
|
return;
|
|
@@ -94,11 +91,11 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
93
|
}
|
|
97
|
-
const allowValue =
|
|
98
|
-
const disallowValue =
|
|
94
|
+
const allowValue = allowAttrs[name] ?? null;
|
|
95
|
+
const disallowValue = disallowAttrs[name] ?? null;
|
|
99
96
|
if (allowValue) {
|
|
100
97
|
if ('enum' in allowValue) {
|
|
101
|
-
invalid =
|
|
98
|
+
invalid = attrCheck(t, name.toLowerCase(), value, true, {
|
|
102
99
|
name,
|
|
103
100
|
type: {
|
|
104
101
|
enum: allowValue.enum,
|
|
@@ -107,7 +104,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
107
104
|
});
|
|
108
105
|
}
|
|
109
106
|
else if ('pattern' in allowValue) {
|
|
110
|
-
if (!
|
|
107
|
+
if (!match(value, allowValue.pattern)) {
|
|
111
108
|
invalid = {
|
|
112
109
|
invalidType: 'invalid-value',
|
|
113
110
|
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), allowValue.pattern),
|
|
@@ -115,12 +112,12 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
115
112
|
}
|
|
116
113
|
}
|
|
117
114
|
else if ('type' in allowValue) {
|
|
118
|
-
invalid =
|
|
115
|
+
invalid = attrCheck(t, name, value, true, { name, type: allowValue.type, description: '' });
|
|
119
116
|
}
|
|
120
117
|
}
|
|
121
118
|
else if (disallowValue) {
|
|
122
119
|
if ('enum' in disallowValue) {
|
|
123
|
-
const checkResult =
|
|
120
|
+
const checkResult = attrCheck(t, name.toLowerCase(), value, true, {
|
|
124
121
|
name,
|
|
125
122
|
type: {
|
|
126
123
|
enum: disallowValue.enum,
|
|
@@ -135,7 +132,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
135
132
|
}
|
|
136
133
|
}
|
|
137
134
|
else if ('pattern' in disallowValue) {
|
|
138
|
-
if (
|
|
135
|
+
if (match(value, disallowValue.pattern)) {
|
|
139
136
|
invalid = {
|
|
140
137
|
invalidType: 'invalid-value',
|
|
141
138
|
message: t('{0} is matched with the below disallowed patterns: {1}', t('the "{0*}" {1}', name, 'attribute'), disallowValue.pattern),
|
|
@@ -150,7 +147,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
150
147
|
};
|
|
151
148
|
}
|
|
152
149
|
else {
|
|
153
|
-
const checkResult =
|
|
150
|
+
const checkResult = attrCheck(t, name, value, true, {
|
|
154
151
|
name,
|
|
155
152
|
type: disallowValue.type,
|
|
156
153
|
description: '',
|
|
@@ -166,7 +163,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
166
163
|
}
|
|
167
164
|
else if (attr.ownerElement.elementType === 'html' && attrSpecs) {
|
|
168
165
|
log('Checking %s[%s="%s"]', attr.nodeName, name, value);
|
|
169
|
-
invalid =
|
|
166
|
+
invalid = isValidAttr(t, name, value, attr.isDynamicValue || false, attr.ownerElement, attrSpecs, log);
|
|
170
167
|
}
|
|
171
168
|
if (invalid !== false) {
|
|
172
169
|
switch (invalid.invalidType) {
|
|
@@ -184,28 +181,28 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
184
181
|
report({
|
|
185
182
|
scope: attr,
|
|
186
183
|
message: invalid.message,
|
|
187
|
-
line: (
|
|
184
|
+
line: (valueNode?.startLine ?? 0) + (invalid.loc?.line ?? 0),
|
|
188
185
|
col: invalid.loc && invalid.loc.line > 0
|
|
189
|
-
?
|
|
190
|
-
: (
|
|
191
|
-
raw:
|
|
186
|
+
? invalid.loc?.col + 1
|
|
187
|
+
: (valueNode?.startCol ?? 0) + (invalid.loc?.col ?? 0),
|
|
188
|
+
raw: invalid.loc?.raw ?? value,
|
|
192
189
|
});
|
|
193
190
|
break;
|
|
194
191
|
}
|
|
195
192
|
case 'non-existent': {
|
|
196
|
-
if (allowToAddPropertiesForPretender &&
|
|
193
|
+
if (allowToAddPropertiesForPretender && attr.ownerElement.pretenderContext?.type === 'origin') {
|
|
197
194
|
return;
|
|
198
195
|
}
|
|
199
|
-
const spec =
|
|
200
|
-
if (spec
|
|
196
|
+
const spec = getSpec(attr.ownerElement, document.specs.specs);
|
|
197
|
+
if (spec?.possibleToAddProperties) {
|
|
201
198
|
return;
|
|
202
199
|
}
|
|
203
200
|
report({
|
|
204
201
|
scope: attr,
|
|
205
202
|
message: invalid.message,
|
|
206
|
-
line: attrName
|
|
207
|
-
col: attrName
|
|
208
|
-
raw: attrName
|
|
203
|
+
line: attrName?.startLine,
|
|
204
|
+
col: attrName?.startCol,
|
|
205
|
+
raw: attrName?.raw,
|
|
209
206
|
});
|
|
210
207
|
}
|
|
211
208
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
4
2
|
const controlSelector = ["input:not([type='hidden' i])", 'select', 'textarea'].join(',');
|
|
5
|
-
|
|
3
|
+
export default createRule({
|
|
6
4
|
defaultSeverity: 'warning',
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
await document.walkOn('Element', el => {
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
4
2
|
const selectors = {
|
|
5
3
|
complementary: ['[role="complementary"]', 'aside'],
|
|
6
4
|
contentinfo: ['[role="contentinfo"]'],
|
|
@@ -11,14 +9,13 @@ const selectors = {
|
|
|
11
9
|
region: ['[role="region"]', 'section[aria-labelledby]', 'section[aria-label]', 'section[title]'],
|
|
12
10
|
};
|
|
13
11
|
const topLevelRoles = ['banner', 'main', 'complementary', 'contentinfo'];
|
|
14
|
-
|
|
12
|
+
export default createRule({
|
|
15
13
|
defaultSeverity: 'warning',
|
|
16
14
|
defaultOptions: {
|
|
17
15
|
ignoreRoles: [],
|
|
18
16
|
labelEachArea: true,
|
|
19
17
|
},
|
|
20
18
|
verify({ document, report, t }) {
|
|
21
|
-
var _a;
|
|
22
19
|
if (document.isFragment) {
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
@@ -72,7 +69,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
72
69
|
if (el.rule.disabled) {
|
|
73
70
|
continue;
|
|
74
71
|
}
|
|
75
|
-
if (
|
|
72
|
+
if (el.rule.options.ignoreRoles?.includes(role)) {
|
|
76
73
|
continue;
|
|
77
74
|
}
|
|
78
75
|
if (el.isDescendantByUUIDList(uuidList)) {
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
5
3
|
defaultSeverity: 'warning',
|
|
6
4
|
async verify({ document, report, t }) {
|
|
7
5
|
await document.walkOn('Attr', attr => {
|
|
8
|
-
|
|
9
|
-
const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
6
|
+
const attrSpec = getAttrSpecs(attr.ownerElement, document.specs);
|
|
10
7
|
if (!attrSpec) {
|
|
11
8
|
return;
|
|
12
9
|
}
|
|
@@ -29,12 +26,12 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
29
26
|
attr.valueNode,
|
|
30
27
|
attr.endQuote,
|
|
31
28
|
];
|
|
32
|
-
const extraRaw = extraTokens.reduce((raw, t) =>
|
|
29
|
+
const extraRaw = extraTokens.reduce((raw, t) => raw + (t?.raw ?? ''), '');
|
|
33
30
|
if (extraRaw) {
|
|
34
31
|
report({
|
|
35
32
|
scope: attr,
|
|
36
|
-
line:
|
|
37
|
-
col:
|
|
33
|
+
line: attr.spacesBeforeEqual?.startLine,
|
|
34
|
+
col: attr.spacesBeforeEqual?.startCol,
|
|
38
35
|
raw: extraRaw,
|
|
39
36
|
message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), t('a {0}', 'boolean attribute')) +
|
|
40
37
|
t('. ') +
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const helpers_1 = require("../helpers");
|
|
5
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule, getAttrSpecs } from '@markuplint/ml-core';
|
|
2
|
+
import { toNormalizedValue } from '../helpers.js';
|
|
3
|
+
export default createRule({
|
|
6
4
|
defaultSeverity: 'warning',
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
await document.walkOn('Attr', attr => {
|
|
9
|
-
|
|
10
|
-
const attrSpec = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
|
|
7
|
+
const attrSpec = getAttrSpecs(attr.ownerElement, document.specs);
|
|
11
8
|
if (!attrSpec) {
|
|
12
9
|
return;
|
|
13
10
|
}
|
|
@@ -18,14 +15,14 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
18
15
|
if (!spec.defaultValue) {
|
|
19
16
|
return;
|
|
20
17
|
}
|
|
21
|
-
const normalizedValue =
|
|
22
|
-
const defaultValue =
|
|
18
|
+
const normalizedValue = toNormalizedValue(attr.value, spec);
|
|
19
|
+
const defaultValue = toNormalizedValue(spec.defaultValue, spec);
|
|
23
20
|
if (defaultValue === normalizedValue) {
|
|
24
21
|
report({
|
|
25
22
|
scope: attr,
|
|
26
|
-
line:
|
|
27
|
-
col:
|
|
28
|
-
raw:
|
|
23
|
+
line: attr.valueNode?.startLine,
|
|
24
|
+
col: attr.valueNode?.startCol,
|
|
25
|
+
raw: attr.valueNode?.raw,
|
|
29
26
|
message: t('It is {0}', t('the {0}', 'default value')),
|
|
30
27
|
});
|
|
31
28
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
import { isNothingContentModel, isPalpableElement } from '@markuplint/ml-spec';
|
|
3
|
+
export default createRule({
|
|
6
4
|
defaultSeverity: 'warning',
|
|
7
5
|
defaultOptions: {
|
|
8
6
|
extendsExposableElements: true,
|
|
@@ -18,13 +16,13 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
18
16
|
if (el.localName === 'textarea') {
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
|
-
if (!
|
|
19
|
+
if (!isPalpableElement(el, el.ownerMLDocument.specs, {
|
|
22
20
|
extendsSvg: false,
|
|
23
21
|
extendsExposableElements: el.rule.options.extendsExposableElements,
|
|
24
22
|
})) {
|
|
25
23
|
return;
|
|
26
24
|
}
|
|
27
|
-
if (
|
|
25
|
+
if (isNothingContentModel(el)) {
|
|
28
26
|
return;
|
|
29
27
|
}
|
|
30
28
|
if (el.rule.options.ignoreIfAriaBusy && el.getAttribute('aria-busy') === 'true') {
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
5
3
|
defaultSeverity: 'warning',
|
|
6
4
|
async verify({ document, report, t }) {
|
|
7
5
|
if (!document.isFragment) {
|