markuplint 3.3.1 → 3.5.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/README.md +1 -1
- package/lib/api/lint.d.ts +2 -2
- package/lib/api/ml-engine.d.ts +22 -21
- package/lib/api/ml-engine.js +9 -3
- package/lib/api/types.d.ts +26 -44
- package/lib/api/v1.d.ts +44 -44
- package/lib/cli/bootstrap.d.ts +54 -54
- package/lib/cli/command.d.ts +2 -2
- package/lib/cli/init/create-config.d.ts +1 -1
- package/lib/cli/init/create-config.js +22 -13
- package/lib/cli/init/get-default-rules.d.ts +3 -2
- package/lib/cli/init/install-module.d.ts +4 -4
- package/lib/cli/init/types.d.ts +5 -17
- package/lib/cli/output.d.ts +1 -1
- package/lib/cli/prompt.d.ts +13 -18
- package/lib/cli/search/index.d.ts +1 -1
- package/lib/global-settings.d.ts +1 -1
- package/lib/i18n.js +3 -3
- package/lib/testing-tool/index.d.ts +26 -44
- package/lib/types.d.ts +18 -18
- package/lib/util.d.ts +3 -3
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://github.com/markuplint/markuplint)
|
|
8
8
|
[](https://twitter.com/intent/user?screen_name=markuplint)
|
|
9
9
|
|
|
10
|
-
**Peace of mind in your markup** -
|
|
10
|
+
**Peace of mind in your markup** - An HTML linter for all markup developers.
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
package/lib/api/lint.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MLResultInfo } from '../types';
|
|
2
1
|
import type { APIOptions } from './types';
|
|
2
|
+
import type { MLResultInfo } from '../types';
|
|
3
3
|
import type { Target } from '@markuplint/file-resolver';
|
|
4
|
-
export declare function lint(targetList: Target[], options?: APIOptions): Promise<MLResultInfo[]>;
|
|
4
|
+
export declare function lint(targetList: readonly Readonly<Target>[], options?: APIOptions): Promise<MLResultInfo[]>;
|
package/lib/api/ml-engine.d.ts
CHANGED
|
@@ -1,30 +1,31 @@
|
|
|
1
|
-
import type { MLResultInfo } from '../types';
|
|
2
1
|
import type { APIOptions, MLEngineEventMap } from './types';
|
|
2
|
+
import type { MLResultInfo } from '../types';
|
|
3
3
|
import type { MLFile, Target } from '@markuplint/file-resolver';
|
|
4
|
+
import type { PlainData } from '@markuplint/ml-config';
|
|
4
5
|
import type { Document, RuleConfigValue } from '@markuplint/ml-core';
|
|
5
6
|
import { StrictEventEmitter } from 'strict-event-emitter';
|
|
6
7
|
type MLEngineOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
readonly debug?: boolean;
|
|
9
|
+
readonly watch?: boolean;
|
|
9
10
|
};
|
|
10
11
|
export default class MLEngine extends StrictEventEmitter<MLEngineEventMap> {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
12
|
+
#private;
|
|
13
|
+
static toMLFile(target: Target): Promise<MLFile | undefined>;
|
|
14
|
+
constructor(file: Readonly<MLFile>, options?: APIOptions & MLEngineOptions);
|
|
15
|
+
get document(): Document<RuleConfigValue, PlainData> | null;
|
|
16
|
+
close(): Promise<void>;
|
|
17
|
+
exec(): Promise<MLResultInfo | null>;
|
|
18
|
+
setCode(code: string): Promise<void>;
|
|
19
|
+
watchMode(enable: boolean): void;
|
|
20
|
+
private createCore;
|
|
21
|
+
private i18n;
|
|
22
|
+
private onChange;
|
|
23
|
+
private provide;
|
|
24
|
+
private resolveConfig;
|
|
25
|
+
private resolveParser;
|
|
26
|
+
private resolveRules;
|
|
27
|
+
private resolveRuleset;
|
|
28
|
+
private resolveSchemas;
|
|
29
|
+
private setup;
|
|
29
30
|
}
|
|
30
31
|
export {};
|
package/lib/api/ml-engine.js
CHANGED
|
@@ -238,7 +238,9 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
238
238
|
}
|
|
239
239
|
return configSet;
|
|
240
240
|
}
|
|
241
|
-
async resolveParser(
|
|
241
|
+
async resolveParser(
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
243
|
+
configSet) {
|
|
242
244
|
const parser = await (0, file_resolver_1.resolveParser)(tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f"), configSet.config.parser, configSet.config.parserOptions);
|
|
243
245
|
this.emit('parser', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, parser.parserModName);
|
|
244
246
|
fileLog('Fetched Parser module: %s', parser.parserModName);
|
|
@@ -253,12 +255,16 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
253
255
|
this.emit('rules', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, rules);
|
|
254
256
|
return rules;
|
|
255
257
|
}
|
|
256
|
-
resolveRuleset(
|
|
258
|
+
resolveRuleset(
|
|
259
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
260
|
+
configSet) {
|
|
257
261
|
const ruleset = (0, ml_core_1.convertRuleset)(configSet.config);
|
|
258
262
|
this.emit('ruleset', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, ruleset);
|
|
259
263
|
return ruleset;
|
|
260
264
|
}
|
|
261
|
-
async resolveSchemas(
|
|
265
|
+
async resolveSchemas(
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
|
|
267
|
+
configSet) {
|
|
262
268
|
const { schemas } = await (0, file_resolver_1.resolveSpecs)(tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, configSet.config.specs);
|
|
263
269
|
this.emit('schemas', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, schemas);
|
|
264
270
|
return schemas;
|
package/lib/api/types.d.ts
CHANGED
|
@@ -1,51 +1,33 @@
|
|
|
1
1
|
import type { ConfigSet } from '@markuplint/file-resolver';
|
|
2
2
|
import type { LocaleSet } from '@markuplint/i18n';
|
|
3
|
-
import type {
|
|
4
|
-
import type { Config, Pretender, Violation } from '@markuplint/ml-config';
|
|
3
|
+
import type { Config, Violation } from '@markuplint/ml-config';
|
|
5
4
|
import type { AnyMLRule, MLSchema, Ruleset } from '@markuplint/ml-core';
|
|
6
5
|
export type APIOptions = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
export type MLFabric = {
|
|
22
|
-
ruleset: Ruleset;
|
|
23
|
-
rules: AnyMLRule[];
|
|
24
|
-
schemas: MLSchema;
|
|
25
|
-
parser: MLMarkupLanguageParser;
|
|
26
|
-
parserOptions: ParserOptions;
|
|
27
|
-
pretenders: Pretender[];
|
|
28
|
-
locale: LocaleSet;
|
|
29
|
-
configErrors?: Error[];
|
|
6
|
+
readonly configFile?: string;
|
|
7
|
+
readonly config?: Config;
|
|
8
|
+
readonly defaultConfig?: Config;
|
|
9
|
+
readonly noSearchConfig?: boolean;
|
|
10
|
+
readonly locale?: string;
|
|
11
|
+
readonly fix?: boolean;
|
|
12
|
+
readonly ignoreExt?: boolean;
|
|
13
|
+
readonly rules?: readonly Readonly<AnyMLRule>[];
|
|
14
|
+
readonly importPresetRules?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated
|
|
17
|
+
*/
|
|
18
|
+
readonly autoLoad?: boolean;
|
|
30
19
|
};
|
|
31
20
|
export type MLEngineEventMap = {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
violations: Violation[],
|
|
45
|
-
fixedCode: string,
|
|
46
|
-
debug: string[] | null,
|
|
47
|
-
message?: string,
|
|
48
|
-
) => void;
|
|
49
|
-
'lint-error': (filePath: string, sourceCode: string, error: Error) => void;
|
|
50
|
-
'config-errors': (filePath: string, errors: Error[]) => void;
|
|
21
|
+
log: (phase: string, message: string) => void;
|
|
22
|
+
config: (filePath: string, config: ConfigSet, message?: string) => void;
|
|
23
|
+
exclude: (filePath: string, setting: string, message?: string) => void;
|
|
24
|
+
parser: (filePath: string, parser: string, message?: string) => void;
|
|
25
|
+
ruleset: (filePath: string, ruleset: Ruleset, message?: string) => void;
|
|
26
|
+
schemas: (filePath: string, schemas: MLSchema, message?: string) => void;
|
|
27
|
+
rules: (filePath: string, rules: readonly Readonly<AnyMLRule>[], message?: string) => void;
|
|
28
|
+
i18n: (filePath: string, locale: LocaleSet, message?: string) => void;
|
|
29
|
+
code: (filePath: string, sourceCode: string, message?: string) => void;
|
|
30
|
+
lint: (filePath: string, sourceCode: string, violations: readonly Violation[], fixedCode: string, debug: readonly string[] | null, message?: string) => void;
|
|
31
|
+
'lint-error': (filePath: string, sourceCode: string, error: Readonly<Error>) => void;
|
|
32
|
+
'config-errors': (filePath: string, errors: readonly Readonly<Error>[]) => void;
|
|
51
33
|
};
|
package/lib/api/v1.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Config, RuleConfigValue } from '@markuplint/ml-config';
|
|
1
|
+
import type { Config, PlainData, RuleConfigValue } from '@markuplint/ml-config';
|
|
2
2
|
import type { MLRule } from '@markuplint/ml-core';
|
|
3
3
|
/**
|
|
4
4
|
* @deprecated
|
|
@@ -6,46 +6,46 @@ import type { MLRule } from '@markuplint/ml-core';
|
|
|
6
6
|
* @returns
|
|
7
7
|
*/
|
|
8
8
|
export declare function lint_v1(options: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}): Promise<import(
|
|
9
|
+
/**
|
|
10
|
+
* Glob pattern
|
|
11
|
+
*/
|
|
12
|
+
readonly files?: string | readonly string[];
|
|
13
|
+
/**
|
|
14
|
+
* Target source code of evaluation
|
|
15
|
+
*/
|
|
16
|
+
readonly sourceCodes?: string | readonly string[];
|
|
17
|
+
/**
|
|
18
|
+
* File names when `sourceCodes`
|
|
19
|
+
*/
|
|
20
|
+
readonly names?: string | readonly string[];
|
|
21
|
+
/**
|
|
22
|
+
* Workspace path when `sourceCodes`
|
|
23
|
+
*/
|
|
24
|
+
readonly workspace?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Configure file or object
|
|
27
|
+
*/
|
|
28
|
+
readonly config?: string | Config;
|
|
29
|
+
/**
|
|
30
|
+
* The config applied when not resolved from files or set it explicitly.
|
|
31
|
+
*/
|
|
32
|
+
readonly defaultConfig?: Config;
|
|
33
|
+
/**
|
|
34
|
+
* Rules (default: `@markuplint/rules`)
|
|
35
|
+
*/
|
|
36
|
+
readonly rules?: readonly Readonly<MLRule<RuleConfigValue, PlainData>>[];
|
|
37
|
+
/**
|
|
38
|
+
* Auto resolve rules
|
|
39
|
+
*
|
|
40
|
+
* Auto importing form *node_modules* when set `@markuplint/rule-{RULE_NAME}` or `markuplint-rule-{RULE_NAME}` in config rules
|
|
41
|
+
*/
|
|
42
|
+
readonly rulesAutoResolve?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Auto fix
|
|
45
|
+
*/
|
|
46
|
+
readonly fix?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Locale
|
|
49
|
+
*/
|
|
50
|
+
readonly locale?: string;
|
|
51
|
+
}): Promise<import("..").MLResultInfo[]>;
|
package/lib/cli/bootstrap.d.ts
CHANGED
|
@@ -1,57 +1,57 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
1
2
|
import meow from 'meow';
|
|
2
|
-
export declare const help =
|
|
3
|
-
'\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" 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\t--search Search lines of codes that include the target element by selectors.\n\n\t--help, -h Show help.\n\t--version, -v Show version.\n\nExamples\n\t$ markuplint verifyee.html --config path/to/.markuplintrc\n\t$ cat verifyee.html | markuplint\n';
|
|
3
|
+
export declare const 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\" 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\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";
|
|
4
4
|
export declare const cli: meow.Result<{
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
5
|
+
config: {
|
|
6
|
+
type: "string";
|
|
7
|
+
alias: string;
|
|
8
|
+
};
|
|
9
|
+
fix: {
|
|
10
|
+
type: "boolean";
|
|
11
|
+
default: false;
|
|
12
|
+
};
|
|
13
|
+
format: {
|
|
14
|
+
type: "string";
|
|
15
|
+
alias: string;
|
|
16
|
+
};
|
|
17
|
+
searchConfig: {
|
|
18
|
+
type: "boolean";
|
|
19
|
+
default: true;
|
|
20
|
+
};
|
|
21
|
+
ignoreExt: {
|
|
22
|
+
type: "boolean";
|
|
23
|
+
default: false;
|
|
24
|
+
};
|
|
25
|
+
importPresetRules: {
|
|
26
|
+
type: "boolean";
|
|
27
|
+
default: true;
|
|
28
|
+
};
|
|
29
|
+
locale: {
|
|
30
|
+
type: "string";
|
|
31
|
+
};
|
|
32
|
+
color: {
|
|
33
|
+
type: "boolean";
|
|
34
|
+
default: true;
|
|
35
|
+
};
|
|
36
|
+
problemOnly: {
|
|
37
|
+
type: "boolean";
|
|
38
|
+
alias: string;
|
|
39
|
+
default: false;
|
|
40
|
+
};
|
|
41
|
+
verbose: {
|
|
42
|
+
type: "boolean";
|
|
43
|
+
default: false;
|
|
44
|
+
};
|
|
45
|
+
init: {
|
|
46
|
+
type: "boolean";
|
|
47
|
+
default: false;
|
|
48
|
+
};
|
|
49
|
+
createRule: {
|
|
50
|
+
type: "boolean";
|
|
51
|
+
default: false;
|
|
52
|
+
};
|
|
53
|
+
search: {
|
|
54
|
+
type: "string";
|
|
55
|
+
};
|
|
56
56
|
}>;
|
|
57
|
-
export type CLIOptions = typeof cli.flags
|
|
57
|
+
export type CLIOptions = ReadonlyDeep<typeof cli.flags>;
|
package/lib/cli/command.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIOptions } from '../api/types';
|
|
2
1
|
import type { CLIOptions } from './bootstrap';
|
|
2
|
+
import type { APIOptions } from '../api/types';
|
|
3
3
|
import type { Target } from '@markuplint/file-resolver';
|
|
4
|
-
export declare function command(files: Target[], options: CLIOptions, apiOptions?: APIOptions): Promise<boolean>;
|
|
4
|
+
export declare function command(files: readonly Readonly<Target>[], options: CLIOptions, apiOptions?: APIOptions): Promise<boolean>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { DefaultRules, Langs, RuleSettingMode } from './types';
|
|
2
2
|
import type { Config } from '@markuplint/ml-config';
|
|
3
3
|
export declare const langs: Record<Langs, string>;
|
|
4
|
-
export declare function createConfig(langs: Langs[], mode: RuleSettingMode, defaultRules: DefaultRules): Config;
|
|
4
|
+
export declare function createConfig(langs: readonly Langs[], mode: RuleSettingMode, defaultRules: DefaultRules): Config;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createConfig = exports.langs = void 0;
|
|
4
|
-
const ml_config_1 = require("@markuplint/ml-config");
|
|
5
4
|
const extRExp = {
|
|
6
5
|
jsx: '\\.[jt]sx?$',
|
|
7
6
|
vue: '\\.vue$',
|
|
@@ -32,28 +31,36 @@ exports.langs = {
|
|
|
32
31
|
};
|
|
33
32
|
function createConfig(langs, mode, defaultRules) {
|
|
34
33
|
let config = {};
|
|
34
|
+
const parser = { ...config.parser };
|
|
35
35
|
for (const lang of langs) {
|
|
36
|
-
config.parser = config.parser || {};
|
|
37
36
|
const ext = extRExp[lang];
|
|
38
37
|
if (!ext) {
|
|
39
38
|
continue;
|
|
40
39
|
}
|
|
41
|
-
|
|
40
|
+
parser[ext] = `@markuplint/${lang}-parser`;
|
|
42
41
|
if (lang === 'vue') {
|
|
43
|
-
config =
|
|
42
|
+
config = {
|
|
43
|
+
...config,
|
|
44
44
|
specs: {
|
|
45
|
+
...config.specs,
|
|
45
46
|
'\\.vue$': '@markuplint/vue-spec',
|
|
46
47
|
},
|
|
47
|
-
}
|
|
48
|
+
};
|
|
48
49
|
}
|
|
49
50
|
if (lang === 'jsx') {
|
|
50
|
-
config =
|
|
51
|
+
config = {
|
|
52
|
+
...config,
|
|
51
53
|
specs: {
|
|
54
|
+
...config.specs,
|
|
52
55
|
'\\.[jt]sx?$': '@markuplint/react-spec',
|
|
53
56
|
},
|
|
54
|
-
}
|
|
57
|
+
};
|
|
55
58
|
}
|
|
56
59
|
}
|
|
60
|
+
if (Object.keys(parser).length) {
|
|
61
|
+
config.parser = parser;
|
|
62
|
+
}
|
|
63
|
+
const rules = { ...config.rules };
|
|
57
64
|
if (Array.isArray(mode)) {
|
|
58
65
|
const ruleNames = Object.keys(defaultRules);
|
|
59
66
|
for (const ruleName of ruleNames) {
|
|
@@ -62,10 +69,7 @@ function createConfig(langs, mode, defaultRules) {
|
|
|
62
69
|
continue;
|
|
63
70
|
}
|
|
64
71
|
if (mode.includes(rule.category)) {
|
|
65
|
-
|
|
66
|
-
config.rules = {};
|
|
67
|
-
}
|
|
68
|
-
config.rules[ruleName] = rule.defaultValue;
|
|
72
|
+
rules[ruleName] = rule.defaultValue;
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
}
|
|
@@ -73,13 +77,18 @@ function createConfig(langs, mode, defaultRules) {
|
|
|
73
77
|
config.extends = [...(config.extends || []), 'markuplint:recommended'];
|
|
74
78
|
}
|
|
75
79
|
else {
|
|
76
|
-
config.rules = {};
|
|
77
80
|
const ruleNames = Object.keys(defaultRules);
|
|
78
81
|
for (const ruleName of ruleNames) {
|
|
79
82
|
const rule = defaultRules[ruleName];
|
|
80
|
-
|
|
83
|
+
if (!rule) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
rules[ruleName] = rule.defaultValue;
|
|
81
87
|
}
|
|
82
88
|
}
|
|
89
|
+
if (Object.keys(rules).length) {
|
|
90
|
+
config.rules = rules;
|
|
91
|
+
}
|
|
83
92
|
return config;
|
|
84
93
|
}
|
|
85
94
|
exports.createConfig = createConfig;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare function getDefaultRules(version: string): Promise<{
|
|
2
|
+
[x: string]: import("./types").Rule;
|
|
3
|
+
}>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Langs } from './types';
|
|
2
2
|
export type InstallModuleResult = {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
success: boolean;
|
|
4
|
+
alreadyExists: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare function selectModules(selectedLangs: Langs[]): string[];
|
|
7
|
-
export declare function installModule(module: string[], dev?: boolean): Promise<InstallModuleResult>;
|
|
6
|
+
export declare function selectModules(selectedLangs: readonly Langs[]): string[];
|
|
7
|
+
export declare function installModule(module: readonly string[], dev?: boolean): Promise<InstallModuleResult>;
|
package/lib/cli/init/types.d.ts
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
|
-
export type Langs =
|
|
2
|
-
| 'jsx'
|
|
3
|
-
| 'vue'
|
|
4
|
-
| 'svelte'
|
|
5
|
-
| 'astro'
|
|
6
|
-
| 'pug'
|
|
7
|
-
| 'php'
|
|
8
|
-
| 'smarty'
|
|
9
|
-
| 'erb'
|
|
10
|
-
| 'ejs'
|
|
11
|
-
| 'mustache'
|
|
12
|
-
| 'nunjucks'
|
|
13
|
-
| 'liquid';
|
|
1
|
+
export type Langs = 'jsx' | 'vue' | 'svelte' | 'astro' | 'pug' | 'php' | 'smarty' | 'erb' | 'ejs' | 'mustache' | 'nunjucks' | 'liquid';
|
|
14
2
|
export type Category = 'validation' | 'a11y' | 'naming-convention' | 'style' | 'maintainability';
|
|
15
|
-
export type RuleSettingMode = Category[] | 'recommended' | 'none';
|
|
16
|
-
export type DefaultRules = Record<string, Rule
|
|
3
|
+
export type RuleSettingMode = readonly Category[] | 'recommended' | 'none';
|
|
4
|
+
export type DefaultRules = Readonly<Record<string, Rule>>;
|
|
17
5
|
export type Rule = {
|
|
18
|
-
|
|
19
|
-
|
|
6
|
+
readonly category: Category;
|
|
7
|
+
readonly defaultValue: boolean | string | number;
|
|
20
8
|
};
|
package/lib/cli/output.d.ts
CHANGED
package/lib/cli/prompt.d.ts
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
type SelectQuestion<T> = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
readonly message: string;
|
|
3
|
+
readonly choices: readonly {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly value: T;
|
|
6
|
+
}[];
|
|
7
7
|
};
|
|
8
8
|
export declare function select<T>(question: SelectQuestion<T>): Promise<T>;
|
|
9
9
|
export declare function multiSelect<T>(question: SelectQuestion<T>): Promise<T[]>;
|
|
10
|
-
export declare function input<T extends string = string>(question: string, validation?: RegExp): Promise<T>;
|
|
11
|
-
export declare function confirm(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
questions: {
|
|
19
|
-
message: string;
|
|
20
|
-
name: T;
|
|
21
|
-
}[],
|
|
22
|
-
): Promise<Record<T, boolean>>;
|
|
10
|
+
export declare function input<T extends string = string>(question: string, validation?: Readonly<RegExp>): Promise<T>;
|
|
11
|
+
export declare function confirm(question: string, options?: {
|
|
12
|
+
readonly initial?: boolean;
|
|
13
|
+
}): Promise<boolean>;
|
|
14
|
+
export declare function confirmSequence<T extends string = string>(questions: readonly {
|
|
15
|
+
readonly message: string;
|
|
16
|
+
readonly name: T;
|
|
17
|
+
}[]): Promise<Record<T, boolean>>;
|
|
23
18
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { CLIOptions } from '../bootstrap';
|
|
2
|
-
export default function (files: string[], options: CLIOptions, selectors: string): Promise<void>;
|
|
2
|
+
export default function (files: readonly string[], options: CLIOptions, selectors: string): Promise<void>;
|
package/lib/global-settings.d.ts
CHANGED
package/lib/i18n.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var _a;
|
|
3
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
3
|
exports.i18n = void 0;
|
|
5
4
|
const tslib_1 = require("tslib");
|
|
@@ -12,9 +11,10 @@ async function getLocale() {
|
|
|
12
11
|
return cachedLocale;
|
|
13
12
|
}
|
|
14
13
|
async function i18n(locale) {
|
|
14
|
+
var _a;
|
|
15
15
|
locale = locale || (await getLocale()) || 'en';
|
|
16
|
-
const langCode = locale.split('-')[0];
|
|
17
|
-
const loadLocaleSet = await (
|
|
16
|
+
const langCode = (_a = locale.split('-')[0]) !== null && _a !== void 0 ? _a : locale;
|
|
17
|
+
const loadLocaleSet = await Promise.resolve(`${`@markuplint/i18n/locales/${langCode}`}`).then(s => tslib_1.__importStar(require(s))).catch(() => null);
|
|
18
18
|
const localeSet = loadLocaleSet ||
|
|
19
19
|
// @ts-ignore
|
|
20
20
|
(await Promise.resolve().then(() => tslib_1.__importStar(require('@markuplint/i18n/locales/en'))));
|
|
@@ -1,51 +1,33 @@
|
|
|
1
1
|
import type { Target } from '@markuplint/file-resolver';
|
|
2
|
-
import type { Config, RuleConfigValue, Rule, RegexSelector } from '@markuplint/ml-config';
|
|
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
|
-
|
|
6
|
-
|
|
7
|
-
rules?: AnyMLRule[],
|
|
8
|
-
locale?: string,
|
|
9
|
-
fix?: boolean,
|
|
10
|
-
): Promise<{
|
|
11
|
-
violations: 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
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
},
|
|
22
|
-
fix?: boolean,
|
|
23
|
-
locale?: string,
|
|
24
|
-
): Promise<{
|
|
25
|
-
violations: 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
|
-
|
|
30
|
-
|
|
31
|
-
rules?: AnyMLRule[],
|
|
32
|
-
locale?: string,
|
|
33
|
-
fix?: boolean,
|
|
34
|
-
): Promise<{
|
|
35
|
-
violations: import('@markuplint/ml-config').Violation[];
|
|
36
|
-
fixedCode: string;
|
|
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
|
-
export interface NodeRule<T extends RuleConfigValue, O =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
20
|
+
export interface NodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
21
|
+
selector?: string;
|
|
22
|
+
regexSelector?: RegexSelector;
|
|
23
|
+
categories?: string[];
|
|
24
|
+
roles?: string[];
|
|
25
|
+
obsolete?: boolean;
|
|
26
|
+
rule?: Rule<T, O>;
|
|
45
27
|
}
|
|
46
|
-
export interface ChildNodeRule<T extends RuleConfigValue, O =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
28
|
+
export interface ChildNodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
29
|
+
selector?: string;
|
|
30
|
+
regexSelector?: RegexSelector;
|
|
31
|
+
inheritance?: boolean;
|
|
32
|
+
rule?: Rule<T, O>;
|
|
51
33
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { Config, Violation } from '@markuplint/ml-config';
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
}
|
|
27
27
|
export type Nullable<T> = T | null | undefined;
|
package/lib/util.d.ts
CHANGED
|
@@ -4,12 +4,12 @@ export declare function uuid(): string;
|
|
|
4
4
|
export declare const markuplint: string;
|
|
5
5
|
export declare function write(message: string): void;
|
|
6
6
|
export declare namespace write {
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
var _a: () => boolean;
|
|
8
|
+
export { _a as break };
|
|
9
9
|
}
|
|
10
10
|
export declare function error(message: string): void;
|
|
11
11
|
export declare namespace error {
|
|
12
|
-
|
|
12
|
+
var exit: () => never;
|
|
13
13
|
}
|
|
14
14
|
export declare const head: (method: string, noColor?: boolean) => string;
|
|
15
15
|
export declare function p(s: number | string, pad: number, start?: boolean): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markuplint",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.5.0",
|
|
4
|
+
"description": "An HTML linter for all markup developers",
|
|
5
5
|
"author": "Yusuke Hirao",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"private": false,
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"execa": "5"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@markuplint/create-rule-helper": "3.
|
|
32
|
-
"@markuplint/file-resolver": "3.
|
|
33
|
-
"@markuplint/html-parser": "3.
|
|
34
|
-
"@markuplint/html-spec": "3.
|
|
35
|
-
"@markuplint/i18n": "3.
|
|
36
|
-
"@markuplint/ml-ast": "3.
|
|
37
|
-
"@markuplint/ml-config": "3.
|
|
38
|
-
"@markuplint/ml-core": "3.
|
|
39
|
-
"@markuplint/ml-spec": "3.
|
|
40
|
-
"@markuplint/rules": "3.
|
|
31
|
+
"@markuplint/create-rule-helper": "3.5.0",
|
|
32
|
+
"@markuplint/file-resolver": "3.5.0",
|
|
33
|
+
"@markuplint/html-parser": "3.5.0",
|
|
34
|
+
"@markuplint/html-spec": "3.5.0",
|
|
35
|
+
"@markuplint/i18n": "3.5.0",
|
|
36
|
+
"@markuplint/ml-ast": "3.1.0",
|
|
37
|
+
"@markuplint/ml-config": "3.5.0",
|
|
38
|
+
"@markuplint/ml-core": "3.5.0",
|
|
39
|
+
"@markuplint/ml-spec": "3.5.0",
|
|
40
|
+
"@markuplint/rules": "3.5.0",
|
|
41
41
|
"chokidar": "^3.5.3",
|
|
42
42
|
"cli-color": "^2.0.3",
|
|
43
43
|
"debug": "^4.3.4",
|
|
@@ -53,7 +53,8 @@
|
|
|
53
53
|
"strict-event-emitter": "^0.2.8",
|
|
54
54
|
"strip-ansi": "6",
|
|
55
55
|
"tslib": "^2.4.1",
|
|
56
|
+
"type-fest": "^3.6.1",
|
|
56
57
|
"uuid": "^9.0.0"
|
|
57
58
|
},
|
|
58
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
|
|
59
60
|
}
|