markuplint 2.0.0-rc.3 → 2.1.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.
Files changed (71) hide show
  1. package/README.md +87 -30
  2. package/lib/api/index.d.mts +2 -0
  3. package/lib/api/index.mjs +2 -0
  4. package/lib/api/lint.d.mts +4 -0
  5. package/lib/api/lint.mjs +15 -0
  6. package/lib/api/ml-engine.d.mts +27 -0
  7. package/lib/api/ml-engine.js +7 -3
  8. package/lib/api/ml-engine.mjs +232 -0
  9. package/lib/api/types.d.mts +43 -0
  10. package/lib/api/types.d.ts +1 -1
  11. package/lib/api/types.mjs +1 -0
  12. package/lib/api/v1.d.mts +51 -0
  13. package/lib/api/v1.d.ts +0 -9
  14. package/lib/api/v1.js +0 -1
  15. package/lib/api/v1.mjs +39 -0
  16. package/lib/cli/bootstrap.d.mts +52 -0
  17. package/lib/cli/bootstrap.d.ts +24 -9
  18. package/lib/cli/bootstrap.js +39 -20
  19. package/lib/cli/bootstrap.mjs +81 -0
  20. package/lib/cli/command.d.mts +3 -0
  21. package/lib/cli/command.js +15 -2
  22. package/lib/cli/command.mjs +50 -0
  23. package/lib/cli/create-rule/index.d.mts +1 -0
  24. package/lib/cli/create-rule/index.js +4 -1
  25. package/lib/cli/create-rule/index.mjs +51 -0
  26. package/lib/cli/index.d.mts +1 -0
  27. package/lib/cli/index.mjs +64 -0
  28. package/lib/cli/index.spec.d.mts +1 -0
  29. package/lib/cli/index.spec.mjs +48 -0
  30. package/lib/cli/init/index.d.mts +1 -0
  31. package/lib/cli/init/index.js +92 -55
  32. package/lib/cli/init/index.mjs +266 -0
  33. package/lib/cli/init/install-module.d.mts +5 -0
  34. package/lib/cli/init/install-module.mjs +61 -0
  35. package/lib/cli/output.d.mts +3 -0
  36. package/lib/cli/output.mjs +31 -0
  37. package/lib/cli/prompt.d.mts +18 -0
  38. package/lib/cli/prompt.mjs +68 -0
  39. package/lib/debug.d.mts +3 -0
  40. package/lib/debug.mjs +10 -0
  41. package/lib/global-settings.d.mts +5 -0
  42. package/lib/global-settings.mjs +10 -0
  43. package/lib/i18n.d.mts +6 -0
  44. package/lib/i18n.mjs +19 -0
  45. package/lib/index.d.mts +8 -0
  46. package/lib/index.mjs +8 -0
  47. package/lib/reporter/index.d.mts +2 -0
  48. package/lib/reporter/index.mjs +2 -0
  49. package/lib/reporter/simple-reporter.d.mts +3 -0
  50. package/lib/reporter/simple-reporter.js +7 -7
  51. package/lib/reporter/simple-reporter.mjs +30 -0
  52. package/lib/reporter/standard-reporter.d.mts +3 -0
  53. package/lib/reporter/standard-reporter.js +10 -10
  54. package/lib/reporter/standard-reporter.mjs +43 -0
  55. package/lib/testing-tool/index.d.mts +35 -0
  56. package/lib/testing-tool/index.js +2 -0
  57. package/lib/testing-tool/index.mjs +83 -0
  58. package/lib/types.d.mts +27 -0
  59. package/lib/types.mjs +1 -0
  60. package/lib/util.d.mts +19 -0
  61. package/lib/util.d.ts +16 -0
  62. package/lib/util.js +75 -1
  63. package/lib/util.mjs +73 -0
  64. package/lib/v1.d.mts +4 -0
  65. package/lib/v1.mjs +4 -0
  66. package/media/screenshot01.png +0 -0
  67. package/package.json +14 -14
  68. package/tsconfig.tsbuildinfo +1 -1
  69. package/RESOLVE_CONFIG.md +0 -77
  70. package/lib/reporter/utils.d.ts +0 -6
  71. package/lib/reporter/utils.js +0 -40
