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
package/lib/cli/bootstrap.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { ReadonlyDeep } from 'type-fest';
|
|
2
|
+
/**
|
|
3
|
+
* Help text displayed when the CLI is invoked with `--help` or without arguments.
|
|
4
|
+
* Documents all available options, flags, and usage examples.
|
|
5
|
+
*/
|
|
2
6
|
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--show-config Output computed configuration of the target file. Supports \"details\" and empty. Default: empty.\n\t--verbose Output with detailed information.\n\t--include-node-modules Include files in node_modules directory. Default: false.\n\t--severity-parse-error Specifies the severity level of parse errors. Supports \"error\", \"warning\", and \"off\". Default: \"error\".\n\t--max-count Limit the number of violations shown. Default: 0 (no limit).\n\t--max-warnings Number of warnings to trigger nonzero exit code. Default: -1 (no limit).\n\t--progressive-output Output results immediately after processing each file. 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";
|
|
7
|
+
/**
|
|
8
|
+
* The parsed CLI instance created by `meow`, providing access to
|
|
9
|
+
* positional arguments (`cli.input`) and parsed flags (`cli.flags`).
|
|
10
|
+
*/
|
|
3
11
|
export declare const cli: import("meow").Result<{
|
|
4
12
|
config: {
|
|
5
13
|
type: "string";
|
|
@@ -84,4 +92,8 @@ export declare const cli: import("meow").Result<{
|
|
|
84
92
|
default: false;
|
|
85
93
|
};
|
|
86
94
|
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Deeply read-only type representing the parsed CLI flags.
|
|
97
|
+
* Derived from the `meow` flag definitions in {@link cli}.
|
|
98
|
+
*/
|
|
87
99
|
export type CLIOptions = ReadonlyDeep<typeof cli.flags>;
|
package/lib/cli/bootstrap.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import meow from 'meow';
|
|
2
|
+
/**
|
|
3
|
+
* Help text displayed when the CLI is invoked with `--help` or without arguments.
|
|
4
|
+
* Documents all available options, flags, and usage examples.
|
|
5
|
+
*/
|
|
2
6
|
export const help = `
|
|
3
7
|
Usage
|
|
4
8
|
$ markuplint <HTML file paths (glob format)>
|
|
@@ -34,6 +38,10 @@ Examples
|
|
|
34
38
|
$ markuplint verifyee.html --config path/to/.markuplintrc
|
|
35
39
|
$ cat verifyee.html | markuplint
|
|
36
40
|
`;
|
|
41
|
+
/**
|
|
42
|
+
* The parsed CLI instance created by `meow`, providing access to
|
|
43
|
+
* positional arguments (`cli.input`) and parsed flags (`cli.flags`).
|
|
44
|
+
*/
|
|
37
45
|
export const cli = meow(help, {
|
|
38
46
|
importMeta: import.meta,
|
|
39
47
|
flags: {
|
package/lib/cli/command.d.ts
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
import type { CLIOptions } from './bootstrap.js';
|
|
2
2
|
import type { APIOptions } from '../api/types.js';
|
|
3
3
|
import type { Target } from '@markuplint/file-resolver';
|
|
4
|
+
/**
|
|
5
|
+
* Executes the markuplint linting command against the given files.
|
|
6
|
+
*
|
|
7
|
+
* Resolves file targets, creates an {@link MLEngine} for each file, collects
|
|
8
|
+
* violations, and outputs results in the requested format. When the `--fix`
|
|
9
|
+
* flag is set, overwrites files with their auto-fixed content.
|
|
10
|
+
*
|
|
11
|
+
* @param files - The list of file targets (paths or inline source code) to lint.
|
|
12
|
+
* @param options - CLI options controlling output format, fix mode, locale, and other behaviors.
|
|
13
|
+
* @param apiOptions - Optional overrides for the underlying API (e.g., custom rules or config).
|
|
14
|
+
* @returns `true` if any errors were found (or warnings exceeded the limit), `false` otherwise.
|
|
15
|
+
*/
|
|
4
16
|
export declare function command(files: readonly Readonly<Target>[], options: CLIOptions, apiOptions?: APIOptions): Promise<boolean>;
|
package/lib/cli/command.js
CHANGED
|
@@ -5,6 +5,18 @@ import { ViolationCollector } from '@markuplint/ml-core';
|
|
|
5
5
|
import { MLEngine } from '../api/index.js';
|
|
6
6
|
import { log } from '../debug.js';
|
|
7
7
|
import { output } from './output.js';
|
|
8
|
+
/**
|
|
9
|
+
* Executes the markuplint linting command against the given files.
|
|
10
|
+
*
|
|
11
|
+
* Resolves file targets, creates an {@link MLEngine} for each file, collects
|
|
12
|
+
* violations, and outputs results in the requested format. When the `--fix`
|
|
13
|
+
* flag is set, overwrites files with their auto-fixed content.
|
|
14
|
+
*
|
|
15
|
+
* @param files - The list of file targets (paths or inline source code) to lint.
|
|
16
|
+
* @param options - CLI options controlling output format, fix mode, locale, and other behaviors.
|
|
17
|
+
* @param apiOptions - Optional overrides for the underlying API (e.g., custom rules or config).
|
|
18
|
+
* @returns `true` if any errors were found (or warnings exceeded the limit), `false` otherwise.
|
|
19
|
+
*/
|
|
8
20
|
export async function command(files, options, apiOptions) {
|
|
9
21
|
const fix = options.fix;
|
|
10
22
|
const configFile = options.config &&
|
package/lib/cli/index.d.ts
CHANGED
package/lib/cli/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module cli
|
|
3
|
+
*
|
|
4
|
+
* CLI entry point for markuplint.
|
|
5
|
+
* Parses command-line arguments, dispatches to the appropriate handler
|
|
6
|
+
* (lint, init, search, or help), and manages the process exit code.
|
|
7
|
+
*/
|
|
1
8
|
import { text } from 'node:stream/consumers';
|
|
2
9
|
import { verbosely } from '../debug.js';
|
|
3
10
|
import { cli } from './bootstrap.js';
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import type { DefaultRules, Langs, RuleSettingMode } from './types.js';
|
|
2
2
|
import type { Config } from '@markuplint/ml-config';
|
|
3
|
+
/**
|
|
4
|
+
* Human-readable display names for each supported template language/framework,
|
|
5
|
+
* shown in the interactive init wizard prompts.
|
|
6
|
+
*/
|
|
3
7
|
export declare const langs: Record<Langs, string>;
|
|
8
|
+
/**
|
|
9
|
+
* Builds a markuplint configuration object based on the user's init wizard selections.
|
|
10
|
+
*
|
|
11
|
+
* Configures parsers and spec modules for the selected template languages,
|
|
12
|
+
* and populates rules based on the chosen rule-setting mode (custom categories,
|
|
13
|
+
* recommended preset, or all defaults).
|
|
14
|
+
*
|
|
15
|
+
* @param langs - The template languages/frameworks selected by the user.
|
|
16
|
+
* @param mode - The rule selection mode: an array of categories, `'recommended'`, or `'none'`.
|
|
17
|
+
* @param defaultRules - The full set of available default rules with their categories and values.
|
|
18
|
+
* @returns A complete markuplint `Config` object ready to be serialized to a file.
|
|
19
|
+
*/
|
|
4
20
|
export declare function createConfig(langs: readonly Langs[], mode: RuleSettingMode, defaultRules: DefaultRules): Config;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps each supported language/framework to a file-extension regular expression
|
|
3
|
+
* used in the generated configuration's `parser` field.
|
|
4
|
+
*/
|
|
1
5
|
const extRExp = {
|
|
2
6
|
jsx: '\\.[jt]sx?$',
|
|
3
7
|
vue: '\\.vue$',
|
|
@@ -14,6 +18,10 @@ const extRExp = {
|
|
|
14
18
|
nunjucks: '\\.nunjucks$',
|
|
15
19
|
liquid: '\\.liquid$',
|
|
16
20
|
};
|
|
21
|
+
/**
|
|
22
|
+
* Human-readable display names for each supported template language/framework,
|
|
23
|
+
* shown in the interactive init wizard prompts.
|
|
24
|
+
*/
|
|
17
25
|
export const langs = {
|
|
18
26
|
jsx: 'React (JSX)',
|
|
19
27
|
vue: 'Vue',
|
|
@@ -30,6 +38,18 @@ export const langs = {
|
|
|
30
38
|
nunjucks: 'Nunjucks',
|
|
31
39
|
liquid: 'liquid (Shopify)',
|
|
32
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Builds a markuplint configuration object based on the user's init wizard selections.
|
|
43
|
+
*
|
|
44
|
+
* Configures parsers and spec modules for the selected template languages,
|
|
45
|
+
* and populates rules based on the chosen rule-setting mode (custom categories,
|
|
46
|
+
* recommended preset, or all defaults).
|
|
47
|
+
*
|
|
48
|
+
* @param langs - The template languages/frameworks selected by the user.
|
|
49
|
+
* @param mode - The rule selection mode: an array of categories, `'recommended'`, or `'none'`.
|
|
50
|
+
* @param defaultRules - The full set of available default rules with their categories and values.
|
|
51
|
+
* @returns A complete markuplint `Config` object ready to be serialized to a file.
|
|
52
|
+
*/
|
|
33
53
|
export function createConfig(langs, mode, defaultRules) {
|
|
34
54
|
let config = {};
|
|
35
55
|
const parser = { ...config.parser };
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects all built-in rules that have a defined category and returns them
|
|
3
|
+
* as a record of rule name to rule metadata.
|
|
4
|
+
*
|
|
5
|
+
* Rules with `'warning'` default severity are disabled by default (`false`),
|
|
6
|
+
* while all others use their defined default value or `true`.
|
|
7
|
+
*
|
|
8
|
+
* @returns A read-only mapping from rule names to their category and default configuration value.
|
|
9
|
+
*/
|
|
1
10
|
export declare function getDefaultRules(): {
|
|
2
11
|
[x: string]: import("./types.js").Rule;
|
|
3
12
|
};
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import builtinRules from '@markuplint/rules';
|
|
2
|
+
/**
|
|
3
|
+
* Collects all built-in rules that have a defined category and returns them
|
|
4
|
+
* as a record of rule name to rule metadata.
|
|
5
|
+
*
|
|
6
|
+
* Rules with `'warning'` default severity are disabled by default (`false`),
|
|
7
|
+
* while all others use their defined default value or `true`.
|
|
8
|
+
*
|
|
9
|
+
* @returns A read-only mapping from rule names to their category and default configuration value.
|
|
10
|
+
*/
|
|
2
11
|
export function getDefaultRules() {
|
|
3
12
|
const rules = {};
|
|
4
13
|
for (const [ruleName, rule] of Object.entries(builtinRules)) {
|
package/lib/cli/init/index.d.ts
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module cli/init
|
|
3
|
+
*
|
|
4
|
+
* Interactive initialization wizard for markuplint.
|
|
5
|
+
* Guides the user through selecting template engines, rule categories,
|
|
6
|
+
* and dependency installation, then writes a `.markuplintrc` config file.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Runs the interactive initialization flow.
|
|
10
|
+
*
|
|
11
|
+
* Prompts the user to select template engines, choose rule categories or the
|
|
12
|
+
* recommended preset, generates a `.markuplintrc` configuration file in the
|
|
13
|
+
* current working directory, and optionally installs the required npm packages.
|
|
14
|
+
*/
|
|
1
15
|
export declare function initialize(): Promise<void>;
|
package/lib/cli/init/index.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module cli/init
|
|
3
|
+
*
|
|
4
|
+
* Interactive initialization wizard for markuplint.
|
|
5
|
+
* Guides the user through selecting template engines, rule categories,
|
|
6
|
+
* and dependency installation, then writes a `.markuplintrc` config file.
|
|
7
|
+
*/
|
|
1
8
|
import fs from 'node:fs/promises';
|
|
2
9
|
import path from 'node:path';
|
|
3
10
|
import { installModule, multiSelect, confirm, confirmSequence, header } from '@markuplint/cli-utils';
|
|
@@ -21,6 +28,13 @@ const ruleCategories = {
|
|
|
21
28
|
message: 'Are you going to check for the code styles?',
|
|
22
29
|
},
|
|
23
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* Runs the interactive initialization flow.
|
|
33
|
+
*
|
|
34
|
+
* Prompts the user to select template engines, choose rule categories or the
|
|
35
|
+
* recommended preset, generates a `.markuplintrc` configuration file in the
|
|
36
|
+
* current working directory, and optionally installs the required npm packages.
|
|
37
|
+
*/
|
|
24
38
|
export async function initialize() {
|
|
25
39
|
process.stdout.write(header('Initialization'));
|
|
26
40
|
process.stdout.write('\n');
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { Langs } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determines the list of npm modules that need to be installed based on the
|
|
4
|
+
* user's template language selections.
|
|
5
|
+
*
|
|
6
|
+
* Always includes `markuplint` itself, adds a parser package for each selected
|
|
7
|
+
* language, and includes spec packages for Vue and React when applicable.
|
|
8
|
+
*
|
|
9
|
+
* @param selectedLangs - The template languages/frameworks selected by the user.
|
|
10
|
+
* @returns An array of npm package names to install.
|
|
11
|
+
*/
|
|
2
12
|
export declare function selectModules(selectedLangs: readonly Langs[]): string[];
|
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines the list of npm modules that need to be installed based on the
|
|
3
|
+
* user's template language selections.
|
|
4
|
+
*
|
|
5
|
+
* Always includes `markuplint` itself, adds a parser package for each selected
|
|
6
|
+
* language, and includes spec packages for Vue and React when applicable.
|
|
7
|
+
*
|
|
8
|
+
* @param selectedLangs - The template languages/frameworks selected by the user.
|
|
9
|
+
* @returns An array of npm package names to install.
|
|
10
|
+
*/
|
|
1
11
|
export function selectModules(selectedLangs) {
|
|
2
12
|
const modules = ['markuplint', ...selectedLangs.map(lang => `@markuplint/${lang}-parser`)];
|
|
3
13
|
if (selectedLangs.includes('vue')) {
|
package/lib/cli/init/types.d.ts
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
2
|
+
/**
|
|
3
|
+
* Identifiers for template engines and frameworks supported by the init wizard.
|
|
4
|
+
*/
|
|
2
5
|
export type Langs = 'jsx' | 'vue' | 'svelte' | 'sveltekit' | 'astro' | 'alpine' | 'pug' | 'php' | 'smarty' | 'erb' | 'ejs' | 'mustache' | 'nunjucks' | 'liquid';
|
|
6
|
+
/**
|
|
7
|
+
* Rule categories used to group lint rules during interactive initialization.
|
|
8
|
+
*/
|
|
3
9
|
export type Category = 'validation' | 'a11y' | 'naming-convention' | 'style' | 'maintainability';
|
|
10
|
+
/**
|
|
11
|
+
* Determines how rules are selected during initialization.
|
|
12
|
+
*
|
|
13
|
+
* - An array of {@link Category} values enables per-category customization.
|
|
14
|
+
* - `'recommended'` applies the built-in recommended preset.
|
|
15
|
+
* - `'none'` skips rule configuration entirely.
|
|
16
|
+
*/
|
|
4
17
|
export type RuleSettingMode = readonly Category[] | 'recommended' | 'none';
|
|
18
|
+
/**
|
|
19
|
+
* A mapping from rule names to their metadata, used to populate default rule values.
|
|
20
|
+
*/
|
|
5
21
|
export type DefaultRules = Readonly<Record<string, Rule>>;
|
|
22
|
+
/**
|
|
23
|
+
* Metadata for a single rule as used by the init wizard.
|
|
24
|
+
*/
|
|
6
25
|
export type Rule = {
|
|
7
26
|
readonly category: Category;
|
|
8
27
|
readonly defaultValue: RuleConfigValue;
|
package/lib/cli/output.d.ts
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { CLIOptions } from './bootstrap.js';
|
|
2
2
|
import type { MLResultInfo } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Writes lint results to stdout or stderr using the reporter selected by `--format`.
|
|
5
|
+
*
|
|
6
|
+
* Violations are written to stderr (and set `process.exitCode` to 1),
|
|
7
|
+
* while clean results are written to stdout. When `--no-color` is set,
|
|
8
|
+
* ANSI escape codes are stripped before output. JSON format is handled
|
|
9
|
+
* separately by the caller, so this function returns early for JSON.
|
|
10
|
+
*
|
|
11
|
+
* @param results - The lint result information for a single file.
|
|
12
|
+
* @param options - CLI options that control the output format and color.
|
|
13
|
+
*/
|
|
3
14
|
export declare function output(results: MLResultInfo, options: CLIOptions): void;
|
package/lib/cli/output.js
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
import stripAnsi from 'strip-ansi';
|
|
2
2
|
import { simpleReporter, standardReporter, githubReporter } from '../reporter/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Writes lint results to stdout or stderr using the reporter selected by `--format`.
|
|
5
|
+
*
|
|
6
|
+
* Violations are written to stderr (and set `process.exitCode` to 1),
|
|
7
|
+
* while clean results are written to stdout. When `--no-color` is set,
|
|
8
|
+
* ANSI escape codes are stripped before output. JSON format is handled
|
|
9
|
+
* separately by the caller, so this function returns early for JSON.
|
|
10
|
+
*
|
|
11
|
+
* @param results - The lint result information for a single file.
|
|
12
|
+
* @param options - CLI options that control the output format and color.
|
|
13
|
+
*/
|
|
3
14
|
export function output(results, options) {
|
|
4
15
|
const format = options.format ?? 'Standard';
|
|
5
16
|
let out;
|
|
@@ -1,2 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module cli/search
|
|
3
|
+
*
|
|
4
|
+
* Element search subcommand for the markuplint CLI.
|
|
5
|
+
* Finds lines of code that match the given CSS selectors across the target files
|
|
6
|
+
* and outputs their locations in `file:line:col` format.
|
|
7
|
+
*/
|
|
1
8
|
import type { CLIOptions } from '../bootstrap.js';
|
|
9
|
+
/**
|
|
10
|
+
* Searches the given files for elements matching a CSS selector and prints their locations.
|
|
11
|
+
*
|
|
12
|
+
* Internally creates a temporary lint rule that uses `document.querySelectorAll`
|
|
13
|
+
* to find matching nodes, then outputs each match as `file:line:col` to stdout.
|
|
14
|
+
*
|
|
15
|
+
* @param files - The file paths (or glob patterns) to search.
|
|
16
|
+
* @param options - CLI options forwarded to the underlying lint command.
|
|
17
|
+
* @param selectors - A CSS selector string to match elements against.
|
|
18
|
+
*/
|
|
2
19
|
export declare function search(files: readonly string[], options: CLIOptions, selectors: string): Promise<void>;
|
package/lib/cli/search/index.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module cli/search
|
|
3
|
+
*
|
|
4
|
+
* Element search subcommand for the markuplint CLI.
|
|
5
|
+
* Finds lines of code that match the given CSS selectors across the target files
|
|
6
|
+
* and outputs their locations in `file:line:col` format.
|
|
7
|
+
*/
|
|
1
8
|
import { createRule, MLRule } from '@markuplint/ml-core';
|
|
2
9
|
import { command } from '../command.js';
|
|
10
|
+
/**
|
|
11
|
+
* Searches the given files for elements matching a CSS selector and prints their locations.
|
|
12
|
+
*
|
|
13
|
+
* Internally creates a temporary lint rule that uses `document.querySelectorAll`
|
|
14
|
+
* to find matching nodes, then outputs each match as `file:line:col` to stdout.
|
|
15
|
+
*
|
|
16
|
+
* @param files - The file paths (or glob patterns) to search.
|
|
17
|
+
* @param options - CLI options forwarded to the underlying lint command.
|
|
18
|
+
* @param selectors - A CSS selector string to match elements against.
|
|
19
|
+
*/
|
|
3
20
|
export async function search(files, options, selectors) {
|
|
4
21
|
const name = '__CLI_SEARCH__';
|
|
5
22
|
const locations = [];
|
package/lib/debug.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
1
|
import debug from 'debug';
|
|
2
|
+
/**
|
|
3
|
+
* Debug logger instance for the markuplint CLI, using the `markuplint-cli` namespace.
|
|
4
|
+
*/
|
|
2
5
|
export declare const log: debug.Debugger;
|
|
6
|
+
/**
|
|
7
|
+
* Enables verbose debug logging for both the CLI and the core library.
|
|
8
|
+
*
|
|
9
|
+
* When called, it activates the `markuplint-cli*` and `ml-*` debug namespaces
|
|
10
|
+
* and turns on the core library's internal debug output.
|
|
11
|
+
*/
|
|
3
12
|
export declare function verbosely(): void;
|
package/lib/debug.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { enableDebug } from '@markuplint/ml-core';
|
|
2
2
|
import debug from 'debug';
|
|
3
|
+
/**
|
|
4
|
+
* Debug logger instance for the markuplint CLI, using the `markuplint-cli` namespace.
|
|
5
|
+
*/
|
|
3
6
|
export const log = debug('markuplint-cli');
|
|
7
|
+
/**
|
|
8
|
+
* Enables verbose debug logging for both the CLI and the core library.
|
|
9
|
+
*
|
|
10
|
+
* When called, it activates the `markuplint-cli*` and `ml-*` debug namespaces
|
|
11
|
+
* and turns on the core library's internal debug output.
|
|
12
|
+
*/
|
|
4
13
|
export function verbosely() {
|
|
5
14
|
if (!log.enabled) {
|
|
6
15
|
const namespace = `${log.namespace}*,ml-*`;
|
package/lib/get-json-module.d.ts
CHANGED
|
@@ -1 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads a JSON module by its path using `require`, returning `null` if the module cannot be found.
|
|
3
|
+
*
|
|
4
|
+
* This is a safe wrapper around `require` that swallows resolution errors,
|
|
5
|
+
* making it suitable for optional module loading (e.g., locale files).
|
|
6
|
+
*
|
|
7
|
+
* @template T - The expected shape of the JSON module.
|
|
8
|
+
* @param modulePath - The module specifier or file path to load.
|
|
9
|
+
* @returns The parsed JSON module, or `null` if it could not be loaded.
|
|
10
|
+
*/
|
|
1
11
|
export declare function getJsonModule<T extends {}>(modulePath: string): T | null;
|
package/lib/get-json-module.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import { createRequire } from 'node:module';
|
|
2
2
|
const require = createRequire(import.meta.url);
|
|
3
|
+
/**
|
|
4
|
+
* Loads a JSON module by its path using `require`, returning `null` if the module cannot be found.
|
|
5
|
+
*
|
|
6
|
+
* This is a safe wrapper around `require` that swallows resolution errors,
|
|
7
|
+
* making it suitable for optional module loading (e.g., locale files).
|
|
8
|
+
*
|
|
9
|
+
* @template T - The expected shape of the JSON module.
|
|
10
|
+
* @param modulePath - The module specifier or file path to load.
|
|
11
|
+
* @returns The parsed JSON module, or `null` if it could not be loaded.
|
|
12
|
+
*/
|
|
3
13
|
export function getJsonModule(modulePath) {
|
|
4
14
|
try {
|
|
5
15
|
return require(modulePath);
|
package/lib/global-settings.d.ts
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shape of the global settings that apply across all markuplint operations.
|
|
3
|
+
*/
|
|
1
4
|
export type GlobalSettings = {
|
|
2
5
|
readonly locale: string;
|
|
3
6
|
};
|
|
7
|
+
/**
|
|
8
|
+
* Merges the provided settings into the current global settings.
|
|
9
|
+
*
|
|
10
|
+
* Settings are shallowly merged, so only the specified keys are overwritten.
|
|
11
|
+
*
|
|
12
|
+
* @param settings - A partial set of global settings to apply.
|
|
13
|
+
*/
|
|
4
14
|
export declare function setGlobal(settings: Partial<GlobalSettings>): void;
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current global settings as a read-only object.
|
|
17
|
+
*
|
|
18
|
+
* @returns The current global settings.
|
|
19
|
+
*/
|
|
5
20
|
export declare function getGlobal(): Readonly<Partial<GlobalSettings>>;
|
package/lib/global-settings.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
let globalSettings = {};
|
|
2
|
+
/**
|
|
3
|
+
* Merges the provided settings into the current global settings.
|
|
4
|
+
*
|
|
5
|
+
* Settings are shallowly merged, so only the specified keys are overwritten.
|
|
6
|
+
*
|
|
7
|
+
* @param settings - A partial set of global settings to apply.
|
|
8
|
+
*/
|
|
2
9
|
export function setGlobal(settings) {
|
|
3
10
|
globalSettings = {
|
|
4
11
|
...globalSettings,
|
|
5
12
|
...settings,
|
|
6
13
|
};
|
|
7
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Returns the current global settings as a read-only object.
|
|
17
|
+
*
|
|
18
|
+
* @returns The current global settings.
|
|
19
|
+
*/
|
|
8
20
|
export function getGlobal() {
|
|
9
21
|
return globalSettings;
|
|
10
22
|
}
|
package/lib/i18n.d.ts
CHANGED
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { LocaleSet } from '@markuplint/i18n';
|
|
2
|
+
/**
|
|
3
|
+
* Loads the locale-specific message set for use in violation messages.
|
|
4
|
+
*
|
|
5
|
+
* If no locale is provided, it auto-detects the OS locale. When the requested
|
|
6
|
+
* locale is not available, it falls back to English (`en`).
|
|
7
|
+
*
|
|
8
|
+
* @param locale - An optional BCP 47 locale string (e.g., `"ja"`, `"en-US"`).
|
|
9
|
+
* @returns The loaded locale set containing translated messages and the resolved locale code.
|
|
10
|
+
*/
|
|
2
11
|
export declare function i18n(locale?: string): Promise<LocaleSet>;
|
package/lib/i18n.js
CHANGED
|
@@ -7,6 +7,15 @@ async function getLocale() {
|
|
|
7
7
|
}
|
|
8
8
|
return cachedLocale;
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Loads the locale-specific message set for use in violation messages.
|
|
12
|
+
*
|
|
13
|
+
* If no locale is provided, it auto-detects the OS locale. When the requested
|
|
14
|
+
* locale is not available, it falls back to English (`en`).
|
|
15
|
+
*
|
|
16
|
+
* @param locale - An optional BCP 47 locale string (e.g., `"ja"`, `"en-US"`).
|
|
17
|
+
* @returns The loaded locale set containing translated messages and the resolved locale code.
|
|
18
|
+
*/
|
|
10
19
|
export async function i18n(locale) {
|
|
11
20
|
locale = locale ?? (await getLocale()) ?? 'en';
|
|
12
21
|
const langCode = locale.split('-')[0] ?? locale;
|
package/lib/index.d.ts
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module markuplint
|
|
3
|
+
*
|
|
4
|
+
* Main package entry point for markuplint.
|
|
5
|
+
* Re-exports the public API surface including the lint engine, types,
|
|
6
|
+
* internationalization utilities, testing tools, and version information.
|
|
7
|
+
*/
|
|
8
|
+
/** The primary linting engine and options for linting from source code strings. */
|
|
1
9
|
export { MLEngine, FromCodeOptions } from './api/index.js';
|
|
10
|
+
/** Event map type describing events emitted by {@link MLEngine}. */
|
|
2
11
|
export { MLEngineEventMap } from './api/types.js';
|
|
12
|
+
/** Internationalization utilities for loading locale-specific message sets. */
|
|
3
13
|
export * from './i18n.js';
|
|
14
|
+
/** Testing utilities for verifying markuplint rules and configurations. */
|
|
4
15
|
export * from './testing-tool/index.js';
|
|
16
|
+
/** Shared type definitions for lint results and violations. */
|
|
5
17
|
export * from './types.js';
|
|
18
|
+
/** The current markuplint package version string. */
|
|
6
19
|
export { version } from './version.js';
|
|
7
20
|
/**
|
|
8
|
-
* @deprecated
|
|
21
|
+
* @deprecated Use the current API exports instead.
|
|
9
22
|
*/
|
|
10
23
|
export * from './v1.js';
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module markuplint
|
|
3
|
+
*
|
|
4
|
+
* Main package entry point for markuplint.
|
|
5
|
+
* Re-exports the public API surface including the lint engine, types,
|
|
6
|
+
* internationalization utilities, testing tools, and version information.
|
|
7
|
+
*/
|
|
8
|
+
/** The primary linting engine and options for linting from source code strings. */
|
|
1
9
|
export { MLEngine } from './api/index.js';
|
|
10
|
+
/** Internationalization utilities for loading locale-specific message sets. */
|
|
2
11
|
export * from './i18n.js';
|
|
12
|
+
/** Testing utilities for verifying markuplint rules and configurations. */
|
|
3
13
|
export * from './testing-tool/index.js';
|
|
14
|
+
/** Shared type definitions for lint results and violations. */
|
|
4
15
|
export * from './types.js';
|
|
16
|
+
/** The current markuplint package version string. */
|
|
5
17
|
export { version } from './version.js';
|
|
6
18
|
/**
|
|
7
|
-
* @deprecated
|
|
19
|
+
* @deprecated Use the current API exports instead.
|
|
8
20
|
*/
|
|
9
21
|
export * from './v1.js';
|
|
@@ -1,2 +1,11 @@
|
|
|
1
1
|
import type { MLResultInfo } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Formats lint results as GitHub Actions workflow commands.
|
|
4
|
+
*
|
|
5
|
+
* Each violation is emitted as a `::error`, `::warning`, or `::notice` command
|
|
6
|
+
* that GitHub Actions interprets as an inline annotation on the affected file and line.
|
|
7
|
+
*
|
|
8
|
+
* @param results - The lint result information for a single file.
|
|
9
|
+
* @returns An array of GitHub Actions workflow command strings.
|
|
10
|
+
*/
|
|
2
11
|
export declare function githubReporter(results: MLResultInfo): string[];
|
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { messageToString } from '@markuplint/cli-utils';
|
|
2
|
+
/**
|
|
3
|
+
* Formats lint results as GitHub Actions workflow commands.
|
|
4
|
+
*
|
|
5
|
+
* Each violation is emitted as a `::error`, `::warning`, or `::notice` command
|
|
6
|
+
* that GitHub Actions interprets as an inline annotation on the affected file and line.
|
|
7
|
+
*
|
|
8
|
+
* @param results - The lint result information for a single file.
|
|
9
|
+
* @returns An array of GitHub Actions workflow command strings.
|
|
10
|
+
*/
|
|
2
11
|
export function githubReporter(results) {
|
|
3
12
|
const out = [];
|
|
4
13
|
for (const violation of results.violations) {
|
package/lib/reporter/index.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module reporter
|
|
3
|
+
*
|
|
4
|
+
* Output reporters for markuplint lint results.
|
|
5
|
+
* Provides standard (detailed), simple (compact), and GitHub Actions annotation formats.
|
|
6
|
+
*/
|
|
7
|
+
/** Detailed multi-line reporter showing source context around each violation. */
|
|
1
8
|
export * from './standard-reporter.js';
|
|
9
|
+
/** Compact single-line-per-violation reporter. */
|
|
2
10
|
export * from './simple-reporter.js';
|
|
11
|
+
/** GitHub Actions workflow command reporter using `::error` and `::warning` annotations. */
|
|
3
12
|
export * from './github-reporter.js';
|
package/lib/reporter/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module reporter
|
|
3
|
+
*
|
|
4
|
+
* Output reporters for markuplint lint results.
|
|
5
|
+
* Provides standard (detailed), simple (compact), and GitHub Actions annotation formats.
|
|
6
|
+
*/
|
|
7
|
+
/** Detailed multi-line reporter showing source context around each violation. */
|
|
1
8
|
export * from './standard-reporter.js';
|
|
9
|
+
/** Compact single-line-per-violation reporter. */
|
|
2
10
|
export * from './simple-reporter.js';
|
|
11
|
+
/** GitHub Actions workflow command reporter using `::error` and `::warning` annotations. */
|
|
3
12
|
export * from './github-reporter.js';
|
|
@@ -1,3 +1,14 @@
|
|
|
1
1
|
import type { CLIOptions } from '../cli/bootstrap.js';
|
|
2
2
|
import type { MLResultInfo } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Formats lint results using the simple (compact) reporter.
|
|
5
|
+
*
|
|
6
|
+
* Produces one line per violation showing location, severity icon,
|
|
7
|
+
* message, and rule ID in a condensed format. Clean files display
|
|
8
|
+
* a check mark or warning icon unless `--problem-only` is set.
|
|
9
|
+
*
|
|
10
|
+
* @param results - The lint result information for a single file.
|
|
11
|
+
* @param options - CLI options controlling problem-only output.
|
|
12
|
+
* @returns An array of formatted output lines.
|
|
13
|
+
*/
|
|
3
14
|
export declare function simpleReporter(results: MLResultInfo, options: CLIOptions): string[];
|
|
@@ -2,6 +2,17 @@ import { name, font, pad, getWidth, messageToString, xterm } from '@markuplint/c
|
|
|
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 simple (compact) reporter.
|
|
7
|
+
*
|
|
8
|
+
* Produces one line per violation showing location, severity icon,
|
|
9
|
+
* message, and rule ID in a condensed format. Clean files display
|
|
10
|
+
* a check mark or warning icon unless `--problem-only` is set.
|
|
11
|
+
*
|
|
12
|
+
* @param results - The lint result information for a single file.
|
|
13
|
+
* @param options - CLI options controlling problem-only output.
|
|
14
|
+
* @returns An array of formatted output lines.
|
|
15
|
+
*/
|
|
5
16
|
export function simpleReporter(results, options) {
|
|
6
17
|
const sizes = {
|
|
7
18
|
line: 0,
|