markuplint 2.0.0-rc.6 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/README.md +70 -20
  2. package/lib/api/index.d.mts +2 -0
  3. package/lib/api/index.mjs +2 -0
  4. package/lib/api/lint.d.mts +4 -0
  5. package/lib/api/lint.mjs +15 -0
  6. package/lib/api/ml-engine.d.mts +27 -0
  7. package/lib/api/ml-engine.mjs +232 -0
  8. package/lib/api/types.d.mts +43 -0
  9. package/lib/api/types.mjs +1 -0
  10. package/lib/api/v1.d.mts +51 -0
  11. package/lib/api/v1.mjs +39 -0
  12. package/lib/cli/bootstrap.d.mts +52 -0
  13. package/lib/cli/bootstrap.mjs +81 -0
  14. package/lib/cli/command.d.mts +3 -0
  15. package/lib/cli/command.mjs +50 -0
  16. package/lib/cli/create-rule/index.d.mts +1 -0
  17. package/lib/cli/create-rule/index.mjs +51 -0
  18. package/lib/cli/index.d.mts +1 -0
  19. package/lib/cli/index.mjs +64 -0
  20. package/lib/cli/index.spec.d.mts +1 -0
  21. package/lib/cli/index.spec.mjs +48 -0
  22. package/lib/cli/init/index.d.mts +1 -0
  23. package/lib/cli/init/index.mjs +266 -0
  24. package/lib/cli/init/install-module.d.mts +5 -0
  25. package/lib/cli/init/install-module.mjs +61 -0
  26. package/lib/cli/output.d.mts +3 -0
  27. package/lib/cli/output.mjs +31 -0
  28. package/lib/cli/prompt.d.mts +18 -0
  29. package/lib/cli/prompt.mjs +68 -0
  30. package/lib/debug.d.mts +3 -0
  31. package/lib/debug.mjs +10 -0
  32. package/lib/global-settings.d.mts +5 -0
  33. package/lib/global-settings.mjs +10 -0
  34. package/lib/i18n.d.mts +6 -0
  35. package/lib/i18n.mjs +19 -0
  36. package/lib/index.d.mts +8 -0
  37. package/lib/index.mjs +8 -0
  38. package/lib/reporter/index.d.mts +2 -0
  39. package/lib/reporter/index.mjs +2 -0
  40. package/lib/reporter/simple-reporter.d.mts +3 -0
  41. package/lib/reporter/simple-reporter.mjs +30 -0
  42. package/lib/reporter/standard-reporter.d.mts +3 -0
  43. package/lib/reporter/standard-reporter.mjs +43 -0
  44. package/lib/testing-tool/index.d.mts +35 -0
  45. package/lib/testing-tool/index.mjs +83 -0
  46. package/lib/types.d.mts +27 -0
  47. package/lib/types.mjs +1 -0
  48. package/lib/util.d.mts +19 -0
  49. package/lib/util.mjs +73 -0
  50. package/lib/v1.d.mts +4 -0
  51. package/lib/v1.mjs +4 -0
  52. package/media/screenshot01.png +0 -0
  53. package/package.json +14 -14
  54. package/tsconfig.tsbuildinfo +1 -1
  55. package/RESOLVE_CONFIG.md +0 -77
  56. package/lib/cli/head.d.ts +0 -1
  57. package/lib/cli/head.js +0 -31
  58. package/lib/reporter/utils.d.ts +0 -6
  59. package/lib/reporter/utils.js +0 -40
