@markuplint/rules 2.4.3 → 3.0.0-alpha.1
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 +2 -6
- package/lib/attr-check.js +1 -1
- package/lib/attr-duplication/index.js +10 -7
- package/lib/attr-value-quotes/index.js +22 -26
- package/lib/case-sensitive-attr-name/index.d.ts +1 -5
- package/lib/case-sensitive-attr-name/index.js +52 -82
- package/lib/case-sensitive-tag-name/index.js +39 -31
- package/lib/character-reference/index.d.ts +2 -1
- package/lib/character-reference/index.js +6 -8
- package/lib/class-naming/index.js +12 -12
- package/lib/create-message.d.ts +1 -1
- package/lib/create-message.js +5 -5
- package/lib/deprecated-attr/index.js +17 -18
- package/lib/deprecated-element/index.js +5 -7
- package/lib/disallowed-element/index.js +8 -9
- package/lib/doctype/index.d.ts +1 -1
- package/lib/doctype/index.js +8 -8
- package/lib/end-tag/index.js +5 -2
- package/lib/helpers.d.ts +15 -28
- package/lib/helpers.js +42 -156
- package/lib/id-duplication/index.js +4 -6
- package/lib/index.d.ts +12 -21
- package/lib/index.js +0 -8
- package/lib/ineffective-attr/index.js +20 -28
- package/lib/invalid-attr/index.js +83 -83
- package/lib/landmark-roles/index.d.ts +2 -2
- package/lib/landmark-roles/index.js +10 -10
- package/lib/no-boolean-attr-value/index.js +34 -35
- package/lib/no-default-value/index.js +21 -25
- package/lib/no-hard-code-id/index.js +10 -14
- package/lib/no-refer-to-non-existent-id/index.d.ts +4 -1
- package/lib/no-refer-to-non-existent-id/index.js +77 -83
- package/lib/no-use-event-handler-attr/index.js +21 -23
- package/lib/permitted-contents/choice.d.ts +3 -0
- package/lib/permitted-contents/choice.js +37 -0
- package/lib/permitted-contents/complex-branch.d.ts +13 -0
- package/lib/permitted-contents/complex-branch.js +27 -0
- package/lib/permitted-contents/content-model.d.ts +2 -0
- package/lib/permitted-contents/content-model.js +49 -0
- package/lib/permitted-contents/count-pattern.d.ts +13 -0
- package/lib/permitted-contents/count-pattern.js +155 -0
- package/lib/permitted-contents/debug.d.ts +2 -0
- package/lib/permitted-contents/debug.js +5 -0
- package/lib/permitted-contents/index.d.ts +2 -5
- package/lib/permitted-contents/index.js +78 -249
- package/lib/permitted-contents/matches-selector.d.ts +3 -0
- package/lib/permitted-contents/matches-selector.js +185 -0
- package/lib/permitted-contents/order.d.ts +13 -0
- package/lib/permitted-contents/order.js +89 -0
- package/lib/permitted-contents/recursive-branch.d.ts +4 -0
- package/lib/permitted-contents/recursive-branch.js +43 -0
- package/lib/permitted-contents/represent-transparent-nodes.d.ts +6 -0
- package/lib/permitted-contents/represent-transparent-nodes.js +79 -0
- package/lib/permitted-contents/start.d.ts +12 -0
- package/lib/permitted-contents/start.js +71 -0
- package/lib/permitted-contents/transparent.d.ts +2 -0
- package/lib/permitted-contents/transparent.js +34 -0
- package/lib/permitted-contents/types.d.ts +45 -0
- package/lib/permitted-contents/types.js +2 -0
- package/lib/permitted-contents/utils.d.ts +32 -0
- package/lib/permitted-contents/utils.js +184 -0
- package/lib/require-accessible-name/index.d.ts +5 -1
- package/lib/require-accessible-name/index.js +11 -4
- package/lib/required-attr/index.js +16 -25
- package/lib/required-element/index.d.ts +1 -1
- package/lib/required-element/index.js +6 -6
- package/lib/required-h1/index.d.ts +2 -2
- package/lib/required-h1/index.js +3 -3
- package/lib/use-list/index.js +2 -2
- package/lib/wai-aria/checkings/abstract-role.d.ts +3 -0
- package/lib/wai-aria/checkings/abstract-role.js +22 -0
- package/lib/wai-aria/checkings/default-value.d.ts +6 -0
- package/lib/wai-aria/checkings/default-value.js +17 -0
- package/lib/wai-aria/checkings/deprecated-props.d.ts +7 -0
- package/lib/wai-aria/checkings/deprecated-props.js +18 -0
- package/lib/wai-aria/checkings/disallowed-prop.d.ts +7 -0
- package/lib/wai-aria/checkings/disallowed-prop.js +22 -0
- package/lib/wai-aria/checkings/implicit-props.d.ts +7 -0
- package/lib/wai-aria/checkings/implicit-props.js +50 -0
- package/lib/wai-aria/checkings/implicit-role.d.ts +3 -0
- package/lib/wai-aria/checkings/implicit-role.js +21 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +11 -0
- package/lib/wai-aria/checkings/interaction-in-hidden.js +47 -0
- package/lib/wai-aria/checkings/no-global-prop.d.ts +6 -0
- package/lib/wai-aria/checkings/no-global-prop.js +14 -0
- package/lib/wai-aria/checkings/non-existant-role.d.ts +3 -0
- package/lib/wai-aria/checkings/non-existant-role.js +28 -0
- package/lib/wai-aria/checkings/permitted-roles.d.ts +3 -0
- package/lib/wai-aria/checkings/permitted-roles.js +28 -0
- package/lib/wai-aria/checkings/presentational-children.d.ts +29 -0
- package/lib/wai-aria/checkings/presentational-children.js +60 -0
- package/lib/wai-aria/checkings/required-owned-elements.d.ts +11 -0
- package/lib/wai-aria/checkings/required-owned-elements.js +63 -0
- package/lib/wai-aria/checkings/required-prop.d.ts +9 -0
- package/lib/wai-aria/checkings/required-prop.js +27 -0
- package/lib/wai-aria/checkings/value.d.ts +7 -0
- package/lib/wai-aria/checkings/value.js +21 -0
- package/lib/wai-aria/index.d.ts +1 -8
- package/lib/wai-aria/index.js +66 -207
- package/lib/wai-aria/types.d.ts +13 -0
- package/lib/wai-aria/types.js +2 -0
- package/package.json +8 -7
- package/schema.json +0 -12
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/attr-equal-space-after/index.d.ts +0 -3
- package/lib/attr-equal-space-after/index.js +0 -90
- package/lib/attr-equal-space-before/index.d.ts +0 -3
- package/lib/attr-equal-space-before/index.js +0 -90
- package/lib/attr-spacing/index.d.ts +0 -6
- package/lib/attr-spacing/index.js +0 -100
- package/lib/indentation/index.d.ts +0 -7
- package/lib/indentation/index.js +0 -208
- package/lib/permitted-contents/array.combination.d.ts +0 -1
- package/lib/permitted-contents/array.combination.js +0 -33
- package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +0 -11
- package/lib/permitted-contents/permitted-content.spec-to-regexp.js +0 -225
- package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +0 -2
- package/lib/permitted-contents/unfold-content-models-to-tags.js +0 -8
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
const alwaysMsg = 'Always insert {0} before {1} of {2}';
|
|
5
|
-
const neverMsg = 'Never insert {0} before {1} of {2}';
|
|
6
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
7
|
-
defaultServerity: 'warning',
|
|
8
|
-
defaultValue: 'never',
|
|
9
|
-
async verify(context) {
|
|
10
|
-
await context.document.walkOn('Element', node => {
|
|
11
|
-
for (const attr of node.attributes) {
|
|
12
|
-
if (attr.attrType === 'ps-attr' || !(attr.equal && attr.spacesAfterEqual && attr.spacesBeforeEqual)) {
|
|
13
|
-
continue;
|
|
14
|
-
}
|
|
15
|
-
const hasSpace = !!attr.spacesBeforeEqual.raw;
|
|
16
|
-
const hasLineBreak = /\r?\n/.test(attr.spacesBeforeEqual.raw);
|
|
17
|
-
let isBad = false;
|
|
18
|
-
let rawMessage;
|
|
19
|
-
switch (node.rule.value) {
|
|
20
|
-
case 'always': {
|
|
21
|
-
isBad = !hasSpace;
|
|
22
|
-
rawMessage = alwaysMsg;
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
case 'never': {
|
|
26
|
-
isBad = hasSpace;
|
|
27
|
-
rawMessage = neverMsg;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case 'always-single-line': {
|
|
31
|
-
// or 'no-newline'
|
|
32
|
-
isBad = !hasSpace || hasLineBreak;
|
|
33
|
-
rawMessage = alwaysMsg;
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
36
|
-
case 'never-single-line': {
|
|
37
|
-
isBad = hasSpace && !hasLineBreak;
|
|
38
|
-
rawMessage = neverMsg;
|
|
39
|
-
break;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
if (isBad) {
|
|
43
|
-
context.report({
|
|
44
|
-
scope: node,
|
|
45
|
-
message: context.translate(rawMessage, 'space', 'equal sign', 'attribute'),
|
|
46
|
-
line: attr.spacesBeforeEqual.startLine,
|
|
47
|
-
col: attr.spacesBeforeEqual.startCol,
|
|
48
|
-
raw: attr.spacesBeforeEqual.raw + attr.equal.raw + attr.spacesAfterEqual.raw,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
async fix({ document }) {
|
|
55
|
-
await document.walkOn('Element', node => {
|
|
56
|
-
for (const attr of node.attributes) {
|
|
57
|
-
if (attr.attrType === 'ps-attr' || !(attr.equal && attr.spacesAfterEqual && attr.spacesBeforeEqual)) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const hasSpace = !!attr.spacesBeforeEqual.raw;
|
|
61
|
-
const hasLineBreak = /\r?\n/.test(attr.spacesBeforeEqual.raw);
|
|
62
|
-
switch (node.rule.value) {
|
|
63
|
-
case 'always': {
|
|
64
|
-
if (!hasSpace) {
|
|
65
|
-
attr.spacesBeforeEqual.fix(' ');
|
|
66
|
-
}
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
case 'never': {
|
|
70
|
-
attr.spacesBeforeEqual.fix('');
|
|
71
|
-
break;
|
|
72
|
-
}
|
|
73
|
-
case 'always-single-line': {
|
|
74
|
-
// or 'no-newline'
|
|
75
|
-
if (!hasSpace || hasLineBreak) {
|
|
76
|
-
attr.spacesBeforeEqual.fix(' ');
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case 'never-single-line': {
|
|
81
|
-
if (hasSpace && !hasLineBreak) {
|
|
82
|
-
attr.spacesBeforeEqual.fix('');
|
|
83
|
-
}
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
5
|
-
defaultServerity: 'warning',
|
|
6
|
-
defaultOptions: {
|
|
7
|
-
lineBreak: 'either',
|
|
8
|
-
width: 1,
|
|
9
|
-
},
|
|
10
|
-
async verify(context) {
|
|
11
|
-
await context.document.walkOn('Element', node => {
|
|
12
|
-
const attrs = node.attributes;
|
|
13
|
-
for (const attr of attrs) {
|
|
14
|
-
if (attr.attrType === 'ps-attr') {
|
|
15
|
-
continue;
|
|
16
|
-
}
|
|
17
|
-
const hasSpace = !!attr.spacesBeforeName.raw;
|
|
18
|
-
const hasLineBreak = /\r?\n/.test(attr.spacesBeforeName.raw);
|
|
19
|
-
// console.log({ attr: `${attr.spacesBeforeName.raw}${attr.raw}`, hasSpace, hasLineBreak });
|
|
20
|
-
if (!hasSpace) {
|
|
21
|
-
context.report({
|
|
22
|
-
scope: node,
|
|
23
|
-
message: context.translate('Required {0}', 'space'),
|
|
24
|
-
line: attr.spacesBeforeName.startLine,
|
|
25
|
-
col: attr.spacesBeforeName.startCol,
|
|
26
|
-
raw: attr.spacesBeforeName.raw,
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
if (hasLineBreak) {
|
|
31
|
-
if (node.rule.option.lineBreak === 'never') {
|
|
32
|
-
context.report({
|
|
33
|
-
scope: node,
|
|
34
|
-
message: context.translate('Never {0}', 'break line'),
|
|
35
|
-
line: attr.spacesBeforeName.startLine,
|
|
36
|
-
col: attr.spacesBeforeName.startCol,
|
|
37
|
-
raw: attr.spacesBeforeName.raw,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
if (node.rule.option.lineBreak === 'always') {
|
|
43
|
-
context.report({
|
|
44
|
-
scope: node,
|
|
45
|
-
message: context.translate('Insert {0}', 'line break'),
|
|
46
|
-
line: attr.spacesBeforeName.startLine,
|
|
47
|
-
col: attr.spacesBeforeName.startCol,
|
|
48
|
-
raw: attr.spacesBeforeName.raw,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
if (node.rule.option.width && node.rule.option.width !== attr.spacesBeforeName.raw.length) {
|
|
52
|
-
context.report({
|
|
53
|
-
scope: node,
|
|
54
|
-
message: context.translate('{0} should be {1}', 'Space', node.rule.option.width),
|
|
55
|
-
line: attr.spacesBeforeName.startLine,
|
|
56
|
-
col: attr.spacesBeforeName.startCol,
|
|
57
|
-
raw: attr.spacesBeforeName.raw,
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
},
|
|
65
|
-
async fix({ document }) {
|
|
66
|
-
await document.walkOn('Element', node => {
|
|
67
|
-
const attrs = node.attributes;
|
|
68
|
-
for (const attr of attrs) {
|
|
69
|
-
if (attr.attrType === 'ps-attr') {
|
|
70
|
-
continue;
|
|
71
|
-
}
|
|
72
|
-
const hasSpace = !!attr.spacesBeforeName.raw;
|
|
73
|
-
const hasLineBreak = /\r?\n/.test(attr.spacesBeforeName.raw);
|
|
74
|
-
const expectWidth = node.rule.option.width || 1;
|
|
75
|
-
const expectSpaces = ' '.repeat(expectWidth);
|
|
76
|
-
if (!hasSpace) {
|
|
77
|
-
attr.spacesBeforeName.fix(expectSpaces);
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
if (hasLineBreak) {
|
|
81
|
-
if (node.rule.option.lineBreak === 'never') {
|
|
82
|
-
attr.spacesBeforeName.fix(expectSpaces);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
if (node.rule.option.lineBreak === 'always') {
|
|
87
|
-
const indent = (0, ml_core_1.getIndent)(node);
|
|
88
|
-
const expectIndent = indent ? indent.raw : '';
|
|
89
|
-
attr.spacesBeforeName.fix(`\n${expectIndent}`);
|
|
90
|
-
}
|
|
91
|
-
else if (node.rule.option.width &&
|
|
92
|
-
node.rule.option.width !== attr.spacesBeforeName.raw.length) {
|
|
93
|
-
attr.spacesBeforeName.fix(expectSpaces);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare type Value = 'tab' | number;
|
|
2
|
-
export interface IndentationOptions {
|
|
3
|
-
alignment?: boolean;
|
|
4
|
-
'indent-nested-nodes'?: boolean | 'always' | 'never';
|
|
5
|
-
}
|
|
6
|
-
declare const _default: import("@markuplint/ml-core").RuleSeed<Value, IndentationOptions>;
|
|
7
|
-
export default _default;
|
package/lib/indentation/index.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const ml_core_1 = require("@markuplint/ml-core");
|
|
4
|
-
exports.default = (0, ml_core_1.createRule)({
|
|
5
|
-
defaultServerity: 'warning',
|
|
6
|
-
defaultValue: 2,
|
|
7
|
-
defaultOptions: {
|
|
8
|
-
alignment: true,
|
|
9
|
-
'indent-nested-nodes': true,
|
|
10
|
-
},
|
|
11
|
-
async verify(context) {
|
|
12
|
-
await context.document.walk(node => {
|
|
13
|
-
if (node.rule.disabled) {
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
const indent = (0, ml_core_1.getIndent)(node);
|
|
17
|
-
if (indent) {
|
|
18
|
-
/**
|
|
19
|
-
* Validate indent type and length.
|
|
20
|
-
*/
|
|
21
|
-
if (indent.type !== 'none') {
|
|
22
|
-
const ms = node.rule.severity === 'error' ? 'must' : 'should';
|
|
23
|
-
let spec = null;
|
|
24
|
-
if (node.rule.value === 'tab' && indent.type !== 'tab') {
|
|
25
|
-
spec = 'tab';
|
|
26
|
-
}
|
|
27
|
-
else if (typeof node.rule.value === 'number' && indent.type !== 'space') {
|
|
28
|
-
spec = 'space';
|
|
29
|
-
}
|
|
30
|
-
else if (typeof node.rule.value === 'number' &&
|
|
31
|
-
indent.type === 'space' &&
|
|
32
|
-
indent.width % node.rule.value) {
|
|
33
|
-
spec = context.translate('{0} width spaces', `${node.rule.value}`);
|
|
34
|
-
}
|
|
35
|
-
if (spec) {
|
|
36
|
-
const message = context.translate(`{0} ${ms} be {1}`, 'Indentation', spec);
|
|
37
|
-
context.report({
|
|
38
|
-
scope: node,
|
|
39
|
-
message,
|
|
40
|
-
line: indent.line,
|
|
41
|
-
col: 1,
|
|
42
|
-
raw: indent.raw,
|
|
43
|
-
});
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Validate nested parent-children nodes.
|
|
49
|
-
*/
|
|
50
|
-
const nested = node.rule.option['indent-nested-nodes'];
|
|
51
|
-
if (!nested) {
|
|
52
|
-
return;
|
|
53
|
-
}
|
|
54
|
-
const parent = node.syntaxicalParentNode;
|
|
55
|
-
if (parent) {
|
|
56
|
-
const parentIndent = (0, ml_core_1.getIndent)(parent);
|
|
57
|
-
const parentIndentWidth = parentIndent ? parentIndent.width : 0;
|
|
58
|
-
const childIndentWidth = indent.width;
|
|
59
|
-
const expectedWidth = node.rule.value === 'tab' ? 1 : node.rule.value;
|
|
60
|
-
const diff = childIndentWidth - parentIndentWidth;
|
|
61
|
-
if (nested === 'never') {
|
|
62
|
-
if (diff !== 0) {
|
|
63
|
-
const message = context.translate(diff < 1 ? 'Should increase indentation' : 'Should decrease indentation');
|
|
64
|
-
context.report({
|
|
65
|
-
scope: node,
|
|
66
|
-
message,
|
|
67
|
-
line: indent.line,
|
|
68
|
-
col: 1,
|
|
69
|
-
raw: indent.raw,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
if (diff !== expectedWidth) {
|
|
75
|
-
const message = context.translate(diff < 1 ? 'Should increase indentation' : 'Should decrease indentation');
|
|
76
|
-
context.report({
|
|
77
|
-
scope: node,
|
|
78
|
-
message,
|
|
79
|
-
line: indent.line,
|
|
80
|
-
col: 1,
|
|
81
|
-
raw: indent.raw,
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Validate alignment end-tags.
|
|
89
|
-
*/
|
|
90
|
-
if (node instanceof ml_core_1.ElementCloseTag) {
|
|
91
|
-
const closeTag = node;
|
|
92
|
-
const startTag = closeTag.startTag;
|
|
93
|
-
if (!closeTag.rule.option.alignment) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
const closeTagIndent = (0, ml_core_1.getIndent)(closeTag);
|
|
97
|
-
if (!closeTagIndent) {
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (startTag.endLine === closeTag.endLine) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
const startTagIndent = (0, ml_core_1.getIndent)(startTag);
|
|
104
|
-
const endTagIndentationWidth = closeTagIndent ? closeTagIndent.width : 0;
|
|
105
|
-
const startTagIndentationWidth = startTagIndent ? startTagIndent.width : 0;
|
|
106
|
-
if (startTagIndentationWidth !== endTagIndentationWidth) {
|
|
107
|
-
const message = context.translate('Start tag and end tag indentation should align');
|
|
108
|
-
context.report({
|
|
109
|
-
scope: closeTag,
|
|
110
|
-
message,
|
|
111
|
-
line: closeTagIndent ? closeTagIndent.line : closeTag.startLine,
|
|
112
|
-
col: 1,
|
|
113
|
-
raw: closeTagIndent ? closeTagIndent.raw : '',
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
async fix({ document }) {
|
|
120
|
-
/**
|
|
121
|
-
* Validate indent type and length.
|
|
122
|
-
*/
|
|
123
|
-
await document.walk(node => {
|
|
124
|
-
const indent = (0, ml_core_1.getIndent)(node);
|
|
125
|
-
if (!node.rule.disabled && indent) {
|
|
126
|
-
if (indent.type !== 'none') {
|
|
127
|
-
const spec = node.rule.value === 'tab' ? '\t' : ' ';
|
|
128
|
-
const baseWidth = node.rule.value === 'tab' ? 4 : node.rule.value;
|
|
129
|
-
let width;
|
|
130
|
-
if (node.rule.value === 'tab') {
|
|
131
|
-
width = indent.type === 'tab' ? indent.width : Math.ceil(indent.width / baseWidth);
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
width =
|
|
135
|
-
indent.type === 'tab'
|
|
136
|
-
? indent.width * baseWidth
|
|
137
|
-
: Math.ceil(indent.width / baseWidth) * baseWidth;
|
|
138
|
-
}
|
|
139
|
-
const raw = indent.raw;
|
|
140
|
-
const fixed = spec.repeat(width);
|
|
141
|
-
if (raw !== fixed) {
|
|
142
|
-
indent.fix(fixed);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
await document.walk(node => {
|
|
148
|
-
if (node.rule.disabled) {
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
const indent = (0, ml_core_1.getIndent)(node);
|
|
152
|
-
if (indent) {
|
|
153
|
-
/**
|
|
154
|
-
* Validate nested parent-children nodes.
|
|
155
|
-
*/
|
|
156
|
-
const nested = node.rule.option['indent-nested-nodes'];
|
|
157
|
-
if (!nested) {
|
|
158
|
-
return;
|
|
159
|
-
}
|
|
160
|
-
const parent = node.syntaxicalParentNode;
|
|
161
|
-
if (!parent) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
const parentIndent = (0, ml_core_1.getIndent)(parent);
|
|
165
|
-
if (!parentIndent) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
const parentIndentWidth = parentIndent.width;
|
|
169
|
-
const childIndentWidth = indent.width;
|
|
170
|
-
const expectedWidth = node.rule.value === 'tab' ? 1 : node.rule.value;
|
|
171
|
-
const diff = childIndentWidth - parentIndentWidth;
|
|
172
|
-
if (nested === 'never') {
|
|
173
|
-
if (diff !== 0) {
|
|
174
|
-
const fixed = parentIndent.raw;
|
|
175
|
-
indent.fix(fixed);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
if (diff !== expectedWidth) {
|
|
180
|
-
const fixed = (node.rule.value === 'tab' ? '\t' : ' ').repeat(parentIndentWidth + expectedWidth);
|
|
181
|
-
indent.fix(fixed);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
/**
|
|
187
|
-
* Validate alignment end-tags.
|
|
188
|
-
*/
|
|
189
|
-
await document.walkOn('ElementCloseTag', endTag => {
|
|
190
|
-
if (!endTag.rule || !endTag.rule.option) {
|
|
191
|
-
return;
|
|
192
|
-
}
|
|
193
|
-
if (!endTag.rule.option.alignment) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
const endTagIndent = (0, ml_core_1.getIndent)(endTag);
|
|
197
|
-
const startTagIndent = (0, ml_core_1.getIndent)(endTag.startTag);
|
|
198
|
-
if (endTagIndent && startTagIndent) {
|
|
199
|
-
const endTagIndentationWidth = endTagIndent.width;
|
|
200
|
-
const startTagIndentationWidth = startTagIndent.width;
|
|
201
|
-
if (startTagIndentationWidth !== endTagIndentationWidth) {
|
|
202
|
-
const fixed = startTagIndent.raw;
|
|
203
|
-
endTagIndent.fix(fixed);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
});
|
|
207
|
-
},
|
|
208
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function combination<T>(array: T[]): T[][];
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function combination(array) {
|
|
4
|
-
// Unique
|
|
5
|
-
array = Array.from(new Set(array));
|
|
6
|
-
if (array.length <= 1) {
|
|
7
|
-
return [array];
|
|
8
|
-
}
|
|
9
|
-
// Sort
|
|
10
|
-
array.sort();
|
|
11
|
-
// Combination
|
|
12
|
-
const combinated = [];
|
|
13
|
-
for (const i1 of array) {
|
|
14
|
-
for (const i2 of array) {
|
|
15
|
-
for (const i3 of array) {
|
|
16
|
-
for (const i4 of array) {
|
|
17
|
-
for (const i5 of array) {
|
|
18
|
-
const item = Array.from(new Set([i1, i2, i3, i4, i5]));
|
|
19
|
-
if (item.length === array.length) {
|
|
20
|
-
const itemA = JSON.stringify(item);
|
|
21
|
-
if (!combinated.includes(itemA)) {
|
|
22
|
-
combinated.push(itemA);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const result = combinated.map(i => JSON.parse(i));
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
exports.default = combination;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { PermittedContent } from '@markuplint/ml-spec';
|
|
2
|
-
export default class ExpGenerator {
|
|
3
|
-
private _id;
|
|
4
|
-
private _idCounter;
|
|
5
|
-
constructor(_id: number);
|
|
6
|
-
specToRegExp(contentRule: PermittedContent[] | boolean, parentExp?: RegExp | null, ownNS?: string | null): RegExp;
|
|
7
|
-
private _toPattern;
|
|
8
|
-
private _interleavePattern;
|
|
9
|
-
private _targetTags;
|
|
10
|
-
private _resolveTags;
|
|
11
|
-
}
|