@@ -0,0 +1,52 @@
1
+ export declare const help = "\nUsage\n\t$ markuplint <HTML file pathes (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\" 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--verbose Output with detailed information.\n\n\t--init Initialize settings interactively.\n\t--create-rule Add the scaffold of a custom rule.\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";
2
+ export declare const cli: import("meow").Result<{
3
+ config: {
4
+ type: "string";
5
+ alias: string;
6
+ };
7
+ fix: {
8
+ type: "boolean";
9
+ default: false;
10
+ };
11
+ format: {
12
+ type: "string";
13
+ alias: string;
14
+ };
15
+ searchConfig: {
16
+ type: "boolean";
17
+ default: true;
18
+ };
19
+ ignoreExt: {
20
+ type: "boolean";
21
+ default: false;
22
+ };
23
+ importPresetRules: {
24
+ type: "boolean";
25
+ default: true;
26
+ };
27
+ locale: {
28
+ type: "string";
29
+ };
30
+ color: {
31
+ type: "boolean";
32
+ default: true;
33
+ };
34
+ problemOnly: {
35
+ type: "boolean";
36
+ alias: string;
37
+ default: false;
38
+ };
39
+ verbose: {
40
+ type: "boolean";
41
+ default: false;
42
+ };
43
+ init: {
44
+ type: "boolean";
45
+ default: false;
46
+ };
47
+ createRule: {
48
+ type: "boolean";
49
+ default: false;
50
+ };
51
+ }>;
52
+ export declare type CLIOptions = typeof cli.flags;
@@ -1,25 +1,32 @@
1
1
  import meow from 'meow';
