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.
Files changed (65) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +4 -2
  3. package/bin/markuplint.mjs +3 -0
  4. package/lib/api/index.d.ts +2 -2
  5. package/lib/api/index.js +2 -10
  6. package/lib/api/lint.d.ts +2 -2
  7. package/lib/api/lint.js +5 -10
  8. package/lib/api/ml-engine.d.ts +28 -23
  9. package/lib/api/ml-engine.js +123 -103
  10. package/lib/api/types.d.ts +32 -32
  11. package/lib/api/types.js +1 -2
  12. package/lib/api/v1.d.ts +43 -43
  13. package/lib/api/v1.js +12 -20
  14. package/lib/cli/bootstrap.d.ts +65 -63
  15. package/lib/cli/bootstrap.js +12 -11
  16. package/lib/cli/command.d.ts +3 -7
  17. package/lib/cli/command.js +26 -34
  18. package/lib/cli/index.js +59 -71
  19. package/lib/cli/init/create-config.d.ts +2 -6
  20. package/lib/cli/init/create-config.js +14 -12
  21. package/lib/cli/init/get-default-rules.d.ts +3 -3
  22. package/lib/cli/init/get-default-rules.js +12 -53
  23. package/lib/cli/init/index.js +28 -37
  24. package/lib/cli/init/select-modules.d.ts +2 -0
  25. package/lib/cli/init/select-modules.js +10 -0
  26. package/lib/cli/init/types.d.ts +4 -15
  27. package/lib/cli/init/types.js +1 -2
  28. package/lib/cli/output.d.ts +2 -2
  29. package/lib/cli/output.js +8 -14
  30. package/lib/cli/search/index.d.ts +2 -2
  31. package/lib/cli/search/index.js +10 -14
  32. package/lib/debug.js +9 -13
  33. package/lib/get-json-module.d.ts +1 -0
  34. package/lib/get-json-module.js +10 -0
  35. package/lib/global-settings.d.ts +1 -1
  36. package/lib/global-settings.js +2 -7
  37. package/lib/i18n.js +8 -15
  38. package/lib/index.d.ts +7 -5
  39. package/lib/index.js +6 -10
  40. package/lib/reporter/github-reporter.d.ts +1 -1
  41. package/lib/reporter/github-reporter.js +7 -9
  42. package/lib/reporter/index.d.ts +3 -3
  43. package/lib/reporter/index.js +3 -6
  44. package/lib/reporter/simple-reporter.d.ts +2 -2
  45. package/lib/reporter/simple-reporter.js +11 -16
  46. package/lib/reporter/standard-reporter.d.ts +2 -2
  47. package/lib/reporter/standard-reporter.js +37 -28
  48. package/lib/testing-tool/index.d.ts +23 -41
  49. package/lib/testing-tool/index.js +41 -47
  50. package/lib/types.d.ts +17 -17
  51. package/lib/types.js +1 -2
  52. package/lib/v1.d.ts +1 -1
  53. package/lib/v1.js +1 -5
  54. package/lib/version.d.ts +1 -0
  55. package/lib/version.js +3 -0
  56. package/package.json +26 -34
  57. package/bin/markuplint +0 -3
  58. package/lib/cli/create-rule/index.d.ts +0 -1
  59. package/lib/cli/create-rule/index.js +0 -85
  60. package/lib/cli/init/install-module.d.ts +0 -7
  61. package/lib/cli/init/install-module.js +0 -80
  62. package/lib/cli/prompt.d.ts +0 -23
  63. package/lib/cli/prompt.js +0 -77
  64. package/lib/util.d.ts +0 -17
  65. package/lib/util.js +0 -88
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.simpleReporter = void 0;
4
- const tslib_1 = require("tslib");
5
- const cli_color_1 = tslib_1.__importDefault(require("cli-color"));
6
- const util_1 = require("../util");
7
- const loggerError = cli_color_1.default.red;
8
- const loggerWarning = cli_color_1.default.xterm(208);
9
- function simpleReporter(results, options) {
1
+ import { name, font, pad, getWidth, messageToString } from '@markuplint/cli-utils';
2
+ const commandName = name.toLowerCase();
3
+ const loggerError = font.red;
4
+ const loggerWarning = font.xterm(208);
5
+ export function simpleReporter(results, options) {
10
6
  const sizes = {
11
7
  line: 0,
12
8
  col: 0,
@@ -15,21 +11,20 @@ function simpleReporter(results, options) {
15
11
  for (const violation of results.violations) {
16
12
  sizes.line = Math.max(sizes.line, violation.line.toString(10).length);
17
13
  sizes.col = Math.max(sizes.col, violation.col.toString(10).length);
18
- const meg = (0, util_1.messageToString)(violation.message, violation.reason);
19
- sizes.meg = Math.max(sizes.meg, (0, util_1.w)(meg));
14
+ const meg = messageToString(violation.message, violation.reason);
15
+ sizes.meg = Math.max(sizes.meg, getWidth(meg));
20
16
  }
21
17
  const out = [];
22
18
  if (results.violations.length > 0) {
23
- out.push(`<${util_1.markuplint}> ${cli_color_1.default.underline(results.filePath)}: ${loggerError('✗')}`);
19
+ out.push(`<${commandName}> ${font.underline(results.filePath)}: ${loggerError('✗')}`);
24
20
  for (const violation of results.violations) {
25
21
  const s = violation.severity === 'error' ? loggerError('✖') : loggerWarning('⚠️');
26
- const meg = (0, util_1.messageToString)(violation.message, violation.reason);
27
- out.push(` ${cli_color_1.default.cyan(`${(0, util_1.p)(violation.line, sizes.line, true)}:${(0, util_1.p)(violation.col, sizes.col)}`)} ${s} ${(0, util_1.p)(meg, sizes.meg)} ${cli_color_1.default.xterm(8)(violation.ruleId)} `);
22
+ const meg = messageToString(violation.message, violation.reason);
23
+ out.push(` ${font.cyan(`${pad(violation.line, sizes.line, true)}:${pad(violation.col, sizes.col)}`)} ${s} ${pad(meg, sizes.meg)} ${font.xterm(8)(violation.ruleId)} `);
28
24
  }
29
25
  }
30
26
  else if (!options.problemOnly) {
31
- out.push(`<${util_1.markuplint}> ${cli_color_1.default.underline(results.filePath)}: ${cli_color_1.default.green('✓')}`);
27
+ out.push(`<${commandName}> ${font.underline(results.filePath)}: ${font.green('✓')}`);
32
28
  }
33
29
  return out;
34
30
  }
35
- exports.simpleReporter = simpleReporter;
@@ -1,3 +1,3 @@
1
- import type { CLIOptions } from '../cli/bootstrap';
2
- import type { MLResultInfo } from '../types';
1
+ import type { CLIOptions } from '../cli/bootstrap.js';
2
+ import type { MLResultInfo } from '../types.js';
3
3
  export declare function standardReporter(results: MLResultInfo, options: CLIOptions): string[];
@@ -1,13 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.standardReporter = void 0;
4
- const tslib_1 = require("tslib");
5
- const cli_color_1 = tslib_1.__importDefault(require("cli-color"));
6
- const util_1 = require("../util");
7
- const loggerError = cli_color_1.default.red;
8
- const loggerWarning = cli_color_1.default.xterm(208);
9
- function standardReporter(results, options) {
10
- var _a, _b, _c;
1
+ import { messageToString, font, name, invisibleSpace, space, pad, getWidth } from '@markuplint/cli-utils';
2
+ const commandName = name.toLowerCase();
3
+ const loggerError = font.red;
4
+ const loggerWarning = font.xterm(208);
5
+ export function standardReporter(results, options) {
11
6
  const sizes = {
12
7
  line: 0,
13
8
  col: 0,
@@ -16,34 +11,48 @@ function standardReporter(results, options) {
16
11
  for (const violation of results.violations) {
17
12
  sizes.line = Math.max(sizes.line, violation.line.toString(10).length);
18
13
  sizes.col = Math.max(sizes.col, violation.col.toString(10).length);
19
- const meg = (0, util_1.messageToString)(violation.message, violation.reason);
20
- sizes.meg = Math.max(sizes.meg, (0, util_1.w)(meg));
14
+ const meg = messageToString(violation.message, violation.reason);
15
+ sizes.meg = Math.max(sizes.meg, getWidth(meg));
21
16
  }
22
17
  const out = [];
23
18
  if (results.violations.length > 0) {
24
- const lines = results.sourceCode.split(/\r?\n/g);
19
+ const lines = results.sourceCode.split(/\r?\n/);
25
20
  for (const violation of results.violations) {
26
- const prev = (_a = lines[violation.line - 2]) !== null && _a !== void 0 ? _a : '';
27
- const line = (_b = lines[violation.line - 1]) !== null && _b !== void 0 ? _b : '';
28
- const next = (_c = lines[violation.line - 0]) !== null && _c !== void 0 ? _c : '';
29
- const before = line.substring(0, violation.col - 1);
30
- const after = line.substring(violation.col - 1 + violation.raw.length);
31
21
  const logger = violation.severity === 'error' ? loggerError : loggerWarning;
32
- const meg = (0, util_1.messageToString)(violation.message, violation.reason);
33
- out.push(`<${util_1.markuplint}> ${logger(`${violation.severity}: ${meg} (${violation.ruleId}) ${cli_color_1.default.underline(`${results.filePath}:${violation.line}:${violation.col}`)}`)}`);
34
- if (violation.line - 1 > 0) {
35
- out.push(` ${cli_color_1.default.cyan((0, util_1.p)(violation.line - 1, sizes.col, true))}: ${(0, util_1.space)(prev)}`);
22
+ const meg = messageToString(violation.message, violation.reason);
23
+ const startLine = violation.line - 1;
24
+ // Main message
25
+ out.push(`<${commandName}> ${logger(`${violation.severity}: ${meg} (${violation.ruleId}) ${font.underline(`${results.filePath}:${violation.line}:${violation.col}`)}`)}`);
26
+ // Previous line
27
+ if (startLine > 0) {
28
+ const prev = lines[startLine - 1] ?? '';
29
+ out.push(` ${font.cyan(pad(startLine, sizes.col, true))}: ${space(prev)}`);
36
30
  }
37
- out.push(` ${cli_color_1.default.cyan((0, util_1.p)(violation.line, sizes.col, true))}: ${(0, util_1.space)(before)}${cli_color_1.default.bgRed(violation.raw)}${(0, util_1.space)(after)}`);
38
- if (!options.color) {
39
- out.push(` ${(0, util_1.invisibleSpace)(before)}${'^'.repeat(violation.raw.length)}${(0, util_1.invisibleSpace)(after)}`);
31
+ // Current line
32
+ const rawLines = violation.raw.split(/\r?\n/);
33
+ const line = lines[startLine] ?? '';
34
+ for (const [i, rawLine] of rawLines.entries()) {
35
+ const currentLine = lines[startLine + i] ?? '';
36
+ const beforeChars = i === 0 ? line.slice(0, Math.max(0, violation.col - 1)) : rawLine.match(/^\s+/)?.[0] ?? '';
37
+ const codeChars = rawLine.trim();
38
+ const afterChars = currentLine.slice(Math.max(0, beforeChars.length + codeChars.length));
39
+ const lineNoChars = pad(violation.line + i, sizes.col, true);
40
+ const lineNo = font.cyan(lineNoChars);
41
+ const before = i === 0 ? space(beforeChars) : font.bgRed(space(beforeChars));
42
+ const code = font.bgRed(codeChars);
43
+ const after = space(afterChars);
44
+ out.push(` ${lineNo}: ${before}${code}${space(after)}`);
45
+ if (!options.color) {
46
+ out.push(` ${invisibleSpace(lineNoChars + ': ' + beforeChars)}${'^'.repeat(codeChars.length)}${invisibleSpace(afterChars)}`);
47
+ }
40
48
  }
41
- out.push(` ${cli_color_1.default.cyan((0, util_1.p)(violation.line + 1, sizes.col, true))}: ${(0, util_1.space)(next)}`);
49
+ // Next line
50
+ const next = lines[startLine + rawLines.length] ?? '';
51
+ out.push(` ${font.cyan(pad(startLine + rawLines.length + 1, sizes.col, true))}: ${space(next)}`);
42
52
  }
43
53
  }
44
54
  else if (!options.problemOnly) {
45
- out.push(`<${util_1.markuplint}> ${cli_color_1.default.green('passed')} ${cli_color_1.default.underline(results.filePath)}`);
55
+ out.push(`<${commandName}> ${font.green('passed')} ${font.underline(results.filePath)}`);
46
56
  }
47
57
  return out;
48
58
  }
49
- exports.standardReporter = standardReporter;
@@ -1,51 +1,33 @@
1
1
  import type { Target } from '@markuplint/file-resolver';
2
2
  import type { Config, RuleConfigValue, Rule, RegexSelector, PlainData } from '@markuplint/ml-config';
3
3
  import type { AnyMLRule, RuleSeed } from '@markuplint/ml-core';
4
- export declare function mlTest(
5
- sourceCode: string,
6
- config: Config,
7
- rules?: readonly Readonly<AnyMLRule>[],
8
- locale?: string,
9
- fix?: boolean,
10
- ): Promise<{
11
- violations: readonly import('@markuplint/ml-config').Violation[];
12
- fixedCode: string;
4
+ export declare function mlTest(sourceCode: string, config: Config, rules?: readonly Readonly<AnyMLRule>[], locale?: string, fix?: boolean): Promise<{
5
+ violations: readonly import("@markuplint/ml-config").Violation[];
6
+ fixedCode: string;
13
7
  }>;
14
- export declare function mlRuleTest<T extends RuleConfigValue, O extends PlainData>(
15
- rule: Readonly<RuleSeed<T, O>>,
16
- sourceCode: string,
17
- config?: Omit<Config, 'rules' | 'nodeRules' | 'childNodeRules'> & {
18
- rule?: Rule<T, Partial<O>>;
19
- nodeRule?: NodeRule<T, Partial<O>>[];
20
- childNodeRule?: ChildNodeRule<T, Partial<O>>[];
21
- },
22
- fix?: boolean,
23
- locale?: string,
24
- ): Promise<{
25
- violations: readonly import('@markuplint/ml-config').Violation[];
26
- fixedCode: string;
8
+ export declare function mlRuleTest<T extends RuleConfigValue, O extends PlainData>(rule: Readonly<RuleSeed<T, O>>, sourceCode: string, config?: Omit<Config, 'rules' | 'nodeRules' | 'childNodeRules'> & {
9
+ rule?: Rule<T, Partial<O>>;
10
+ nodeRule?: NodeRule<T, Partial<O>>[];
11
+ childNodeRule?: ChildNodeRule<T, Partial<O>>[];
12
+ }, fix?: boolean, locale?: string): Promise<{
13
+ violations: readonly import("@markuplint/ml-config").Violation[];
14
+ fixedCode: string;
27
15
  }>;
28
- export declare function mlTestFile(
29
- target: Target,
30
- config?: Config,
31
- rules?: readonly Readonly<AnyMLRule>[],
32
- locale?: string,
33
- fix?: boolean,
34
- ): Promise<{
35
- violations: readonly import('@markuplint/ml-config').Violation[];
36
- fixedCode: string | undefined;
16
+ export declare function mlTestFile(target: Target, config?: Config, rules?: readonly Readonly<AnyMLRule>[], locale?: string, fix?: boolean): Promise<{
17
+ violations: readonly import("@markuplint/ml-config").Violation[];
18
+ fixedCode: string | undefined;
37
19
  }>;
38
20
  export interface NodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
39
- selector?: string;
40
- regexSelector?: RegexSelector;
41
- categories?: string[];
42
- roles?: string[];
43
- obsolete?: boolean;
44
- rule?: Rule<T, O>;
21
+ selector?: string;
22
+ regexSelector?: RegexSelector;
23
+ categories?: string[];
24
+ roles?: string[];
25
+ obsolete?: boolean;
26
+ rule?: Rule<T, O>;
45
27
  }
46
28
  export interface ChildNodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
47
- selector?: string;
48
- regexSelector?: RegexSelector;
49
- inheritance?: boolean;
50
- rule?: Rule<T, O>;
29
+ selector?: string;
30
+ regexSelector?: RegexSelector;
31
+ inheritance?: boolean;
32
+ rule?: Rule<T, O>;
51
33
  }
@@ -1,16 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mlTestFile = exports.mlRuleTest = exports.mlTest = void 0;
4
- const ml_core_1 = require("@markuplint/ml-core");
5
- const api_1 = require("../api");
6
- const global_settings_1 = require("../global-settings");
7
- async function mlTest(sourceCode, config, rules, locale = 'en', fix = false) {
8
- var _a, _b;
9
- const global = (0, global_settings_1.getGlobal)();
10
- const results = await (0, api_1.lint)([{ sourceCode }], {
1
+ import { MLRule } from '@markuplint/ml-core';
2
+ import { lint } from '../api/index.js';
3
+ import { getGlobal } from '../global-settings.js';
4
+ export async function mlTest(sourceCode, config, rules, locale = 'en', fix = false) {
5
+ const global = getGlobal();
6
+ const results = await lint([{ sourceCode }], {
11
7
  config,
12
8
  rules,
13
- locale: locale !== null && locale !== void 0 ? locale : global.locale,
9
+ locale: locale ?? global.locale,
14
10
  fix,
15
11
  ignoreExt: true,
16
12
  autoLoad: true,
@@ -18,46 +14,47 @@ async function mlTest(sourceCode, config, rules, locale = 'en', fix = false) {
18
14
  });
19
15
  const result = results[0];
20
16
  return {
21
- violations: (_a = result === null || result === void 0 ? void 0 : result.violations) !== null && _a !== void 0 ? _a : [],
22
- fixedCode: (_b = result === null || result === void 0 ? void 0 : result.fixedCode) !== null && _b !== void 0 ? _b : sourceCode,
17
+ violations: result?.violations ?? [],
18
+ fixedCode: result?.fixedCode ?? sourceCode,
23
19
  };
24
20
  }
25
- exports.mlTest = mlTest;
26
- async function mlRuleTest(rule, sourceCode, config = { rule: true }, fix = false, locale = 'en') {
21
+ export async function mlRuleTest(rule, sourceCode,
22
+ // eslint-disable-next-line unicorn/no-object-as-default-parameter
23
+ config = { rule: true }, fix = false, locale = 'en') {
27
24
  const _config = {
28
25
  ...config,
29
- rules: config.rule !== undefined
30
- ? {
31
- '<current-rule>': config.rule,
32
- }
33
- : config.rule === undefined && config.nodeRule === undefined && config.childNodeRule === undefined
26
+ rules: config.rule === undefined
27
+ ? config.rule === undefined && config.nodeRule === undefined && config.childNodeRule === undefined
34
28
  ? {
35
29
  '<current-rule>': true,
36
30
  }
37
- : undefined,
38
- nodeRules: config.nodeRule !== undefined
39
- ? config.nodeRule.map(nodeConfig => ({
31
+ : undefined
32
+ : {
33
+ '<current-rule>': config.rule,
34
+ },
35
+ nodeRules: config.nodeRule === undefined
36
+ ? undefined
37
+ : config.nodeRule.map(nodeConfig => ({
40
38
  ...nodeConfig,
41
- rules: nodeConfig.rule !== undefined
42
- ? {
39
+ rules: nodeConfig.rule === undefined
40
+ ? undefined
41
+ : {
43
42
  '<current-rule>': nodeConfig.rule,
44
- }
45
- : undefined,
46
- }))
47
- : undefined,
48
- childNodeRules: config.childNodeRule !== undefined
49
- ? config.childNodeRule.map(childNodeConfig => ({
43
+ },
44
+ })),
45
+ childNodeRules: config.childNodeRule === undefined
46
+ ? undefined
47
+ : config.childNodeRule.map(childNodeConfig => ({
50
48
  ...childNodeConfig,
51
- rules: childNodeConfig.rule !== undefined
52
- ? {
49
+ rules: childNodeConfig.rule === undefined
50
+ ? undefined
51
+ : {
53
52
  '<current-rule>': childNodeConfig.rule,
54
- }
55
- : undefined,
56
- }))
57
- : undefined,
53
+ },
54
+ })),
58
55
  };
59
56
  const res = await mlTest(sourceCode, _config, [
60
- new ml_core_1.MLRule({
57
+ new MLRule({
61
58
  name: '<current-rule>',
62
59
  ...rule,
63
60
  }),
@@ -68,14 +65,12 @@ async function mlRuleTest(rule, sourceCode, config = { rule: true }, fix = false
68
65
  });
69
66
  return res;
70
67
  }
71
- exports.mlRuleTest = mlRuleTest;
72
- async function mlTestFile(target, config, rules, locale, fix = false) {
73
- var _a, _b;
74
- const global = (0, global_settings_1.getGlobal)();
75
- const results = await (0, api_1.lint)([target], {
68
+ export async function mlTestFile(target, config, rules, locale, fix = false) {
69
+ const global = getGlobal();
70
+ const results = await lint([target], {
76
71
  config,
77
72
  rules,
78
- locale: locale !== null && locale !== void 0 ? locale : global.locale,
73
+ locale: locale ?? global.locale,
79
74
  fix,
80
75
  ignoreExt: true,
81
76
  noSearchConfig: !!config,
@@ -84,8 +79,7 @@ async function mlTestFile(target, config, rules, locale, fix = false) {
84
79
  });
85
80
  const result = results[0];
86
81
  return {
87
- violations: (_a = result === null || result === void 0 ? void 0 : result.violations) !== null && _a !== void 0 ? _a : [],
88
- fixedCode: (_b = result === null || result === void 0 ? void 0 : result.fixedCode) !== null && _b !== void 0 ? _b : result === null || result === void 0 ? void 0 : result.sourceCode,
82
+ violations: result?.violations ?? [],
83
+ fixedCode: result?.fixedCode ?? result?.sourceCode,
89
84
  };
90
85
  }
91
- exports.mlTestFile = mlTestFile;
package/lib/types.d.ts CHANGED
@@ -1,26 +1,26 @@
1
1
  import type { Config, PlainData, RuleConfigValue, Violation } from '@markuplint/ml-config';
2
2
  import type { Document, Ruleset } from '@markuplint/ml-core';
3
3
  export interface MLResultInfo {
4
- readonly violations: readonly Violation[];
5
- readonly filePath: string;
6
- readonly sourceCode: string;
7
- readonly fixedCode: string;
4
+ readonly violations: readonly Violation[];
5
+ readonly filePath: string;
6
+ readonly sourceCode: string;
7
+ readonly fixedCode: string;
8
8
  }
9
9
  /**
10
10
  * @deprecated
11
11
  */
12
12
  export interface MLResultInfo_v1 {
13
- results: Violation[];
14
- filePath: string;
15
- sourceCode: string;
16
- fixedCode: string;
17
- document: Document<RuleConfigValue, PlainData> | null;
18
- parser: string;
19
- locale?: string;
20
- ruleset: Ruleset;
21
- configSet: {
22
- config: Config;
23
- files: string[];
24
- error: string[];
25
- };
13
+ results: Violation[];
14
+ filePath: string;
15
+ sourceCode: string;
16
+ fixedCode: string;
17
+ document: Document<RuleConfigValue, PlainData> | null;
18
+ parser: string;
19
+ locale?: string;
20
+ ruleset: Ruleset;
21
+ configSet: {
22
+ config: Config;
23
+ files: string[];
24
+ error: string[];
25
+ };
26
26
  }
package/lib/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/lib/v1.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  /**
2
2
  * @deprecated
3
3
  */
4
- export { lint_v1 as exec } from './api/v1';
4
+ export { lint_v1 as exec } from './api/v1.js';
package/lib/v1.js CHANGED
@@ -1,8 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exec = void 0;
4
1
  /**
5
2
  * @deprecated
6
3
  */
7
- var v1_1 = require("./api/v1");
8
- Object.defineProperty(exports, "exec", { enumerable: true, get: function () { return v1_1.lint_v1; } });
4
+ export { lint_v1 as exec } from './api/v1.js';
@@ -0,0 +1 @@
1
+ export declare const version: string;
package/lib/version.js ADDED
@@ -0,0 +1,3 @@
1
+ // @ts-ignore
2
+ import pkg from '../package.json' assert { type: 'json' };
3
+ export const version = pkg.version;
package/package.json CHANGED
@@ -1,18 +1,23 @@
1
1
  {
2
2
  "name": "markuplint",
3
- "version": "3.15.0",
3
+ "version": "4.0.0-alpha.10",
4
4
  "description": "An HTML linter for all markup developers",
5
5
  "author": "Yusuke Hirao",
6
6
  "license": "MIT",
7
7
  "private": false,
8
8
  "repository": "git@github.com:markuplint/markuplint.git",
9
- "main": "lib/index.js",
10
- "types": "lib/index.d.ts",
9
+ "type": "module",
10
+ "exports": {
11
+ ".": {
12
+ "import": "./lib/index.js"
13
+ }
14
+ },
15
+ "types": "./lib/index.d.ts",
11
16
  "typedoc": {
12
17
  "entryPoint": "./src/index.ts"
13
18
  },
14
19
  "bin": {
15
- "markuplint": "bin/markuplint"
20
+ "markuplint": "./bin/markuplint.mjs"
16
21
  },
17
22
  "scripts": {
18
23
  "build": "tsc",
@@ -20,39 +25,26 @@
20
25
  "clean": "tsc --build --clean"
21
26
  },
22
27
  "dependencies": {
23
- "@markuplint/create-rule-helper": "3.15.0",
24
- "@markuplint/file-resolver": "3.15.0",
25
- "@markuplint/html-parser": "3.13.0",
26
- "@markuplint/html-spec": "3.14.0",
27
- "@markuplint/i18n": "3.12.0",
28
- "@markuplint/ml-ast": "3.2.0",
29
- "@markuplint/ml-config": "3.14.0",
30
- "@markuplint/ml-core": "3.15.0",
31
- "@markuplint/ml-spec": "3.14.0",
32
- "@markuplint/rules": "3.15.0",
33
- "@markuplint/shared": "3.8.0",
34
- "@types/cli-color": "^2.0.6",
28
+ "@markuplint/cli-utils": "4.0.0-alpha.10",
29
+ "@markuplint/file-resolver": "4.0.0-alpha.10",
30
+ "@markuplint/html-parser": "4.0.0-alpha.10",
31
+ "@markuplint/html-spec": "4.0.0-alpha.10",
32
+ "@markuplint/i18n": "4.0.0-alpha.10",
33
+ "@markuplint/ml-ast": "4.0.0-alpha.10",
34
+ "@markuplint/ml-config": "4.0.0-alpha.10",
35
+ "@markuplint/ml-core": "4.0.0-alpha.10",
36
+ "@markuplint/ml-spec": "4.0.0-alpha.10",
37
+ "@markuplint/rules": "4.0.0-alpha.10",
38
+ "@markuplint/shared": "4.0.0-alpha.10",
35
39
  "@types/debug": "^4.1.12",
36
- "@types/has-yarn": "^1.0.1",
37
- "@types/meow": "^6.0.0",
38
- "@types/uuid": "^9.0.7",
39
40
  "chokidar": "^3.5.3",
40
- "cli-color": "^2.0.3",
41
41
  "debug": "^4.3.4",
42
- "detect-installed": "^2.0.4",
43
- "eastasianwidth": "^0.2.0",
44
- "enquirer": "^2.4.1",
45
- "get-stdin": "8",
46
- "gray-matter": "^4.0.3",
47
- "has-yarn": "2",
48
- "meow": "9",
49
- "node-fetch": "2",
50
- "os-locale": "5",
42
+ "get-stdin": "^9.0.0",
43
+ "meow": "^13.1.0",
44
+ "os-locale": "^6.0.2",
51
45
  "strict-event-emitter": "^0.5.1",
52
- "strip-ansi": "6",
53
- "tslib": "^2.6.2",
54
- "type-fest": "^4.8.2",
55
- "uuid": "^9.0.1"
46
+ "strip-ansi": "^7.1.0",
47
+ "type-fest": "^4.10.1"
56
48
  },
57
- "gitHead": "b37b749d7ac0f9e6cbd022ee7031bc020c6677d3"
49
+ "gitHead": "b41153ea665aa8f091daf6114a06047f4ccb8350"
58
50
  }
package/bin/markuplint DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- require('../lib/cli');
@@ -1 +0,0 @@
1
- export declare function createRule(): Promise<void>;
@@ -1,85 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createRule = void 0;
4
- const tslib_1 = require("tslib");
5
- const node_path_1 = require("node:path");
6
- const create_rule_helper_1 = require("@markuplint/create-rule-helper");
7
- const cli_color_1 = tslib_1.__importDefault(require("cli-color"));
8
- const util_1 = require("../../util");
9
- const install_module_1 = require("../init/install-module");
10
- const prompt_1 = require("../prompt");
11
- const icons = {
12
- README: '📝',
13
- index: '📜',
14
- schema: '⚙️ ',
15
- package: '🎁',
16
- tsconfig: '💎',
17
- };
18
- async function createRule() {
19
- var _a;
20
- (0, util_1.write)((0, util_1.head)('Create a rule'));
21
- util_1.write.break();
22
- const firstChoices = [
23
- { name: 'Add the rule to this project', value: 'ADD_TO_PROJECT' },
24
- { name: 'Create the rule and publish it as a package', value: 'PUBLISH_AS_PACKAGE' },
25
- ];
26
- if (await (0, create_rule_helper_1.isMarkuplintRepo)()) {
27
- firstChoices.push({ name: 'Contribute the new rule to markuplint core rules', value: 'CONTRIBUTE_TO_CORE' });
28
- }
29
- const purpose = await (0, prompt_1.select)({
30
- message: 'What purpose do you create the rule for?',
31
- choices: firstChoices,
32
- });
33
- const dirQuestion = purpose === 'ADD_TO_PROJECT' ? 'What is the directory name?' : 'What is the plugin name?';
34
- const pluginName = purpose === 'CONTRIBUTE_TO_CORE' ? '' : await (0, prompt_1.input)(dirQuestion, /^[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)*$/i);
35
- const ruleName = await (0, prompt_1.input)('What is the rule name?', /^[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)*$/i);
36
- const core = purpose === 'CONTRIBUTE_TO_CORE'
37
- ? {
38
- description: await (0, prompt_1.input)('Description:'),
39
- category: await (0, prompt_1.select)({
40
- message: 'Category:',
41
- choices: [
42
- { name: 'Conformance checking', value: 'validation' },
43
- { name: 'Accessibility', value: 'a11y' },
44
- { name: 'Naming Convention', value: 'naming-convention' },
45
- { name: 'Maintainability', value: 'maintainability' },
46
- { name: 'Style', value: 'style' },
47
- ],
48
- }),
49
- severity: await (0, prompt_1.select)({
50
- message: 'Severity:',
51
- choices: [
52
- { name: 'error', value: 'error' },
53
- { name: 'warning', value: 'warning' },
54
- ],
55
- }),
56
- }
57
- : undefined;
58
- const lang = purpose === 'CONTRIBUTE_TO_CORE'
59
- ? 'TYPESCRIPT'
60
- : await (0, prompt_1.select)({
61
- message: 'Which language will you implement?',
62
- choices: [
63
- { name: 'TypeScript', value: 'TYPESCRIPT' },
64
- { name: 'JavaScript', value: 'JAVASCRIPT' },
65
- ],
66
- });
67
- const needTest = purpose === 'CONTRIBUTE_TO_CORE' ? true : await (0, prompt_1.confirm)('Do you need the test?', { initial: true });
68
- const result = await (0, create_rule_helper_1.createRuleHelper)({ purpose, pluginName, ruleName, lang, needTest, core });
69
- for (const file of result.files) {
70
- output(pluginName || 'core', file.test ? '🖍 ' : (_a = icons[file.name]) !== null && _a !== void 0 ? _a : '🛡 ', file.fileName, (0, node_path_1.resolve)(file.destDir, file.fileName + file.ext));
71
- }
72
- if (result.dependencies.length > 0) {
73
- await (0, install_module_1.installModule)(result.dependencies);
74
- }
75
- if (result.devDependencies.length > 0) {
76
- await (0, install_module_1.installModule)(result.devDependencies, true);
77
- }
78
- }
79
- exports.createRule = createRule;
80
- function output(name, icon, title, path) {
81
- const _marker = cli_color_1.default.xterm(39)('✔') + ' ';
82
- const _title = (icon, title) => `${icon} ` + cli_color_1.default.bold(`${name}/${title}`);
83
- const _file = (path) => ' ' + cli_color_1.default.cyanBright(path);
84
- (0, util_1.write)(_marker + _title(icon, title) + _file(path));
85
- }
@@ -1,7 +0,0 @@
1
- import type { Langs } from './types';
2
- export type InstallModuleResult = {
3
- success: boolean;
4
- alreadyExists: boolean;
5
- };
6
- export declare function selectModules(selectedLangs: readonly Langs[]): string[];
7
- export declare function installModule(module: readonly string[], dev?: boolean): Promise<InstallModuleResult>;