@markuplint/rules 3.0.0-canary.3 → 3.0.0-dev.176
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 +1 -1
- package/lib/attr-check.d.ts +20 -8
- package/lib/attr-check.js +31 -22
- package/lib/attr-duplication/index.d.ts +3 -1
- package/lib/attr-duplication/index.js +2 -1
- 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/class-naming/index.js +2 -4
- package/lib/create-message.d.ts +13 -2
- package/lib/create-message.js +4 -3
- package/lib/debug.js +1 -1
- package/lib/deprecated-attr/index.d.ts +3 -1
- package/lib/deprecated-element/index.d.ts +3 -1
- package/lib/deprecated-element/index.js +2 -2
- 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 +37 -22
- package/lib/helpers.js +27 -14
- package/lib/id-duplication/index.d.ts +3 -1
- package/lib/index.d.ts +243 -3
- package/lib/index.js +6 -1
- package/lib/ineffective-attr/index.d.ts +3 -1
- package/lib/ineffective-attr/index.js +2 -5
- package/lib/invalid-attr/index.d.ts +39 -12
- package/lib/invalid-attr/index.js +153 -27
- package/lib/label-has-control/index.d.ts +3 -1
- package/lib/landmark-roles/index.d.ts +3 -3
- package/lib/landmark-roles/index.js +9 -5
- package/lib/no-boolean-attr-value/index.d.ts +3 -1
- package/lib/no-default-value/index.d.ts +3 -1
- package/lib/no-empty-palpable-content/index.d.ts +3 -3
- package/lib/no-empty-palpable-content/index.js +11 -3
- package/lib/no-hard-code-id/index.d.ts +3 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
- package/lib/no-refer-to-non-existent-id/index.js +65 -5
- package/lib/no-use-event-handler-attr/index.d.ts +2 -2
- package/lib/no-use-event-handler-attr/index.js +4 -4
- package/lib/permitted-contents/choice.d.ts +8 -1
- package/lib/permitted-contents/choice.js +37 -2
- package/lib/permitted-contents/complex-branch.d.ts +8 -1
- package/lib/permitted-contents/complex-branch.js +4 -2
- package/lib/permitted-contents/content-model.d.ts +1 -1
- package/lib/permitted-contents/content-model.js +7 -3
- package/lib/permitted-contents/count-pattern.d.ts +18 -2
- package/lib/permitted-contents/count-pattern.js +71 -64
- package/lib/permitted-contents/debug.browser.d.ts +30 -0
- package/lib/permitted-contents/debug.browser.js +14 -0
- package/lib/permitted-contents/debug.d.ts +2 -1
- package/lib/permitted-contents/debug.js +9 -1
- package/lib/permitted-contents/index.d.ts +1 -1
- package/lib/permitted-contents/index.js +12 -15
- package/lib/permitted-contents/matches-selector.d.ts +7 -2
- package/lib/permitted-contents/matches-selector.js +8 -6
- package/lib/permitted-contents/order.d.ts +8 -1
- package/lib/permitted-contents/order.js +25 -15
- package/lib/permitted-contents/recursive-branch.d.ts +8 -1
- package/lib/permitted-contents/recursive-branch.js +5 -3
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +7 -3
- package/lib/permitted-contents/represent-transparent-nodes.js +4 -5
- package/lib/permitted-contents/start.d.ts +7 -1
- package/lib/permitted-contents/start.js +5 -3
- package/lib/permitted-contents/transparent.d.ts +2 -2
- package/lib/permitted-contents/transparent.js +11 -14
- package/lib/permitted-contents/types.d.ts +35 -28
- package/lib/permitted-contents/utils.d.ts +96 -28
- package/lib/permitted-contents/utils.js +135 -17
- package/lib/placeholder-label-option/index.d.ts +2 -0
- package/lib/placeholder-label-option/index.js +88 -0
- package/lib/require-accessible-name/index.d.ts +2 -2
- package/lib/require-accessible-name/index.js +5 -5
- package/lib/require-datetime/index.d.ts +6 -0
- package/lib/require-datetime/index.js +34 -0
- package/lib/require-datetime/types.d.ts +10 -0
- package/lib/require-datetime/types.js +2 -0
- package/lib/require-datetime/utils.d.ts +11 -0
- package/lib/require-datetime/utils.js +137 -0
- package/lib/required-attr/index.d.ts +3 -3
- package/lib/required-attr/index.js +19 -16
- package/lib/required-element/index.d.ts +2 -2
- package/lib/required-element/index.js +3 -2
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/required-h1/index.js +4 -3
- package/lib/use-list/index.d.ts +3 -3
- package/lib/use-list/index.js +7 -5
- package/lib/wai-aria/checkings/_.d.ts +15 -0
- package/lib/wai-aria/checkings/_.js +27 -0
- package/lib/wai-aria/checkings/abstract-role.js +1 -1
- package/lib/wai-aria/checkings/default-value.d.ts +7 -3
- package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
- package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
- package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
- package/lib/wai-aria/checkings/implicit-props.js +3 -2
- package/lib/wai-aria/checkings/implicit-role.js +1 -1
- package/lib/wai-aria/checkings/interaction-in-hidden.js +3 -1
- package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
- package/lib/wai-aria/checkings/non-existent-role.js +1 -1
- package/lib/wai-aria/checkings/permitted-roles.js +1 -1
- package/lib/wai-aria/checkings/presentational-children.js +4 -2
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +7 -3
- package/lib/wai-aria/checkings/required-owned-elements.js +28 -12
- package/lib/wai-aria/checkings/required-prop copy.d.ts +15 -0
- package/lib/wai-aria/checkings/required-prop copy.js +27 -0
- package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
- package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +15 -0
- package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
- package/lib/wai-aria/checkings/value.d.ts +15 -6
- package/lib/wai-aria/checkings/value.js +3 -1
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/index.js +13 -12
- package/lib/wai-aria/types.d.ts +10 -10
- package/lib/xxx/index.d.ts +2 -0
- package/lib/xxx/index.js +32 -0
- package/package.json +16 -11
- package/schema.json +6 -0
- package/test/attr-check.spec.js +77 -0
- package/test/attr-duplication/index.spec.js +159 -0
- package/test/attr-value-quotes/index.spec.js +133 -0
- package/test/case-sensitive-attr-name/index.spec.js +65 -0
- package/test/case-sensitive-tag-name/index.spec.js +80 -0
- package/test/character-reference/index.spec.js +57 -0
- package/test/class-naming/index.spec.js +470 -0
- package/test/create-message.spec.js +497 -0
- package/test/deprecated-attr/index.spec.js +48 -0
- package/test/deprecated-element/index.spec.js +48 -0
- package/test/disallowed-element/index.spec.js +90 -0
- package/test/doctype/index.spec.js +50 -0
- package/test/end-tag/index.spec.js +162 -0
- package/test/id-duplication/index.spec.js +47 -0
- package/test/ineffective-attr/index.spec.js +31 -0
- package/test/invalid-attr/index.spec.js +1632 -0
- package/test/label-has-control/index.spec.js +29 -0
- package/test/landmark-roles/index.spec.js +187 -0
- package/test/no-boolean-attr-value/index.spec.js +41 -0
- package/test/no-default-value/index.spec.js +74 -0
- package/test/no-empty-palpable-content/index.spec.js +115 -0
- package/test/no-hard-code-id/index.spec.js +100 -0
- package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
- package/test/no-use-event-handler-attr/index.spec.js +57 -0
- package/test/permitted-contents/choice.spec.js +174 -0
- package/test/permitted-contents/count-pattern.spec.js +308 -0
- package/test/permitted-contents/index.spec.js +1371 -0
- package/test/permitted-contents/matches-selector.spec.js +59 -0
- package/test/permitted-contents/order.spec.js +351 -0
- package/test/permitted-contents/recursive-branch.spec.js +41 -0
- package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
- package/test/permitted-contents/start.spec.js +67 -0
- package/test/placeholder-label-option/index.spec.js +113 -0
- package/test/require-accessible-name/index.spec.js +446 -0
- package/test/require-datetime/index.spec.js +54 -0
- package/test/require-datetime/utils.spec.js +52 -0
- package/test/required-attr/index.spec.js +414 -0
- package/test/required-element/index.spec.js +188 -0
- package/test/required-h1/index.spec.js +69 -0
- package/test/use-list/index.spec.js +109 -0
- package/test/wai-aria/checkings/value.spec.js +33 -0
- package/test/wai-aria/index.spec.js +1173 -0
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
package/README.md
CHANGED
package/lib/attr-check.d.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import type { Translator } from '@markuplint/i18n';
|
|
2
2
|
import type { Attribute as AttrSpec, AttributeType } from '@markuplint/ml-spec';
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
3
4
|
type Invalid = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
|
|
6
|
+
message: string;
|
|
7
|
+
loc?: Loc;
|
|
7
8
|
};
|
|
8
9
|
type Loc = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
raw: string;
|
|
11
|
+
line: number;
|
|
12
|
+
col: number;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
14
15
|
* Use in rules `invalid-attr` and `wai-aria`
|
|
@@ -18,6 +19,17 @@ type Loc = {
|
|
|
18
19
|
* @param isCustomRule
|
|
19
20
|
* @param spec
|
|
20
21
|
*/
|
|
21
|
-
export declare function attrCheck(
|
|
22
|
-
|
|
22
|
+
export declare function attrCheck(
|
|
23
|
+
t: Translator,
|
|
24
|
+
name: string,
|
|
25
|
+
value: string,
|
|
26
|
+
isCustomRule: boolean,
|
|
27
|
+
spec?: AttrSpec,
|
|
28
|
+
): Invalid | false;
|
|
29
|
+
export declare function valueCheck(
|
|
30
|
+
t: Translator,
|
|
31
|
+
name: string,
|
|
32
|
+
value: string,
|
|
33
|
+
type: ReadonlyDeep<AttributeType>,
|
|
34
|
+
): [string, Loc] | false;
|
|
23
35
|
export {};
|
package/lib/attr-check.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.valueCheck = exports.attrCheck = void 0;
|
|
4
|
+
const shared_1 = require("@markuplint/shared");
|
|
4
5
|
const types_1 = require("@markuplint/types");
|
|
5
6
|
const create_message_1 = require("./create-message");
|
|
6
7
|
const debug_1 = require("./debug");
|
|
@@ -22,6 +23,12 @@ function attrCheck(t, name, value, isCustomRule, spec) {
|
|
|
22
23
|
// Ignore checking because ARIA attributes are check on another rule
|
|
23
24
|
return false;
|
|
24
25
|
}
|
|
26
|
+
// @see https://www.w3.org/TR/adapt/
|
|
27
|
+
// It is an experimental
|
|
28
|
+
if (/^adapt-.+$/.test(name)) {
|
|
29
|
+
// Ignore checking because "adapt-*" attribute is any type
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
25
32
|
}
|
|
26
33
|
// Existence
|
|
27
34
|
if (!spec) {
|
|
@@ -41,35 +48,37 @@ function attrCheck(t, name, value, isCustomRule, spec) {
|
|
|
41
48
|
t('Did you mean "{0*}"?', spec.name),
|
|
42
49
|
};
|
|
43
50
|
}
|
|
44
|
-
|
|
51
|
+
if (spec.noUse) {
|
|
52
|
+
return {
|
|
53
|
+
invalidType: 'disallowed-attr',
|
|
54
|
+
message: t('{0} is {1:c}', t('the "{0*}" {1}', name, 'attribute'), 'disallowed'),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const types = (0, shared_1.toNonNullableArrayFromItemOrArray)(spec.type);
|
|
45
58
|
const invalidList = types.map(type => {
|
|
46
|
-
if (!type) {
|
|
47
|
-
(0, debug_1.log)('attrCheck: %o', arguments);
|
|
48
|
-
throw new Error('type is empty in spec');
|
|
49
|
-
}
|
|
50
59
|
const invalid = valueCheck(t, name, value, type);
|
|
51
|
-
if (invalid) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
if (invalid === false) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
if (typeof invalid === 'string') {
|
|
64
|
+
return {
|
|
65
|
+
invalidType: 'invalid-value',
|
|
66
|
+
message: invalid,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return {
|
|
71
|
+
invalidType: 'invalid-value',
|
|
72
|
+
message: invalid[0],
|
|
73
|
+
loc: invalid[1],
|
|
74
|
+
};
|
|
65
75
|
}
|
|
66
|
-
return false;
|
|
67
76
|
});
|
|
68
|
-
if (invalidList.some(i =>
|
|
77
|
+
if (invalidList.some(i => i === false)) {
|
|
69
78
|
return false;
|
|
70
79
|
}
|
|
71
80
|
const invalid = invalidList.find(i => i);
|
|
72
|
-
return invalid
|
|
81
|
+
return invalid !== null && invalid !== void 0 ? invalid : false;
|
|
73
82
|
}
|
|
74
83
|
exports.attrCheck = attrCheck;
|
|
75
84
|
function valueCheck(t, name, value, type) {
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: Readonly<
|
|
2
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
3
|
+
>;
|
|
2
4
|
export default _default;
|
|
@@ -5,6 +5,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
5
5
|
async verify({ document, report, t }) {
|
|
6
6
|
const message = t('{0} is {1:c}', t('the {0}', 'attribute name'), 'duplicated');
|
|
7
7
|
await document.walkOn('Element', node => {
|
|
8
|
+
var _a;
|
|
8
9
|
const attrNameStack = [];
|
|
9
10
|
for (const attr of node.getAttributeTokens()) {
|
|
10
11
|
if (attr.isDuplicatable) {
|
|
@@ -13,7 +14,7 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
13
14
|
const attrName = attr.name;
|
|
14
15
|
const name = node.elementType === 'html' ? attrName.toLowerCase() : attrName;
|
|
15
16
|
if (attrNameStack.includes(name)) {
|
|
16
|
-
const scope = attr.nameNode
|
|
17
|
+
const scope = (_a = attr.nameNode) !== null && _a !== void 0 ? _a : attr;
|
|
17
18
|
report({
|
|
18
19
|
scope: {
|
|
19
20
|
rule: node.rule,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type Type = 'double' | 'single';
|
|
2
2
|
export type Quote = '"' | "'";
|
|
3
3
|
export type QuoteMap = {
|
|
4
|
-
|
|
4
|
+
[P in Type]: Quote;
|
|
5
5
|
};
|
|
6
|
-
declare const _default: import(
|
|
6
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Type, undefined>>;
|
|
7
7
|
export default _default;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
2
|
-
declare const _default: import(
|
|
2
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<RuleConfigValue, undefined>>;
|
|
3
3
|
export default _default;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
+
const shared_1 = require("@markuplint/shared");
|
|
4
5
|
const helpers_1 = require("../helpers");
|
|
5
6
|
exports.default = (0, ml_core_1.createRule)({
|
|
6
7
|
defaultSeverity: 'warning',
|
|
7
8
|
defaultValue: null,
|
|
8
9
|
async verify({ document, report, t }) {
|
|
9
10
|
await document.walkOn('Element', el => {
|
|
10
|
-
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
const classPatterns = Array.isArray(el.rule.value) ? el.rule.value : [el.rule.value];
|
|
11
|
+
const classPatterns = (0, shared_1.toNoEmptyStringArrayFromStringOrArray)(el.rule.value).filter(className => className && typeof className === 'string');
|
|
14
12
|
const attrs = el.getAttributeToken('class');
|
|
15
13
|
for (const attr of attrs) {
|
|
16
14
|
if (attr.isDynamicValue) {
|
package/lib/create-message.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
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
|
-
|
|
5
|
-
export declare function
|
|
4
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
5
|
+
export declare function createMessageValueExpected(
|
|
6
|
+
t: Translator,
|
|
7
|
+
baseTarget: string,
|
|
8
|
+
type: ReadonlyDeep<AttributeType>,
|
|
9
|
+
matches: UnmatchedResult,
|
|
10
|
+
): string;
|
|
11
|
+
export declare function __createMessageValueExpected(
|
|
12
|
+
t: Translator,
|
|
13
|
+
baseTarget: string,
|
|
14
|
+
expected: string | null,
|
|
15
|
+
matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candidate' | 'ref' | 'extra'>,
|
|
16
|
+
): string;
|
package/lib/create-message.js
CHANGED
|
@@ -22,6 +22,7 @@ function createMessageValueExpected(t, baseTarget, type, matches) {
|
|
|
22
22
|
}
|
|
23
23
|
exports.createMessageValueExpected = createMessageValueExpected;
|
|
24
24
|
function __createMessageValueExpected(t, baseTarget, expected, matches) {
|
|
25
|
+
var _a;
|
|
25
26
|
let target = baseTarget;
|
|
26
27
|
let reasonPart;
|
|
27
28
|
let expectPart;
|
|
@@ -51,7 +52,7 @@ function __createMessageValueExpected(t, baseTarget, expected, matches) {
|
|
|
51
52
|
break;
|
|
52
53
|
}
|
|
53
54
|
case 'extra-token': {
|
|
54
|
-
const token = matches.partName
|
|
55
|
+
const token = (_a = matches.partName) !== null && _a !== void 0 ? _a : 'token';
|
|
55
56
|
reasonPart = t('Found {0}', t('extra {0}', token)) + ' ' + t([matches.raw]);
|
|
56
57
|
if (matches.extra) {
|
|
57
58
|
const extra = expectValueToWord(t, matches.extra, 'Any');
|
|
@@ -201,7 +202,7 @@ exports.__createMessageValueExpected = __createMessageValueExpected;
|
|
|
201
202
|
function createExpectedObject(type, matches, t) {
|
|
202
203
|
var _a;
|
|
203
204
|
const expectedObject = [];
|
|
204
|
-
if (
|
|
205
|
+
if (matches.expects && matches.expects.length > 0) {
|
|
205
206
|
expectedObject.push(...matches.expects.map(expect => {
|
|
206
207
|
return expectValueToWord(t, expect, type);
|
|
207
208
|
}));
|
|
@@ -221,7 +222,7 @@ function createExpectedObject(type, matches, t) {
|
|
|
221
222
|
? null
|
|
222
223
|
: 1 < expectedObject.length
|
|
223
224
|
? t('either {0}', t(expectedObject))
|
|
224
|
-
: expectedObject[0];
|
|
225
|
+
: (_a = expectedObject[0]) !== null && _a !== void 0 ? _a : null;
|
|
225
226
|
return expects;
|
|
226
227
|
}
|
|
227
228
|
function expectValueToWord(t, expect, type) {
|
package/lib/debug.js
CHANGED
|
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.log = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const debug_1 = tslib_1.__importDefault(require("debug"));
|
|
6
|
-
exports.log = (0, debug_1.default)('
|
|
6
|
+
exports.log = (0, debug_1.default)('ml-rules');
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: Readonly<
|
|
2
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
3
|
+
>;
|
|
2
4
|
export default _default;
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: Readonly<
|
|
2
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
3
|
+
>;
|
|
2
4
|
export default _default;
|
|
@@ -10,8 +10,8 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
10
10
|
return;
|
|
11
11
|
}
|
|
12
12
|
const spec = (0, ml_core_1.getSpec)(el, document.specs.specs);
|
|
13
|
-
if (spec && (spec.obsolete || spec.deprecated || spec.nonStandard)) {
|
|
14
|
-
const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete ? 'obsolete' : 'non-standard');
|
|
13
|
+
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 != null ? 'obsolete' : 'non-standard');
|
|
15
15
|
report({
|
|
16
16
|
scope: el,
|
|
17
17
|
message,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<string[], undefined>>;
|
|
2
2
|
export default _default;
|
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: import(
|
|
4
|
+
declare const _default: Readonly<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: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
|
|
2
2
|
export default _default;
|
package/lib/helpers.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { Log } from './debug';
|
|
2
2
|
import type { Translator } from '@markuplint/i18n';
|
|
3
|
+
import type { PlainData } from '@markuplint/ml-config';
|
|
3
4
|
import type { Element, RuleConfigValue, Document } from '@markuplint/ml-core';
|
|
4
5
|
import type { Attribute } from '@markuplint/ml-spec';
|
|
5
|
-
|
|
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;
|
|
6
11
|
export declare function match(needle: string, pattern: string): boolean;
|
|
7
12
|
/**
|
|
8
13
|
* PotentialCustomElementName
|
|
@@ -20,28 +25,38 @@ export declare function match(needle: string, pattern: string): boolean;
|
|
|
20
25
|
* 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
26
|
*/
|
|
22
27
|
export declare const rePCENChar: string;
|
|
23
|
-
export declare function isValidAttr(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
export declare function isValidAttr(
|
|
29
|
+
t: Translator,
|
|
30
|
+
name: string,
|
|
31
|
+
value: string,
|
|
32
|
+
isDynamicValue: boolean,
|
|
33
|
+
node: Element<any, any>,
|
|
34
|
+
attrSpecs: readonly Attribute[],
|
|
35
|
+
log?: Log,
|
|
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
|
+
};
|
|
32
49
|
export declare function toNormalizedValue(value: string, spec: Attribute): string;
|
|
33
50
|
export declare function accnameMayBeMutable(el: Element<any, any>, document: Document<any, any>): boolean;
|
|
34
|
-
export declare function getOwnedLabel<V extends RuleConfigValue, O
|
|
35
|
-
|
|
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
55
|
export declare class Collection<T> {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
56
|
+
#private;
|
|
57
|
+
constructor(...items: readonly (T | null | undefined)[]);
|
|
58
|
+
[Symbol.iterator](): Iterator<T>;
|
|
59
|
+
add(...items: readonly (T | null | undefined)[]): void;
|
|
60
|
+
toArray(): readonly T[];
|
|
42
61
|
}
|
|
43
|
-
|
|
44
|
-
-readonly [P in keyof T]: T[P];
|
|
45
|
-
};
|
|
46
|
-
export declare function deepCopy<T>(value: T): Writeable<T>;
|
|
47
|
-
export {};
|
|
62
|
+
export declare function deepCopy<T>(value: T): WritableDeep<T>;
|
package/lib/helpers.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var _Collection_items;
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.deepCopy = exports.Collection = exports.
|
|
4
|
+
exports.deepCopy = exports.Collection = exports.getOwnedLabel = exports.accnameMayBeMutable = exports.toNormalizedValue = exports.isValidAttr = exports.rePCENChar = exports.match = exports.attrMatches = void 0;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
const structured_clone_1 = tslib_1.__importDefault(require("@ungap/structured-clone"));
|
|
8
|
-
const html_entities_1 = require("html-entities");
|
|
9
8
|
const attr_check_1 = require("./attr-check");
|
|
10
|
-
function attrMatches(
|
|
11
|
-
|
|
9
|
+
function attrMatches(
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
11
|
+
node, condition) {
|
|
12
|
+
if (condition == null) {
|
|
12
13
|
return true;
|
|
13
14
|
}
|
|
14
|
-
const condSelector =
|
|
15
|
+
const condSelector = typeof condition === 'string' ? condition : condition.join(',');
|
|
15
16
|
return node.matches(condSelector);
|
|
16
17
|
}
|
|
17
18
|
exports.attrMatches = attrMatches;
|
|
@@ -60,18 +61,26 @@ exports.rePCENChar = [
|
|
|
60
61
|
'[\uFDF0-\uFFFD]',
|
|
61
62
|
'[\uD800-\uDBFF][\uDC00-\uDFFF]',
|
|
62
63
|
].join('|');
|
|
63
|
-
function isValidAttr(t, name, value, isDynamicValue,
|
|
64
|
+
function isValidAttr(t, name, value, isDynamicValue,
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
66
|
+
node, attrSpecs,
|
|
67
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
68
|
+
log) {
|
|
64
69
|
let invalid = false;
|
|
65
70
|
const spec = attrSpecs.find(s => s.name.toLowerCase() === name.toLowerCase());
|
|
66
71
|
log && log('Spec of the %s attr: %o', name, spec);
|
|
67
72
|
invalid = (0, attr_check_1.attrCheck)(t, name, value, false, spec);
|
|
68
|
-
if (
|
|
73
|
+
if (invalid === false &&
|
|
74
|
+
spec &&
|
|
75
|
+
spec.condition != null &&
|
|
76
|
+
!node.hasSpreadAttr &&
|
|
77
|
+
!attrMatches(node, spec.condition)) {
|
|
69
78
|
invalid = {
|
|
70
79
|
invalidType: 'non-existent',
|
|
71
80
|
message: t('{0} is {1}', t('the "{0*}" {1}', name, 'attribute'), 'disallowed'),
|
|
72
81
|
};
|
|
73
82
|
}
|
|
74
|
-
if (invalid && invalid.invalidType === 'invalid-value' && isDynamicValue) {
|
|
83
|
+
if (invalid !== false && invalid.invalidType === 'invalid-value' && isDynamicValue) {
|
|
75
84
|
invalid = false;
|
|
76
85
|
}
|
|
77
86
|
return invalid;
|
|
@@ -106,7 +115,11 @@ function toNormalizedValue(value, spec) {
|
|
|
106
115
|
return normalized;
|
|
107
116
|
}
|
|
108
117
|
exports.toNormalizedValue = toNormalizedValue;
|
|
109
|
-
function accnameMayBeMutable(
|
|
118
|
+
function accnameMayBeMutable(
|
|
119
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
120
|
+
el,
|
|
121
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
122
|
+
document) {
|
|
110
123
|
if (el.hasMutableAttributes() || el.hasMutableChildren(true)) {
|
|
111
124
|
return true;
|
|
112
125
|
}
|
|
@@ -118,7 +131,11 @@ function accnameMayBeMutable(el, document) {
|
|
|
118
131
|
}
|
|
119
132
|
exports.accnameMayBeMutable = accnameMayBeMutable;
|
|
120
133
|
const labelable = ['button', 'input:not([type=hidden])', 'meter', 'output', 'progress', 'select', 'textarea'];
|
|
121
|
-
function getOwnedLabel(
|
|
134
|
+
function getOwnedLabel(
|
|
135
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
136
|
+
el,
|
|
137
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
138
|
+
document) {
|
|
122
139
|
if (!labelable.some(cond => el.matches(cond))) {
|
|
123
140
|
return null;
|
|
124
141
|
}
|
|
@@ -132,10 +149,6 @@ function getOwnedLabel(el, document) {
|
|
|
132
149
|
return ownedLabel;
|
|
133
150
|
}
|
|
134
151
|
exports.getOwnedLabel = getOwnedLabel;
|
|
135
|
-
function decodeCharRef(characterReference) {
|
|
136
|
-
return (0, html_entities_1.decode)(characterReference);
|
|
137
|
-
}
|
|
138
|
-
exports.decodeCharRef = decodeCharRef;
|
|
139
152
|
class Collection {
|
|
140
153
|
constructor(...items) {
|
|
141
154
|
_Collection_items.set(this, new Set());
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
declare const _default:
|
|
1
|
+
declare const _default: Readonly<
|
|
2
|
+
import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
|
|
3
|
+
>;
|
|
2
4
|
export default _default;
|