2
- export declare const help = "\nUsage\n\t$ markuplint <HTML file pathes (glob format)>\n\t$ <stdout> | markuplint\n\nOptions\n\t--config-file, -c FILE_PATH Ruleset file path.\n\t--fix, Fix HTML.\n\t--format, -f FORMAT Output format. Support \"JSON\", \"Simple\" and \"Standard\". Default: \"Standard\".\n\t--no-color, Output no color.\n\t--problem-only, -p Output only problems, without passeds.\n\t--verbose Output with detailed information.\n\n\t--init Initialize settings interactively.\n\t--create-rule Add the scaffold of a custom rule.\n\n\t--help, -h Show help.\n\t--version, -v Show version.\n\nExamples\n\t$ markuplint verifyee.html --ruleset path/to/.markuplintrc\n\t$ cat verifyee.html | markuplint\n";
2
+ export declare const help = "\nUsage\n\t$ markuplint <HTML file pathes (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\" 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--verbose Output with detailed information.\n\n\t--init Initialize settings interactively.\n\t--create-rule Add the scaffold of a custom rule.\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
3
  export declare const cli: meow.Result<{
4
- init: {
5
- type: "boolean";
6
- default: false;
4
+ config: {
5
+ type: "string";
6
+ alias: string;
7
7
  };
8
- createRule: {
8
+ fix: {
9
9
  type: "boolean";
10
10
  default: false;
11
11
  };
12
- configFile: {
12
+ format: {
13
13
  type: "string";
14
14
  alias: string;
15
15
  };
16
- fix: {
16
+ searchConfig: {
17
+ type: "boolean";
18
+ default: true;
19
+ };
20
+ ignoreExt: {
17
21
  type: "boolean";
18
22
  default: false;
19
23
  };
20
- format: {
24
+ importPresetRules: {
25
+ type: "boolean";
26
+ default: true;
27
+ };
28
+ locale: {
21
29
  type: "string";
22
- alias: string;
23
30
  };
24
31
  color: {
25
32
  type: "boolean";
@@ -34,5 +41,13 @@ export declare const cli: meow.Result<{
34
41
  type: "boolean";
35
42
  default: false;
36
43
  };
44
+ init: {
45
+ type: "boolean";
46
+ default: false;
47
+ };
48
+ createRule: {
49
+ type: "boolean";
50
+ default: false;
51
+ };
37
52
  }>;
38
53
  export declare type CLIOptions = typeof cli.flags;
@@ -9,34 +9,30 @@ Usage
9
9
  $ <stdout> | markuplint
10
10
 
11
11
  Options
12
- --config-file, -c FILE_PATH Ruleset file path.
13
- --fix, Fix HTML.
14
- --format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
15
- --no-color, Output no color.
16
- --problem-only, -p Output only problems, without passeds.
17
- --verbose Output with detailed information.
12
+ --config, -c FILE_PATH A configuration file path.
13
+ --fix, Fix HTML.
14
+ --format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
15
+ --no-search-config No search a configure file automatically.
16
+ --ignore-ext Evaluate files that are received even though the type of extension.
17
+ --no-import-preset-rules No import preset rules.
18
+ --locale Locale of the message of violation. Default is an OS setting.
19
+ --no-color, Output no color.
20
+ --problem-only, -p Output only problems, without passeds.
21
+ --verbose Output with detailed information.
18
22
 
19
- --init Initialize settings interactively.
20
- --create-rule Add the scaffold of a custom rule.
23
+ --init Initialize settings interactively.
24
+ --create-rule Add the scaffold of a custom rule.
21
25
 
22
- --help, -h Show help.
23
- --version, -v Show version.
26
+ --help, -h Show help.
27
+ --version, -v Show version.
24
28
 
25
29
  Examples
26
- $ markuplint verifyee.html --ruleset path/to/.markuplintrc
30
+ $ markuplint verifyee.html --config path/to/.markuplintrc
27
31
  $ cat verifyee.html | markuplint
28
32
  `;
29
33
  exports.cli = (0, meow_1.default)(exports.help, {
30
34
  flags: {
31
- init: {
32
- type: 'boolean',
33
- default: false,
34
- },
35
- createRule: {
36
- type: 'boolean',
37
- default: false,
38
- },
39
- configFile: {
35
+ config: {
40
36
  type: 'string',
41
37
  alias: 'c',
42
38
  },
@@ -48,6 +44,21 @@ exports.cli = (0, meow_1.default)(exports.help, {
48
44
  type: 'string',
49
45
  alias: 'f',
50
46
  },
47
+ searchConfig: {
48
+ type: 'boolean',
49
+ default: true,
50
+ },
51
+ ignoreExt: {
52
+ type: 'boolean',
53
+ default: false,
54
+ },
55
+ importPresetRules: {
56
+ type: 'boolean',
57
+ default: true,
58
+ },
59
+ locale: {
60
+ type: 'string',
61
+ },
51
62
  color: {
52
63
  type: 'boolean',
53
64
  default: true,
@@ -61,5 +72,13 @@ exports.cli = (0, meow_1.default)(exports.help, {
61
72
  type: 'boolean',
62
73
  default: false,
63
74
  },
75
+ init: {
76
+ type: 'boolean',
77
+ default: false,
78
+ },
79
+ createRule: {
80
+ type: 'boolean',
81
+ default: false,
82
+ },
64
83
  },
65
84
  });
@@ -0,0 +1,81 @@
1
+ import meow from 'meow';
2
+ export const help = `
3
+ Usage
4
+ $ markuplint <HTML file pathes (glob format)>
5
+ $ <stdout> | markuplint
6
+
7
+ Options
8
+ --config, -c FILE_PATH A configuration file path.
9
+ --fix, Fix HTML.
10
+ --format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
11
+ --no-search-config No search a configure file automatically.
12
+ --ignore-ext Evaluate files that are received even though the type of extension.
13
+ --no-import-preset-rules No import preset rules.
14
+ --locale Locale of the message of violation. Default is an OS setting.
15
+ --no-color, Output no color.
16
+ --problem-only, -p Output only problems, without passeds.
17
+ --verbose Output with detailed information.
18
+
19
+ --init Initialize settings interactively.
20
+ --create-rule Add the scaffold of a custom rule.
21
+
22
+ --help, -h Show help.
23
+ --version, -v Show version.
24
+
25
+ Examples
26
+ $ markuplint verifyee.html --config path/to/.markuplintrc
27
+ $ cat verifyee.html | markuplint
28
+ `;
29
+ export const cli = meow(help, {
30
+ importMeta: import.meta,
31
+ flags: {
32
+ config: {
33
+ type: 'string',
34
+ alias: 'c',
35
+ },
36
+ fix: {
37
+ type: 'boolean',
38
+ default: false,
39
+ },
40
+ format: {
41
+ type: 'string',
42
+ alias: 'f',
43
+ },
44
+ searchConfig: {
45
+ type: 'boolean',
46
+ default: true,
47
+ },
48
+ ignoreExt: {
49
+ type: 'boolean',
50
+ default: false,
51
+ },
52
+ importPresetRules: {
53
+ type: 'boolean',
54
+ default: true,
55
+ },
56
+ locale: {
57
+ type: 'string',
58
+ },
59
+ color: {
60
+ type: 'boolean',
61
+ default: true,
62
+ },
63
+ problemOnly: {
64
+ type: 'boolean',
65
+ alias: 'p',
66
+ default: false,
67
+ },
68
+ verbose: {
69
+ type: 'boolean',
70
+ default: false,
71
+ },
72
+ init: {
73
+ type: 'boolean',
74
+ default: false,
75
+ },
76
+ createRule: {
77
+ type: 'boolean',
78
+ default: false,
79
+ },
80
+ },
81
+ });
@@ -0,0 +1,3 @@
1
+ import type { CLIOptions } from './bootstrap.mjs';
2
+ import type { Target } from '@markuplint/file-resolver';
3
+ export declare function command(files: Target[], options: CLIOptions): Promise<boolean>;
@@ -10,7 +10,12 @@ const debug_1 = require("../debug");
10
10
  const output_1 = require("./output");
11
11
  async function command(files, options) {
12
12
  const fix = options.fix;
13
- const configFile = options.configFile && path_1.default.join(process.cwd(), options.configFile);
13
+ const configFile = options.config && path_1.default.join(process.cwd(), options.config);
14
+ const locale = options.locale;
15
+ const searchConfig = options.searchConfig;
16
+ const ignoreExt = options.ignoreExt;
17
+ const importPresetRules = options.importPresetRules;
18
+ const verbose = options.verbose;
14
19
  const fileList = await (0, file_resolver_1.resolveFiles)(files);
15
20
  if (debug_1.log.enabled) {
16
21
  (0, debug_1.log)('File list: %O', fileList.map(f => f.path));
@@ -19,7 +24,15 @@ async function command(files, options) {
19
24
  }
20
25
  let hasError = false;
21
26
  for (const file of fileList) {
22
- const engine = new api_1.MLEngine(file, { configFile });
27
+ const engine = new api_1.MLEngine(file, {
28
+ configFile,
29
+ fix,
30
+ locale,
31
+ noSearchConfig: !searchConfig,
32
+ ignoreExt,
33
+ importPresetRules,
34
+ debug: verbose,
35
+ });
23
36
  const result = await engine.exec();
24
37
  if (!result) {
25
38
  continue;
@@ -0,0 +1,50 @@
1
+ import { promises as fs } from 'fs';
2
+ import path from 'path';
3
+ import { resolveFiles } from '@markuplint/file-resolver';
4
+ import { MLEngine } from '../api/index.mjs';
5
+ import { log } from '../debug.mjs';
6
+ import { output } from './output.mjs';
7
+ export async function command(files, options) {
8
+ const fix = options.fix;
9
+ const configFile = options.config && path.join(process.cwd(), options.config);
10
+ const locale = options.locale;
11
+ const searchConfig = options.searchConfig;
12
+ const ignoreExt = options.ignoreExt;
13
+ const importPresetRules = options.importPresetRules;
14
+ const verbose = options.verbose;
15
+ const fileList = await resolveFiles(files);
16
+ if (log.enabled) {
17
+ log('File list: %O', fileList.map(f => f.path));
18
+ log('Config: %s', configFile || 'N/A');
19
+ log('Fix option: %s', fix);
20
+ }
21
+ let hasError = false;
22
+ for (const file of fileList) {
23
+ const engine = new MLEngine(file, {
24
+ configFile,
25
+ fix,
26
+ locale,
27
+ noSearchConfig: !searchConfig,
28
+ ignoreExt,
29
+ importPresetRules,
30
+ debug: verbose,
31
+ });
32
+ const result = await engine.exec();
33
+ if (!result) {
34
+ continue;
35
+ }
36
+ if (!hasError && result.violations.length) {
37
+ hasError = true;
38
+ }
39
+ if (fix) {
40
+ log('Overwrite file: %s', result.filePath);
41
+ await fs.writeFile(result.filePath, result.fixedCode, { encoding: 'utf8' });
42
+ process.stdout.write(`markuplint: Fix "${result.filePath}"\n`);
43
+ }
44
+ else {
45
+ log('Output reports');
46
+ await output(result, options);
47
+ }
48
+ }
49
+ return hasError;
50
+ }
@@ -0,0 +1 @@
1
+ export declare function createRule(): Promise<void>;
@@ -4,9 +4,12 @@ exports.createRule = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const create_rule_helper_1 = require("@markuplint/create-rule-helper");
6
6
  const cli_color_1 = (0, tslib_1.__importDefault)(require("cli-color"));
7
+ const util_1 = require("../../util");
7
8
  const install_module_1 = require("../init/install-module");
8
9
  const prompt_1 = require("../prompt");
9
10
  async function createRule() {
11
+ (0, util_1.write)((0, util_1.head)('Create a rule'));
12
+ util_1.write.break();
10
13
  const purpose = await (0, prompt_1.select)({
11
14
  message: 'What purpose do you create the rule for?',
12
15
  choices: [
@@ -49,5 +52,5 @@ function output(name, icon, title, path) {
49
52
  const _marker = cli_color_1.default.xterm(39)('✔') + ' ';
50
53
  const _title = (icon, title) => `${icon} ` + cli_color_1.default.bold(`${name}/${title}`);
51
54
  const _file = (path) => ' ' + cli_color_1.default.cyanBright(path);
52
- process.stdout.write(_marker + _title(icon, title) + _file(path) + '\n');
55
+ (0, util_1.write)(_marker + _title(icon, title) + _file(path));
53
56
  }
@@ -0,0 +1,51 @@
1
+ import * as createRuleHelper from '@markuplint/create-rule-helper';
2
+ import c from 'cli-color';
3
+ import { write, head } from '../../util.mjs';
4
+ import { installModule } from '../init/install-module.mjs';
5
+ import { input, select, confirm } from '../prompt.mjs';
6
+ export async function createRule() {
7
+ write(head('Create a rule'));
8
+ write.break();
9
+ const purpose = await select({
10
+ message: 'What purpose do you create the rule for?',
11
+ choices: [
12
+ { name: 'Add the rule to this project', value: 'ADD_TO_PROJECT' },
13
+ { name: 'Create the rule and publish it as a package', value: 'PUBLISH_AS_PACKAGE' },
14
+ { name: 'Contribute the new rule to markuplint core rules', value: 'CONTRIBUTE_TO_CORE' },
15
+ ],
16
+ });
17
+ const name = await input('What is the name?', /^[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)*$/i);
18
+ const lang = purpose === 'CONTRIBUTE_TO_CORE'
19
+ ? 'TYPESCRIPT'
20
+ : await select({
21
+ message: 'Which language will you implement?',
22
+ choices: [
23
+ { name: 'TypeScript', value: 'TYPESCRIPT' },
24
+ { name: 'JavaScript', value: 'JAVASCRIPT' },
25
+ ],
26
+ });
27
+ const needTest = purpose === 'CONTRIBUTE_TO_CORE' ? true : await confirm('Do you need the test?', { initial: true });
28
+ const result = await createRuleHelper.createRuleHelper({ purpose, name, lang, needTest });
29
+ output(name, '📝', 'README.md', result.readme);
30
+ output(name, '📜', 'index', result.main);
31
+ if (result.test) {
32
+ output(name, '🖍 ', 'index.spec', result.test);
33
+ }
34
+ if (result.schemaJson) {
35
+ output(name, '⚙️ ', 'schema.json', result.schemaJson);
36
+ }
37
+ if (result.packageJson) {
38
+ output(name, '🎁 ', 'package.json', result.packageJson);
39
+ if (result.tsConfig) {
40
+ output(name, '💎 ', 'tsconfig.json', result.tsConfig);
41
+ }
42
+ await installModule(result.dependencies);
43
+ await installModule(result.devDependencies, true);
44
+ }
45
+ }
46
+ function output(name, icon, title, path) {
47
+ const _marker = c.xterm(39)('✔') + ' ';
48
+ const _title = (icon, title) => `${icon} ` + c.bold(`${name}/${title}`);
49
+ const _file = (path) => ' ' + c.cyanBright(path);
50
+ write(_marker + _title(icon, title) + _file(path));
51
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,64 @@
1
+ import getStdin from 'get-stdin';
2
+ import { verbosely } from '../debug.mjs';
3
+ import { cli } from './bootstrap.mjs';
4
+ import { command } from './command.mjs';
5
+ import { createRule } from './create-rule/index.mjs';
6
+ import { initialize } from './init/index.mjs';
7
+ (async () => {
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(err => {
19
+ process.stderr.write(err + '\n');
20
+ process.exit(1);
21
+ });
22
+ return;
23
+ }
24
+ if (cli.flags.createRule) {
25
+ await createRule().catch(err => {
26
+ process.stderr.write(err + '\n');
27
+ process.exit(1);
28
+ });
29
+ return;
30
+ }
31
+ const files = cli.input;
32
+ if (files.length) {
33
+ const hasError = await command(files, cli.flags).catch(err => {
34
+ throw err;
35
+ // process.exit(1);
36
+ });
37
+ process.exit(hasError ? 1 : 0);
38
+ }
39
+ if (usePipe()) {
40
+ getStdin()
41
+ .then(async (stdin) => {
42
+ if (stdin) {
43
+ const hasError = await command([{ sourceCode: stdin }], cli.flags).catch(err => {
44
+ process.stderr.write(err + '\n');
45
+ process.exit(1);
46
+ });
47
+ process.exit(hasError ? 1 : 0);
48
+ }
49
+ // result is empty
50
+ cli.showHelp(1);
51
+ })
52
+ .catch(reason => {
53
+ // eslint-disable-next-line no-console
54
+ console.warn(reason);
55
+ process.exit(1);
56
+ });
57
+ }
58
+ else {
59
+ cli.showHelp(1);
60
+ }
61
+ })();
62
+ function usePipe() {
63
+ return !process.stdin.isTTY && process.stdout.isTTY;
64
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,48 @@
1
+ import path from 'path';
2
+ import { execa } from 'execa';
3
+ import { cli } from './bootstrap.mjs';
4
+ const entryFilePath = path.resolve(__dirname, '../../bin/markuplint');
5
+ describe('STDOUT Test', () => {
6
+ it('empty', async () => {
7
+ const resultPromise = execa(entryFilePath, []);
8
+ await expect(resultPromise).rejects.toThrow(cli.help);
9
+ });
10
+ it('version', async () => {
11
+ const { stdout } = await execa(entryFilePath, ['--version']);
12
+ expect(stdout).toBe(cli.pkg.version);
13
+ });
14
+ it('version', async () => {
15
+ const { stdout } = await execa(entryFilePath, ['-v']);
16
+ expect(stdout).toBe(cli.pkg.version);
17
+ });
18
+ it('version', async () => {
19
+ const { stdout } = await execa(entryFilePath, ['--help']);
20
+ const { stdout: stdoutShort } = await execa(entryFilePath, ['-h']);
21
+ expect(stdout).toBe(stdoutShort);
22
+ });
23
+ it('verify', async () => {
24
+ const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/001.html');
25
+ const { stdout, exitCode } = await execa(entryFilePath, ['--no-color', targetFilePath]);
26
+ expect(stdout).toBe(`<markuplint> passed ${targetFilePath}`);
27
+ expect(exitCode).toBe(0);
28
+ });
29
+ it('verify --problem-only', async () => {
30
+ const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/001.html');
31
+ const { stdout } = await execa(entryFilePath, ['--problem-only', targetFilePath]);
32
+ expect(stdout).toBe('');
33
+ });
34
+ it('verify and feilure', async () => {
35
+ const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/002.html');
36
+ const { stdout, stderr, exitCode } = await execa(entryFilePath, ['--no-color', targetFilePath], {
37
+ reject: false,
38
+ });
39
+ expect(stdout).toBe('');
40
+ expect(stderr.split('\n').length).toBe(34);
41
+ expect(exitCode).toBe(1);
42
+ });
43
+ it('format', async () => {
44
+ const targetFilePath = path.resolve(__dirname, '../../../../test/fixture/001.html');
45
+ const { stdout } = await execa(entryFilePath, ['--format', 'JSON', targetFilePath]);
46
+ expect(stdout).toBe('[]');
47
+ });
48
+ });
@@ -0,0 +1 @@
1
+ export declare function initialize(): Promise<void>;