markuplint 3.4.0 → 3.6.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 +4 -4
- package/lib/api/lint.d.ts +1 -1
- package/lib/api/ml-engine.d.ts +5 -4
- package/lib/api/ml-engine.js +21 -15
- package/lib/api/types.d.ts +16 -27
- package/lib/api/v1.d.ts +11 -11
- package/lib/api/v1.js +4 -7
- package/lib/cli/bootstrap.d.ts +2 -1
- package/lib/cli/command.d.ts +5 -1
- package/lib/cli/command.js +2 -2
- package/lib/cli/create-rule/index.js +2 -2
- package/lib/cli/index.js +1 -1
- package/lib/cli/init/create-config.d.ts +5 -1
- package/lib/cli/init/create-config.js +21 -14
- package/lib/cli/init/get-default-rules.d.ts +3 -2
- package/lib/cli/init/install-module.d.ts +2 -2
- package/lib/cli/init/install-module.js +1 -1
- package/lib/cli/init/types.d.ts +4 -4
- package/lib/cli/output.js +2 -2
- package/lib/cli/prompt.d.ts +9 -9
- package/lib/cli/search/index.d.ts +1 -1
- package/lib/cli/search/index.js +2 -1
- package/lib/global-settings.d.ts +1 -1
- package/lib/i18n.js +7 -8
- package/lib/reporter/simple-reporter.js +1 -1
- package/lib/reporter/standard-reporter.js +5 -4
- package/lib/testing-tool/index.d.ts +10 -10
- package/lib/types.d.ts +6 -7
- package/lib/util.d.ts +0 -2
- package/lib/util.js +1 -5
- package/package.json +15 -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
|
|
|
@@ -47,7 +47,7 @@ Add a command to the `scripts` option on `package.json`:
|
|
|
47
47
|
```json
|
|
48
48
|
{
|
|
49
49
|
"scripts": {
|
|
50
|
-
"html
|
|
50
|
+
"lint:html": "markuplint **/*.html"
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
```
|
|
@@ -57,9 +57,9 @@ If you want to change the target path, you can change it for your project.
|
|
|
57
57
|
Execute the script:
|
|
58
58
|
|
|
59
59
|
```
|
|
60
|
-
$ npm run html
|
|
60
|
+
$ npm run lint:html
|
|
61
61
|
# or
|
|
62
|
-
$ yarn html
|
|
62
|
+
$ yarn lint:html
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
### Command line options
|
package/lib/api/lint.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { APIOptions } from './types';
|
|
2
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,17 +1,18 @@
|
|
|
1
1
|
import type { APIOptions, MLEngineEventMap } from './types';
|
|
2
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
|
-
debug?: boolean;
|
|
8
|
-
watch?: boolean;
|
|
8
|
+
readonly debug?: boolean;
|
|
9
|
+
readonly watch?: boolean;
|
|
9
10
|
};
|
|
10
11
|
export default class MLEngine extends StrictEventEmitter<MLEngineEventMap> {
|
|
11
12
|
#private;
|
|
12
13
|
static toMLFile(target: Target): Promise<MLFile | undefined>;
|
|
13
|
-
constructor(file: MLFile
|
|
14
|
-
get document(): Document<RuleConfigValue,
|
|
14
|
+
constructor(file: Readonly<MLFile>, options?: APIOptions & MLEngineOptions);
|
|
15
|
+
get document(): Document<RuleConfigValue, PlainData> | null;
|
|
15
16
|
close(): Promise<void>;
|
|
16
17
|
exec(): Promise<MLResultInfo | null>;
|
|
17
18
|
setCode(code: string): Promise<void>;
|
package/lib/api/ml-engine.js
CHANGED
|
@@ -79,7 +79,7 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
79
79
|
fixedCode,
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
-
const debugMap =
|
|
82
|
+
const debugMap = 'debugMap' in core.document ? core.document.debugMap() : null;
|
|
83
83
|
this.emit('lint', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, sourceCode, violations, fixedCode, debugMap);
|
|
84
84
|
log('exec: end');
|
|
85
85
|
return {
|
|
@@ -150,7 +150,7 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
150
150
|
await this.exec();
|
|
151
151
|
}
|
|
152
152
|
async provide(cache = true) {
|
|
153
|
-
var _a, _b, _c;
|
|
153
|
+
var _a, _b, _c, _d;
|
|
154
154
|
const configSet = await this.resolveConfig(cache);
|
|
155
155
|
fileLog('Fetched Config files: %O', configSet.files);
|
|
156
156
|
fileLog('Resolved Config: %O', configSet.config);
|
|
@@ -162,7 +162,7 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
162
162
|
return null;
|
|
163
163
|
}
|
|
164
164
|
// Exclude
|
|
165
|
-
const excludeFiles = configSet.config.excludeFiles
|
|
165
|
+
const excludeFiles = (_a = configSet.config.excludeFiles) !== null && _a !== void 0 ? _a : [];
|
|
166
166
|
for (const excludeFile of excludeFiles) {
|
|
167
167
|
if (tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").matches(excludeFile)) {
|
|
168
168
|
this.emit('exclude', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, excludeFile);
|
|
@@ -171,7 +171,7 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
const { parser, parserOptions, matched } = await this.resolveParser(configSet);
|
|
174
|
-
const checkingExt = !((
|
|
174
|
+
const checkingExt = !((_b = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _b === void 0 ? void 0 : _b.ignoreExt);
|
|
175
175
|
if (checkingExt && !matched) {
|
|
176
176
|
this.emit('log', 'ext-unmatched', `Avoided linting because a file is unmatched by the extension: ${tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path}`);
|
|
177
177
|
fileLog('Avoided linting because a file is unmatched by the extension: %s', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path);
|
|
@@ -181,7 +181,7 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
181
181
|
fileLog('Resolved ruleset: %O', ruleset);
|
|
182
182
|
const schemas = await this.resolveSchemas(configSet);
|
|
183
183
|
if (fileLog.enabled) {
|
|
184
|
-
if (schemas[0].cites.length) {
|
|
184
|
+
if (schemas[0].cites.length > 0) {
|
|
185
185
|
const [, ...additionalSpecs] = schemas;
|
|
186
186
|
fileLog('Resolved schemas: HTML Standard');
|
|
187
187
|
for (const additionalSpec of additionalSpecs) {
|
|
@@ -194,14 +194,14 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
194
194
|
}
|
|
195
195
|
const rules = await this.resolveRules(configSet.plugins, ruleset);
|
|
196
196
|
fileLog('Resolved rules: %O', rules);
|
|
197
|
-
const locale = await (0, i18n_1.i18n)((
|
|
197
|
+
const locale = await (0, i18n_1.i18n)((_c = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _c === void 0 ? void 0 : _c.locale);
|
|
198
198
|
if (fileLog.enabled) {
|
|
199
199
|
fileLog('Loaded %d rules: %O', rules.length, rules.map(r => r.name));
|
|
200
200
|
}
|
|
201
201
|
return {
|
|
202
202
|
parser,
|
|
203
203
|
parserOptions,
|
|
204
|
-
pretenders: (
|
|
204
|
+
pretenders: (_d = configSet.config.pretenders) !== null && _d !== void 0 ? _d : [],
|
|
205
205
|
ruleset,
|
|
206
206
|
schemas,
|
|
207
207
|
rules,
|
|
@@ -210,16 +210,16 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
210
210
|
};
|
|
211
211
|
}
|
|
212
212
|
async resolveConfig(cache) {
|
|
213
|
-
var _a, _b, _c, _d, _e, _f;
|
|
213
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
214
214
|
const defaultConfigKey = ((_a = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _a === void 0 ? void 0 : _a.defaultConfig) && tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").set((_b = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _b === void 0 ? void 0 : _b.defaultConfig);
|
|
215
215
|
configLog('defaultConfigKey: %s', defaultConfigKey !== null && defaultConfigKey !== void 0 ? defaultConfigKey : 'N/A');
|
|
216
216
|
this.emit('log', 'defaultConfigKey', defaultConfigKey !== null && defaultConfigKey !== void 0 ? defaultConfigKey : 'N/A');
|
|
217
217
|
const configFilePathsFromTarget = ((_c = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _c === void 0 ? void 0 : _c.noSearchConfig)
|
|
218
218
|
? defaultConfigKey !== null && defaultConfigKey !== void 0 ? defaultConfigKey : null
|
|
219
|
-
: (await tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").search(tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f")))
|
|
219
|
+
: (_d = (await tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").search(tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f")))) !== null && _d !== void 0 ? _d : defaultConfigKey;
|
|
220
220
|
configLog('configFilePathsFromTarget: %s', configFilePathsFromTarget !== null && configFilePathsFromTarget !== void 0 ? configFilePathsFromTarget : 'N/A');
|
|
221
221
|
this.emit('log', 'configFilePathsFromTarget', configFilePathsFromTarget !== null && configFilePathsFromTarget !== void 0 ? configFilePathsFromTarget : 'N/A');
|
|
222
|
-
const configKey = ((
|
|
222
|
+
const configKey = ((_e = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _e === void 0 ? void 0 : _e.config) && tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").set(tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f").config);
|
|
223
223
|
configLog('option.config: %s', configKey !== null && configKey !== void 0 ? configKey : 'N/A');
|
|
224
224
|
this.emit('log', 'option.config', configFilePathsFromTarget !== null && configFilePathsFromTarget !== void 0 ? configFilePathsFromTarget : 'N/A');
|
|
225
225
|
let defaultRecommended = null;
|
|
@@ -230,15 +230,17 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
230
230
|
}
|
|
231
231
|
configLog('defaultRecommended: %s', defaultRecommended !== null && defaultRecommended !== void 0 ? defaultRecommended : 'N/A');
|
|
232
232
|
this.emit('log', 'defaultRecommended', defaultRecommended !== null && defaultRecommended !== void 0 ? defaultRecommended : 'N/A');
|
|
233
|
-
const configSet = await tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").resolve(tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f"), [configFilePathsFromTarget, (
|
|
233
|
+
const configSet = await tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").resolve(tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f"), [configFilePathsFromTarget, (_f = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _f === void 0 ? void 0 : _f.configFile, configKey, defaultRecommended], cache);
|
|
234
234
|
this.emit('config', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, configSet);
|
|
235
|
-
if ((
|
|
235
|
+
if ((_g = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _g === void 0 ? void 0 : _g.watch) {
|
|
236
236
|
// It doesn't watch the main HTML file because it may is watched and managed by a language server or text editor or more.
|
|
237
237
|
tslib_1.__classPrivateFieldGet(this, _MLEngine_watcher, "f").add(Array.from(configSet.files));
|
|
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,32 +1,21 @@
|
|
|
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
|
-
configFile?: string;
|
|
8
|
-
config?: Config;
|
|
9
|
-
defaultConfig?: Config;
|
|
10
|
-
noSearchConfig?: boolean;
|
|
11
|
-
locale?: string;
|
|
12
|
-
fix?: boolean;
|
|
13
|
-
ignoreExt?: boolean;
|
|
14
|
-
rules?: AnyMLRule[];
|
|
15
|
-
importPresetRules?: boolean;
|
|
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;
|
|
16
15
|
/**
|
|
17
16
|
* @deprecated
|
|
18
17
|
*/
|
|
19
|
-
autoLoad?: boolean;
|
|
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[];
|
|
18
|
+
readonly autoLoad?: boolean;
|
|
30
19
|
};
|
|
31
20
|
export type MLEngineEventMap = {
|
|
32
21
|
log: (phase: string, message: string) => void;
|
|
@@ -35,17 +24,17 @@ export type MLEngineEventMap = {
|
|
|
35
24
|
parser: (filePath: string, parser: string, message?: string) => void;
|
|
36
25
|
ruleset: (filePath: string, ruleset: Ruleset, message?: string) => void;
|
|
37
26
|
schemas: (filePath: string, schemas: MLSchema, message?: string) => void;
|
|
38
|
-
rules: (filePath: string, rules: AnyMLRule[], message?: string) => void;
|
|
27
|
+
rules: (filePath: string, rules: readonly Readonly<AnyMLRule>[], message?: string) => void;
|
|
39
28
|
i18n: (filePath: string, locale: LocaleSet, message?: string) => void;
|
|
40
29
|
code: (filePath: string, sourceCode: string, message?: string) => void;
|
|
41
30
|
lint: (
|
|
42
31
|
filePath: string,
|
|
43
32
|
sourceCode: string,
|
|
44
|
-
violations: Violation[],
|
|
33
|
+
violations: readonly Violation[],
|
|
45
34
|
fixedCode: string,
|
|
46
|
-
debug: string[] | null,
|
|
35
|
+
debug: readonly string[] | null,
|
|
47
36
|
message?: string,
|
|
48
37
|
) => void;
|
|
49
|
-
'lint-error': (filePath: string, sourceCode: string, error: Error) => void;
|
|
50
|
-
'config-errors': (filePath: string, errors: Error[]) => void;
|
|
38
|
+
'lint-error': (filePath: string, sourceCode: string, error: Readonly<Error>) => void;
|
|
39
|
+
'config-errors': (filePath: string, errors: readonly Readonly<Error>[]) => void;
|
|
51
40
|
};
|
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
|
|
@@ -9,43 +9,43 @@ export declare function lint_v1(options: {
|
|
|
9
9
|
/**
|
|
10
10
|
* Glob pattern
|
|
11
11
|
*/
|
|
12
|
-
files?: string | string[];
|
|
12
|
+
readonly files?: string | readonly string[];
|
|
13
13
|
/**
|
|
14
14
|
* Target source code of evaluation
|
|
15
15
|
*/
|
|
16
|
-
sourceCodes?: string | string[];
|
|
16
|
+
readonly sourceCodes?: string | readonly string[];
|
|
17
17
|
/**
|
|
18
18
|
* File names when `sourceCodes`
|
|
19
19
|
*/
|
|
20
|
-
names?: string | string[];
|
|
20
|
+
readonly names?: string | readonly string[];
|
|
21
21
|
/**
|
|
22
22
|
* Workspace path when `sourceCodes`
|
|
23
23
|
*/
|
|
24
|
-
workspace?: string;
|
|
24
|
+
readonly workspace?: string;
|
|
25
25
|
/**
|
|
26
26
|
* Configure file or object
|
|
27
27
|
*/
|
|
28
|
-
config?: string | Config;
|
|
28
|
+
readonly config?: string | Config;
|
|
29
29
|
/**
|
|
30
30
|
* The config applied when not resolved from files or set it explicitly.
|
|
31
31
|
*/
|
|
32
|
-
defaultConfig?: Config;
|
|
32
|
+
readonly defaultConfig?: Config;
|
|
33
33
|
/**
|
|
34
34
|
* Rules (default: `@markuplint/rules`)
|
|
35
35
|
*/
|
|
36
|
-
rules?: MLRule<RuleConfigValue,
|
|
36
|
+
readonly rules?: readonly Readonly<MLRule<RuleConfigValue, PlainData>>[];
|
|
37
37
|
/**
|
|
38
38
|
* Auto resolve rules
|
|
39
39
|
*
|
|
40
40
|
* Auto importing form *node_modules* when set `@markuplint/rule-{RULE_NAME}` or `markuplint-rule-{RULE_NAME}` in config rules
|
|
41
41
|
*/
|
|
42
|
-
rulesAutoResolve?: boolean;
|
|
42
|
+
readonly rulesAutoResolve?: boolean;
|
|
43
43
|
/**
|
|
44
44
|
* Auto fix
|
|
45
45
|
*/
|
|
46
|
-
fix?: boolean;
|
|
46
|
+
readonly fix?: boolean;
|
|
47
47
|
/**
|
|
48
48
|
* Locale
|
|
49
49
|
*/
|
|
50
|
-
locale?: string;
|
|
50
|
+
readonly locale?: string;
|
|
51
51
|
}): Promise<import('..').MLResultInfo[]>;
|
package/lib/api/v1.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.lint_v1 = void 0;
|
|
4
|
+
const shared_1 = require("@markuplint/shared");
|
|
4
5
|
const lint_1 = require("./lint");
|
|
5
6
|
/**
|
|
6
7
|
* @deprecated
|
|
@@ -9,12 +10,8 @@ const lint_1 = require("./lint");
|
|
|
9
10
|
*/
|
|
10
11
|
async function lint_v1(options) {
|
|
11
12
|
var _a;
|
|
12
|
-
const filePathList =
|
|
13
|
-
const codes = options.sourceCodes
|
|
14
|
-
? Array.isArray(options.sourceCodes)
|
|
15
|
-
? options.sourceCodes
|
|
16
|
-
: [options.sourceCodes]
|
|
17
|
-
: [];
|
|
13
|
+
const filePathList = (0, shared_1.toNoEmptyStringArrayFromStringOrArray)(options.files);
|
|
14
|
+
const codes = (0, shared_1.toNoEmptyStringArrayFromStringOrArray)(options.sourceCodes);
|
|
18
15
|
const files = [
|
|
19
16
|
...filePathList,
|
|
20
17
|
...codes.map((code, i) => {
|
|
@@ -37,7 +34,7 @@ async function lint_v1(options) {
|
|
|
37
34
|
const result = await (0, lint_1.lint)(files, {
|
|
38
35
|
config,
|
|
39
36
|
configFile,
|
|
40
|
-
noSearchConfig:
|
|
37
|
+
noSearchConfig: filePathList.length === 0,
|
|
41
38
|
rules: options.rules,
|
|
42
39
|
autoLoad: (_a = options.rulesAutoResolve) !== null && _a !== void 0 ? _a : true,
|
|
43
40
|
locale: options.locale,
|
package/lib/cli/bootstrap.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ReadonlyDeep } from 'type-fest';
|
|
1
2
|
import meow from 'meow';
|
|
2
3
|
export declare const help =
|
|
3
4
|
'\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';
|
|
@@ -54,4 +55,4 @@ export declare const cli: meow.Result<{
|
|
|
54
55
|
type: 'string';
|
|
55
56
|
};
|
|
56
57
|
}>;
|
|
57
|
-
export type CLIOptions = typeof cli.flags
|
|
58
|
+
export type CLIOptions = ReadonlyDeep<typeof cli.flags>;
|
package/lib/cli/command.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { CLIOptions } from './bootstrap';
|
|
2
2
|
import type { APIOptions } from '../api/types';
|
|
3
3
|
import type { Target } from '@markuplint/file-resolver';
|
|
4
|
-
export declare function command(
|
|
4
|
+
export declare function command(
|
|
5
|
+
files: readonly Readonly<Target>[],
|
|
6
|
+
options: CLIOptions,
|
|
7
|
+
apiOptions?: APIOptions,
|
|
8
|
+
): Promise<boolean>;
|
package/lib/cli/command.js
CHANGED
|
@@ -20,7 +20,7 @@ async function command(files, options, apiOptions) {
|
|
|
20
20
|
const fileList = await (0, file_resolver_1.resolveFiles)(files);
|
|
21
21
|
if (debug_1.log.enabled) {
|
|
22
22
|
(0, debug_1.log)('File list: %O', fileList.map(f => f.path));
|
|
23
|
-
(0, debug_1.log)('Config: %s', configFile
|
|
23
|
+
(0, debug_1.log)('Config: %s', configFile !== null && configFile !== void 0 ? configFile : 'N/A');
|
|
24
24
|
(0, debug_1.log)('Fix option: %s', fix);
|
|
25
25
|
}
|
|
26
26
|
const format = (_a = options.format) === null || _a === void 0 ? void 0 : _a.toLowerCase().trim();
|
|
@@ -41,7 +41,7 @@ async function command(files, options, apiOptions) {
|
|
|
41
41
|
if (!result) {
|
|
42
42
|
continue;
|
|
43
43
|
}
|
|
44
|
-
if (!hasError && result.violations.length) {
|
|
44
|
+
if (!hasError && result.violations.length > 0) {
|
|
45
45
|
hasError = true;
|
|
46
46
|
}
|
|
47
47
|
if (fix) {
|
|
@@ -69,10 +69,10 @@ async function createRule() {
|
|
|
69
69
|
for (const file of result.files) {
|
|
70
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
71
|
}
|
|
72
|
-
if (result.dependencies.length) {
|
|
72
|
+
if (result.dependencies.length > 0) {
|
|
73
73
|
await (0, install_module_1.installModule)(result.dependencies);
|
|
74
74
|
}
|
|
75
|
-
if (result.devDependencies.length) {
|
|
75
|
+
if (result.devDependencies.length > 0) {
|
|
76
76
|
await (0, install_module_1.installModule)(result.devDependencies, true);
|
|
77
77
|
}
|
|
78
78
|
}
|
package/lib/cli/index.js
CHANGED
|
@@ -34,7 +34,7 @@ const search_1 = tslib_1.__importDefault(require("./search"));
|
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
36
|
const files = bootstrap_1.cli.input;
|
|
37
|
-
if (files.length) {
|
|
37
|
+
if (files.length > 0) {
|
|
38
38
|
if (bootstrap_1.cli.flags.search) {
|
|
39
39
|
await (0, search_1.default)(files, bootstrap_1.cli.flags, bootstrap_1.cli.flags.search).catch(err => {
|
|
40
40
|
process.stderr.write(err + '\n');
|
|
@@ -1,4 +1,8 @@
|
|
|
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(
|
|
4
|
+
export declare function createConfig(
|
|
5
|
+
langs: readonly Langs[],
|
|
6
|
+
mode: RuleSettingMode,
|
|
7
|
+
defaultRules: DefaultRules,
|
|
8
|
+
): 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$',
|
|
@@ -31,29 +30,38 @@ exports.langs = {
|
|
|
31
30
|
liquid: 'liquid (Shopify)',
|
|
32
31
|
};
|
|
33
32
|
function createConfig(langs, mode, defaultRules) {
|
|
33
|
+
var _a;
|
|
34
34
|
let config = {};
|
|
35
|
+
const parser = { ...config.parser };
|
|
35
36
|
for (const lang of langs) {
|
|
36
|
-
config.parser = config.parser || {};
|
|
37
37
|
const ext = extRExp[lang];
|
|
38
38
|
if (!ext) {
|
|
39
39
|
continue;
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
parser[ext] = `@markuplint/${lang}-parser`;
|
|
42
42
|
if (lang === 'vue') {
|
|
43
|
-
config =
|
|
43
|
+
config = {
|
|
44
|
+
...config,
|
|
44
45
|
specs: {
|
|
46
|
+
...config.specs,
|
|
45
47
|
'\\.vue$': '@markuplint/vue-spec',
|
|
46
48
|
},
|
|
47
|
-
}
|
|
49
|
+
};
|
|
48
50
|
}
|
|
49
51
|
if (lang === 'jsx') {
|
|
50
|
-
config =
|
|
52
|
+
config = {
|
|
53
|
+
...config,
|
|
51
54
|
specs: {
|
|
55
|
+
...config.specs,
|
|
52
56
|
'\\.[jt]sx?$': '@markuplint/react-spec',
|
|
53
57
|
},
|
|
54
|
-
}
|
|
58
|
+
};
|
|
55
59
|
}
|
|
56
60
|
}
|
|
61
|
+
if (Object.keys(parser).length > 0) {
|
|
62
|
+
config.parser = parser;
|
|
63
|
+
}
|
|
64
|
+
const rules = { ...config.rules };
|
|
57
65
|
if (Array.isArray(mode)) {
|
|
58
66
|
const ruleNames = Object.keys(defaultRules);
|
|
59
67
|
for (const ruleName of ruleNames) {
|
|
@@ -62,27 +70,26 @@ function createConfig(langs, mode, defaultRules) {
|
|
|
62
70
|
continue;
|
|
63
71
|
}
|
|
64
72
|
if (mode.includes(rule.category)) {
|
|
65
|
-
|
|
66
|
-
config.rules = {};
|
|
67
|
-
}
|
|
68
|
-
config.rules[ruleName] = rule.defaultValue;
|
|
73
|
+
rules[ruleName] = rule.defaultValue;
|
|
69
74
|
}
|
|
70
75
|
}
|
|
71
76
|
}
|
|
72
77
|
else if (mode === 'recommended') {
|
|
73
|
-
config.extends = [...(config.extends
|
|
78
|
+
config.extends = [...((_a = config.extends) !== null && _a !== void 0 ? _a : []), 'markuplint:recommended'];
|
|
74
79
|
}
|
|
75
80
|
else {
|
|
76
|
-
config.rules = {};
|
|
77
81
|
const ruleNames = Object.keys(defaultRules);
|
|
78
82
|
for (const ruleName of ruleNames) {
|
|
79
83
|
const rule = defaultRules[ruleName];
|
|
80
84
|
if (!rule) {
|
|
81
85
|
continue;
|
|
82
86
|
}
|
|
83
|
-
|
|
87
|
+
rules[ruleName] = rule.defaultValue;
|
|
84
88
|
}
|
|
85
89
|
}
|
|
90
|
+
if (Object.keys(rules).length > 0) {
|
|
91
|
+
config.rules = rules;
|
|
92
|
+
}
|
|
86
93
|
return config;
|
|
87
94
|
}
|
|
88
95
|
exports.createConfig = createConfig;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare function getDefaultRules(version: string): Promise<{
|
|
2
|
+
[x: string]: import('./types').Rule;
|
|
3
|
+
}>;
|
|
@@ -3,5 +3,5 @@ export type InstallModuleResult = {
|
|
|
3
3
|
success: boolean;
|
|
4
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
|
@@ -12,9 +12,9 @@ export type Langs =
|
|
|
12
12
|
| 'nunjucks'
|
|
13
13
|
| 'liquid';
|
|
14
14
|
export type Category = 'validation' | 'a11y' | 'naming-convention' | 'style' | 'maintainability';
|
|
15
|
-
export type RuleSettingMode = Category[] | 'recommended' | 'none';
|
|
16
|
-
export type DefaultRules = Record<string, Rule
|
|
15
|
+
export type RuleSettingMode = readonly Category[] | 'recommended' | 'none';
|
|
16
|
+
export type DefaultRules = Readonly<Record<string, Rule>>;
|
|
17
17
|
export type Rule = {
|
|
18
|
-
category: Category;
|
|
19
|
-
defaultValue: boolean | string | number;
|
|
18
|
+
readonly category: Category;
|
|
19
|
+
readonly defaultValue: boolean | string | number;
|
|
20
20
|
};
|
package/lib/cli/output.js
CHANGED
|
@@ -20,13 +20,13 @@ function output(results, options) {
|
|
|
20
20
|
out = (0, reporter_1.standardReporter)(results, options);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
if (
|
|
23
|
+
if (out.length === 0) {
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
26
|
let msg = `${out.join('\n')}\n`;
|
|
27
27
|
msg = options.color ? msg : (0, strip_ansi_1.default)(msg);
|
|
28
28
|
// If it has errors, Write to `stderr` and failure and exit.
|
|
29
|
-
if (results.violations.length) {
|
|
29
|
+
if (results.violations.length > 0) {
|
|
30
30
|
process.stderr.write(msg);
|
|
31
31
|
process.exitCode = 1;
|
|
32
32
|
return;
|
package/lib/cli/prompt.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
type SelectQuestion<T> = {
|
|
2
|
-
message: string;
|
|
3
|
-
choices: {
|
|
4
|
-
name: string;
|
|
5
|
-
value: T;
|
|
2
|
+
readonly message: string;
|
|
3
|
+
readonly choices: readonly {
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly value: T;
|
|
6
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>;
|
|
10
|
+
export declare function input<T extends string = string>(question: string, validation?: Readonly<RegExp>): Promise<T>;
|
|
11
11
|
export declare function confirm(
|
|
12
12
|
question: string,
|
|
13
13
|
options?: {
|
|
14
|
-
initial?: boolean;
|
|
14
|
+
readonly initial?: boolean;
|
|
15
15
|
},
|
|
16
16
|
): Promise<boolean>;
|
|
17
17
|
export declare function confirmSequence<T extends string = string>(
|
|
18
|
-
questions: {
|
|
19
|
-
message: string;
|
|
20
|
-
name: T;
|
|
18
|
+
questions: readonly {
|
|
19
|
+
readonly message: string;
|
|
20
|
+
readonly name: T;
|
|
21
21
|
}[],
|
|
22
22
|
): Promise<Record<T, boolean>>;
|
|
23
23
|
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/cli/search/index.js
CHANGED
|
@@ -17,8 +17,9 @@ async function default_1(files, options, selectors) {
|
|
|
17
17
|
verify({ document }) {
|
|
18
18
|
const nodes = document.querySelectorAll(selectors);
|
|
19
19
|
locations.push(...Array.from(nodes).map(node => {
|
|
20
|
+
var _a;
|
|
20
21
|
return {
|
|
21
|
-
file: document.filename
|
|
22
|
+
file: (_a = document.filename) !== null && _a !== void 0 ? _a : '_NO_FILE_',
|
|
22
23
|
line: node.startLine,
|
|
23
24
|
col: node.startCol,
|
|
24
25
|
};
|
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,13 +11,13 @@ async function getLocale() {
|
|
|
12
11
|
return cachedLocale;
|
|
13
12
|
}
|
|
14
13
|
async function i18n(locale) {
|
|
15
|
-
var _a;
|
|
16
|
-
locale = locale
|
|
17
|
-
const langCode = (
|
|
18
|
-
const loadLocaleSet = await (
|
|
19
|
-
const localeSet = loadLocaleSet
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
var _a, _b;
|
|
15
|
+
locale = (_a = locale !== null && locale !== void 0 ? locale : (await getLocale())) !== null && _a !== void 0 ? _a : 'en';
|
|
16
|
+
const langCode = (_b = locale.split('-')[0]) !== null && _b !== void 0 ? _b : locale;
|
|
17
|
+
const loadLocaleSet = await Promise.resolve(`${`@markuplint/i18n/locales/${langCode}`}`).then(s => tslib_1.__importStar(require(s))).catch(() => null);
|
|
18
|
+
const localeSet = loadLocaleSet !== null && loadLocaleSet !== void 0 ? loadLocaleSet :
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
(await Promise.resolve().then(() => tslib_1.__importStar(require('@markuplint/i18n/locales/en'))));
|
|
22
21
|
return {
|
|
23
22
|
...localeSet,
|
|
24
23
|
locale: loadLocaleSet ? langCode : 'en',
|
|
@@ -19,7 +19,7 @@ function simpleReporter(results, options) {
|
|
|
19
19
|
sizes.meg = Math.max(sizes.meg, (0, util_1.w)(meg));
|
|
20
20
|
}
|
|
21
21
|
const out = [];
|
|
22
|
-
if (results.violations.length) {
|
|
22
|
+
if (results.violations.length > 0) {
|
|
23
23
|
out.push(`<${util_1.markuplint}> ${cli_color_1.default.underline(results.filePath)}: ${loggerError('✗')}`);
|
|
24
24
|
for (const violation of results.violations) {
|
|
25
25
|
const s = violation.severity === 'error' ? loggerError('✖') : loggerWarning('⚠️');
|
|
@@ -7,6 +7,7 @@ const util_1 = require("../util");
|
|
|
7
7
|
const loggerError = cli_color_1.default.red;
|
|
8
8
|
const loggerWarning = cli_color_1.default.xterm(208);
|
|
9
9
|
function standardReporter(results, options) {
|
|
10
|
+
var _a, _b, _c;
|
|
10
11
|
const sizes = {
|
|
11
12
|
line: 0,
|
|
12
13
|
col: 0,
|
|
@@ -19,12 +20,12 @@ function standardReporter(results, options) {
|
|
|
19
20
|
sizes.meg = Math.max(sizes.meg, (0, util_1.w)(meg));
|
|
20
21
|
}
|
|
21
22
|
const out = [];
|
|
22
|
-
if (results.violations.length) {
|
|
23
|
+
if (results.violations.length > 0) {
|
|
23
24
|
const lines = results.sourceCode.split(/\r?\n/g);
|
|
24
25
|
for (const violation of results.violations) {
|
|
25
|
-
const prev = lines[violation.line - 2]
|
|
26
|
-
const line = lines[violation.line - 1]
|
|
27
|
-
const next = lines[violation.line - 0]
|
|
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 : '';
|
|
28
29
|
const before = line.substring(0, violation.col - 1);
|
|
29
30
|
const after = line.substring(violation.col - 1 + violation.raw.length);
|
|
30
31
|
const logger = violation.severity === 'error' ? loggerError : loggerWarning;
|
|
@@ -1,18 +1,18 @@
|
|
|
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
4
|
export declare function mlTest(
|
|
5
5
|
sourceCode: string,
|
|
6
6
|
config: Config,
|
|
7
|
-
rules?: AnyMLRule[],
|
|
7
|
+
rules?: readonly Readonly<AnyMLRule>[],
|
|
8
8
|
locale?: string,
|
|
9
9
|
fix?: boolean,
|
|
10
10
|
): Promise<{
|
|
11
|
-
violations: import('@markuplint/ml-config').Violation[];
|
|
11
|
+
violations: readonly import('@markuplint/ml-config').Violation[];
|
|
12
12
|
fixedCode: string;
|
|
13
13
|
}>;
|
|
14
|
-
export declare function mlRuleTest<T extends RuleConfigValue, O
|
|
15
|
-
rule: RuleSeed<T, O
|
|
14
|
+
export declare function mlRuleTest<T extends RuleConfigValue, O extends PlainData>(
|
|
15
|
+
rule: Readonly<RuleSeed<T, O>>,
|
|
16
16
|
sourceCode: string,
|
|
17
17
|
config?: Omit<Config, 'rules' | 'nodeRules' | 'childNodeRules'> & {
|
|
18
18
|
rule?: Rule<T, Partial<O>>;
|
|
@@ -22,20 +22,20 @@ export declare function mlRuleTest<T extends RuleConfigValue, O = null>(
|
|
|
22
22
|
fix?: boolean,
|
|
23
23
|
locale?: string,
|
|
24
24
|
): Promise<{
|
|
25
|
-
violations: import('@markuplint/ml-config').Violation[];
|
|
25
|
+
violations: readonly import('@markuplint/ml-config').Violation[];
|
|
26
26
|
fixedCode: string;
|
|
27
27
|
}>;
|
|
28
28
|
export declare function mlTestFile(
|
|
29
29
|
target: Target,
|
|
30
30
|
config?: Config,
|
|
31
|
-
rules?: AnyMLRule[],
|
|
31
|
+
rules?: readonly Readonly<AnyMLRule>[],
|
|
32
32
|
locale?: string,
|
|
33
33
|
fix?: boolean,
|
|
34
34
|
): Promise<{
|
|
35
|
-
violations: import('@markuplint/ml-config').Violation[];
|
|
35
|
+
violations: readonly import('@markuplint/ml-config').Violation[];
|
|
36
36
|
fixedCode: string | undefined;
|
|
37
37
|
}>;
|
|
38
|
-
export interface NodeRule<T extends RuleConfigValue, O =
|
|
38
|
+
export interface NodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
39
39
|
selector?: string;
|
|
40
40
|
regexSelector?: RegexSelector;
|
|
41
41
|
categories?: string[];
|
|
@@ -43,7 +43,7 @@ export interface NodeRule<T extends RuleConfigValue, O = void> {
|
|
|
43
43
|
obsolete?: boolean;
|
|
44
44
|
rule?: Rule<T, O>;
|
|
45
45
|
}
|
|
46
|
-
export interface ChildNodeRule<T extends RuleConfigValue, O =
|
|
46
|
+
export interface ChildNodeRule<T extends RuleConfigValue, O extends PlainData = undefined> {
|
|
47
47
|
selector?: string;
|
|
48
48
|
regexSelector?: RegexSelector;
|
|
49
49
|
inheritance?: boolean;
|
package/lib/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
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
|
-
violations: Violation[];
|
|
5
|
-
filePath: string;
|
|
6
|
-
sourceCode: string;
|
|
7
|
-
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
|
|
@@ -14,7 +14,7 @@ export interface MLResultInfo_v1 {
|
|
|
14
14
|
filePath: string;
|
|
15
15
|
sourceCode: string;
|
|
16
16
|
fixedCode: string;
|
|
17
|
-
document: Document<
|
|
17
|
+
document: Document<RuleConfigValue, PlainData> | null;
|
|
18
18
|
parser: string;
|
|
19
19
|
locale?: string;
|
|
20
20
|
ruleset: Ruleset;
|
|
@@ -24,4 +24,3 @@ export interface MLResultInfo_v1 {
|
|
|
24
24
|
error: string[];
|
|
25
25
|
};
|
|
26
26
|
}
|
|
27
|
-
export type Nullable<T> = T | null | undefined;
|
package/lib/util.d.ts
CHANGED
package/lib/util.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.messageToString = exports.invisibleSpace = exports.space = exports.w = exports.p = exports.head = exports.error = exports.write = exports.markuplint = exports.uuid =
|
|
3
|
+
exports.messageToString = exports.invisibleSpace = exports.space = exports.w = exports.p = exports.head = exports.error = exports.write = exports.markuplint = exports.uuid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const cli_color_1 = tslib_1.__importDefault(require("cli-color"));
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
const eastasianwidth_1 = tslib_1.__importDefault(require("eastasianwidth"));
|
|
8
8
|
const strip_ansi_1 = tslib_1.__importDefault(require("strip-ansi"));
|
|
9
9
|
const uuid_1 = require("uuid");
|
|
10
|
-
function nonNullableFilter(item) {
|
|
11
|
-
return !!item;
|
|
12
|
-
}
|
|
13
|
-
exports.nonNullableFilter = nonNullableFilter;
|
|
14
10
|
function uuid() {
|
|
15
11
|
return (0, uuid_1.v4)();
|
|
16
12
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markuplint",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "3.6.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,17 @@
|
|
|
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.6.0",
|
|
32
|
+
"@markuplint/file-resolver": "3.6.0",
|
|
33
|
+
"@markuplint/html-parser": "3.6.0",
|
|
34
|
+
"@markuplint/html-spec": "3.6.0",
|
|
35
|
+
"@markuplint/i18n": "3.6.0",
|
|
36
|
+
"@markuplint/ml-ast": "3.1.0",
|
|
37
|
+
"@markuplint/ml-config": "3.6.0",
|
|
38
|
+
"@markuplint/ml-core": "3.6.0",
|
|
39
|
+
"@markuplint/ml-spec": "3.6.0",
|
|
40
|
+
"@markuplint/rules": "3.6.0",
|
|
41
|
+
"@markuplint/shared": "3.5.0",
|
|
41
42
|
"chokidar": "^3.5.3",
|
|
42
43
|
"cli-color": "^2.0.3",
|
|
43
44
|
"debug": "^4.3.4",
|
|
@@ -53,7 +54,8 @@
|
|
|
53
54
|
"strict-event-emitter": "^0.2.8",
|
|
54
55
|
"strip-ansi": "6",
|
|
55
56
|
"tslib": "^2.4.1",
|
|
57
|
+
"type-fest": "^3.6.1",
|
|
56
58
|
"uuid": "^9.0.0"
|
|
57
59
|
},
|
|
58
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "715dd53d3b1064a9bcf616c1533921cad9e3b187"
|
|
59
61
|
}
|