markuplint 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/LICENSE +1 -1
- package/README.md +4 -2
- package/bin/markuplint.mjs +3 -0
- package/lib/api/index.d.ts +2 -2
- package/lib/api/index.js +2 -10
- package/lib/api/lint.d.ts +2 -2
- package/lib/api/lint.js +5 -10
- package/lib/api/ml-engine.d.ts +28 -23
- package/lib/api/ml-engine.js +123 -103
- package/lib/api/types.d.ts +32 -32
- package/lib/api/types.js +1 -2
- package/lib/api/v1.d.ts +43 -43
- package/lib/api/v1.js +12 -20
- package/lib/cli/bootstrap.d.ts +65 -63
- package/lib/cli/bootstrap.js +12 -11
- package/lib/cli/command.d.ts +3 -7
- package/lib/cli/command.js +26 -34
- package/lib/cli/index.js +59 -71
- package/lib/cli/init/create-config.d.ts +2 -6
- package/lib/cli/init/create-config.js +14 -12
- package/lib/cli/init/get-default-rules.d.ts +3 -3
- package/lib/cli/init/get-default-rules.js +12 -53
- package/lib/cli/init/index.js +28 -37
- package/lib/cli/init/select-modules.d.ts +2 -0
- package/lib/cli/init/select-modules.js +10 -0
- package/lib/cli/init/types.d.ts +4 -15
- package/lib/cli/init/types.js +1 -2
- package/lib/cli/output.d.ts +2 -2
- package/lib/cli/output.js +8 -14
- package/lib/cli/search/index.d.ts +2 -2
- package/lib/cli/search/index.js +10 -14
- package/lib/debug.js +9 -13
- package/lib/get-json-module.d.ts +1 -0
- package/lib/get-json-module.js +10 -0
- package/lib/global-settings.d.ts +1 -1
- package/lib/global-settings.js +2 -7
- package/lib/i18n.js +8 -15
- package/lib/index.d.ts +7 -5
- package/lib/index.js +6 -10
- package/lib/reporter/github-reporter.d.ts +1 -1
- package/lib/reporter/github-reporter.js +7 -9
- package/lib/reporter/index.d.ts +3 -3
- package/lib/reporter/index.js +3 -6
- package/lib/reporter/simple-reporter.d.ts +2 -2
- package/lib/reporter/simple-reporter.js +11 -16
- package/lib/reporter/standard-reporter.d.ts +2 -2
- package/lib/reporter/standard-reporter.js +37 -28
- package/lib/testing-tool/index.d.ts +23 -41
- package/lib/testing-tool/index.js +41 -47
- package/lib/types.d.ts +17 -17
- package/lib/types.js +1 -2
- package/lib/v1.d.ts +1 -1
- package/lib/v1.js +1 -5
- package/lib/version.d.ts +1 -0
- package/lib/version.js +3 -0
- package/package.json +26 -34
- package/bin/markuplint +0 -3
- package/lib/cli/create-rule/index.d.ts +0 -1
- package/lib/cli/create-rule/index.js +0 -85
- package/lib/cli/init/install-module.d.ts +0 -7
- package/lib/cli/init/install-module.js +0 -80
- package/lib/cli/prompt.d.ts +0 -23
- package/lib/cli/prompt.js +0 -77
- package/lib/util.d.ts +0 -17
- package/lib/util.js +0 -88
package/lib/api/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/api/v1.d.ts
CHANGED
|
@@ -6,46 +6,46 @@ import type { MLRule } from '@markuplint/ml-core';
|
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
8
|
export declare function lint_v1(options: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}): Promise<import(
|
|
9
|
+
/**
|
|
10
|
+
* Glob pattern
|
|
11
|
+
*/
|
|
12
|
+
readonly files?: string | readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* Target source code of evaluation
|
|
15
|
+
*/
|
|
16
|
+
readonly sourceCodes?: string | readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* File names when `sourceCodes`
|
|
19
|
+
*/
|
|
20
|
+
readonly names?: string | readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* Workspace path when `sourceCodes`
|
|
23
|
+
*/
|
|
24
|
+
readonly workspace?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Configure file or object
|
|
27
|
+
*/
|
|
28
|
+
readonly config?: string | Config;
|
|
29
|
+
/**
|
|
30
|
+
* The config applied when not resolved from files or set it explicitly.
|
|
31
|
+
*/
|
|
32
|
+
readonly defaultConfig?: Config;
|
|
33
|
+
/**
|
|
34
|
+
* Rules (default: `@markuplint/rules`)
|
|
35
|
+
*/
|
|
36
|
+
readonly rules?: readonly Readonly<MLRule<RuleConfigValue, PlainData>>[];
|
|
37
|
+
/**
|
|
38
|
+
* Auto resolve rules
|
|
39
|
+
*
|
|
40
|
+
* Auto importing form *node_modules* when set `@markuplint/rule-{RULE_NAME}` or `markuplint-rule-{RULE_NAME}` in config rules
|
|
41
|
+
*/
|
|
42
|
+
readonly rulesAutoResolve?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Auto fix
|
|
45
|
+
*/
|
|
46
|
+
readonly fix?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Locale
|
|
49
|
+
*/
|
|
50
|
+
readonly locale?: string;
|
|
51
|
+
}): Promise<import("../types.js").MLResultInfo[]>;
|
package/lib/api/v1.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.lint_v1 = void 0;
|
|
4
|
-
const shared_1 = require("@markuplint/shared");
|
|
5
|
-
const lint_1 = require("./lint");
|
|
1
|
+
import { toNoEmptyStringArrayFromStringOrArray } from '@markuplint/shared';
|
|
2
|
+
import { lint } from './lint.js';
|
|
6
3
|
/**
|
|
7
4
|
* @deprecated
|
|
8
5
|
* @param options
|
|
9
6
|
* @returns
|
|
10
7
|
*/
|
|
11
|
-
async function lint_v1(options) {
|
|
12
|
-
|
|
13
|
-
const
|
|
14
|
-
const codes = (0, shared_1.toNoEmptyStringArrayFromStringOrArray)(options.sourceCodes);
|
|
8
|
+
export async function lint_v1(options) {
|
|
9
|
+
const filePathList = toNoEmptyStringArrayFromStringOrArray(options.files);
|
|
10
|
+
const codes = toNoEmptyStringArrayFromStringOrArray(options.sourceCodes);
|
|
15
11
|
const files = [
|
|
16
12
|
...filePathList,
|
|
17
|
-
...codes.map((code, i) => {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
workspace: (_b = options.workspace) === null || _b === void 0 ? void 0 : _b[i],
|
|
23
|
-
});
|
|
24
|
-
}),
|
|
13
|
+
...codes.map((code, i) => ({
|
|
14
|
+
sourceCode: code,
|
|
15
|
+
name: Array.isArray(options.names) ? options.names?.[i] : options.names,
|
|
16
|
+
workspace: options.workspace?.[i],
|
|
17
|
+
})),
|
|
25
18
|
];
|
|
26
19
|
let config;
|
|
27
20
|
let configFile;
|
|
@@ -31,14 +24,13 @@ async function lint_v1(options) {
|
|
|
31
24
|
else if (options.config) {
|
|
32
25
|
config = options.config;
|
|
33
26
|
}
|
|
34
|
-
const result = await
|
|
27
|
+
const result = await lint(files, {
|
|
35
28
|
config,
|
|
36
29
|
configFile,
|
|
37
30
|
noSearchConfig: filePathList.length === 0,
|
|
38
31
|
rules: options.rules,
|
|
39
|
-
autoLoad:
|
|
32
|
+
autoLoad: options.rulesAutoResolve ?? true,
|
|
40
33
|
locale: options.locale,
|
|
41
34
|
});
|
|
42
35
|
return result;
|
|
43
36
|
}
|
|
44
|
-
exports.lint_v1 = lint_v1;
|
package/lib/cli/bootstrap.d.ts
CHANGED
|
@@ -1,66 +1,68 @@
|
|
|
1
1
|
import type { ReadonlyDeep } from 'type-fest';
|
|
2
|
-
import
|
|
3
|
-
export declare const
|
|
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
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
2
|
+
export declare const help = "\nUsage\n\t$ markuplint <HTML file paths (glob format)>\n\t$ <stdout> | markuplint\n\nOptions\n\t--config, -c FILE_PATH A configuration file path.\n\t--fix, Fix HTML.\n\t--format, -f FORMAT Output format. Support \"JSON\", \"Simple\", \"GitHub\" and \"Standard\". Default: \"Standard\".\n\t--no-search-config No search a configure file automatically.\n\t--ignore-ext Evaluate files that are received even though the type of extension.\n\t--no-import-preset-rules No import preset rules.\n\t--locale Locale of the message of violation. Default is an OS setting.\n\t--no-color, Output no color.\n\t--problem-only, -p Output only problems, without passeds.\n\t--allow-warnings Return status code 0 even if there are warnings.\n\t--allow-empty-input Return status code 1 even if there are no input files.\n\t--verbose Output with detailed information.\n\t--include-node-modules Include files in node_modules directory. Default: false.\n\n\t--init Initialize settings interactively.\n\t--search Search lines of codes that include the target element by selectors.\n\n\t--help, -h Show help.\n\t--version, -v Show version.\n\nExamples\n\t$ markuplint verifyee.html --config path/to/.markuplintrc\n\t$ cat verifyee.html | markuplint\n";
|
|
3
|
+
export declare const cli: import("meow").Result<{
|
|
4
|
+
config: {
|
|
5
|
+
type: "string";
|
|
6
|
+
shortFlag: string;
|
|
7
|
+
};
|
|
8
|
+
fix: {
|
|
9
|
+
type: "boolean";
|
|
10
|
+
default: false;
|
|
11
|
+
};
|
|
12
|
+
format: {
|
|
13
|
+
type: "string";
|
|
14
|
+
shortFlag: string;
|
|
15
|
+
};
|
|
16
|
+
searchConfig: {
|
|
17
|
+
type: "boolean";
|
|
18
|
+
default: true;
|
|
19
|
+
};
|
|
20
|
+
ignoreExt: {
|
|
21
|
+
type: "boolean";
|
|
22
|
+
default: false;
|
|
23
|
+
};
|
|
24
|
+
importPresetRules: {
|
|
25
|
+
type: "boolean";
|
|
26
|
+
default: true;
|
|
27
|
+
};
|
|
28
|
+
locale: {
|
|
29
|
+
type: "string";
|
|
30
|
+
};
|
|
31
|
+
color: {
|
|
32
|
+
type: "boolean";
|
|
33
|
+
default: true;
|
|
34
|
+
};
|
|
35
|
+
problemOnly: {
|
|
36
|
+
type: "boolean";
|
|
37
|
+
shortFlag: string;
|
|
38
|
+
default: false;
|
|
39
|
+
};
|
|
40
|
+
allowWarnings: {
|
|
41
|
+
type: "boolean";
|
|
42
|
+
default: false;
|
|
43
|
+
};
|
|
44
|
+
allowEmptyInput: {
|
|
45
|
+
type: "boolean";
|
|
46
|
+
default: true;
|
|
47
|
+
};
|
|
48
|
+
verbose: {
|
|
49
|
+
type: "boolean";
|
|
50
|
+
default: false;
|
|
51
|
+
};
|
|
52
|
+
init: {
|
|
53
|
+
type: "boolean";
|
|
54
|
+
default: false;
|
|
55
|
+
};
|
|
56
|
+
createRule: {
|
|
57
|
+
type: "boolean";
|
|
58
|
+
default: false;
|
|
59
|
+
};
|
|
60
|
+
search: {
|
|
61
|
+
type: "string";
|
|
62
|
+
};
|
|
63
|
+
includeNodeModules: {
|
|
64
|
+
type: "boolean";
|
|
65
|
+
default: false;
|
|
66
|
+
};
|
|
65
67
|
}>;
|
|
66
68
|
export type CLIOptions = ReadonlyDeep<typeof cli.flags>;
|
package/lib/cli/bootstrap.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.cli = exports.help = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const meow_1 = tslib_1.__importDefault(require("meow"));
|
|
6
|
-
exports.help = `
|
|
1
|
+
import meow from 'meow';
|
|
2
|
+
export const help = `
|
|
7
3
|
Usage
|
|
8
4
|
$ markuplint <HTML file paths (glob format)>
|
|
9
5
|
$ <stdout> | markuplint
|
|
@@ -21,9 +17,9 @@ Options
|
|
|
21
17
|
--allow-warnings Return status code 0 even if there are warnings.
|
|
22
18
|
--allow-empty-input Return status code 1 even if there are no input files.
|
|
23
19
|
--verbose Output with detailed information.
|
|
20
|
+
--include-node-modules Include files in node_modules directory. Default: false.
|
|
24
21
|
|
|
25
22
|
--init Initialize settings interactively.
|
|
26
|
-
--create-rule Add the scaffold of a custom rule.
|
|
27
23
|
--search Search lines of codes that include the target element by selectors.
|
|
28
24
|
|
|
29
25
|
--help, -h Show help.
|
|
@@ -33,11 +29,12 @@ Examples
|
|
|
33
29
|
$ markuplint verifyee.html --config path/to/.markuplintrc
|
|
34
30
|
$ cat verifyee.html | markuplint
|
|
35
31
|
`;
|
|
36
|
-
|
|
32
|
+
export const cli = meow(help, {
|
|
33
|
+
importMeta: import.meta,
|
|
37
34
|
flags: {
|
|
38
35
|
config: {
|
|
39
36
|
type: 'string',
|
|
40
|
-
|
|
37
|
+
shortFlag: 'c',
|
|
41
38
|
},
|
|
42
39
|
fix: {
|
|
43
40
|
type: 'boolean',
|
|
@@ -45,7 +42,7 @@ exports.cli = (0, meow_1.default)(exports.help, {
|
|
|
45
42
|
},
|
|
46
43
|
format: {
|
|
47
44
|
type: 'string',
|
|
48
|
-
|
|
45
|
+
shortFlag: 'f',
|
|
49
46
|
},
|
|
50
47
|
searchConfig: {
|
|
51
48
|
type: 'boolean',
|
|
@@ -68,7 +65,7 @@ exports.cli = (0, meow_1.default)(exports.help, {
|
|
|
68
65
|
},
|
|
69
66
|
problemOnly: {
|
|
70
67
|
type: 'boolean',
|
|
71
|
-
|
|
68
|
+
shortFlag: 'p',
|
|
72
69
|
default: false,
|
|
73
70
|
},
|
|
74
71
|
allowWarnings: {
|
|
@@ -95,5 +92,9 @@ exports.cli = (0, meow_1.default)(exports.help, {
|
|
|
95
92
|
search: {
|
|
96
93
|
type: 'string',
|
|
97
94
|
},
|
|
95
|
+
includeNodeModules: {
|
|
96
|
+
type: 'boolean',
|
|
97
|
+
default: false,
|
|
98
|
+
},
|
|
98
99
|
},
|
|
99
100
|
});
|
package/lib/cli/command.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { CLIOptions } from './bootstrap';
|
|
2
|
-
import type { APIOptions } from '../api/types';
|
|
1
|
+
import type { CLIOptions } from './bootstrap.js';
|
|
2
|
+
import type { APIOptions } from '../api/types.js';
|
|
3
3
|
import type { Target } from '@markuplint/file-resolver';
|
|
4
|
-
export declare function command(
|
|
5
|
-
files: readonly Readonly<Target>[],
|
|
6
|
-
options: CLIOptions,
|
|
7
|
-
apiOptions?: APIOptions,
|
|
8
|
-
): Promise<boolean>;
|
|
4
|
+
export declare function command(files: readonly Readonly<Target>[], options: CLIOptions, apiOptions?: APIOptions): Promise<boolean>;
|
package/lib/cli/command.js
CHANGED
|
@@ -1,38 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const api_1 = require("../api");
|
|
9
|
-
const debug_1 = require("../debug");
|
|
10
|
-
const output_1 = require("./output");
|
|
11
|
-
async function command(files, options, apiOptions) {
|
|
12
|
-
var _a;
|
|
1
|
+
import { promises as fs } from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { resolveFiles } from '@markuplint/file-resolver';
|
|
4
|
+
import { MLEngine } from '../api/index.js';
|
|
5
|
+
import { log } from '../debug.js';
|
|
6
|
+
import { output } from './output.js';
|
|
7
|
+
export async function command(files, options, apiOptions) {
|
|
13
8
|
const fix = options.fix;
|
|
14
|
-
const configFile = options.config &&
|
|
9
|
+
const configFile = options.config && path.join(process.cwd(), options.config);
|
|
15
10
|
const locale = options.locale;
|
|
16
11
|
const searchConfig = options.searchConfig;
|
|
17
12
|
const ignoreExt = options.ignoreExt;
|
|
18
13
|
const importPresetRules = options.importPresetRules;
|
|
19
14
|
const verbose = options.verbose;
|
|
20
|
-
const
|
|
15
|
+
const ignoreGlob = options.includeNodeModules ? undefined : 'node_modules/**';
|
|
16
|
+
const fileList = await resolveFiles(files, ignoreGlob);
|
|
21
17
|
if (fileList.length === 0 && !options.allowEmptyInput) {
|
|
22
18
|
process.stderr.write('Markuplint: No target files.\n');
|
|
23
19
|
// Error
|
|
24
20
|
return true;
|
|
25
21
|
}
|
|
26
|
-
if (
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
22
|
+
if (log.enabled) {
|
|
23
|
+
log('File list: %O', fileList.map(f => f.path));
|
|
24
|
+
log('Config: %s', configFile ?? 'N/A');
|
|
25
|
+
log('Fix option: %s', fix);
|
|
30
26
|
}
|
|
31
|
-
const format =
|
|
27
|
+
const format = options.format?.toLowerCase().trim();
|
|
32
28
|
let hasError = false;
|
|
33
29
|
const jsonOutput = [];
|
|
34
30
|
for (const file of fileList) {
|
|
35
|
-
const engine = new
|
|
31
|
+
const engine = new MLEngine(file, {
|
|
36
32
|
configFile,
|
|
37
33
|
fix,
|
|
38
34
|
locale,
|
|
@@ -52,21 +48,18 @@ async function command(files, options, apiOptions) {
|
|
|
52
48
|
hasError = true;
|
|
53
49
|
}
|
|
54
50
|
if (fix) {
|
|
55
|
-
|
|
56
|
-
await
|
|
57
|
-
process.stdout.write(`markuplint: Fix "${result.filePath}"\n`);
|
|
51
|
+
log('Overwrite file: %s', result.filePath);
|
|
52
|
+
await fs.writeFile(result.filePath, result.fixedCode, { encoding: 'utf8' });
|
|
58
53
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
(0, debug_1.log)('Output reports');
|
|
68
|
-
(0, output_1.output)(result, options);
|
|
54
|
+
if (format === 'json') {
|
|
55
|
+
jsonOutput.push(...result.violations.map(v => ({
|
|
56
|
+
...v,
|
|
57
|
+
filePath: result.filePath,
|
|
58
|
+
})));
|
|
59
|
+
continue;
|
|
69
60
|
}
|
|
61
|
+
log('Output reports');
|
|
62
|
+
output(result, options);
|
|
70
63
|
}
|
|
71
64
|
if (format === 'json') {
|
|
72
65
|
process.stdout.write(JSON.stringify(jsonOutput, null, 2) + '\n');
|
|
@@ -74,4 +67,3 @@ async function command(files, options, apiOptions) {
|
|
|
74
67
|
}
|
|
75
68
|
return hasError;
|
|
76
69
|
}
|
|
77
|
-
exports.command = command;
|
package/lib/cli/index.js
CHANGED
|
@@ -1,78 +1,66 @@
|
|
|
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
|
-
process.
|
|
33
|
-
});
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
const files = bootstrap_1.cli.input;
|
|
37
|
-
if (files.length > 0) {
|
|
38
|
-
if (bootstrap_1.cli.flags.search) {
|
|
39
|
-
await (0, search_1.default)(files, bootstrap_1.cli.flags, bootstrap_1.cli.flags.search).catch(err => {
|
|
40
|
-
process.stderr.write(err + '\n');
|
|
41
|
-
process.exit(1);
|
|
42
|
-
});
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
const hasError = await (0, command_1.command)(files, bootstrap_1.cli.flags).catch(err => {
|
|
46
|
-
throw err;
|
|
47
|
-
});
|
|
48
|
-
process.exit(hasError ? 1 : 0);
|
|
49
|
-
}
|
|
50
|
-
if (usePipe()) {
|
|
51
|
-
(0, get_stdin_1.default)()
|
|
52
|
-
.then(async (stdin) => {
|
|
53
|
-
if (stdin) {
|
|
54
|
-
const hasError = await (0, command_1.command)([{ sourceCode: stdin }], {
|
|
55
|
-
...bootstrap_1.cli.flags,
|
|
56
|
-
ignoreExt: true,
|
|
57
|
-
}).catch(err => {
|
|
58
|
-
process.stderr.write(err + '\n');
|
|
59
|
-
process.exit(1);
|
|
60
|
-
});
|
|
61
|
-
process.exit(hasError ? 1 : 0);
|
|
62
|
-
}
|
|
63
|
-
// result is empty
|
|
64
|
-
bootstrap_1.cli.showHelp(1);
|
|
65
|
-
})
|
|
66
|
-
.catch(reason => {
|
|
67
|
-
// eslint-disable-next-line no-console
|
|
68
|
-
console.warn(reason);
|
|
1
|
+
import getStdin from 'get-stdin';
|
|
2
|
+
import { verbosely } from '../debug.js';
|
|
3
|
+
import { cli } from './bootstrap.js';
|
|
4
|
+
import { command } from './command.js';
|
|
5
|
+
import { initialize } from './init/index.js';
|
|
6
|
+
import { search } from './search/index.js';
|
|
7
|
+
/* eslint-disable unicorn/no-process-exit */
|
|
8
|
+
if (cli.flags.v) {
|
|
9
|
+
cli.showVersion(); // And exit successfully.
|
|
10
|
+
}
|
|
11
|
+
if (cli.flags.h) {
|
|
12
|
+
cli.showHelp(0); // And exit successfully.
|
|
13
|
+
}
|
|
14
|
+
if (cli.flags.verbose) {
|
|
15
|
+
verbosely();
|
|
16
|
+
}
|
|
17
|
+
if (cli.flags.init) {
|
|
18
|
+
await initialize().catch(error => {
|
|
19
|
+
process.stderr.write(error + '\n');
|
|
20
|
+
process.exit(1);
|
|
21
|
+
});
|
|
22
|
+
process.exit(0);
|
|
23
|
+
}
|
|
24
|
+
if (cli.flags.createRule) {
|
|
25
|
+
process.stderr.write("Use to run 'npx @markuplint/create-rule' instead of 'markuplint --create-rule'.\n");
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
const files = cli.input;
|
|
29
|
+
if (files.length > 0) {
|
|
30
|
+
if (cli.flags.search) {
|
|
31
|
+
await search(files, cli.flags, cli.flags.search).catch(error => {
|
|
32
|
+
process.stderr.write(error + '\n');
|
|
69
33
|
process.exit(1);
|
|
70
34
|
});
|
|
35
|
+
process.exit(0);
|
|
71
36
|
}
|
|
72
|
-
|
|
73
|
-
|
|
37
|
+
const hasError = await command(files, cli.flags).catch(error => {
|
|
38
|
+
throw error;
|
|
39
|
+
});
|
|
40
|
+
process.exit(hasError ? 1 : 0);
|
|
41
|
+
}
|
|
42
|
+
if (usePipe()) {
|
|
43
|
+
const stdin = await getStdin().catch(error => {
|
|
44
|
+
// eslint-disable-next-line no-console
|
|
45
|
+
console.warn(error);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
if (!stdin) {
|
|
49
|
+
// result is empty
|
|
50
|
+
cli.showHelp(1);
|
|
74
51
|
}
|
|
75
|
-
}
|
|
52
|
+
const hasError = await command([{ sourceCode: stdin }], {
|
|
53
|
+
...cli.flags,
|
|
54
|
+
ignoreExt: true,
|
|
55
|
+
}).catch(error => {
|
|
56
|
+
process.stderr.write(error + '\n');
|
|
57
|
+
process.exit(1);
|
|
58
|
+
});
|
|
59
|
+
process.exit(hasError ? 1 : 0);
|
|
60
|
+
}
|
|
61
|
+
// No arguments
|
|
62
|
+
cli.showHelp(1);
|
|
63
|
+
/* eslint-enable unicorn/no-process-exit */
|
|
76
64
|
function usePipe() {
|
|
77
65
|
return !process.stdin.isTTY && process.stdout.isTTY;
|
|
78
66
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { DefaultRules, Langs, RuleSettingMode } from './types';
|
|
1
|
+
import type { DefaultRules, Langs, RuleSettingMode } from './types.js';
|
|
2
2
|
import type { Config } from '@markuplint/ml-config';
|
|
3
3
|
export declare const langs: Record<Langs, string>;
|
|
4
|
-
export declare function createConfig(
|
|
5
|
-
langs: readonly Langs[],
|
|
6
|
-
mode: RuleSettingMode,
|
|
7
|
-
defaultRules: DefaultRules,
|
|
8
|
-
): Config;
|
|
4
|
+
export declare function createConfig(langs: readonly Langs[], mode: RuleSettingMode, defaultRules: DefaultRules): Config;
|