package/README.md CHANGED
@@ -1,27 +1,66 @@
1
1
  # ![markuplint](https://cdn.rawgit.com/YusukeHirao/markuplint/HEAD/media/logo-v.svg)
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/markuplint.svg)](https://badge.fury.io/js/markuplint)
4
- [![Build Status](https://travis-ci.org/markuplint/markuplint.svg?branch=main)](https://travis-ci.org/markuplint/markuplint) [![Coverage Status](https://coveralls.io/repos/github/markuplint/markuplint/badge.svg?branch=main)](https://coveralls.io/github/markuplint/markuplint?branch=main)
4
+ [![Test](https://github.com/markuplint/markuplint/workflows/Test/badge.svg?branch=main)](https://github.com/markuplint/markuplint/actions?query=workflow%3ATest)
5
+ [![Coverage Status](https://coveralls.io/repos/github/markuplint/markuplint/badge.svg?branch=main)](https://coveralls.io/github/markuplint/markuplint?branch=main)
5
6
 
6
- A Linter for All Markup Languages (for legacy/modern HTML, Web Components, SVG, MathML, AMP HTML and more).
7
+ Peace of mind in your markup - A Linter for All Markup Languages.
7
8
 
8
- ## Install
9
+ ## Features
10
+
11
+ - Conformance checking that according to HTML Living Standard, WAI-ARIA, and ARIA in HTML.
12
+ - Supports SVG and CSS Values.
13
+ - Supports React, Vue, Svelte, Pug, PHP, and more.
14
+ - Possible to specify the rule to each element if you use the selector.
15
+ - Possible to create a custom rule.
16
+
17
+ ![Screenshot: Violation Report CLI output](https://raw.githubusercontent.com/markuplint/markuplint/main/packages/markuplint/media/screenshot01.png)
18
+
19
+ ## Instant using
9
20
 
10
21
  ```
11
- $ npm install -D markuplint
12
- $ yarn add -D markuplint
22
+ $ npx markuplint target.html
13
23
  ```
14
24
 
15
25
  Supported for _Node.js_ `v12.4.0` or later.
16
26
 
17
27
  ## Usage
18
28
 
19
- ### CLI
29
+ ### Initialization
30
+
31
+ Create a [configuration](https://markuplint.dev/configuration) file and install dependencies.
20
32
 
21
33
  ```
22
- $ npx markuplint verifyee.html
34
+ $ npx markuplint --init
35
+ # or
36
+ $ yarn run markuplint --init
23
37
  ```
24
38
 
39
+ Answer questions interactively.
40
+ By doing this, needed modules are installed includes `markuplint`.
41
+
42
+ Add a command to the `scripts` option on `package.json`:
43
+
44
+ ```json
45
+ {
46
+ "scripts": {
47
+ "html:lint": "markuplint **/*.html"
48
+ }
49
+ }
50
+ ```
51
+
52
+ If you want to change the target path, you can change it for your project.
53
+
54
+ Execute the script:
55
+
56
+ ```
57
+ $ npm run html:lint
58
+ # or
59
+ $ yarn html:lint
60
+ ```
61
+
62
+ ### Command line options
63
+
25
64
  ```
26
65
  $ npx markuplint --help
27
66
 
@@ -52,27 +91,38 @@ Examples
52
91
  $ cat verifyee.html | markuplint
53
92
  ```
54
93
 
55
- ![Screen shot](media/screenshot01.png)
94
+ ## Guideline
95
+
96
+ - [Getting Started](https://markuplint.dev/getting-started)
97
+ - [Rules](https://markuplint.dev/rules)
98
+ - [Configuration](https://markuplint.dev/configuration)
99
+ - [API](https://markuplint.dev/api-docs)
100
+ - [Playground](https://playground.markuplint.dev/)
101
+
102
+ ## Editor Extensions
103
+
104
+ | Editor | Installation Page | Author |
105
+ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ---------------------------------------------- |
106
+ | <a href="https://marketplace.visualstudio.com/items?itemName=yusukehirao.vscode-markuplint"><img src="https://raw.githubusercontent.com/markuplint/markuplint/main/media/vscode.png" width="75" height="82" alt="Visual Studio Code: markuplint extension"></a> | [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=yusukehirao.vscode-markuplint) | [@YusukeHirao](https://github.com/YusukeHirao) |
56
107
 
57
- ### API
108
+ ## License
58
109
 
59
- - [Functions](https://markuplint.dev/api-docs#Functions)
60
- - [Interface Document](https://api.markuplint.dev) (genereated by [TypeDoc](https://typedoc.org/))
110
+ [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmarkuplint%2Fmarkuplint.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fmarkuplint%2Fmarkuplint?ref=badge_large)
61
111
 
62
- ## Configuration
112
+ ## Sponsors
63
113
 
64
- - [Configuration](https://markuplint.dev/configuration)
114
+ [:heart: Sponsor](https://github.com/sponsors/markuplint)
65
115
 
66
- ## Rules
116
+ ### Personal Supporters
67
117
 
68
- - [Rules](https://markuplint.dev/rules)
69
- - Customizing your rule **🚧 WIP**
118
+ [<img width="36" src="https://avatars.githubusercontent.com/u/6581173?v=4" alt="mikimhk"/>](https://github.com/mikimhk)
119
+ [<img width="36" src="https://avatars.githubusercontent.com/u/91733847?v=4" alt="Tokitake" />](https://github.com/Tokitake)
70
120
 
71
121
  ## Thanks
72
122
 
73
123
  This linter is inspired by:
74
124
 
75
- - [HTMLHint](http://htmlhint.com/)
76
- - [ESLint](https://eslint.org/)
77
- - [stylelint](https://stylelint.io/)
78
- - [textlint](https://textlint.github.io/)
125
+ - [HTMLHint](http://htmlhint.com/)
126
+ - [ESLint](https://eslint.org/)
127
+ - [stylelint](https://stylelint.io/)
128
+ - [textlint](https://textlint.github.io/)
@@ -0,0 +1,2 @@
1
+ export { default as MLEngine } from './ml-engine.mjs';
2
+ export { lint } from './lint.mjs';
@@ -0,0 +1,2 @@
1
+ export { default as MLEngine } from './ml-engine.mjs';
2
+ export { lint } from './lint.mjs';
@@ -0,0 +1,4 @@
1
+ import type { MLResultInfo } from '../types.mjs';
2
+ import type { APIOptions } from './types.mjs';
3
+ import type { Target } from '@markuplint/file-resolver';
4
+ export declare function lint(targetList: Target[], options?: APIOptions): Promise<MLResultInfo[]>;
@@ -0,0 +1,15 @@
1
+ import { resolveFiles } from '@markuplint/file-resolver';
2
+ import MLEngine from './ml-engine.mjs';
3
+ export async function lint(targetList, options) {
4
+ const res = [];
5
+ const files = await resolveFiles(targetList);
6
+ for (const file of files) {
7
+ const engine = new MLEngine(file, options);
8
+ const result = await engine.exec();
9
+ if (!result) {
10
+ continue;
11
+ }
12
+ res.push(result);
13
+ }
14
+ return res;
15
+ }
@@ -0,0 +1,27 @@
1
+ import type { MLResultInfo } from '../types.mjs';
2
+ import type { APIOptions, MLEngineEventMap } from './types.mjs';
3
+ import type { MLFile, Target } from '@markuplint/file-resolver';
4
+ import { StrictEventEmitter } from 'strict-event-emitter';
5
+ declare type MLEngineOptions = {
6
+ debug?: boolean;
7
+ watch?: boolean;
8
+ };
9
+ export default class MLEngine extends StrictEventEmitter<MLEngineEventMap> {
10
+ #private;
11
+ static toMLFile(target: Target): Promise<MLFile>;
12
+ constructor(file: MLFile, options?: APIOptions & MLEngineOptions);
13
+ exec(): Promise<MLResultInfo | null>;
14
+ setCode(code: string): Promise<void>;
15
+ close(): Promise<void>;
16
+ private setup;
17
+ private provide;
18
+ private cretateCore;
19
+ private resolveConfig;
20
+ private resolveParser;
21
+ private resolveRuleset;
22
+ private resolveSchemas;
23
+ private resolveRules;
24
+ private i18n;
25
+ private watch;
26
+ }
27
+ export {};
@@ -0,0 +1,232 @@
1
+ var _MLEngine_file, _MLEngine_options, _MLEngine_core, _MLEngine_watcher;
2
+ import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
3
+ import { configProvider, resolveFiles, resolveParser, resolveRules, resolveSpecs } from '@markuplint/file-resolver';
4
+ import { MLCore, convertRuleset } from '@markuplint/ml-core';
5
+ import { FSWatcher } from 'chokidar';
6
+ import { StrictEventEmitter } from 'strict-event-emitter';
7
+ import { log as coreLog, verbosely } from '../debug.mjs';
8
+ import { i18n } from '../i18n.mjs';
9
+ const log = coreLog.extend('ml-engine');
10
+ const fileLog = log.extend('file');
11
+ export default class MLEngine extends StrictEventEmitter {
12
+ constructor(file, options) {
13
+ super();
14
+ _MLEngine_file.set(this, void 0);
15
+ _MLEngine_options.set(this, void 0);
16
+ _MLEngine_core.set(this, null);
17
+ _MLEngine_watcher.set(this, new FSWatcher());
18
+ __classPrivateFieldSet(this, _MLEngine_file, file, "f");
19
+ __classPrivateFieldSet(this, _MLEngine_options, options, "f");
20
+ if (__classPrivateFieldGet(this, _MLEngine_options, "f")?.debug) {
21
+ verbosely();
22
+ }
23
+ if (options?.watch) {
24
+ __classPrivateFieldGet(this, _MLEngine_watcher, "f").on('all', this.watch.bind(this));
25
+ }
26
+ else {
27
+ __classPrivateFieldGet(this, _MLEngine_watcher, "f").close();
28
+ }
29
+ }
30
+ static async toMLFile(target) {
31
+ const files = await resolveFiles([target]);
32
+ return files[0];
33
+ }
34
+ async exec() {
35
+ log('exec: start');
36
+ const core = await this.setup();
37
+ if (!core) {
38
+ log('exec: cancel (unsetuped yet)');
39
+ return null;
40
+ }
41
+ const violations = await core.verify(__classPrivateFieldGet(this, _MLEngine_options, "f")?.fix).catch(e => {
42
+ if (e instanceof Error) {
43
+ return e;
44
+ }
45
+ throw e;
46
+ });
47
+ const sourceCode = await __classPrivateFieldGet(this, _MLEngine_file, "f").getCode();
48
+ const fixedCode = core.document.toString();
49
+ if (violations instanceof Error) {
50
+ this.emit('lint-error', __classPrivateFieldGet(this, _MLEngine_file, "f").path, sourceCode, violations);
51
+ const errMessage = violations.stack ?? violations.message;
52
+ log('exec: error %O', errMessage);
53
+ return {
54
+ violations: [
55
+ {
56
+ severity: 'error',
57
+ message: errMessage,
58
+ ruleId: '@markuplint/ml-core',
59
+ line: 0,
60
+ col: 0,
61
+ raw: '',
62
+ },
63
+ ],
64
+ filePath: __classPrivateFieldGet(this, _MLEngine_file, "f").path,
65
+ sourceCode,
66
+ fixedCode,
67
+ };
68
+ }
69
+ const debugMap = ('debugMap' in core.document && core.document.debugMap()) || null;
70
+ this.emit('lint', __classPrivateFieldGet(this, _MLEngine_file, "f").path, sourceCode, violations, fixedCode, debugMap);
71
+ log('exec: end');
72
+ return {
73
+ violations,
74
+ filePath: __classPrivateFieldGet(this, _MLEngine_file, "f").path,
75
+ sourceCode,
76
+ fixedCode,
77
+ };
78
+ }
79
+ async setCode(code) {
80
+ const core = await this.setup();
81
+ if (!core) {
82
+ return;
83
+ }
84
+ __classPrivateFieldGet(this, _MLEngine_file, "f").setCode(code);
85
+ core.setCode(code);
86
+ }
87
+ async close() {
88
+ this.removeAllListeners();
89
+ await __classPrivateFieldGet(this, _MLEngine_watcher, "f").close();
90
+ }
91
+ async setup() {
92
+ if (__classPrivateFieldGet(this, _MLEngine_core, "f")) {
93
+ return __classPrivateFieldGet(this, _MLEngine_core, "f");
94
+ }
95
+ const fabric = await this.provide(false);
96
+ if (!fabric) {
97
+ return null;
98
+ }
99
+ if (fabric.configErrors) {
100
+ this.emit('config-errors', __classPrivateFieldGet(this, _MLEngine_file, "f").path, fabric.configErrors);
101
+ }
102
+ const core = this.cretateCore(fabric);
103
+ return core;
104
+ }
105
+ async provide(remerge) {
106
+ const configSet = await this.resolveConfig(remerge);
107
+ fileLog('Fetched Config files: %O', configSet.files);
108
+ fileLog('Resolved Config: %O', configSet.config);
109
+ fileLog('Resolved Plugins: %O', configSet.plugins);
110
+ fileLog('Resolve Errors: %O', configSet.errs);
111
+ if (!(await __classPrivateFieldGet(this, _MLEngine_file, "f").isFile())) {
112
+ this.emit('log', 'file-no-exists', `The file doesn't exist or it is not a file: ${__classPrivateFieldGet(this, _MLEngine_file, "f").path}`);
113
+ return null;
114
+ }
115
+ // Exclude
116
+ const excludeFiles = configSet.config.excludeFiles || [];
117
+ for (const excludeFile of excludeFiles) {
118
+ if (__classPrivateFieldGet(this, _MLEngine_file, "f").matches(excludeFile)) {
119
+ this.emit('exclude', __classPrivateFieldGet(this, _MLEngine_file, "f").path, excludeFile);
120
+ return null;
121
+ }
122
+ }
123
+ const { parser, parserOptions, matched } = await this.resolveParser(configSet);
124
+ const checkingExt = !__classPrivateFieldGet(this, _MLEngine_options, "f")?.ignoreExt;
125
+ if (checkingExt && !matched) {
126
+ this.emit('log', 'ext-unmatched', `Avoided linting because a file is unmatched by the extension: ${__classPrivateFieldGet(this, _MLEngine_file, "f").path}`);
127
+ return null;
128
+ }
129
+ const ruleset = this.resolveRuleset(configSet);
130
+ fileLog('Resolved ruleset: %O', ruleset);
131
+ const schemas = await this.resolveSchemas(configSet);
132
+ if (fileLog.enabled) {
133
+ if (schemas[0].cites.length) {
134
+ const [, ...additionalSpecs] = schemas;
135
+ fileLog('Resolved schemas: HTML Standard');
136
+ for (const additionalSpec of additionalSpecs) {
137
+ fileLog('Resolved schemas: %O', additionalSpec);
138
+ }
139
+ }
140
+ else {
141
+ fileLog('Resolved schemas: %O', schemas);
142
+ }
143
+ }
144
+ const rules = await this.resolveRules(configSet.plugins, ruleset);
145
+ fileLog('Resolved rules: %O', rules);
146
+ const locale = await i18n(__classPrivateFieldGet(this, _MLEngine_options, "f")?.locale);
147
+ if (fileLog.enabled) {
148
+ fileLog('Loaded %d rules: %O', rules.length, rules.map(r => r.name));
149
+ }
150
+ return {
151
+ parser,
152
+ parserOptions,
153
+ ruleset,
154
+ schemas,
155
+ rules,
156
+ locale,
157
+ configErrors: configSet.errs,
158
+ };
159
+ }
160
+ async cretateCore(fabric) {
161
+ fileLog('Get source code');
162
+ const sourceCode = await __classPrivateFieldGet(this, _MLEngine_file, "f").getCode();
163
+ fileLog('Source code path: %s', __classPrivateFieldGet(this, _MLEngine_file, "f").path);
164
+ fileLog('Source code size: %dbyte', sourceCode.length);
165
+ this.emit('code', __classPrivateFieldGet(this, _MLEngine_file, "f").path, sourceCode);
166
+ const core = new MLCore({
167
+ sourceCode,
168
+ filename: __classPrivateFieldGet(this, _MLEngine_file, "f").path,
169
+ debug: __classPrivateFieldGet(this, _MLEngine_options, "f")?.debug,
170
+ ...fabric,
171
+ });
172
+ __classPrivateFieldSet(this, _MLEngine_core, core, "f");
173
+ return core;
174
+ }
175
+ async resolveConfig(remerge) {
176
+ const configFilePathsFromTarget = __classPrivateFieldGet(this, _MLEngine_options, "f")?.noSearchConfig
177
+ ? null
178
+ : await configProvider.search(__classPrivateFieldGet(this, _MLEngine_file, "f"));
179
+ this.emit('log', 'configFilePathsFromTarget', configFilePathsFromTarget || 'null');
180
+ const configKey = __classPrivateFieldGet(this, _MLEngine_options, "f")?.config && configProvider.set(__classPrivateFieldGet(this, _MLEngine_options, "f").config);
181
+ this.emit('log', 'configKey', configKey || 'null');
182
+ const configSet = await configProvider.resolve([configFilePathsFromTarget, __classPrivateFieldGet(this, _MLEngine_options, "f")?.configFile, configKey], remerge);
183
+ this.emit('config', __classPrivateFieldGet(this, _MLEngine_file, "f").path, configSet);
184
+ if (__classPrivateFieldGet(this, _MLEngine_options, "f")?.watch) {
185
+ __classPrivateFieldGet(this, _MLEngine_watcher, "f").add(Array.from(configSet.files));
186
+ }
187
+ return configSet;
188
+ }
189
+ async resolveParser(configSet) {
190
+ const parser = await resolveParser(__classPrivateFieldGet(this, _MLEngine_file, "f"), configSet.config.parser, configSet.config.parserOptions);
191
+ this.emit('parser', __classPrivateFieldGet(this, _MLEngine_file, "f").path, parser.parserModName);
192
+ fileLog('Fetched Parser module: %s', parser.parserModName);
193
+ return parser;
194
+ }
195
+ resolveRuleset(configSet) {
196
+ const ruleset = convertRuleset(configSet.config);
197
+ this.emit('ruleset', __classPrivateFieldGet(this, _MLEngine_file, "f").path, ruleset);
198
+ return ruleset;
199
+ }
200
+ async resolveSchemas(configSet) {
201
+ const { schemas } = await resolveSpecs(__classPrivateFieldGet(this, _MLEngine_file, "f").path, configSet.config.specs);
202
+ this.emit('schemas', __classPrivateFieldGet(this, _MLEngine_file, "f").path, schemas);
203
+ return schemas;
204
+ }
205
+ async resolveRules(plugins, ruleset) {
206
+ const rules = await resolveRules(plugins, ruleset, __classPrivateFieldGet(this, _MLEngine_options, "f")?.importPresetRules ?? true, __classPrivateFieldGet(this, _MLEngine_options, "f")?.autoLoad ?? true);
207
+ if (__classPrivateFieldGet(this, _MLEngine_options, "f")?.rules) {
208
+ rules.push(...__classPrivateFieldGet(this, _MLEngine_options, "f").rules);
209
+ }
210
+ this.emit('rules', __classPrivateFieldGet(this, _MLEngine_file, "f").path, rules);
211
+ return rules;
212
+ }
213
+ async i18n() {
214
+ const i18nSettings = await i18n(__classPrivateFieldGet(this, _MLEngine_options, "f")?.locale);
215
+ this.emit('i18n', __classPrivateFieldGet(this, _MLEngine_file, "f").path, i18nSettings);
216
+ return i18nSettings;
217
+ }
218
+ async watch(type, filePath) {
219
+ this.emit('log', `watch:${type}`, filePath);
220
+ const fabric = await this.provide(true);
221
+ if (!fabric) {
222
+ return;
223
+ }
224
+ if (fabric.configErrors) {
225
+ this.emit('config-errors', __classPrivateFieldGet(this, _MLEngine_file, "f").path, fabric.configErrors);
226
+ }
227
+ this.emit('log', 'update:core', __classPrivateFieldGet(this, _MLEngine_file, "f").path);
228
+ __classPrivateFieldGet(this, _MLEngine_core, "f")?.update(fabric);
229
+ this.exec();
230
+ }
231
+ }
232
+ _MLEngine_file = new WeakMap(), _MLEngine_options = new WeakMap(), _MLEngine_core = new WeakMap(), _MLEngine_watcher = new WeakMap();
@@ -0,0 +1,43 @@
1
+ import type { ConfigSet } from '@markuplint/file-resolver';
2
+ import type { LocaleSet } from '@markuplint/i18n';
3
+ import type { MLMarkupLanguageParser } from '@markuplint/ml-ast';
4
+ import type { Config, Violation, ParserOptions } from '@markuplint/ml-config';
5
+ import type { AnyMLRule, MLSchema, Ruleset } from '@markuplint/ml-core';
6
+ export declare 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;
16
+ /**
17
+ * @deprecated
18
+ */
19
+ autoLoad?: boolean;
20
+ };
21
+ export declare type MLFabric = {
22
+ ruleset: Ruleset;
23
+ rules: AnyMLRule[];
24
+ schemas: MLSchema;
25
+ parser: MLMarkupLanguageParser;
26
+ parserOptions: ParserOptions;
27
+ locale: LocaleSet;
28
+ configErrors?: Error[];
29
+ };
30
+ export declare type MLEngineEventMap = {
31
+ log: (phase: string, message: string) => void;
32
+ config: (filePath: string, config: ConfigSet, message?: string) => void;
33
+ exclude: (filePath: string, setting: string, message?: string) => void;
34
+ parser: (filePath: string, parser: string, message?: string) => void;
35
+ ruleset: (filePath: string, ruleset: Ruleset, message?: string) => void;
36
+ schemas: (filePath: string, schemas: MLSchema, message?: string) => void;
37
+ rules: (filePath: string, rules: AnyMLRule[], message?: string) => void;
38
+ i18n: (filePath: string, locale: LocaleSet, message?: string) => void;
39
+ code: (filePath: string, sourceCode: string, message?: string) => void;
40
+ lint: (filePath: string, sourceCode: string, violations: Violation[], fixedCode: string, debug: string[] | null, message?: string) => void;
41
+ 'lint-error': (filePath: string, sourceCode: string, error: Error) => void;
42
+ 'config-errors': (filePath: string, errors: Error[]) => void;
43
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ import type { Config, RuleConfigValue } from '@markuplint/ml-config';
2
+ import type { MLRule } from '@markuplint/ml-core';
3
+ /**
4
+ * @deprecated
5
+ * @param options
6
+ * @returns
7
+ */
8
+ export declare function lint_v1(options: {
9
+ /**
10
+ * Glob pattern
11
+ */
12
+ files?: string | string[];
13
+ /**
14
+ * Target source code of evaluation
15
+ */
16
+ sourceCodes?: string | string[];
17
+ /**
18
+ * File names when `sourceCodes`
19
+ */
20
+ names?: string | string[];
21
+ /**
22
+ * Workspace path when `sourceCodes`
23
+ */
24
+ workspace?: string;
25
+ /**
26
+ * Configure file or object
27
+ */
28
+ config?: string | Config;
29
+ /**
30
+ * The config applied when not resolved from files or set it explicitly.
31
+ */
32
+ defaultConfig?: Config;
33
+ /**
34
+ * Rules (default: `@markuplint/rules`)
35
+ */
36
+ rules?: MLRule<RuleConfigValue, unknown>[];
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
+ rulesAutoResolve?: boolean;
43
+ /**
44
+ * Auto fix
45
+ */
46
+ fix?: boolean;
47
+ /**
48
+ * Locale
49
+ */
50
+ locale?: string;
51
+ }): Promise<import("../types.mjs").MLResultInfo[]>;
package/lib/api/v1.mjs ADDED
@@ -0,0 +1,39 @@
1
+ import { lint } from './lint.mjs';
2
+ /**
3
+ * @deprecated
4
+ * @param options
5
+ * @returns
6
+ */
7
+ export async function lint_v1(options) {
8
+ const filePathList = options.files ? (Array.isArray(options.files) ? options.files : [options.files]) : [];
9
+ const codes = options.sourceCodes
10
+ ? Array.isArray(options.sourceCodes)
11
+ ? options.sourceCodes
12
+ : [options.sourceCodes]
13
+ : [];
14
+ const files = [
15
+ ...filePathList,
16
+ ...codes.map((code, i) => ({
17
+ sourceCode: code,
18
+ name: Array.isArray(options.names) ? options.names?.[i] : options.names,
19
+ workspace: options.workspace?.[i],
20
+ })),
21
+ ];
22
+ let config;
23
+ let configFile;
24
+ if (typeof options.config === 'string') {
25
+ configFile = options.config;
26
+ }
27
+ else if (options.config) {
28
+ config = options.config;
29
+ }
30
+ const result = await lint(files, {
31
+ config,
32
+ configFile,
33
+ noSearchConfig: !options.files,
34
+ rules: options.rules,
35
+ autoLoad: options.rulesAutoResolve ?? true,
36
+ locale: options.locale,
37
+ });
38
+ return result;
39
+ }
@@ -0,0 +1,52 @@
1
+ export declare const help = "\nUsage\n\t$ markuplint <HTML file pathes (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\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";
2
+ export declare const cli: import("meow").Result<{
3
+ config: {
4
+ type: "string";
5
+ alias: string;
6
+ };
7
+ fix: {
8
+ type: "boolean";
9
+ default: false;
10
+ };
11
+ format: {
12
+ type: "string";
13
+ alias: string;
14
+ };
15
+ searchConfig: {
16
+ type: "boolean";
17
+ default: true;
18
+ };
19
+ ignoreExt: {
20
+ type: "boolean";
21
+ default: false;
22
+ };
23
+ importPresetRules: {
24
+ type: "boolean";
25
+ default: true;
26
+ };
27
+ locale: {
28
+ type: "string";
29
+ };
30
+ color: {
31
+ type: "boolean";
32
+ default: true;
33
+ };
34
+ problemOnly: {
35
+ type: "boolean";
36
+ alias: string;
37
+ default: false;
38
+ };
39
+ verbose: {
40
+ type: "boolean";
41
+ default: false;
42
+ };
43
+ init: {
44
+ type: "boolean";
45
+ default: false;
46
+ };
47
+ createRule: {
48
+ type: "boolean";
49
+ default: false;
50
+ };
51
+ }>;
52
+ export declare type CLIOptions = typeof cli.flags;