@markuplint/rules 3.3.1 → 3.5.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.d.ts +9 -19
- package/lib/attr-duplication/index.d.ts +1 -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/create-message.d.ts +3 -12
- package/lib/create-message.js +2 -2
- package/lib/deprecated-attr/index.d.ts +1 -1
- package/lib/deprecated-element/index.d.ts +1 -1
- package/lib/disallowed-element/index.d.ts +1 -1
- package/lib/doctype/index.d.ts +2 -2
- package/lib/end-tag/index.d.ts +1 -1
- package/lib/helpers.d.ts +18 -35
- package/lib/helpers.js +19 -5
- package/lib/id-duplication/index.d.ts +1 -1
- package/lib/index.d.ts +70 -3
- package/lib/index.js +2 -1
- package/lib/ineffective-attr/index.d.ts +1 -1
- package/lib/invalid-attr/index.d.ts +13 -17
- package/lib/label-has-control/index.d.ts +1 -1
- package/lib/landmark-roles/index.d.ts +3 -3
- package/lib/landmark-roles/index.js +6 -2
- package/lib/no-boolean-attr-value/index.d.ts +1 -1
- package/lib/no-default-value/index.d.ts +1 -1
- package/lib/no-empty-palpable-content/index.d.ts +3 -3
- package/lib/no-hard-code-id/index.d.ts +1 -1
- package/lib/no-refer-to-non-existent-id/index.d.ts +4 -7
- package/lib/no-refer-to-non-existent-id/index.js +4 -0
- package/lib/no-use-event-handler-attr/index.d.ts +2 -2
- package/lib/permitted-contents/choice.d.ts +2 -7
- package/lib/permitted-contents/choice.js +3 -1
- package/lib/permitted-contents/complex-branch.d.ts +2 -7
- 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 +6 -2
- package/lib/permitted-contents/count-pattern.d.ts +3 -17
- package/lib/permitted-contents/count-pattern.js +10 -3
- package/lib/permitted-contents/debug.browser.d.ts +15 -15
- package/lib/permitted-contents/debug.d.ts +1 -1
- package/lib/permitted-contents/index.d.ts +1 -1
- package/lib/permitted-contents/index.js +3 -1
- package/lib/permitted-contents/matches-selector.d.ts +2 -8
- package/lib/permitted-contents/matches-selector.js +3 -1
- package/lib/permitted-contents/order.d.ts +2 -7
- package/lib/permitted-contents/order.js +4 -2
- package/lib/permitted-contents/recursive-branch.d.ts +2 -7
- package/lib/permitted-contents/recursive-branch.js +5 -3
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +3 -7
- package/lib/permitted-contents/represent-transparent-nodes.js +3 -1
- package/lib/permitted-contents/start.d.ts +2 -6
- package/lib/permitted-contents/start.js +3 -1
- package/lib/permitted-contents/transparent.d.ts +2 -2
- package/lib/permitted-contents/transparent.js +5 -3
- package/lib/permitted-contents/types.d.ts +31 -30
- package/lib/permitted-contents/utils.d.ts +44 -80
- package/lib/permitted-contents/utils.js +21 -7
- package/lib/placeholder-label-option/index.d.ts +1 -1
- package/lib/placeholder-label-option/index.js +6 -2
- package/lib/require-accessible-name/index.d.ts +2 -2
- package/lib/require-datetime/index.d.ts +2 -2
- package/lib/require-datetime/types.d.ts +2 -2
- package/lib/require-datetime/utils.d.ts +1 -1
- package/lib/require-datetime/utils.js +3 -1
- package/lib/required-attr/index.d.ts +3 -3
- package/lib/required-attr/index.js +14 -11
- package/lib/required-element/index.d.ts +2 -2
- package/lib/required-element/index.js +2 -1
- package/lib/required-h1/index.d.ts +3 -3
- package/lib/required-h1/index.js +3 -2
- package/lib/use-list/index.d.ts +3 -3
- package/lib/use-list/index.js +3 -2
- package/lib/wai-aria/checkings/default-value.d.ts +3 -7
- package/lib/wai-aria/checkings/deprecated-props.d.ts +4 -8
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +4 -8
- package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
- package/lib/wai-aria/checkings/implicit-props.d.ts +4 -8
- package/lib/wai-aria/checkings/interaction-in-hidden.js +3 -1
- package/lib/wai-aria/checkings/no-global-prop.d.ts +3 -7
- package/lib/wai-aria/checkings/presentational-children.js +3 -1
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +3 -7
- package/lib/wai-aria/checkings/required-owned-elements.js +6 -4
- package/lib/wai-aria/checkings/required-prop.d.ts +6 -12
- package/lib/wai-aria/checkings/value.d.ts +6 -10
- package/lib/wai-aria/index.d.ts +1 -1
- package/lib/wai-aria/types.d.ts +10 -10
- package/package.json +9 -8
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ChildNode, Options, Result, Specs } from './types';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
PermittedContentOptional,
|
|
5
|
-
PermittedContentRequire,
|
|
6
|
-
PermittedContentZeroOrMore,
|
|
7
|
-
} from '@markuplint/ml-spec';
|
|
2
|
+
import type { PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentZeroOrMore } from '@markuplint/ml-spec';
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
8
4
|
/**
|
|
9
5
|
* Check count
|
|
10
6
|
*
|
|
@@ -15,14 +11,4 @@ import type {
|
|
|
15
11
|
* @param depth
|
|
16
12
|
* @returns
|
|
17
13
|
*/
|
|
18
|
-
export declare function countPattern(
|
|
19
|
-
pattern:
|
|
20
|
-
| PermittedContentOneOrMore
|
|
21
|
-
| PermittedContentOptional
|
|
22
|
-
| PermittedContentRequire
|
|
23
|
-
| PermittedContentZeroOrMore,
|
|
24
|
-
elements: readonly ChildNode[],
|
|
25
|
-
specs: Specs,
|
|
26
|
-
options: Options,
|
|
27
|
-
depth: number,
|
|
28
|
-
): Result;
|
|
14
|
+
export declare function countPattern(pattern: ReadonlyDeep<PermittedContentOneOrMore> | ReadonlyDeep<PermittedContentOptional> | ReadonlyDeep<PermittedContentRequire> | ReadonlyDeep<PermittedContentZeroOrMore>, elements: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
|
|
@@ -14,7 +14,9 @@ const utils_1 = require("./utils");
|
|
|
14
14
|
* @param depth
|
|
15
15
|
* @returns
|
|
16
16
|
*/
|
|
17
|
-
function countPattern(pattern,
|
|
17
|
+
function countPattern(pattern,
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
19
|
+
elements, specs, options, depth) {
|
|
18
20
|
const ptLog = debug_1.cmLog.extend(`countPattern#${depth}`);
|
|
19
21
|
const collection = new utils_1.Collection(elements);
|
|
20
22
|
const { model, min, max, repeat, missingType } = (0, utils_1.normalizeModel)(pattern);
|
|
@@ -142,7 +144,12 @@ function countPattern(pattern, elements, specs, options, depth) {
|
|
|
142
144
|
}
|
|
143
145
|
exports.countPattern = countPattern;
|
|
144
146
|
const cLog = debug_1.cmLog.extend('countCompereResult');
|
|
145
|
-
function compereResult(
|
|
147
|
+
function compereResult(
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
149
|
+
a,
|
|
150
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
151
|
+
b) {
|
|
152
|
+
var _a;
|
|
146
153
|
cLog('current: %s %O\nbarely: %s %O', a.type, a.hint, b === null || b === void 0 ? void 0 : b.type, b === null || b === void 0 ? void 0 : b.hint);
|
|
147
154
|
if (b == null) {
|
|
148
155
|
return a;
|
|
@@ -150,6 +157,6 @@ function compereResult(a, b) {
|
|
|
150
157
|
if (a.type === 'MATCHED' || a.type === 'MATCHED_ZERO' || a.type === 'UNEXPECTED_EXTRA_NODE') {
|
|
151
158
|
return a;
|
|
152
159
|
}
|
|
153
|
-
const result = [a, b].sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = b.hint.missing) === null || _a === void 0 ? void 0 : _a.barelyMatchedElements) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = a.hint.missing) === null || _c === void 0 ? void 0 : _c.barelyMatchedElements) !== null && _d !== void 0 ? _d : 0); })[0];
|
|
160
|
+
const result = (_a = [a, b].sort((a, b) => { var _a, _b, _c, _d; return ((_b = (_a = b.hint.missing) === null || _a === void 0 ? void 0 : _a.barelyMatchedElements) !== null && _b !== void 0 ? _b : 0) - ((_d = (_c = a.hint.missing) === null || _c === void 0 ? void 0 : _c.barelyMatchedElements) !== null && _d !== void 0 ? _d : 0); })[0]) !== null && _a !== void 0 ? _a : a;
|
|
154
161
|
return result;
|
|
155
162
|
}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
/// <reference types="debug" />
|
|
2
|
-
export declare const cmLog: import(
|
|
2
|
+
export declare const cmLog: import("debug").Debugger;
|
|
3
3
|
export declare const bgGreen: {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
(): void;
|
|
5
|
+
bold(): void;
|
|
6
6
|
};
|
|
7
7
|
export declare const green: {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
(): void;
|
|
9
|
+
bold(): void;
|
|
10
10
|
};
|
|
11
11
|
export declare const bgRed: {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
(): void;
|
|
13
|
+
bold(): void;
|
|
14
14
|
};
|
|
15
15
|
export declare const bgBlue: {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
(): void;
|
|
17
|
+
bold(): void;
|
|
18
18
|
};
|
|
19
19
|
export declare const blue: {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
(): void;
|
|
21
|
+
bold(): void;
|
|
22
22
|
};
|
|
23
23
|
export declare const bgMagenta: {
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
(): void;
|
|
25
|
+
bold(): void;
|
|
26
26
|
};
|
|
27
27
|
export declare const cyan: {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
(): void;
|
|
29
|
+
bold(): void;
|
|
30
30
|
};
|
|
@@ -91,7 +91,9 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
91
91
|
});
|
|
92
92
|
},
|
|
93
93
|
});
|
|
94
|
-
function name(
|
|
94
|
+
function name(
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
96
|
+
scope, t) {
|
|
95
97
|
if (scope.is(scope.ELEMENT_NODE)) {
|
|
96
98
|
return t('the "{0}" {1}', scope.localName, 'element');
|
|
97
99
|
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import type { ChildNode,
|
|
1
|
+
import type { ChildNode, Result, Specs } from './types';
|
|
2
2
|
export type SelectorResult = Result<'UNMATCHED_SELECTOR_BUT_MAY_EMPTY' | 'MISSING_NODE' | 'UNMATCHED_SELECTORS'>;
|
|
3
|
-
export declare function matchesSelector(
|
|
4
|
-
query: string,
|
|
5
|
-
node: ChildNode | undefined,
|
|
6
|
-
specs: Specs,
|
|
7
|
-
options: Options,
|
|
8
|
-
depth: number,
|
|
9
|
-
): SelectorResult;
|
|
3
|
+
export declare function matchesSelector(query: string, node: ChildNode | undefined, specs: Specs, depth: number): SelectorResult;
|
|
@@ -4,7 +4,9 @@ exports.matchesSelector = void 0;
|
|
|
4
4
|
const ml_spec_1 = require("@markuplint/ml-spec");
|
|
5
5
|
const debug_1 = require("./debug");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
function matchesSelector(query,
|
|
7
|
+
function matchesSelector(query,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
|
+
node, specs, depth) {
|
|
8
10
|
const nodeLog = debug_1.cmLog.extend(`node#${depth}`);
|
|
9
11
|
const { selector, hasText, hasCustom } = optCondition(query, specs);
|
|
10
12
|
if (node == null) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ChildNode, Options, Result, Specs } from './types';
|
|
2
2
|
import type { PermittedContentPattern } from '@markuplint/ml-spec';
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
3
4
|
/**
|
|
4
5
|
* Check ordered array
|
|
5
6
|
*
|
|
@@ -10,10 +11,4 @@ import type { PermittedContentPattern } from '@markuplint/ml-spec';
|
|
|
10
11
|
* @param depth
|
|
11
12
|
* @returns
|
|
12
13
|
*/
|
|
13
|
-
export declare function order(
|
|
14
|
-
contents: ReadonlyArray<PermittedContentPattern>,
|
|
15
|
-
nodes: ReadonlyArray<ChildNode>,
|
|
16
|
-
specs: Specs,
|
|
17
|
-
options: Options,
|
|
18
|
-
depth: number,
|
|
19
|
-
): Result;
|
|
14
|
+
export declare function order(contents: ReadonlyDeep<PermittedContentPattern[]>, nodes: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
|
|
@@ -15,7 +15,9 @@ const utils_1 = require("./utils");
|
|
|
15
15
|
* @param depth
|
|
16
16
|
* @returns
|
|
17
17
|
*/
|
|
18
|
-
function order(contents,
|
|
18
|
+
function order(contents,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
20
|
+
nodes, specs, options, depth) {
|
|
19
21
|
var _a, _b, _c, _d, _e;
|
|
20
22
|
const orderLog = debug_1.cmLog.extend(`order#${depth}`);
|
|
21
23
|
const btLog = debug_1.cmLog.extend(`backtrack#${depth}`);
|
|
@@ -27,7 +29,7 @@ function order(contents, nodes, specs, options, depth) {
|
|
|
27
29
|
let backtrackMode = false;
|
|
28
30
|
let afterBacktrack = false;
|
|
29
31
|
const unmatchedResults = [];
|
|
30
|
-
while (patterns.length) {
|
|
32
|
+
while (patterns.length && patterns[0]) {
|
|
31
33
|
result = (0, complex_branch_1.complexBranch)(patterns[0], collection.unmatched, specs, options, depth);
|
|
32
34
|
collection.addMatched(result.matched);
|
|
33
35
|
if (result.type !== 'UNEXPECTED_EXTRA_NODE' && result.type !== 'MATCHED' && result.type !== 'MATCHED_ZERO') {
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
import type { SelectorResult } from './matches-selector';
|
|
2
2
|
import type { ChildNode, Options, Specs } from './types';
|
|
3
3
|
import type { PermittedContentPattern, Model } from '@markuplint/ml-spec';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
nodes: readonly ChildNode[],
|
|
7
|
-
specs: Specs,
|
|
8
|
-
options: Options,
|
|
9
|
-
depth: number,
|
|
10
|
-
): SelectorResult;
|
|
4
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
5
|
+
export declare function recursiveBranch(model: ReadonlyDeep<Model | PermittedContentPattern[]>, nodes: readonly ChildNode[], specs: Specs, options: Options, depth: number): SelectorResult;
|
|
@@ -4,17 +4,19 @@ exports.recursiveBranch = void 0;
|
|
|
4
4
|
const matches_selector_1 = require("./matches-selector");
|
|
5
5
|
const order_1 = require("./order");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
|
-
function recursiveBranch(model,
|
|
7
|
+
function recursiveBranch(model,
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
9
|
+
nodes, specs, options, depth) {
|
|
8
10
|
if (!(0, utils_1.isModel)(model)) {
|
|
9
11
|
return (0, order_1.order)(model, nodes, specs, options, depth + 1);
|
|
10
12
|
}
|
|
11
13
|
if (typeof model === 'string') {
|
|
12
|
-
return (0, matches_selector_1.matchesSelector)(model, nodes[0], specs,
|
|
14
|
+
return (0, matches_selector_1.matchesSelector)(model, nodes[0], specs, depth);
|
|
13
15
|
}
|
|
14
16
|
const collection = new utils_1.Collection(nodes);
|
|
15
17
|
let lastUnmatched = null;
|
|
16
18
|
for (const query of model) {
|
|
17
|
-
const result = (0, matches_selector_1.matchesSelector)(query, collection.unmatched[0], specs,
|
|
19
|
+
const result = (0, matches_selector_1.matchesSelector)(query, collection.unmatched[0], specs, depth);
|
|
18
20
|
collection.addMatched(result.matched);
|
|
19
21
|
if (result.type === 'MATCHED' || result.type === 'MATCHED_ZERO') {
|
|
20
22
|
return {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import type { ChildNode, Options, Result, Specs } from './types';
|
|
2
2
|
export declare const transparentMode: Map<ChildNode, true>;
|
|
3
|
-
export declare function representTransparentNodes(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
options: Options,
|
|
7
|
-
): {
|
|
8
|
-
nodes: ChildNode[];
|
|
9
|
-
errors: Result[];
|
|
3
|
+
export declare function representTransparentNodes(nodes: ChildNode[], specs: Specs, options: Options): {
|
|
4
|
+
nodes: ChildNode[];
|
|
5
|
+
errors: Result[];
|
|
10
6
|
};
|
|
@@ -5,7 +5,9 @@ const ml_spec_1 = require("@markuplint/ml-spec");
|
|
|
5
5
|
const order_1 = require("./order");
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
exports.transparentMode = new Map();
|
|
8
|
-
function representTransparentNodes(
|
|
8
|
+
function representTransparentNodes(
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
10
|
+
nodes, specs, options) {
|
|
9
11
|
var _a;
|
|
10
12
|
const result = [];
|
|
11
13
|
const errors = [];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ContentModelResult, Element, Options, Specs } from './types';
|
|
2
2
|
import type { ContentModel } from '@markuplint/ml-spec';
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
3
4
|
/**
|
|
4
5
|
* Check start
|
|
5
6
|
*
|
|
@@ -9,9 +10,4 @@ import type { ContentModel } from '@markuplint/ml-spec';
|
|
|
9
10
|
* @param options
|
|
10
11
|
* @returns
|
|
11
12
|
*/
|
|
12
|
-
export declare function start(
|
|
13
|
-
contents: ContentModel['contents'],
|
|
14
|
-
el: Element,
|
|
15
|
-
specs: Specs,
|
|
16
|
-
options: Options,
|
|
17
|
-
): ContentModelResult[];
|
|
13
|
+
export declare function start(contents: ReadonlyDeep<ContentModel['contents']>, el: Element, specs: Specs, options: Options): ContentModelResult[];
|
|
@@ -13,7 +13,9 @@ const utils_1 = require("./utils");
|
|
|
13
13
|
* @param options
|
|
14
14
|
* @returns
|
|
15
15
|
*/
|
|
16
|
-
function start(contents,
|
|
16
|
+
function start(contents,
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
18
|
+
el, specs, options) {
|
|
17
19
|
var _a;
|
|
18
20
|
if (contents === false) {
|
|
19
21
|
if (el.childNodes.length) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { ChildNode,
|
|
2
|
-
export declare function transparent(nodes: ChildNode[]
|
|
1
|
+
import type { ChildNode, Result } from './types';
|
|
2
|
+
export declare function transparent(nodes: readonly ChildNode[]): Result;
|
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.transparent = void 0;
|
|
4
4
|
const debug_1 = require("./debug");
|
|
5
5
|
const transparentLog = debug_1.cmLog.extend('transparent');
|
|
6
|
-
function transparent(
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function transparent(
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
8
|
+
nodes) {
|
|
9
|
+
var _a, _b;
|
|
10
|
+
if (nodes.length === 0 || ((_b = (_a = nodes[0]) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement)) {
|
|
9
11
|
transparentLog('Skipped');
|
|
10
12
|
return {
|
|
11
13
|
type: nodes.length === 0 ? 'MATCHED_ZERO' : 'MATCHED',
|
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
import type { Element as _Element, ChildNode as _ChildNode } from '@markuplint/ml-core';
|
|
2
2
|
import type { ContentModel, MLMLSpec } from '@markuplint/ml-spec';
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
3
4
|
export type Element = _Element<TagRule[], Options>;
|
|
4
5
|
export type ChildNode = _ChildNode<TagRule[], Options>;
|
|
5
6
|
export type Specs = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
readonly cites: MLMLSpec['cites'];
|
|
8
|
+
readonly def: MLMLSpec['def'];
|
|
9
|
+
readonly specs: readonly {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly contentModel: {
|
|
12
|
+
readonly contents: MLMLSpec['specs'][0]['contentModel']['contents'];
|
|
13
|
+
};
|
|
14
|
+
}[];
|
|
14
15
|
};
|
|
15
16
|
export type ContentModelResult = {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
type: MatchedReason | UnmatchedReason;
|
|
18
|
+
scope: ChildNode;
|
|
19
|
+
query: Result['query'];
|
|
20
|
+
hint: Result['hint'];
|
|
20
21
|
};
|
|
21
22
|
export type Result<T extends string = MatchedReason> = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
type: MatchedReason | UnmatchedReason | T;
|
|
24
|
+
matched: ChildNode[];
|
|
25
|
+
unmatched: ChildNode[];
|
|
26
|
+
zeroMatch: boolean;
|
|
27
|
+
query: string;
|
|
28
|
+
hint: Hints;
|
|
28
29
|
};
|
|
29
30
|
export type Hints = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
31
|
+
max?: number;
|
|
32
|
+
not?: ChildNode;
|
|
33
|
+
transparent?: Element;
|
|
34
|
+
missing?: {
|
|
35
|
+
barelyMatchedElements?: number;
|
|
36
|
+
need?: string;
|
|
37
|
+
};
|
|
37
38
|
};
|
|
38
39
|
export type MatchedReason = 'MATCHED' | 'MATCHED_ZERO';
|
|
39
40
|
export type UnmatchedReason = 'NOTHING' | 'UNEXPECTED_EXTRA_NODE' | 'TRANSPARENT_MODEL_DISALLOWS' | MissingNodeReason;
|
|
40
41
|
export type MissingNodeReason = 'MISSING_NODE_REQUIRED' | 'MISSING_NODE_ONE_OR_MORE';
|
|
41
42
|
export type RepeatSign = '' | '?' | '+' | '*' | `{${number},${number}}`;
|
|
42
43
|
export type TransparentModel = {
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
el: Element;
|
|
45
|
+
additionalCondition: string;
|
|
45
46
|
};
|
|
46
47
|
export type TagRule = {
|
|
47
|
-
|
|
48
|
-
} & ContentModel
|
|
48
|
+
readonly tag: string;
|
|
49
|
+
} & ReadonlyDeep<ContentModel>;
|
|
49
50
|
export type Options = {
|
|
50
|
-
|
|
51
|
+
readonly ignoreHasMutableChildren: boolean;
|
|
51
52
|
};
|
|
@@ -1,87 +1,51 @@
|
|
|
1
1
|
import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
PermittedContentChoice,
|
|
5
|
-
PermittedContentOneOrMore,
|
|
6
|
-
PermittedContentOptional,
|
|
7
|
-
PermittedContentRequire,
|
|
8
|
-
PermittedContentTransparent,
|
|
9
|
-
PermittedContentZeroOrMore,
|
|
10
|
-
Model,
|
|
11
|
-
} from '@markuplint/ml-spec';
|
|
2
|
+
import type { PermittedContentPattern, PermittedContentChoice, PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentTransparent, PermittedContentZeroOrMore, Model } from '@markuplint/ml-spec';
|
|
3
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
12
4
|
export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];
|
|
13
|
-
export declare function isModel(model: Model | PermittedContentPattern[]): model is Model
|
|
14
|
-
export declare function matches(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
matched: boolean;
|
|
21
|
-
not?: undefined;
|
|
22
|
-
}
|
|
23
|
-
| {
|
|
24
|
-
matched: boolean;
|
|
25
|
-
not: ChildNode | undefined;
|
|
26
|
-
};
|
|
27
|
-
export declare function isRequire(content: PermittedContentPattern): content is PermittedContentRequire;
|
|
28
|
-
export declare function isOptional(content: PermittedContentPattern): content is PermittedContentOptional;
|
|
29
|
-
export declare function isOneOrMore(content: PermittedContentPattern): content is PermittedContentOneOrMore;
|
|
30
|
-
export declare function isZeroOrMore(content: PermittedContentPattern): content is PermittedContentZeroOrMore;
|
|
31
|
-
export declare function isChoice(content: PermittedContentPattern): content is PermittedContentChoice;
|
|
32
|
-
export declare function isTransparent(content: PermittedContentPattern): content is PermittedContentTransparent;
|
|
33
|
-
export declare function normalizeModel(
|
|
34
|
-
pattern:
|
|
35
|
-
| PermittedContentRequire
|
|
36
|
-
| PermittedContentOptional
|
|
37
|
-
| PermittedContentOneOrMore
|
|
38
|
-
| PermittedContentZeroOrMore,
|
|
39
|
-
): {
|
|
40
|
-
model: PermittedContentPattern[] | Model;
|
|
41
|
-
min: number;
|
|
42
|
-
max: number;
|
|
43
|
-
repeat: RepeatSign;
|
|
44
|
-
missingType: MissingNodeReason | undefined;
|
|
5
|
+
export declare function isModel(model: ReadonlyDeep<Model | PermittedContentPattern[]>): model is ReadonlyDeep<Model>;
|
|
6
|
+
export declare function matches(selector: string, node: ChildNode, specs: Specs): {
|
|
7
|
+
matched: boolean;
|
|
8
|
+
not?: undefined;
|
|
9
|
+
} | {
|
|
10
|
+
matched: boolean;
|
|
11
|
+
not: ChildNode | undefined;
|
|
45
12
|
};
|
|
46
|
-
export declare function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
):
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
| import('packages/@markuplint/ml-core/lib').Element<import('./types').TagRule[], import('./types').Options>
|
|
68
|
-
| import('packages/@markuplint/ml-core/lib').Block<import('./types').TagRule[], import('./types').Options>
|
|
69
|
-
| undefined;
|
|
70
|
-
transparent?: Element | undefined;
|
|
13
|
+
export declare function isRequire(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentRequire>;
|
|
14
|
+
export declare function isOptional(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOptional>;
|
|
15
|
+
export declare function isOneOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentOneOrMore>;
|
|
16
|
+
export declare function isZeroOrMore(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentZeroOrMore>;
|
|
17
|
+
export declare function isChoice(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentChoice>;
|
|
18
|
+
export declare function isTransparent(content: ReadonlyDeep<PermittedContentPattern>): content is ReadonlyDeep<PermittedContentTransparent>;
|
|
19
|
+
export declare function normalizeModel(pattern: ReadonlyDeep<PermittedContentRequire> | ReadonlyDeep<PermittedContentOptional> | ReadonlyDeep<PermittedContentOneOrMore> | ReadonlyDeep<PermittedContentZeroOrMore>): {
|
|
20
|
+
model: ReadonlyDeep<PermittedContentPattern[] | Model>;
|
|
21
|
+
min: number;
|
|
22
|
+
max: number;
|
|
23
|
+
repeat: RepeatSign;
|
|
24
|
+
missingType: MissingNodeReason | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare function mergeHints(a: Readonly<Hints>, b: Readonly<Hints>): Partial<{
|
|
27
|
+
missing: Partial<{
|
|
28
|
+
barelyMatchedElements?: number | undefined;
|
|
29
|
+
need?: string | undefined;
|
|
30
|
+
}> | undefined;
|
|
31
|
+
max?: number | undefined;
|
|
32
|
+
not?: import("packages/@markuplint/ml-core/lib").DocumentType<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib/ml-dom/node/character-data").MLCharacterData<import("./types").TagRule[], import("./types").Options, import("packages/@markuplint/ml-ast/lib").MLASTAbstractNode> | import("packages/@markuplint/ml-core/lib").Element<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib").Block<import("./types").TagRule[], import("./types").Options> | undefined;
|
|
33
|
+
transparent?: Element | undefined;
|
|
71
34
|
}>;
|
|
72
35
|
export declare function cleanObject<T extends Object>(object: T): Partial<T>;
|
|
73
36
|
export declare class Collection {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
37
|
+
#private;
|
|
38
|
+
constructor(origin: readonly ChildNode[]);
|
|
39
|
+
get matched(): ChildNode[];
|
|
40
|
+
get matchedCount(): number;
|
|
41
|
+
get nodes(): ChildNode[];
|
|
42
|
+
get unmatched(): ChildNode[];
|
|
43
|
+
addMatched(nodes: ChildNode[]): boolean;
|
|
44
|
+
back(): void;
|
|
45
|
+
lock(): void;
|
|
46
|
+
max(max: number): void;
|
|
47
|
+
toString(highlightExtraNodes?: boolean): string;
|
|
48
|
+
}
|
|
49
|
+
export declare class UnsupportedError extends Error {
|
|
85
50
|
}
|
|
86
|
-
export declare
|
|
87
|
-
export declare function modelLog(model: Model | PermittedContentPattern[], repeat: RepeatSign): string;
|
|
51
|
+
export declare function modelLog(model: ReadonlyDeep<Model | PermittedContentPattern[]>, repeat: RepeatSign): string;
|
|
@@ -7,7 +7,9 @@ const selector_1 = require("@markuplint/selector");
|
|
|
7
7
|
const debug_1 = require("./debug");
|
|
8
8
|
const represent_transparent_nodes_1 = require("./represent-transparent-nodes");
|
|
9
9
|
const getChildNodesWithoutWhitespacesCaches = new Map();
|
|
10
|
-
function getChildNodesWithoutWhitespaces(
|
|
10
|
+
function getChildNodesWithoutWhitespaces(
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
12
|
+
el) {
|
|
11
13
|
let nodes = getChildNodesWithoutWhitespacesCaches.get(el);
|
|
12
14
|
if (nodes) {
|
|
13
15
|
return nodes;
|
|
@@ -36,7 +38,9 @@ function isModel(model) {
|
|
|
36
38
|
return modelMode;
|
|
37
39
|
}
|
|
38
40
|
exports.isModel = isModel;
|
|
39
|
-
function matches(selector,
|
|
41
|
+
function matches(selector,
|
|
42
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
43
|
+
node, specs) {
|
|
40
44
|
const selectorResult = (0, selector_1.createSelector)(selector, specs).search(node);
|
|
41
45
|
const matched = selectorResult.filter((r) => r.matched);
|
|
42
46
|
if (matched.length) {
|
|
@@ -56,7 +60,9 @@ function matches(selector, node, specs) {
|
|
|
56
60
|
};
|
|
57
61
|
}
|
|
58
62
|
exports.matches = matches;
|
|
59
|
-
function descendants(
|
|
63
|
+
function descendants(
|
|
64
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
65
|
+
selectorResult) {
|
|
60
66
|
let nodes = selectorResult.nodes.slice();
|
|
61
67
|
while (selectorResult.has.length) {
|
|
62
68
|
for (const dep of selectorResult.has) {
|
|
@@ -151,7 +157,11 @@ function normalizeModel(pattern) {
|
|
|
151
157
|
};
|
|
152
158
|
}
|
|
153
159
|
exports.normalizeModel = normalizeModel;
|
|
154
|
-
function mergeHints(
|
|
160
|
+
function mergeHints(
|
|
161
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
162
|
+
a,
|
|
163
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
164
|
+
b) {
|
|
155
165
|
const missing = [a.missing, b.missing].sort((a, b) => { var _a, _b; return ((_a = b === null || b === void 0 ? void 0 : b.barelyMatchedElements) !== null && _a !== void 0 ? _a : 0) - ((_b = a === null || a === void 0 ? void 0 : a.barelyMatchedElements) !== null && _b !== void 0 ? _b : 0); })[0];
|
|
156
166
|
return cleanObject({
|
|
157
167
|
...a,
|
|
@@ -171,7 +181,9 @@ function cleanObject(object) {
|
|
|
171
181
|
}
|
|
172
182
|
exports.cleanObject = cleanObject;
|
|
173
183
|
class Collection {
|
|
174
|
-
constructor(
|
|
184
|
+
constructor(
|
|
185
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
186
|
+
origin) {
|
|
175
187
|
_Collection_locked.set(this, new Set());
|
|
176
188
|
_Collection_matched.set(this, new Set());
|
|
177
189
|
_Collection_nodes.set(this, void 0);
|
|
@@ -191,7 +203,9 @@ class Collection {
|
|
|
191
203
|
get unmatched() {
|
|
192
204
|
return Array.from(tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f")).filter(n => !tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").has(n));
|
|
193
205
|
}
|
|
194
|
-
addMatched(
|
|
206
|
+
addMatched(
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
208
|
+
nodes) {
|
|
195
209
|
const i = tslib_1.__classPrivateFieldGet(this, _Collection_matched, "f").size;
|
|
196
210
|
for (const node of nodes) {
|
|
197
211
|
if (!tslib_1.__classPrivateFieldGet(this, _Collection_nodes, "f").has(node)) {
|
|
@@ -268,7 +282,7 @@ function modelLog(model, repeat) {
|
|
|
268
282
|
}
|
|
269
283
|
exports.modelLog = modelLog;
|
|
270
284
|
function orderLog(order, repeat) {
|
|
271
|
-
return order.length === 1
|
|
285
|
+
return order.length === 1 && order[0]
|
|
272
286
|
? markRepeat(patternLog(order[0]), repeat)
|
|
273
287
|
: markRepeat(order.map(pattern => patternLog(pattern)).join(''), repeat);
|
|
274
288
|
}
|
|
@@ -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;
|
|
@@ -26,7 +26,9 @@ exports.default = (0, ml_core_1.createRule)({
|
|
|
26
26
|
* @param select
|
|
27
27
|
* @returns
|
|
28
28
|
*/
|
|
29
|
-
function needPlaceholderLabelOption(
|
|
29
|
+
function needPlaceholderLabelOption(
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
31
|
+
select) {
|
|
30
32
|
const hasRequired = select.hasAttribute('required');
|
|
31
33
|
if (!hasRequired) {
|
|
32
34
|
return false;
|
|
@@ -53,7 +55,9 @@ function needPlaceholderLabelOption(select) {
|
|
|
53
55
|
* @param select
|
|
54
56
|
* @returns
|
|
55
57
|
*/
|
|
56
|
-
function hasPlaceholderLabelOption(
|
|
58
|
+
function hasPlaceholderLabelOption(
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
60
|
+
select) {
|
|
57
61
|
var _a;
|
|
58
62
|
// > has a required attribute specified
|
|
59
63
|
if (!select.hasAttribute('required')) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ARIAVersion } from '@markuplint/ml-spec';
|
|
2
2
|
type Option = {
|
|
3
|
-
|
|
3
|
+
ariaVersion: ARIAVersion;
|
|
4
4
|
};
|
|
5
|
-
declare const _default: import(
|
|
5
|
+
declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Option>>;
|
|
6
6
|
export default _default;
|