@markuplint/rules 3.15.0 → 4.0.0-alpha.10
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/.eslintrc +5 -0
- package/LICENSE +1 -1
- package/lib/attr-check.d.ts +8 -19
- package/lib/attr-check.js +16 -21
- package/lib/attr-duplication/index.d.ts +1 -3
- package/lib/attr-duplication/index.js +6 -6
- package/lib/attr-value-quotes/index.d.ts +2 -2
- package/lib/attr-value-quotes/index.js +8 -10
- package/lib/case-sensitive-attr-name/index.d.ts +1 -1
- package/lib/case-sensitive-attr-name/index.js +12 -13
- package/lib/case-sensitive-tag-name/index.d.ts +1 -1
- package/lib/case-sensitive-tag-name/index.js +5 -4
- package/lib/character-reference/index.d.ts +1 -1
- package/lib/character-reference/index.js +13 -12
- package/lib/class-naming/index.d.ts +1 -1
- package/lib/class-naming/index.js +14 -13
- package/lib/create-message.d.ts +2 -12
- package/lib/create-message.js +26 -26
- package/lib/debug.js +2 -6
- package/lib/deprecated-attr/index.d.ts +1 -3
- package/lib/deprecated-attr/index.js +9 -9
- package/lib/deprecated-element/index.d.ts +1 -3
- package/lib/deprecated-element/index.js +7 -6
- package/lib/disallowed-element/index.d.ts +1 -1
- package/lib/disallowed-element/index.js +9 -8
- package/lib/doctype/index.d.ts +2 -2
- package/lib/doctype/index.js +5 -4
- package/lib/end-tag/index.d.ts +1 -1
- package/lib/end-tag/index.js +8 -8
- package/lib/helpers.d.ts +17 -35
- package/lib/helpers.js +25 -32
- package/lib/id-duplication/index.d.ts +1 -3
- package/lib/id-duplication/index.js +5 -4
- package/lib/index.d.ts +21 -17
- package/lib/index.js +63 -66
- package/lib/ineffective-attr/index.d.ts +1 -3
- package/lib/ineffective-attr/index.js +8 -7
- package/lib/invalid-attr/index.d.ts +31 -38
- package/lib/invalid-attr/index.js +33 -33
- package/lib/label-has-control/index.d.ts +1 -3
- package/lib/label-has-control/index.js +5 -4
- package/lib/landmark-roles/index.d.ts +3 -3
- package/lib/landmark-roles/index.js +16 -18
- package/lib/no-boolean-attr-value/index.d.ts +1 -3
- package/lib/no-boolean-attr-value/index.js +9 -9
- package/lib/no-default-value/index.d.ts +1 -3
- package/lib/no-default-value/index.js +12 -12
- package/lib/no-empty-palpable-content/index.d.ts +3 -3
- package/lib/no-empty-palpable-content/index.js +9 -8
- package/lib/no-hard-code-id/index.d.ts +1 -3
- package/lib/no-hard-code-id/index.js +5 -4
- package/lib/no-refer-to-non-existent-id/index.d.ts +1 -1
- package/lib/no-refer-to-non-existent-id/index.js +37 -38
- package/lib/no-use-event-handler-attr/index.d.ts +2 -2
- package/lib/no-use-event-handler-attr/index.js +7 -6
- package/lib/permitted-contents/choice.d.ts +2 -8
- package/lib/permitted-contents/choice.js +14 -19
- package/lib/permitted-contents/complex-branch.d.ts +2 -8
- 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 +10 -11
- package/lib/permitted-contents/count-pattern.d.ts +3 -18
- package/lib/permitted-contents/count-pattern.js +19 -24
- package/lib/permitted-contents/debug.browser.d.ts +16 -16
- package/lib/permitted-contents/debug.browser.js +9 -12
- package/lib/permitted-contents/debug.d.ts +10 -3
- package/lib/permitted-contents/debug.js +12 -13
- package/lib/permitted-contents/index.d.ts +2 -2
- package/lib/permitted-contents/index.js +13 -13
- package/lib/permitted-contents/matches-selector.d.ts +2 -7
- package/lib/permitted-contents/matches-selector.js +13 -18
- package/lib/permitted-contents/order.d.ts +2 -8
- package/lib/permitted-contents/order.js +19 -24
- package/lib/permitted-contents/recursive-branch.d.ts +3 -9
- package/lib/permitted-contents/recursive-branch.js +9 -13
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +4 -8
- package/lib/permitted-contents/represent-transparent-nodes.js +15 -20
- package/lib/permitted-contents/start.d.ts +2 -7
- package/lib/permitted-contents/start.js +13 -21
- package/lib/permitted-contents/transparent.d.ts +1 -1
- package/lib/permitted-contents/transparent.js +6 -11
- package/lib/permitted-contents/types.d.ts +29 -29
- package/lib/permitted-contents/types.js +1 -2
- package/lib/permitted-contents/utils.d.ts +42 -79
- package/lib/permitted-contents/utils.js +72 -82
- package/lib/placeholder-label-option/index.d.ts +1 -1
- package/lib/placeholder-label-option/index.js +12 -13
- package/lib/require-accessible-name/index.d.ts +2 -2
- package/lib/require-accessible-name/index.js +12 -15
- package/lib/require-datetime/index.d.ts +3 -3
- package/lib/require-datetime/index.js +14 -13
- package/lib/require-datetime/types.d.ts +2 -2
- package/lib/require-datetime/types.js +1 -2
- package/lib/require-datetime/utils.d.ts +1 -1
- package/lib/require-datetime/utils.js +5 -12
- package/lib/required-attr/index.d.ts +3 -3
- package/lib/required-attr/index.js +11 -11
- package/lib/required-element/index.d.ts +2 -2
- package/lib/required-element/index.js +7 -7
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/required-h1/index.js +6 -6
- package/lib/use-list/index.d.ts +6 -2
- package/lib/use-list/index.js +27 -11
- 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 +4 -8
- package/lib/wai-aria/checkings/default-value.js +2 -6
- package/lib/wai-aria/checkings/deprecated-props.d.ts +5 -9
- package/lib/wai-aria/checkings/deprecated-props.js +3 -8
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +5 -9
- package/lib/wai-aria/checkings/disallowed-prop.js +7 -12
- package/lib/wai-aria/checkings/implicit-props.d.ts +5 -9
- package/lib/wai-aria/checkings/implicit-props.js +12 -17
- 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 +4 -8
- 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 +5 -10
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +4 -8
- package/lib/wai-aria/checkings/required-owned-elements.js +7 -11
- package/lib/wai-aria/checkings/required-prop.d.ts +7 -13
- package/lib/wai-aria/checkings/required-prop.js +2 -7
- package/lib/wai-aria/checkings/value.d.ts +7 -16
- package/lib/wai-aria/checkings/value.js +7 -13
- package/lib/wai-aria/index.d.ts +2 -2
- package/lib/wai-aria/index.js +41 -40
- package/lib/wai-aria/types.d.ts +10 -10
- package/lib/wai-aria/types.js +1 -2
- package/package.json +17 -13
- 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 -1631
- 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
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createRule, getSpec } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
3
|
+
meta: {
|
|
4
|
+
category: 'validation',
|
|
5
|
+
},
|
|
5
6
|
async verify({ document, report, t }) {
|
|
6
7
|
await document.walkOn('Element', el => {
|
|
7
8
|
if (!(el.namespaceURI === 'http://www.w3.org/1999/xhtml' ||
|
|
@@ -9,9 +10,9 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
9
10
|
el.elementType !== 'html') {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
|
-
const spec =
|
|
13
|
+
const spec = getSpec(el, document.specs.specs);
|
|
13
14
|
if (spec && (spec.obsolete != null || spec.deprecated || spec.nonStandard)) {
|
|
14
|
-
const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete
|
|
15
|
+
const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete == null ? 'non-standard' : 'obsolete');
|
|
15
16
|
report({
|
|
16
17
|
scope: el,
|
|
17
18
|
message,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: Readonly<import(
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<string[], undefined>>;
|
|
2
2
|
export default _default;
|
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
3
|
+
meta: {
|
|
4
|
+
category: 'validation',
|
|
5
|
+
},
|
|
5
6
|
defaultValue: [],
|
|
6
7
|
async verify({ document, report, t }) {
|
|
7
8
|
for (const query of document.rule.value) {
|
|
8
9
|
const elements = document.querySelectorAll(query);
|
|
9
|
-
|
|
10
|
+
for (const el of elements) {
|
|
10
11
|
const message = t('{0} is disallowed', t('the "{0*}" {1}', query, 'element'));
|
|
11
12
|
report({
|
|
12
13
|
scope: el,
|
|
13
14
|
message,
|
|
14
15
|
});
|
|
15
|
-
}
|
|
16
|
+
}
|
|
16
17
|
}
|
|
17
18
|
await document.walkOn('Element', el => {
|
|
18
19
|
if (el.rule.value === document.rule.value) {
|
|
@@ -20,13 +21,13 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
20
21
|
}
|
|
21
22
|
for (const query of el.rule.value) {
|
|
22
23
|
const elements = el.querySelectorAll(query);
|
|
23
|
-
|
|
24
|
+
for (const el of elements) {
|
|
24
25
|
const message = t('{0} is disallowed', t('the "{0*}" {1}', query, 'element'));
|
|
25
26
|
report({
|
|
26
27
|
scope: el,
|
|
27
28
|
message,
|
|
28
29
|
});
|
|
29
|
-
}
|
|
30
|
+
}
|
|
30
31
|
}
|
|
31
32
|
});
|
|
32
33
|
},
|
package/lib/doctype/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type Option = {
|
|
2
|
-
|
|
2
|
+
denyObsoleteType: boolean;
|
|
3
3
|
};
|
|
4
|
-
declare const _default: Readonly<import(
|
|
4
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<"always", Option>>;
|
|
5
5
|
export default _default;
|
package/lib/doctype/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
3
|
+
meta: {
|
|
4
|
+
category: 'validation',
|
|
5
|
+
},
|
|
5
6
|
defaultValue: 'always',
|
|
6
7
|
defaultOptions: {
|
|
7
8
|
denyObsoleteType: true,
|
package/lib/end-tag/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: Readonly<import(
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
|
|
2
2
|
export default _default;
|
package/lib/end-tag/index.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
import { isVoidElement } from '@markuplint/ml-spec';
|
|
3
|
+
export default createRule({
|
|
4
|
+
meta: {
|
|
5
|
+
category: 'style',
|
|
6
|
+
},
|
|
6
7
|
defaultSeverity: 'warning',
|
|
7
8
|
async verify({ document, report, t }) {
|
|
8
9
|
if (document.endTag === 'never') {
|
|
9
10
|
return;
|
|
10
11
|
}
|
|
11
12
|
await document.walkOn('Element', el => {
|
|
12
|
-
var _a;
|
|
13
13
|
if (el.isOmitted) {
|
|
14
14
|
return;
|
|
15
15
|
}
|
|
16
|
-
if (
|
|
16
|
+
if (isVoidElement(el)) {
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
if (el.closeTag != null) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
if ((document.endTag === 'xml' || el.isForeignElement) &&
|
|
22
|
+
if ((document.endTag === 'xml' || el.isForeignElement) && el.selfClosingSolidus?.raw) {
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
25
|
report({
|
package/lib/helpers.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import type { Log } from './debug';
|
|
1
|
+
import type { Log } from './debug.js';
|
|
2
2
|
import type { Translator } from '@markuplint/i18n';
|
|
3
3
|
import type { PlainData } from '@markuplint/ml-config';
|
|
4
4
|
import type { Element, RuleConfigValue, Document } from '@markuplint/ml-core';
|
|
5
5
|
import type { Attribute } from '@markuplint/ml-spec';
|
|
6
6
|
import type { WritableDeep } from 'type-fest';
|
|
7
|
-
export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(
|
|
8
|
-
node: Element<T, O>,
|
|
9
|
-
condition: Attribute['condition'],
|
|
10
|
-
): boolean;
|
|
7
|
+
export declare function attrMatches<T extends RuleConfigValue, O extends PlainData>(node: Element<T, O>, condition: Attribute['condition']): boolean;
|
|
11
8
|
export declare function match(needle: string, pattern: string): boolean;
|
|
12
9
|
/**
|
|
13
10
|
* PotentialCustomElementName
|
|
@@ -25,38 +22,23 @@ export declare function match(needle: string, pattern: string): boolean;
|
|
|
25
22
|
* 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.
|
|
26
23
|
*/
|
|
27
24
|
export declare const rePCENChar: string;
|
|
28
|
-
export declare function isValidAttr(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
| false
|
|
38
|
-
| {
|
|
39
|
-
invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
|
|
40
|
-
message: string;
|
|
41
|
-
loc?:
|
|
42
|
-
| {
|
|
43
|
-
raw: string;
|
|
44
|
-
line: number;
|
|
45
|
-
col: number;
|
|
46
|
-
}
|
|
47
|
-
| undefined;
|
|
48
|
-
};
|
|
25
|
+
export declare function isValidAttr(t: Translator, name: string, value: string, isDynamicValue: boolean, node: Element<any, any>, attrSpecs: readonly Attribute[], log?: Log): false | {
|
|
26
|
+
invalidType: "non-existent" | "invalid-value" | "disallowed-attr";
|
|
27
|
+
message: string;
|
|
28
|
+
loc?: {
|
|
29
|
+
raw: string;
|
|
30
|
+
line: number;
|
|
31
|
+
col: number;
|
|
32
|
+
} | undefined;
|
|
33
|
+
};
|
|
49
34
|
export declare function toNormalizedValue(value: string, spec: Attribute): string;
|
|
50
35
|
export declare function accnameMayBeMutable(el: Element<any, any>, document: Document<any, any>): boolean;
|
|
51
|
-
export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(
|
|
52
|
-
el: Element<V, O>,
|
|
53
|
-
document: Document<V, O>,
|
|
54
|
-
): Element<V, O> | null;
|
|
36
|
+
export declare function getOwnedLabel<V extends RuleConfigValue, O extends PlainData>(el: Element<V, O>, document: Document<V, O>): Element<V, O> | null;
|
|
55
37
|
export declare class Collection<T> {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
38
|
+
#private;
|
|
39
|
+
constructor(...items: readonly (T | null | undefined)[]);
|
|
40
|
+
[Symbol.iterator](): Iterator<T>;
|
|
41
|
+
add(...items: readonly (T | null | undefined)[]): void;
|
|
42
|
+
toArray(): readonly T[];
|
|
61
43
|
}
|
|
62
44
|
export declare function deepCopy<T>(value: T): WritableDeep<T>;
|
package/lib/helpers.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
2
6
|
var _Collection_items;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.deepCopy = exports.Collection = exports.getOwnedLabel = exports.accnameMayBeMutable = exports.toNormalizedValue = exports.isValidAttr = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
7
|
// @ts-ignore
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function attrMatches(
|
|
8
|
+
import structuredClone from '@ungap/structured-clone';
|
|
9
|
+
import { attrCheck } from './attr-check.js';
|
|
10
|
+
export function attrMatches(
|
|
10
11
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
11
12
|
node, condition) {
|
|
12
13
|
if (condition == null) {
|
|
@@ -15,9 +16,8 @@ node, condition) {
|
|
|
15
16
|
const condSelector = typeof condition === 'string' ? condition : condition.join(',');
|
|
16
17
|
return node.matches(condSelector);
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const matches = pattern.match(/^\/(.*)\/(i|g|m)*$/);
|
|
19
|
+
export function match(needle, pattern) {
|
|
20
|
+
const matches = pattern.match(/^\/(.*)\/([gim])*$/);
|
|
21
21
|
if (matches && matches[1]) {
|
|
22
22
|
const re = matches[1];
|
|
23
23
|
const flag = matches[2];
|
|
@@ -25,7 +25,6 @@ function match(needle, pattern) {
|
|
|
25
25
|
}
|
|
26
26
|
return needle === pattern;
|
|
27
27
|
}
|
|
28
|
-
exports.match = match;
|
|
29
28
|
/**
|
|
30
29
|
* PotentialCustomElementName
|
|
31
30
|
*
|
|
@@ -41,7 +40,7 @@ exports.match = match;
|
|
|
41
40
|
* ASCII-case-insensitively.
|
|
42
41
|
* 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.
|
|
43
42
|
*/
|
|
44
|
-
|
|
43
|
+
export const rePCENChar = [
|
|
45
44
|
'\\-',
|
|
46
45
|
'\\.',
|
|
47
46
|
'[0-9]',
|
|
@@ -61,7 +60,7 @@ exports.rePCENChar = [
|
|
|
61
60
|
'[\uFDF0-\uFFFD]',
|
|
62
61
|
'[\uD800-\uDBFF][\uDC00-\uDFFF]',
|
|
63
62
|
].join('|');
|
|
64
|
-
function isValidAttr(t, name, value, isDynamicValue,
|
|
63
|
+
export function isValidAttr(t, name, value, isDynamicValue,
|
|
65
64
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
66
65
|
node, attrSpecs,
|
|
67
66
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
@@ -69,7 +68,7 @@ log) {
|
|
|
69
68
|
let invalid = false;
|
|
70
69
|
const spec = attrSpecs.find(s => s.name.toLowerCase() === name.toLowerCase());
|
|
71
70
|
log && log('Spec of the %s attr: %o', name, spec);
|
|
72
|
-
invalid =
|
|
71
|
+
invalid = attrCheck(t, name, value, false, spec);
|
|
73
72
|
if (invalid === false &&
|
|
74
73
|
spec &&
|
|
75
74
|
spec.condition != null &&
|
|
@@ -85,15 +84,14 @@ log) {
|
|
|
85
84
|
}
|
|
86
85
|
return invalid;
|
|
87
86
|
}
|
|
88
|
-
|
|
89
|
-
function toNormalizedValue(value, spec) {
|
|
87
|
+
export function toNormalizedValue(value, spec) {
|
|
90
88
|
let normalized = value;
|
|
91
89
|
if (!spec.caseSensitive) {
|
|
92
90
|
normalized = normalized.toLowerCase();
|
|
93
91
|
}
|
|
94
92
|
if (typeof spec.type === 'string') {
|
|
95
93
|
if (spec.type[0] === '<') {
|
|
96
|
-
normalized = normalized.toLowerCase().trim().
|
|
94
|
+
normalized = normalized.toLowerCase().trim().replaceAll(/\s+/g, ' ');
|
|
97
95
|
}
|
|
98
96
|
}
|
|
99
97
|
else {
|
|
@@ -105,17 +103,16 @@ function toNormalizedValue(value, spec) {
|
|
|
105
103
|
normalized = normalized.trim();
|
|
106
104
|
}
|
|
107
105
|
if (spec.type.separator === 'space') {
|
|
108
|
-
normalized = normalized.
|
|
106
|
+
normalized = normalized.replaceAll(/\s+/g, ' ');
|
|
109
107
|
}
|
|
110
108
|
if (spec.type.separator === 'comma') {
|
|
111
|
-
normalized = normalized.
|
|
109
|
+
normalized = normalized.replaceAll(/\s*,\s*/g, ',');
|
|
112
110
|
}
|
|
113
111
|
}
|
|
114
112
|
}
|
|
115
113
|
return normalized;
|
|
116
114
|
}
|
|
117
|
-
|
|
118
|
-
function accnameMayBeMutable(
|
|
115
|
+
export function accnameMayBeMutable(
|
|
119
116
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
120
117
|
el,
|
|
121
118
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
@@ -129,9 +126,8 @@ document) {
|
|
|
129
126
|
}
|
|
130
127
|
return false;
|
|
131
128
|
}
|
|
132
|
-
exports.accnameMayBeMutable = accnameMayBeMutable;
|
|
133
129
|
const labelable = ['button', 'input:not([type=hidden])', 'meter', 'output', 'progress', 'select', 'textarea'];
|
|
134
|
-
function getOwnedLabel(
|
|
130
|
+
export function getOwnedLabel(
|
|
135
131
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
136
132
|
el,
|
|
137
133
|
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
@@ -148,29 +144,26 @@ document) {
|
|
|
148
144
|
}
|
|
149
145
|
return ownedLabel;
|
|
150
146
|
}
|
|
151
|
-
|
|
152
|
-
class Collection {
|
|
147
|
+
export class Collection {
|
|
153
148
|
constructor(...items) {
|
|
154
149
|
_Collection_items.set(this, new Set());
|
|
155
150
|
this.add(...items);
|
|
156
151
|
}
|
|
157
152
|
[(_Collection_items = new WeakMap(), Symbol.iterator)]() {
|
|
158
|
-
return
|
|
153
|
+
return __classPrivateFieldGet(this, _Collection_items, "f").values();
|
|
159
154
|
}
|
|
160
155
|
add(...items) {
|
|
161
156
|
for (const item of items) {
|
|
162
157
|
if (item == null) {
|
|
163
158
|
continue;
|
|
164
159
|
}
|
|
165
|
-
|
|
160
|
+
__classPrivateFieldGet(this, _Collection_items, "f").add(item);
|
|
166
161
|
}
|
|
167
162
|
}
|
|
168
163
|
toArray() {
|
|
169
|
-
return Object.freeze(
|
|
164
|
+
return Object.freeze([...__classPrivateFieldGet(this, _Collection_items, "f")]);
|
|
170
165
|
}
|
|
171
166
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
return (0, structured_clone_1.default)(value);
|
|
167
|
+
export function deepCopy(value) {
|
|
168
|
+
return structuredClone(value);
|
|
175
169
|
}
|
|
176
|
-
exports.deepCopy = deepCopy;
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
declare const _default: Readonly<
|
|
2
|
-
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
3
|
-
>;
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
4
2
|
export default _default;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { createRule } from '@markuplint/ml-core';
|
|
2
|
+
export default createRule({
|
|
3
|
+
meta: {
|
|
4
|
+
category: 'validation',
|
|
5
|
+
},
|
|
5
6
|
async verify({ document, report, t }) {
|
|
6
7
|
const message = t('{0} is {1:c}', t('{0} of {1}', t('the {0}', 'value'), t('the "{0*}" {1}', 'id', 'attribute')), 'duplicated');
|
|
7
8
|
const idStack = [];
|
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;
|
|
@@ -72,19 +72,19 @@ 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: "1.
|
|
75
|
+
ariaVersion: "1.2" | "1.1" | "1.3";
|
|
76
76
|
fragmentRefersNameAttr: boolean;
|
|
77
77
|
}>>;
|
|
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
|
-
ariaVersion: "1.
|
|
84
|
+
ariaVersion: "1.2" | "1.1" | "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,14 @@ 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
|
+
noPrev?: boolean | undefined;
|
|
100
|
+
prevElement?: boolean | undefined;
|
|
101
|
+
prevComment?: boolean | undefined;
|
|
102
|
+
prevCodeBlock?: boolean | undefined;
|
|
99
103
|
}>>;
|
|
100
|
-
readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types").Options>>;
|
|
104
|
+
readonly 'wai-aria': Readonly<import("@markuplint/ml-core").RuleSeed<boolean, import("./wai-aria/types.js").Options>>;
|
|
101
105
|
};
|
|
102
106
|
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,4 +1,2 @@
|
|
|
1
|
-
declare const _default: Readonly<
|
|
2
|
-
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
3
|
-
>;
|
|
1
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
|
|
4
2
|
export default _default;
|