@markuplint/rules 2.0.0-dev.20211227.0 → 2.0.0-dev.20220110.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/attr-check.js +3 -1
- package/lib/attr-duplication/index.d.ts +1 -1
- package/lib/attr-duplication/index.js +0 -2
- package/lib/attr-equal-space-after/index.js +0 -1
- package/lib/attr-equal-space-before/index.js +0 -1
- package/lib/attr-spacing/index.js +0 -1
- package/lib/attr-value-quotes/index.js +0 -1
- package/lib/case-sensitive-attr-name/index.js +0 -1
- package/lib/case-sensitive-tag-name/index.js +0 -1
- package/lib/character-reference/index.d.ts +1 -2
- package/lib/character-reference/index.js +0 -2
- package/lib/class-naming/index.js +23 -23
- package/lib/deprecated-attr/index.d.ts +1 -1
- package/lib/deprecated-attr/index.js +0 -2
- package/lib/deprecated-element/index.d.ts +1 -1
- package/lib/deprecated-element/index.js +0 -2
- package/lib/helpers.d.ts +1 -0
- package/lib/helpers.js +30 -1
- package/lib/id-duplication/index.d.ts +1 -1
- package/lib/id-duplication/index.js +0 -2
- package/lib/index.d.ts +17 -10
- package/lib/index.js +10 -0
- package/lib/ineffective-attr/index.d.ts +1 -1
- package/lib/ineffective-attr/index.js +0 -2
- package/lib/invalid-attr/index.d.ts +1 -1
- package/lib/invalid-attr/index.js +0 -1
- package/lib/landmark-roles/index.js +0 -1
- package/lib/no-boolean-attr-value/index.d.ts +1 -1
- package/lib/no-boolean-attr-value/index.js +1 -3
- package/lib/no-default-value/index.d.ts +2 -0
- package/lib/no-default-value/index.js +38 -0
- package/lib/no-hard-code-id/index.d.ts +2 -0
- package/lib/no-hard-code-id/index.js +27 -0
- package/lib/no-refer-to-non-existent-id/index.d.ts +2 -0
- package/lib/no-refer-to-non-existent-id/index.js +110 -0
- package/lib/no-use-event-handler-attr/index.d.ts +5 -0
- package/lib/no-use-event-handler-attr/index.js +37 -0
- package/lib/permitted-contents/index.js +11 -0
- package/lib/require-element/index.d.ts +2 -0
- package/lib/require-element/index.js +38 -0
- package/lib/required-attr/index.js +1 -2
- package/lib/required-element/index.d.ts +2 -0
- package/lib/required-element/index.js +36 -0
- package/lib/required-h1/index.d.ts +2 -3
- package/lib/required-h1/index.js +0 -1
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/index.js +0 -1
- package/package.json +6 -6
- package/schema.json +24 -0
- package/tsconfig.tsbuildinfo +1 -1
package/lib/attr-check.js
CHANGED
|
@@ -78,7 +78,9 @@ function valueCheck(t, name, value, type) {
|
|
|
78
78
|
return false;
|
|
79
79
|
}
|
|
80
80
|
const matches = (0, types_1.check)(value, type);
|
|
81
|
-
(
|
|
81
|
+
if (debug_1.log.enabled) {
|
|
82
|
+
(0, debug_1.log)(`Result ([${name}="${value}"]): %O`, { ...matches, type });
|
|
83
|
+
}
|
|
82
84
|
if (!matches.matched) {
|
|
83
85
|
const location = {
|
|
84
86
|
raw: matches.raw,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<
|
|
1
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
|
-
defaultValue: null,
|
|
6
|
-
defaultOptions: null,
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
const message = t('{0} is {1:c}', t('the {0}', 'attribute name'), 'duplicated');
|
|
9
7
|
await document.walkOn('Element', async (node) => {
|
|
@@ -6,7 +6,6 @@ const neverMsg = 'Never insert {0} after {1} of {2}';
|
|
|
6
6
|
exports.default = (0, ml_core_1.createRule)({
|
|
7
7
|
defaultServerity: 'warning',
|
|
8
8
|
defaultValue: 'never',
|
|
9
|
-
defaultOptions: null,
|
|
10
9
|
async verify(context) {
|
|
11
10
|
await context.document.walkOn('Element', async (node) => {
|
|
12
11
|
for (const attr of node.attributes) {
|
|
@@ -6,7 +6,6 @@ const neverMsg = 'Never insert {0} before {1} of {2}';
|
|
|
6
6
|
exports.default = (0, ml_core_1.createRule)({
|
|
7
7
|
defaultServerity: 'warning',
|
|
8
8
|
defaultValue: 'never',
|
|
9
|
-
defaultOptions: null,
|
|
10
9
|
async verify(context) {
|
|
11
10
|
await context.document.walkOn('Element', async (node) => {
|
|
12
11
|
for (const attr of node.attributes) {
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
defaultServerity: 'warning',
|
|
6
|
-
defaultValue: true,
|
|
7
6
|
defaultOptions: {
|
|
8
7
|
lineBreak: 'either',
|
|
9
8
|
width: 1,
|
|
@@ -8,7 +8,6 @@ const quoteList = {
|
|
|
8
8
|
exports.default = (0, ml_core_1.createRule)({
|
|
9
9
|
defaultServerity: 'warning',
|
|
10
10
|
defaultValue: 'double',
|
|
11
|
-
defaultOptions: null,
|
|
12
11
|
async verify(context) {
|
|
13
12
|
await context.document.walkOn('Element', async (node) => {
|
|
14
13
|
const message = context.translate('{0} is must {1} on {2}', 'Attribute value', 'quote', `${node.rule.value} quotation mark`);
|
|
@@ -4,7 +4,6 @@ const ml_core_1 = require("@markuplint/ml-core");
|
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
defaultServerity: 'warning',
|
|
6
6
|
defaultValue: 'no-upper',
|
|
7
|
-
defaultOptions: null,
|
|
8
7
|
async verify({ document, report, t }) {
|
|
9
8
|
await document.walkOn('Element', async (node) => {
|
|
10
9
|
if (node.isForeignElement || node.isCustomElement) {
|
|
@@ -4,7 +4,6 @@ const ml_core_1 = require("@markuplint/ml-core");
|
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
defaultServerity: 'warning',
|
|
6
6
|
defaultValue: 'lower',
|
|
7
|
-
defaultOptions: null,
|
|
8
7
|
async verify({ document, report, t }) {
|
|
9
8
|
await document.walk(async (node) => {
|
|
10
9
|
if ('fixNodeName' in node) {
|
|
@@ -4,8 +4,6 @@ const ml_core_1 = require("@markuplint/ml-core");
|
|
|
4
4
|
const defaultChars = ['"', '&', '<', '>'];
|
|
5
5
|
const ignoreParentElement = ['script', 'style'];
|
|
6
6
|
exports.default = (0, ml_core_1.createRule)({
|
|
7
|
-
defaultValue: true,
|
|
8
|
-
defaultOptions: null,
|
|
9
7
|
async verify({ document, report, t }) {
|
|
10
8
|
const targetNodes = [];
|
|
11
9
|
await document.walkOn('Text', async (node) => {
|
|
@@ -5,31 +5,31 @@ const helpers_1 = require("../helpers");
|
|
|
5
5
|
exports.default = (0, ml_core_1.createRule)({
|
|
6
6
|
defaultServerity: 'warning',
|
|
7
7
|
defaultValue: null,
|
|
8
|
-
defaultOptions: null,
|
|
9
8
|
async verify({ document, report, t }) {
|
|
10
9
|
await document.walkOn('Element', async (node) => {
|
|
11
|
-
if (node.rule.value) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
10
|
+
if (!node.rule.value) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const classPatterns = Array.isArray(node.rule.value) ? node.rule.value : [node.rule.value];
|
|
14
|
+
const attrs = node.getAttributeToken('class');
|
|
15
|
+
for (const attr of attrs) {
|
|
16
|
+
if (attr.attrType === 'html-attr' && attr.isDynamicValue) {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
const classAttr = attr.getValue();
|
|
20
|
+
const classList = classAttr.potential
|
|
21
|
+
.split(/\s+/g)
|
|
22
|
+
.map(c => c.trim())
|
|
23
|
+
.filter(c => c);
|
|
24
|
+
for (const className of classList) {
|
|
25
|
+
if (!classPatterns.some(pattern => (0, helpers_1.match)(className, pattern))) {
|
|
26
|
+
report({
|
|
27
|
+
scope: node,
|
|
28
|
+
message: t('{0} is unmatched with the below patterns: {1}', t('the "{0}" {1}', className, 'class name'), `"${classPatterns.join('", "')}"`),
|
|
29
|
+
line: classAttr.line,
|
|
30
|
+
col: classAttr.col,
|
|
31
|
+
raw: classAttr.raw,
|
|
32
|
+
});
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<
|
|
1
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
|
-
defaultValue: null,
|
|
6
|
-
defaultOptions: null,
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
await document.walkOn('Element', async (element) => {
|
|
9
7
|
const attrSpecs = (0, ml_core_1.getAttrSpecs)(element.nameWithNS, document.specs);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<
|
|
1
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -5,8 +5,6 @@ const html_spec_1 = (0, tslib_1.__importDefault)(require("@markuplint/html-spec"
|
|
|
5
5
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
6
6
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
7
7
|
exports.default = (0, ml_core_1.createRule)({
|
|
8
|
-
defaultValue: null,
|
|
9
|
-
defaultOptions: null,
|
|
10
8
|
async verify({ document, report, t }) {
|
|
11
9
|
await document.walkOn('Element', async (el) => {
|
|
12
10
|
const ns = el.ns;
|
package/lib/helpers.d.ts
CHANGED
|
@@ -30,6 +30,7 @@ export declare function isValidAttr(t: Translator, name: string, value: string,
|
|
|
30
30
|
col: number;
|
|
31
31
|
} | undefined;
|
|
32
32
|
};
|
|
33
|
+
export declare function toNormalizedValue(value: string, spec: Attribute): string;
|
|
33
34
|
export declare function ariaSpec(): {
|
|
34
35
|
roles: ARIRRoleAttribute[];
|
|
35
36
|
ariaAttrs: import("@markuplint/ml-spec").ARIAAttribute[];
|
package/lib/helpers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.checkAria = exports.checkAriaValue = exports.getComputedRole = exports.getImplicitRole = exports.getPermittedRoles = exports.getRoleSpec = exports.ariaSpec = exports.isValidAttr = exports.htmlSpec = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
|
|
3
|
+
exports.checkAria = exports.checkAriaValue = exports.getComputedRole = exports.getImplicitRole = exports.getPermittedRoles = exports.getRoleSpec = exports.ariaSpec = exports.toNormalizedValue = exports.isValidAttr = exports.htmlSpec = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
|
|
4
4
|
const html_spec_1 = require("@markuplint/html-spec");
|
|
5
5
|
const attr_check_1 = require("./attr-check");
|
|
6
6
|
function attrMatches(node, condition) {
|
|
@@ -97,6 +97,35 @@ function isValidAttr(t, name, value, isDynamicValue, node, attrSpecs, log) {
|
|
|
97
97
|
return invalid;
|
|
98
98
|
}
|
|
99
99
|
exports.isValidAttr = isValidAttr;
|
|
100
|
+
function toNormalizedValue(value, spec) {
|
|
101
|
+
let normalized = value;
|
|
102
|
+
if (!spec.caseSensitive) {
|
|
103
|
+
normalized = normalized.toLowerCase();
|
|
104
|
+
}
|
|
105
|
+
if (typeof spec.type === 'string') {
|
|
106
|
+
if (spec.type[0] === '<') {
|
|
107
|
+
normalized = normalized.toLowerCase().trim().replace(/\s+/g, ' ');
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
if ('token' in spec.type) {
|
|
112
|
+
if (spec.type.caseInsensitive) {
|
|
113
|
+
normalized = normalized.toLowerCase();
|
|
114
|
+
}
|
|
115
|
+
if (!spec.type.disallowToSurroundBySpaces) {
|
|
116
|
+
normalized = normalized.trim();
|
|
117
|
+
}
|
|
118
|
+
if (spec.type.separator === 'space') {
|
|
119
|
+
normalized = normalized.replace(/\s+/g, ' ');
|
|
120
|
+
}
|
|
121
|
+
if (spec.type.separator === 'comma') {
|
|
122
|
+
normalized = normalized.replace(/\s*,\s*/g, ',');
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
return normalized;
|
|
127
|
+
}
|
|
128
|
+
exports.toNormalizedValue = toNormalizedValue;
|
|
100
129
|
function ariaSpec() {
|
|
101
130
|
const roles = html_spec_1.def['#roles'];
|
|
102
131
|
const ariaAttrs = html_spec_1.def['#ariaAttrs'];
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<
|
|
1
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
|
-
defaultValue: null,
|
|
6
|
-
defaultOptions: null,
|
|
7
5
|
async verify({ document, report, t }) {
|
|
8
6
|
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'value'), t('the "{0}" {1}', 'id', 'attribute')), 'duplicated');
|
|
9
7
|
const idStack = [];
|
package/lib/index.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
declare const _default: {
|
|
2
|
-
'attr-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
2
|
+
'attr-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
3
3
|
'attr-equal-space-after': import("packages/@markuplint/ml-core/lib").RuleSeed<"always" | "never" | "always-single-line" | "never-single-line", null>;
|
|
4
4
|
'attr-equal-space-before': import("packages/@markuplint/ml-core/lib").RuleSeed<"always" | "never" | "always-single-line" | "never-single-line", null>;
|
|
5
5
|
'attr-spacing': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, import("./attr-spacing").AttrSpasingOptions>;
|
|
6
6
|
'attr-value-quotes': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./attr-value-quotes").Type, null>;
|
|
7
7
|
'case-sensitive-attr-name': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./case-sensitive-attr-name").Value, null>;
|
|
8
8
|
'case-sensitive-tag-name': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./case-sensitive-tag-name").Value, null>;
|
|
9
|
-
'character-reference': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
9
|
+
'character-reference': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
10
10
|
'class-naming': import("packages/@markuplint/ml-core/lib").RuleSeed<import("./class-naming").Value, null>;
|
|
11
|
-
'deprecated-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
12
|
-
'deprecated-element': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
11
|
+
'deprecated-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
12
|
+
'deprecated-element': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
13
13
|
doctype: import("packages/@markuplint/ml-core/lib").RuleSeed<"always", {
|
|
14
14
|
denyObsolateType: boolean;
|
|
15
15
|
}>;
|
|
16
|
-
'id-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
16
|
+
'id-duplication': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
17
17
|
indentation: import("packages/@markuplint/ml-core/lib").RuleSeed<import("./indentation").Value, import("./indentation").IndentationOptions>;
|
|
18
|
-
'ineffective-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
19
|
-
'invalid-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
18
|
+
'ineffective-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
19
|
+
'invalid-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
|
|
20
20
|
attrs?: Record<string, {
|
|
21
21
|
enum: [string, ...string[]];
|
|
22
22
|
} | {
|
|
@@ -32,7 +32,13 @@ declare const _default: {
|
|
|
32
32
|
ignoreRoles?: (("banner" | "main" | "complementary" | "contentinfo") | "form" | "navigation" | "region")[] | undefined;
|
|
33
33
|
labelEachArea?: boolean | undefined;
|
|
34
34
|
}>;
|
|
35
|
-
'no-boolean-attr-value': import("packages/@markuplint/ml-core/lib").RuleSeed<
|
|
35
|
+
'no-boolean-attr-value': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
36
|
+
'no-default-value': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
37
|
+
'no-hard-code-id': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
38
|
+
'no-refer-to-non-existent-id': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-config/src").RuleConfigValue, null>;
|
|
39
|
+
'no-use-event-handler-attr': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
|
|
40
|
+
ignore?: string | string[] | undefined;
|
|
41
|
+
}>;
|
|
36
42
|
'permitted-contents': import("packages/@markuplint/ml-core/lib").RuleSeed<import("packages/@markuplint/ml-spec/lib").PermittedStructuresSchema[], {
|
|
37
43
|
ignoreHasMutableChildren: boolean;
|
|
38
44
|
}>;
|
|
@@ -40,8 +46,9 @@ declare const _default: {
|
|
|
40
46
|
name: string;
|
|
41
47
|
value: string | string[];
|
|
42
48
|
})[], null>;
|
|
43
|
-
'required-
|
|
44
|
-
'
|
|
49
|
+
'required-element': import("packages/@markuplint/ml-core/lib").RuleSeed<string[], null>;
|
|
50
|
+
'required-h1': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, import("./required-h1").Options>;
|
|
51
|
+
'wai-aria': import("packages/@markuplint/ml-core/lib").RuleSeed<boolean, {
|
|
45
52
|
checkingValue?: boolean | undefined;
|
|
46
53
|
checkingDeprecatedProps?: boolean | undefined;
|
|
47
54
|
permittedAriaRoles?: boolean | undefined;
|
package/lib/index.js
CHANGED
|
@@ -19,8 +19,13 @@ const ineffective_attr_1 = (0, tslib_1.__importDefault)(require("./ineffective-a
|
|
|
19
19
|
const invalid_attr_1 = (0, tslib_1.__importDefault)(require("./invalid-attr"));
|
|
20
20
|
const landmark_roles_1 = (0, tslib_1.__importDefault)(require("./landmark-roles"));
|
|
21
21
|
const no_boolean_attr_value_1 = (0, tslib_1.__importDefault)(require("./no-boolean-attr-value"));
|
|
22
|
+
const no_default_value_1 = (0, tslib_1.__importDefault)(require("./no-default-value"));
|
|
23
|
+
const no_hard_code_id_1 = (0, tslib_1.__importDefault)(require("./no-hard-code-id"));
|
|
24
|
+
const no_refer_to_non_existent_id_1 = (0, tslib_1.__importDefault)(require("./no-refer-to-non-existent-id"));
|
|
25
|
+
const no_use_event_handler_attr_1 = (0, tslib_1.__importDefault)(require("./no-use-event-handler-attr"));
|
|
22
26
|
const permitted_contents_1 = (0, tslib_1.__importDefault)(require("./permitted-contents"));
|
|
23
27
|
const required_attr_1 = (0, tslib_1.__importDefault)(require("./required-attr"));
|
|
28
|
+
const required_element_1 = (0, tslib_1.__importDefault)(require("./required-element"));
|
|
24
29
|
const required_h1_1 = (0, tslib_1.__importDefault)(require("./required-h1"));
|
|
25
30
|
const wai_aria_1 = (0, tslib_1.__importDefault)(require("./wai-aria"));
|
|
26
31
|
exports.default = {
|
|
@@ -42,8 +47,13 @@ exports.default = {
|
|
|
42
47
|
'invalid-attr': invalid_attr_1.default,
|
|
43
48
|
'landmark-roles': landmark_roles_1.default,
|
|
44
49
|
'no-boolean-attr-value': no_boolean_attr_value_1.default,
|
|
50
|
+
'no-default-value': no_default_value_1.default,
|
|
51
|
+
'no-hard-code-id': no_hard_code_id_1.default,
|
|
52
|
+
'no-refer-to-non-existent-id': no_refer_to_non_existent_id_1.default,
|
|
53
|
+
'no-use-event-handler-attr': no_use_event_handler_attr_1.default,
|
|
45
54
|
'permitted-contents': permitted_contents_1.default,
|
|
46
55
|
'required-attr': required_attr_1.default,
|
|
56
|
+
'required-element': required_element_1.default,
|
|
47
57
|
'required-h1': required_h1_1.default,
|
|
48
58
|
'wai-aria': wai_aria_1.default,
|
|
49
59
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<
|
|
1
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
defaultServerity: 'warning',
|
|
6
|
-
defaultValue: true,
|
|
7
|
-
defaultOptions: null,
|
|
8
6
|
async verify({ document, report, t }) {
|
|
9
7
|
document.walkOn('Element', el => {
|
|
10
8
|
const attrSpec = (0, ml_core_1.getAttrSpecs)(el.nameWithNS, document.specs);
|
|
@@ -6,7 +6,6 @@ const debug_1 = require("../debug");
|
|
|
6
6
|
const helpers_1 = require("../helpers");
|
|
7
7
|
const log = debug_1.log.extend('invalid-attr');
|
|
8
8
|
exports.default = (0, ml_core_1.createRule)({
|
|
9
|
-
defaultValue: true,
|
|
10
9
|
defaultOptions: {},
|
|
11
10
|
async verify({ document, report, t }) {
|
|
12
11
|
await document.walkOn('Element', async (node) => {
|
|
@@ -13,7 +13,6 @@ const selectors = {
|
|
|
13
13
|
const topLevelRoles = ['banner', 'main', 'complementary', 'contentinfo'];
|
|
14
14
|
exports.default = (0, ml_core_1.createRule)({
|
|
15
15
|
defaultServerity: 'warning',
|
|
16
|
-
defaultValue: true,
|
|
17
16
|
defaultOptions: {
|
|
18
17
|
ignoreRoles: [],
|
|
19
18
|
labelEachArea: true,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<
|
|
1
|
+
declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
|
|
2
2
|
export default _default;
|
|
@@ -3,10 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
4
|
exports.default = (0, ml_core_1.createRule)({
|
|
5
5
|
defaultServerity: 'warning',
|
|
6
|
-
defaultValue: true,
|
|
7
|
-
defaultOptions: null,
|
|
8
6
|
async verify({ document, report, t }) {
|
|
9
|
-
document.walkOn('Element', el => {
|
|
7
|
+
await document.walkOn('Element', el => {
|
|
10
8
|
const attrSpec = (0, ml_core_1.getAttrSpecs)(el.nameWithNS, document.specs);
|
|
11
9
|
if (!attrSpec) {
|
|
12
10
|
return;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
exports.default = (0, ml_core_1.createRule)({
|
|
6
|
+
defaultServerity: 'warning',
|
|
7
|
+
async verify({ document, report, t }) {
|
|
8
|
+
await document.walkOn('Element', el => {
|
|
9
|
+
const attrSpec = (0, ml_core_1.getAttrSpecs)(el.nameWithNS, document.specs);
|
|
10
|
+
if (!attrSpec) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
for (const attr of el.attributes) {
|
|
14
|
+
if (attr.attrType !== 'html-attr') {
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
const spec = attrSpec.find(s => s.name === attr.getName().potential);
|
|
18
|
+
if (!spec) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
if (!spec.defaultValue) {
|
|
22
|
+
continue;
|
|
23
|
+
}
|
|
24
|
+
const normalizedValue = (0, helpers_1.toNormalizedValue)(attr.getValue().potential, spec);
|
|
25
|
+
const defaultValue = (0, helpers_1.toNormalizedValue)(spec.defaultValue, spec);
|
|
26
|
+
if (defaultValue === normalizedValue) {
|
|
27
|
+
report({
|
|
28
|
+
scope: el,
|
|
29
|
+
line: attr.value.startLine,
|
|
30
|
+
col: attr.value.startCol,
|
|
31
|
+
raw: attr.value.raw,
|
|
32
|
+
message: t('It is {0}', t('the {0}', 'default value')),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
exports.default = (0, ml_core_1.createRule)({
|
|
5
|
+
defaultServerity: 'warning',
|
|
6
|
+
async verify({ document, report, t }) {
|
|
7
|
+
if (!document.isFragment) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
await document.walkOn('Element', el => {
|
|
11
|
+
for (const attr of el.attributes) {
|
|
12
|
+
if ((attr.attrType === 'html-attr' && !attr.isDynamicValue) ||
|
|
13
|
+
(attr.attrType === 'ps-attr' &&
|
|
14
|
+
attr.potentialName.toLowerCase() === 'id' &&
|
|
15
|
+
attr.valueType !== 'code')) {
|
|
16
|
+
report({
|
|
17
|
+
scope: el,
|
|
18
|
+
line: attr.startLine,
|
|
19
|
+
col: attr.startCol,
|
|
20
|
+
raw: attr.raw,
|
|
21
|
+
message: t('It is {0:c}', 'hard-coded'),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
},
|
|
27
|
+
});
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
const helpers_1 = require("../helpers");
|
|
5
|
+
exports.default = (0, ml_core_1.createRule)({
|
|
6
|
+
async verify({ document, report, t }) {
|
|
7
|
+
const { ariaAttrs } = (0, helpers_1.ariaSpec)();
|
|
8
|
+
const idList = new Set();
|
|
9
|
+
let hasDynamicId = false;
|
|
10
|
+
await document.walkOn('Element', el => {
|
|
11
|
+
for (const attr of el.attributes) {
|
|
12
|
+
if (attr.getName().potential.toLowerCase() !== 'id') {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (attr.attrType === 'html-attr') {
|
|
16
|
+
if (attr.isDynamicValue) {
|
|
17
|
+
hasDynamicId = true;
|
|
18
|
+
}
|
|
19
|
+
idList.add(attr.getValue().potential);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
if (attr.valueType !== 'code') {
|
|
23
|
+
idList.add(attr.getValue().potential);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
if (hasDynamicId) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
document.walkOn('Element', el => {
|
|
32
|
+
const attrSpec = (0, ml_core_1.getAttrSpecs)(el.nameWithNS, document.specs);
|
|
33
|
+
if (!attrSpec) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
for (const attr of el.attributes) {
|
|
37
|
+
if (attr.attrType !== 'html-attr') {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const name = attr.getName().potential;
|
|
41
|
+
if (name.toLowerCase() === 'id') {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
const value = attr.getValue().potential;
|
|
45
|
+
const spec = attrSpec.find(s => s.name === name);
|
|
46
|
+
if (spec) {
|
|
47
|
+
// DOMID and DOMID List do not become in the array type.
|
|
48
|
+
if (Array.isArray(spec.type)) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (spec.type === 'DOMID' && !idList.has(value)) {
|
|
52
|
+
report({
|
|
53
|
+
scope: el,
|
|
54
|
+
line: attr.value.startLine,
|
|
55
|
+
col: attr.value.startCol,
|
|
56
|
+
raw: attr.value.raw,
|
|
57
|
+
message: t('Missing {0}', t('"{0*}" ID', value)),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
if (typeof spec.type !== 'string' && 'token' in spec.type && spec.type.token === 'DOMID') {
|
|
61
|
+
const refs = value
|
|
62
|
+
.split(spec.type.separator === 'space' ? /\s/ : ',')
|
|
63
|
+
.map(id => id.trim())
|
|
64
|
+
.filter(_ => _);
|
|
65
|
+
for (const ref of refs) {
|
|
66
|
+
if (!idList.has(ref)) {
|
|
67
|
+
report({
|
|
68
|
+
scope: el,
|
|
69
|
+
line: attr.value.startLine,
|
|
70
|
+
col: attr.value.startCol,
|
|
71
|
+
raw: attr.value.raw,
|
|
72
|
+
message: t('Missing {0}', t('"{0*}" ID', ref)),
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
const aria = ariaAttrs.find(aria => aria.name === name);
|
|
79
|
+
if (aria) {
|
|
80
|
+
if (aria.value === 'ID reference' && !idList.has(value)) {
|
|
81
|
+
report({
|
|
82
|
+
scope: el,
|
|
83
|
+
line: attr.value.startLine,
|
|
84
|
+
col: attr.value.startCol,
|
|
85
|
+
raw: attr.value.raw,
|
|
86
|
+
message: t('Missing {0}', t('"{0*}" ID', value)),
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
else if (aria.value === 'ID reference list') {
|
|
90
|
+
const refs = value
|
|
91
|
+
.split(/\s/)
|
|
92
|
+
.map(id => id.trim())
|
|
93
|
+
.filter(_ => _);
|
|
94
|
+
for (const ref of refs) {
|
|
95
|
+
if (!idList.has(ref)) {
|
|
96
|
+
report({
|
|
97
|
+
scope: el,
|
|
98
|
+
line: attr.value.startLine,
|
|
99
|
+
col: attr.value.startCol,
|
|
100
|
+
raw: attr.value.raw,
|
|
101
|
+
message: t('Missing {0}', t('"{0*}" ID', ref)),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
});
|