@markuplint/rules 2.0.0-rc.6 → 2.0.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/README.md +34 -66
- package/lib/attr-check.d.ts +19 -8
- package/lib/attr-duplication/index.d.ts +1 -1
- package/lib/attr-equal-space-after/index.d.ts +1 -1
- package/lib/attr-equal-space-before/index.d.ts +1 -1
- package/lib/attr-spacing/index.d.ts +3 -3
- 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 +12 -2
- 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 +74 -41
- package/lib/id-duplication/index.d.ts +1 -1
- package/lib/indentation/index.d.ts +3 -3
- package/lib/index.d.ts +147 -61
- package/lib/ineffective-attr/index.d.ts +1 -1
- package/lib/invalid-attr/index.d.ts +16 -12
- package/lib/landmark-roles/index.d.ts +3 -3
- package/lib/no-boolean-attr-value/index.d.ts +1 -1
- package/lib/no-default-value/index.d.ts +1 -1
- package/lib/no-hard-code-id/index.d.ts +1 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +1 -1
- package/lib/no-use-event-handler-attr/index.d.ts +2 -2
- package/lib/permitted-contents/index.d.ts +2 -2
- package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +8 -8
- package/lib/permitted-contents/types.d.ts +6 -6
- package/lib/require-element/index.d.ts +1 -1
- package/lib/required-attr/index.d.ts +3 -3
- package/lib/required-element/index.d.ts +2 -2
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/wai-aria/index.d.ts +7 -7
- package/package.json +7 -7
- package/tsconfig.tsbuildinfo +1 -1
package/README.md
CHANGED
|
@@ -8,86 +8,54 @@
|
|
|
8
8
|
|
|
9
9
|
### Conformance checking
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
- [`attr-duplication`](./src/attr-duplication)
|
|
12
|
+
- [`character-reference`](./src/character-reference)
|
|
13
|
+
- [`deprecated-attr`](./src/deprecated-attr)
|
|
14
|
+
- [`deprecated-element`](./src/deprecated-element)
|
|
15
|
+
- [`disallowed-element`](./src/disallowed-element)
|
|
16
|
+
- [`doctype`](./src/doctype)
|
|
17
|
+
- [`id-duplication`](./src/id-duplication)
|
|
18
|
+
- [`ineffective-attr`](./src/ineffective-attr)
|
|
19
|
+
- [`invalid-attr`](./src/invalid-attr)
|
|
20
|
+
- [`permitted-contents`](./src/permitted-contents)
|
|
21
|
+
- [`required-attr`](./src/required-attr)
|
|
22
|
+
- [`required-element`](./src/required-element)
|
|
23
23
|
|
|
24
24
|
### Accessibility
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
| 🚧 | 🚧 | 🚧 | [heading-in-sectioning-content](./src/heading-in-sectioning-content/) | |
|
|
31
|
-
| 🚧 | 🚧 | 🚧 | [heading-in-sectioning-root](./src/heading-in-sectioning-root/) | |
|
|
32
|
-
| 🚧 | 🚧 | 🚧 | [heading-levels-skipping](./src/heading-levels-skipping/) | |
|
|
33
|
-
| 🚧 | 🚧 | 🚧 | [labeling-controls](./src/labeling-controls/) | |
|
|
34
|
-
| ✅ | ✅ | ✅ | [landmark-roles](./src/landmark-roles/) | |
|
|
35
|
-
| ✅ | ✅ | ✅ | [required-h1](./src/required-h1/) | |
|
|
26
|
+
- [`landmark-roles`](./src/landmark-roles)
|
|
27
|
+
- [`no-refer-to-non-existent-id`](./src/no-refer-to-non-existent-id)
|
|
28
|
+
- [`required-h1`](./src/required-h1)
|
|
29
|
+
- [`wai-aria`](./src/wai-aria)
|
|
36
30
|
|
|
37
|
-
###
|
|
31
|
+
### Naming Convention
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
| -------- | ---- | -------- | ------------------------------------- | ------- |
|
|
41
|
-
| 🚧 | 🚧 | 🚧 | [external-link](./src/external-link/) | 🚧 |
|
|
33
|
+
- [`class-naming`](./src/class-naming)
|
|
42
34
|
|
|
43
|
-
###
|
|
35
|
+
### Maintenability
|
|
44
36
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
| ✅ | ✅ | ✅ | [class-naming](./src/class-naming/) | |
|
|
48
|
-
| 🚧 | 🚧 | 🚧 | [custom-element-naming](./src/custom-element-naming/) | |
|
|
49
|
-
| 🚧 | 🚧 | 🚧 | [data-attr-naming](./src/data-attr-naming/) | |
|
|
50
|
-
| 🚧 | 🚧 | 🚧 | [required-element](./src/required-element/) | |
|
|
37
|
+
- [`no-hard-code-id`](./src/no-hard-code-id)
|
|
38
|
+
- [`no-use-event-handler-attr`](./src/no-use-event-handler-attr)
|
|
51
39
|
|
|
52
40
|
### Style
|
|
53
41
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
| ✅ | ✅ | ✅ | [indentation](./src/indentation/) | ✅ |
|
|
65
|
-
| 🚧 | 🚧 | 🚧 | [indentation-attr](./src/indentation-attr/) | 🚧 |
|
|
66
|
-
| 🚧 | 🚧 | 🚧 | [path](./src/path/) | |
|
|
67
|
-
| 🚧 | 🚧 | ✅ | [self-closing-tag](./src/self-closing-tag/) | 🚧 |
|
|
68
|
-
| 🚧 | 🚧 | 🚧 | [tag-omission](./src/tag-omission/) | 🚧 |
|
|
42
|
+
- [`attr-equal-space-after`](./src/attr-equal-space-after)
|
|
43
|
+
- [`attr-equal-space-before`](./src/attr-equal-space-before)
|
|
44
|
+
- [`attr-spacing`](./src/attr-spacing)
|
|
45
|
+
- [`attr-value-quotes`](./src/attr-value-quotes)
|
|
46
|
+
- [`case-sensitive-attr-name`](./src/case-sensitive-attr-name)
|
|
47
|
+
- [`case-sensitive-tag-name`](./src/case-sensitive-tag-name)
|
|
48
|
+
- [`end-tag`](./src/end-tag)
|
|
49
|
+
- [`indentation`](./src/indentation)
|
|
50
|
+
- [`no-boolean-attr-value`](./src/no-boolean-attr-value)
|
|
51
|
+
- [`no-default-value`](./src/no-default-value)
|
|
69
52
|
|
|
70
53
|
## Install
|
|
71
54
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
Prerequisites: [Node.js](https://nodejs.org) (Version 12.4.0 or later)
|
|
55
|
+
Generally, you **don't have to install** this package because markuplint dependents it defaultly.
|
|
75
56
|
|
|
76
57
|
```sh
|
|
77
|
-
$ npm install @markuplint/rules
|
|
78
|
-
|
|
79
|
-
$ yarn add @markuplint/rules
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
## Contributing
|
|
58
|
+
$ npm install -D @markuplint/rules
|
|
83
59
|
|
|
60
|
+
$ yarn add -D @markuplint/rules
|
|
84
61
|
```
|
|
85
|
-
$ git clone git@github.com:markuplint/markuplint.git -b main
|
|
86
|
-
$ yarn
|
|
87
|
-
$ yarn build
|
|
88
|
-
$ yarn test
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
Copyright © 2021 markuplint. Under the MIT License.
|
package/lib/attr-check.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { Translator } from '@markuplint/i18n';
|
|
2
2
|
import type { Attribute as AttrSpec, AttributeType } from '@markuplint/ml-spec';
|
|
3
3
|
declare type Invalid = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
invalidType: 'non-existent' | 'invalid-value';
|
|
5
|
+
message: string;
|
|
6
|
+
loc?: Loc;
|
|
7
7
|
};
|
|
8
8
|
declare type Loc = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
raw: string;
|
|
10
|
+
line: number;
|
|
11
|
+
col: number;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
14
|
* Use in rules `invalid-attr` and `wai-aria`
|
|
@@ -18,6 +18,17 @@ declare type Loc = {
|
|
|
18
18
|
* @param isCustomRule
|
|
19
19
|
* @param spec
|
|
20
20
|
*/
|
|
21
|
-
export declare function attrCheck(
|
|
22
|
-
|
|
21
|
+
export declare function attrCheck(
|
|
22
|
+
t: Translator,
|
|
23
|
+
name: string,
|
|
24
|
+
value: string,
|
|
25
|
+
isCustomRule: boolean,
|
|
26
|
+
spec?: AttrSpec,
|
|
27
|
+
): Invalid | false;
|
|
28
|
+
export declare function valueCheck(
|
|
29
|
+
t: Translator,
|
|
30
|
+
name: string,
|
|
31
|
+
value: string,
|
|
32
|
+
type: AttributeType,
|
|
33
|
+
): string | [string, Loc] | false;
|
|
23
34
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export interface AttrSpasingOptions {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
lineBreak?: 'either' | 'always' | 'never';
|
|
3
|
+
width?: number | false;
|
|
4
4
|
}
|
|
5
|
-
declare const _default: import(
|
|
5
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, AttrSpasingOptions>;
|
|
6
6
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare type Type = 'double' | 'single';
|
|
2
2
|
export declare type Quote = '"' | "'";
|
|
3
3
|
export declare type QuoteMap = {
|
|
4
|
-
|
|
4
|
+
[P in Type]: Quote;
|
|
5
5
|
};
|
|
6
|
-
declare const _default: import(
|
|
6
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<Type, null>;
|
|
7
7
|
export default _default;
|
|
@@ -3,5 +3,5 @@ export declare type Value = 'lower' | 'upper';
|
|
|
3
3
|
* @deprecated
|
|
4
4
|
*/
|
|
5
5
|
export declare type Value_v1 = 'no-upper' | 'no-lower';
|
|
6
|
-
declare const _default: import(
|
|
6
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<Value | Value_v1, null>;
|
|
7
7
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
package/lib/create-message.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { Translator } from '@markuplint/i18n';
|
|
2
2
|
import type { AttributeType } from '@markuplint/ml-spec';
|
|
3
3
|
import type { UnmatchedResult } from '@markuplint/types';
|
|
4
|
-
export declare function createMessageValueExpected(
|
|
5
|
-
|
|
4
|
+
export declare function createMessageValueExpected(
|
|
5
|
+
t: Translator,
|
|
6
|
+
baseTarget: string,
|
|
7
|
+
type: AttributeType,
|
|
8
|
+
matches: UnmatchedResult,
|
|
9
|
+
): string;
|
|
10
|
+
export declare function __createMessageValueExpected(
|
|
11
|
+
t: Translator,
|
|
12
|
+
baseTarget: string,
|
|
13
|
+
expected: string | null,
|
|
14
|
+
matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candicate' | 'ref' | 'extra'>,
|
|
15
|
+
): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<string[], null>;
|
|
2
2
|
export default _default;
|
package/lib/doctype/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
declare type Option = {
|
|
2
|
-
|
|
2
|
+
denyObsolateType: boolean;
|
|
3
3
|
};
|
|
4
|
-
declare const _default: import(
|
|
4
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<'always', Option>;
|
|
5
5
|
export default _default;
|
package/lib/end-tag/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, null>;
|
|
2
2
|
export default _default;
|
package/lib/helpers.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import type { Log } from './debug';
|
|
|
2
2
|
import type { Translator } from '@markuplint/i18n';
|
|
3
3
|
import type { Element, RuleConfigValue } from '@markuplint/ml-core';
|
|
4
4
|
import type { ARIRRoleAttribute, Attribute, MLMLSpec, PermittedRoles } from '@markuplint/ml-spec';
|
|
5
|
-
export declare function attrMatches<T extends RuleConfigValue, R>(
|
|
5
|
+
export declare function attrMatches<T extends RuleConfigValue, R>(
|
|
6
|
+
node: Element<T, R>,
|
|
7
|
+
condition: Attribute['condition'],
|
|
8
|
+
): boolean;
|
|
6
9
|
export declare function match(needle: string, pattern: string): boolean;
|
|
7
10
|
/**
|
|
8
11
|
* PotentialCustomElementName
|
|
@@ -20,26 +23,44 @@ export declare function match(needle: string, pattern: string): boolean;
|
|
|
20
23
|
* Originally, it is not possible to define a name including ASCII upper alphas in the custom element, but it is not treated as illegal by the HTML parser.
|
|
21
24
|
*/
|
|
22
25
|
export declare const rePCENChar: string;
|
|
23
|
-
export declare function htmlSpec(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
export declare function htmlSpec(
|
|
27
|
+
specs: Readonly<MLMLSpec>,
|
|
28
|
+
nameWithNS: string,
|
|
29
|
+
): import('@markuplint/ml-spec').ElementSpec | null;
|
|
30
|
+
export declare function isValidAttr(
|
|
31
|
+
t: Translator,
|
|
32
|
+
name: string,
|
|
33
|
+
value: string,
|
|
34
|
+
isDynamicValue: boolean,
|
|
35
|
+
node: Element<any, any>,
|
|
36
|
+
attrSpecs: Attribute[],
|
|
37
|
+
log?: Log,
|
|
38
|
+
):
|
|
39
|
+
| false
|
|
40
|
+
| {
|
|
41
|
+
invalidType: 'non-existent' | 'invalid-value';
|
|
42
|
+
message: string;
|
|
43
|
+
loc?:
|
|
44
|
+
| {
|
|
45
|
+
raw: string;
|
|
46
|
+
line: number;
|
|
47
|
+
col: number;
|
|
48
|
+
}
|
|
49
|
+
| undefined;
|
|
50
|
+
};
|
|
33
51
|
export declare function toNormalizedValue(value: string, spec: Attribute): string;
|
|
34
52
|
export declare function ariaSpec(specs: Readonly<MLMLSpec>): {
|
|
35
|
-
|
|
36
|
-
|
|
53
|
+
roles: ARIRRoleAttribute[];
|
|
54
|
+
ariaAttrs: import('@markuplint/ml-spec').ARIAAttribute[];
|
|
37
55
|
};
|
|
38
|
-
export declare function getRoleSpec(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
56
|
+
export declare function getRoleSpec(
|
|
57
|
+
specs: Readonly<MLMLSpec>,
|
|
58
|
+
roleName: string,
|
|
59
|
+
): {
|
|
60
|
+
name: string;
|
|
61
|
+
isAbstract: boolean;
|
|
62
|
+
statesAndProps: import('@markuplint/ml-spec').ARIARoleOwnedPropOrState[];
|
|
63
|
+
superClassRoles: ARIRRoleAttribute[];
|
|
43
64
|
} | null;
|
|
44
65
|
/**
|
|
45
66
|
* Getting permitted ARIA roles.
|
|
@@ -50,9 +71,12 @@ export declare function getRoleSpec(specs: Readonly<MLMLSpec>, roleName: string)
|
|
|
50
71
|
*/
|
|
51
72
|
export declare function getPermittedRoles(specs: Readonly<MLMLSpec>, el: Element<any, any>): PermittedRoles;
|
|
52
73
|
export declare function getImplicitRole(specs: Readonly<MLMLSpec>, el: Element<any, any>): string | false;
|
|
53
|
-
export declare function getComputedRole(
|
|
54
|
-
|
|
55
|
-
|
|
74
|
+
export declare function getComputedRole(
|
|
75
|
+
specs: Readonly<MLMLSpec>,
|
|
76
|
+
el: Element<any, any>,
|
|
77
|
+
): {
|
|
78
|
+
name: string;
|
|
79
|
+
isImplicit: boolean;
|
|
56
80
|
} | null;
|
|
57
81
|
/**
|
|
58
82
|
*
|
|
@@ -63,23 +87,32 @@ export declare function getComputedRole(specs: Readonly<MLMLSpec>, el: Element<a
|
|
|
63
87
|
* @param tokenEnum
|
|
64
88
|
*/
|
|
65
89
|
export declare function checkAriaValue(type: string, value: string, tokenEnum: string[]): boolean;
|
|
66
|
-
export declare function checkAria(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
export declare function checkAria(
|
|
91
|
+
specs: Readonly<MLMLSpec>,
|
|
92
|
+
attrName: string,
|
|
93
|
+
currentValue: string,
|
|
94
|
+
role?: string,
|
|
95
|
+
):
|
|
96
|
+
| {
|
|
97
|
+
currentValue: string;
|
|
98
|
+
isValid: boolean;
|
|
99
|
+
}
|
|
100
|
+
| {
|
|
101
|
+
currentValue: string;
|
|
102
|
+
isValid: boolean;
|
|
103
|
+
name: string;
|
|
104
|
+
type: 'property' | 'state';
|
|
105
|
+
deprecated?: true | undefined;
|
|
106
|
+
isGlobal?: true | undefined;
|
|
107
|
+
value: import('@markuplint/ml-spec').ARIAAttributeValue;
|
|
108
|
+
conditionalValue?:
|
|
109
|
+
| {
|
|
110
|
+
role: string[];
|
|
111
|
+
value: import('@markuplint/ml-spec').ARIAAttributeValue;
|
|
112
|
+
}[]
|
|
113
|
+
| undefined;
|
|
114
|
+
enum: string[];
|
|
115
|
+
defaultValue?: string | undefined;
|
|
116
|
+
equivalentHtmlAttrs?: import('@markuplint/ml-spec').EquivalentHtmlAttr[] | undefined;
|
|
117
|
+
valueDescriptions?: Record<string, string> | undefined;
|
|
118
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare type Value = 'tab' | number;
|
|
2
2
|
export interface IndentationOptions {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
alignment?: boolean;
|
|
4
|
+
'indent-nested-nodes'?: boolean | 'always' | 'never';
|
|
5
5
|
}
|
|
6
|
-
declare const _default: import(
|
|
6
|
+
declare const _default: import('@markuplint/ml-core').RuleSeed<Value, IndentationOptions>;
|
|
7
7
|
export default _default;
|