markuplint 4.14.0 → 4.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.ja.md +419 -0
- package/ARCHITECTURE.md +419 -0
- package/CHANGELOG.md +22 -3
- package/SKILL.md +110 -0
- package/docs/maintenance.ja.md +207 -0
- package/docs/maintenance.md +207 -0
- package/lib/api/index.d.ts +8 -0
- package/lib/api/index.js +8 -0
- package/lib/api/lint.d.ts +7 -0
- package/lib/api/lint.js +7 -0
- package/lib/api/ml-engine.d.ts +48 -0
- package/lib/api/ml-engine.js +43 -0
- package/lib/api/types.d.ts +6 -0
- package/lib/api/v1.d.ts +8 -3
- package/lib/api/v1.js +8 -3
- package/lib/cli/bootstrap.d.ts +12 -0
- package/lib/cli/bootstrap.js +8 -0
- package/lib/cli/command.d.ts +12 -0
- package/lib/cli/command.js +12 -0
- package/lib/cli/index.d.ts +7 -0
- package/lib/cli/index.js +7 -0
- package/lib/cli/init/create-config.d.ts +16 -0
- package/lib/cli/init/create-config.js +20 -0
- package/lib/cli/init/get-default-rules.d.ts +9 -0
- package/lib/cli/init/get-default-rules.js +9 -0
- package/lib/cli/init/index.d.ts +14 -0
- package/lib/cli/init/index.js +14 -0
- package/lib/cli/init/select-modules.d.ts +10 -0
- package/lib/cli/init/select-modules.js +10 -0
- package/lib/cli/init/types.d.ts +19 -0
- package/lib/cli/output.d.ts +11 -0
- package/lib/cli/output.js +11 -0
- package/lib/cli/search/index.d.ts +17 -0
- package/lib/cli/search/index.js +17 -0
- package/lib/debug.d.ts +9 -0
- package/lib/debug.js +9 -0
- package/lib/get-json-module.d.ts +10 -0
- package/lib/get-json-module.js +10 -0
- package/lib/global-settings.d.ts +15 -0
- package/lib/global-settings.js +12 -0
- package/lib/i18n.d.ts +9 -0
- package/lib/i18n.js +9 -0
- package/lib/index.d.ts +14 -1
- package/lib/index.js +13 -1
- package/lib/reporter/github-reporter.d.ts +9 -0
- package/lib/reporter/github-reporter.js +9 -0
- package/lib/reporter/index.d.ts +9 -0
- package/lib/reporter/index.js +9 -0
- package/lib/reporter/simple-reporter.d.ts +11 -0
- package/lib/reporter/simple-reporter.js +11 -0
- package/lib/reporter/standard-reporter.d.ts +12 -0
- package/lib/reporter/standard-reporter.js +12 -0
- package/lib/testing-tool/index.d.ts +44 -0
- package/lib/testing-tool/index.js +32 -0
- package/lib/types.d.ts +3 -0
- package/lib/v1.d.ts +3 -1
- package/lib/v1.js +3 -1
- package/lib/version.d.ts +3 -0
- package/lib/version.js +3 -0
- package/package.json +17 -17
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import type { CLIOptions } from '../cli/bootstrap.js';
|
|
2
2
|
import type { MLResultInfo } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Formats lint results using the standard (detailed) reporter.
|
|
5
|
+
*
|
|
6
|
+
* Produces multi-line output that shows each violation's message with
|
|
7
|
+
* surrounding source code context, highlighted error regions, and
|
|
8
|
+
* line numbers. Clean files are reported as "passed" or "skipped"
|
|
9
|
+
* unless `--problem-only` is set.
|
|
10
|
+
*
|
|
11
|
+
* @param results - The lint result information for a single file.
|
|
12
|
+
* @param options - CLI options controlling color and problem-only output.
|
|
13
|
+
* @returns An array of formatted output lines.
|
|
14
|
+
*/
|
|
3
15
|
export declare function standardReporter(results: MLResultInfo, options: CLIOptions): string[];
|
|
@@ -2,6 +2,18 @@ import { messageToString, font, name, invisibleSpace, space, pad, getWidth, xter
|
|
|
2
2
|
const commandName = name.toLowerCase();
|
|
3
3
|
const loggerError = font.red;
|
|
4
4
|
const loggerWarning = xterm(208);
|
|
5
|
+
/**
|
|
6
|
+
* Formats lint results using the standard (detailed) reporter.
|
|
7
|
+
*
|
|
8
|
+
* Produces multi-line output that shows each violation's message with
|
|
9
|
+
* surrounding source code context, highlighted error regions, and
|
|
10
|
+
* line numbers. Clean files are reported as "passed" or "skipped"
|
|
11
|
+
* unless `--problem-only` is set.
|
|
12
|
+
*
|
|
13
|
+
* @param results - The lint result information for a single file.
|
|
14
|
+
* @param options - CLI options controlling color and problem-only output.
|
|
15
|
+
* @returns An array of formatted output lines.
|
|
16
|
+
*/
|
|
5
17
|
export function standardReporter(results, options) {
|
|
6
18
|
const sizes = {
|
|
7
19
|
line: 0,
|
|
@@ -1,10 +1,32 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Lints inline source code with a given configuration. Convenience function for testing.
|
|
6
|
+
*
|
|
7
|
+
* @param sourceCode - The markup source code to lint
|
|
8
|
+
* @param config - The markuplint configuration to apply
|
|
9
|
+
* @param rules - Optional custom rules; if omitted, preset rules are imported
|
|
10
|
+
* @param locale - The locale for error messages (defaults to `'en'`)
|
|
11
|
+
* @param fix - Whether to attempt auto-fixing
|
|
12
|
+
* @returns An object containing violations and the fixed code
|
|
13
|
+
*/
|
|
4
14
|
export declare function mlTest(sourceCode: string, config: Config, rules?: readonly Readonly<AnyMLRule>[], locale?: string, fix?: boolean): Promise<{
|
|
5
15
|
violations: readonly import("@markuplint/ml-config").Violation[];
|
|
6
16
|
fixedCode: string;
|
|
7
17
|
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Tests a single rule against inline source code. Designed for rule unit testing.
|
|
20
|
+
*
|
|
21
|
+
* @template T - The rule's configuration value type
|
|
22
|
+
* @template O - The rule's options type
|
|
23
|
+
* @param rule - The rule seed to test
|
|
24
|
+
* @param sourceCode - The markup source code to lint
|
|
25
|
+
* @param config - Configuration with rule settings, nodeRule, and childNodeRule
|
|
26
|
+
* @param fix - Whether to attempt auto-fixing
|
|
27
|
+
* @param locale - The locale for error messages (defaults to `'en'`)
|
|
28
|
+
* @returns An object containing violations (without ruleId) and the fixed code
|
|
29
|
+
*/
|
|
8
30
|
export declare function mlRuleTest<T extends RuleConfigValue, O extends PlainData>(rule: Readonly<RuleSeed<T, O>>, sourceCode: string, config?: Omit<Config, 'rules' | 'nodeRules' | 'childNodeRules'> & {
|
|
9
31
|
rule?: Rule<T, Partial<O>>;
|
|
10
32
|
nodeRule?: NodeRule<T, Partial<O>>[];
|
|
@@ -13,10 +35,26 @@ export declare function mlRuleTest<T extends RuleConfigValue, O extends PlainDat
|
|
|
13
35
|
violations: readonly import("@markuplint/ml-config").Violation[];
|
|
14
36
|
fixedCode: string;
|
|
15
37
|
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Lints a file target with a given configuration. Convenience function for integration testing.
|
|
40
|
+
*
|
|
41
|
+
* @param target - A file path or inline source code target
|
|
42
|
+
* @param config - The markuplint configuration to apply
|
|
43
|
+
* @param rules - Optional custom rules; if omitted, preset rules are imported
|
|
44
|
+
* @param locale - The locale for error messages
|
|
45
|
+
* @param fix - Whether to attempt auto-fixing
|
|
46
|
+
* @returns An object containing violations and the fixed code
|
|
47
|
+
*/
|
|
16
48
|
export declare function mlTestFile(target: Target, config?: Config, rules?: readonly Readonly<AnyMLRule>[], locale?: string, fix?: boolean): Promise<{
|
|
17
49
|
violations: readonly import("@markuplint/ml-config").Violation[];
|
|
18
50
|
fixedCode: string | undefined;
|
|
19
51
|
}>;
|
|
52
|
+
/**
|
|
53
|
+
* A node-level rule override configuration for testing, targeting elements by selector.
|
|
54
|
+
*
|
|
55
|
+
* @template T - The rule's configuration value type
|
|
56
|
+
* @template O - The rule's options type
|
|
57
|
+
*/
|
|
20
58
|
export interface NodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
21
59
|
selector?: string;
|
|
22
60
|
regexSelector?: RegexSelector;
|
|
@@ -25,6 +63,12 @@ export interface NodeRule<T extends RuleConfigValue, O extends PlainData = undef
|
|
|
25
63
|
obsolete?: boolean;
|
|
26
64
|
rule?: Rule<T, O>;
|
|
27
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* A child-node-level rule override configuration for testing, targeting child elements by selector.
|
|
68
|
+
*
|
|
69
|
+
* @template T - The rule's configuration value type
|
|
70
|
+
* @template O - The rule's options type
|
|
71
|
+
*/
|
|
28
72
|
export interface ChildNodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
29
73
|
selector?: string;
|
|
30
74
|
regexSelector?: RegexSelector;
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import { MLRule } from '@markuplint/ml-core';
|
|
2
2
|
import { lint } from '../api/index.js';
|
|
3
3
|
import { getGlobal } from '../global-settings.js';
|
|
4
|
+
/**
|
|
5
|
+
* Lints inline source code with a given configuration. Convenience function for testing.
|
|
6
|
+
*
|
|
7
|
+
* @param sourceCode - The markup source code to lint
|
|
8
|
+
* @param config - The markuplint configuration to apply
|
|
9
|
+
* @param rules - Optional custom rules; if omitted, preset rules are imported
|
|
10
|
+
* @param locale - The locale for error messages (defaults to `'en'`)
|
|
11
|
+
* @param fix - Whether to attempt auto-fixing
|
|
12
|
+
* @returns An object containing violations and the fixed code
|
|
13
|
+
*/
|
|
4
14
|
export async function mlTest(sourceCode, config, rules, locale = 'en', fix = false) {
|
|
5
15
|
const global = getGlobal();
|
|
6
16
|
const results = await lint([{ sourceCode }], {
|
|
@@ -18,6 +28,18 @@ export async function mlTest(sourceCode, config, rules, locale = 'en', fix = fal
|
|
|
18
28
|
fixedCode: result?.fixedCode ?? sourceCode,
|
|
19
29
|
};
|
|
20
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Tests a single rule against inline source code. Designed for rule unit testing.
|
|
33
|
+
*
|
|
34
|
+
* @template T - The rule's configuration value type
|
|
35
|
+
* @template O - The rule's options type
|
|
36
|
+
* @param rule - The rule seed to test
|
|
37
|
+
* @param sourceCode - The markup source code to lint
|
|
38
|
+
* @param config - Configuration with rule settings, nodeRule, and childNodeRule
|
|
39
|
+
* @param fix - Whether to attempt auto-fixing
|
|
40
|
+
* @param locale - The locale for error messages (defaults to `'en'`)
|
|
41
|
+
* @returns An object containing violations (without ruleId) and the fixed code
|
|
42
|
+
*/
|
|
21
43
|
export async function mlRuleTest(rule, sourceCode,
|
|
22
44
|
// eslint-disable-next-line unicorn/no-object-as-default-parameter
|
|
23
45
|
config = { rule: true }, fix = false, locale = 'en') {
|
|
@@ -68,6 +90,16 @@ config = { rule: true }, fix = false, locale = 'en') {
|
|
|
68
90
|
});
|
|
69
91
|
return res;
|
|
70
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Lints a file target with a given configuration. Convenience function for integration testing.
|
|
95
|
+
*
|
|
96
|
+
* @param target - A file path or inline source code target
|
|
97
|
+
* @param config - The markuplint configuration to apply
|
|
98
|
+
* @param rules - Optional custom rules; if omitted, preset rules are imported
|
|
99
|
+
* @param locale - The locale for error messages
|
|
100
|
+
* @param fix - Whether to attempt auto-fixing
|
|
101
|
+
* @returns An object containing violations and the fixed code
|
|
102
|
+
*/
|
|
71
103
|
export async function mlTestFile(target, config, rules, locale, fix = false) {
|
|
72
104
|
const global = getGlobal();
|
|
73
105
|
const results = await lint([target], {
|
package/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { Config, PlainData, RuleConfigValue, Violation } from '@markuplint/ml-config';
|
|
2
2
|
import type { Document, Ruleset } from '@markuplint/ml-core';
|
|
3
|
+
/**
|
|
4
|
+
* The result of linting a single file, including violations, source code, and fix results.
|
|
5
|
+
*/
|
|
3
6
|
export interface MLResultInfo {
|
|
4
7
|
readonly violations: readonly Violation[];
|
|
5
8
|
readonly filePath: string;
|
package/lib/v1.d.ts
CHANGED
package/lib/v1.js
CHANGED
package/lib/version.d.ts
CHANGED
package/lib/version.js
CHANGED
|
@@ -2,4 +2,7 @@ import { createRequire } from 'node:module';
|
|
|
2
2
|
const require = createRequire(import.meta.url);
|
|
3
3
|
// TODO: Use import attribute in Node.js v22 and v20.10 or later
|
|
4
4
|
const pkg = require('../package.json');
|
|
5
|
+
/**
|
|
6
|
+
* The current version string of the markuplint package, read from `package.json`.
|
|
7
|
+
*/
|
|
5
8
|
export const version = pkg.version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markuplint",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.18.0",
|
|
4
4
|
"description": "An HTML linter for all markup developers",
|
|
5
5
|
"author": "Yusuke Hirao",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,25 +23,25 @@
|
|
|
23
23
|
"clean": "tsc --build --clean tsconfig.build.json"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@markuplint/cli-utils": "4.
|
|
27
|
-
"@markuplint/file-resolver": "4.
|
|
28
|
-
"@markuplint/html-parser": "4.
|
|
29
|
-
"@markuplint/html-spec": "4.
|
|
30
|
-
"@markuplint/i18n": "4.
|
|
31
|
-
"@markuplint/ml-ast": "4.
|
|
32
|
-
"@markuplint/ml-config": "4.
|
|
33
|
-
"@markuplint/ml-core": "4.
|
|
34
|
-
"@markuplint/ml-spec": "4.
|
|
35
|
-
"@markuplint/rules": "4.
|
|
36
|
-
"@markuplint/shared": "4.
|
|
37
|
-
"@types/debug": "4.1.
|
|
38
|
-
"chokidar": "
|
|
26
|
+
"@markuplint/cli-utils": "4.18.0",
|
|
27
|
+
"@markuplint/file-resolver": "4.18.0",
|
|
28
|
+
"@markuplint/html-parser": "4.18.0",
|
|
29
|
+
"@markuplint/html-spec": "4.18.0",
|
|
30
|
+
"@markuplint/i18n": "4.18.0",
|
|
31
|
+
"@markuplint/ml-ast": "4.18.0",
|
|
32
|
+
"@markuplint/ml-config": "4.18.0",
|
|
33
|
+
"@markuplint/ml-core": "4.18.0",
|
|
34
|
+
"@markuplint/ml-spec": "4.18.0",
|
|
35
|
+
"@markuplint/rules": "4.18.0",
|
|
36
|
+
"@markuplint/shared": "4.18.0",
|
|
37
|
+
"@types/debug": "4.1.13",
|
|
38
|
+
"chokidar": "5.0.0",
|
|
39
39
|
"debug": "4.4.3",
|
|
40
40
|
"meow": "13.2.0",
|
|
41
41
|
"os-locale": "6.0.2",
|
|
42
42
|
"strict-event-emitter": "0.5.1",
|
|
43
|
-
"strip-ansi": "7.
|
|
44
|
-
"type-fest": "
|
|
43
|
+
"strip-ansi": "7.2.0",
|
|
44
|
+
"type-fest": "5.6.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "1885af6349def3f19df975b9e9c399dd47361de1"
|
|
47
47
|
}
|