markuplint 3.0.0-rc.5 → 3.0.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/lib/api/ml-engine.js +16 -3
- package/lib/cli/create-rule/index.js +40 -20
- package/package.json +10 -10
package/lib/api/ml-engine.js
CHANGED
|
@@ -10,6 +10,7 @@ const debug_1 = require("../debug");
|
|
|
10
10
|
const i18n_1 = require("../i18n");
|
|
11
11
|
const log = debug_1.log.extend('ml-engine');
|
|
12
12
|
const fileLog = log.extend('file');
|
|
13
|
+
const configLog = log.extend('config');
|
|
13
14
|
class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
14
15
|
static async toMLFile(target) {
|
|
15
16
|
const files = await (0, file_resolver_1.resolveFiles)([target]);
|
|
@@ -211,13 +212,25 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
|
|
|
211
212
|
async resolveConfig(cache) {
|
|
212
213
|
var _a, _b, _c, _d, _e, _f;
|
|
213
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
|
+
configLog('defaultConfigKey: %s', defaultConfigKey !== null && defaultConfigKey !== void 0 ? defaultConfigKey : 'N/A');
|
|
216
|
+
this.emit('log', 'defaultConfigKey', defaultConfigKey !== null && defaultConfigKey !== void 0 ? defaultConfigKey : 'N/A');
|
|
214
217
|
const configFilePathsFromTarget = ((_c = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _c === void 0 ? void 0 : _c.noSearchConfig)
|
|
215
218
|
? defaultConfigKey !== null && defaultConfigKey !== void 0 ? defaultConfigKey : null
|
|
216
219
|
: (await tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").search(tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f"))) || defaultConfigKey;
|
|
217
|
-
|
|
220
|
+
configLog('configFilePathsFromTarget: %s', configFilePathsFromTarget !== null && configFilePathsFromTarget !== void 0 ? configFilePathsFromTarget : 'N/A');
|
|
221
|
+
this.emit('log', 'configFilePathsFromTarget', configFilePathsFromTarget !== null && configFilePathsFromTarget !== void 0 ? configFilePathsFromTarget : 'N/A');
|
|
218
222
|
const configKey = ((_d = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _d === void 0 ? void 0 : _d.config) && tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").set(tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f").config);
|
|
219
|
-
|
|
220
|
-
|
|
223
|
+
configLog('option.config: %s', configKey !== null && configKey !== void 0 ? configKey : 'N/A');
|
|
224
|
+
this.emit('log', 'option.config', configFilePathsFromTarget !== null && configFilePathsFromTarget !== void 0 ? configFilePathsFromTarget : 'N/A');
|
|
225
|
+
let defaultRecommended = null;
|
|
226
|
+
if (!defaultConfigKey && !configFilePathsFromTarget && !configKey) {
|
|
227
|
+
// No configured
|
|
228
|
+
// Default: set recommended
|
|
229
|
+
defaultRecommended = tslib_1.__classPrivateFieldGet(this, _MLEngine_configProvider, "f").set({ extends: ['markuplint:recommended'] });
|
|
230
|
+
}
|
|
231
|
+
configLog('defaultRecommended: %s', defaultRecommended !== null && defaultRecommended !== void 0 ? defaultRecommended : 'N/A');
|
|
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, (_e = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _e === void 0 ? void 0 : _e.configFile, configKey, defaultRecommended], cache);
|
|
221
234
|
this.emit('config', tslib_1.__classPrivateFieldGet(this, _MLEngine_file, "f").path, configSet);
|
|
222
235
|
if ((_f = tslib_1.__classPrivateFieldGet(this, _MLEngine_options, "f")) === null || _f === void 0 ? void 0 : _f.watch) {
|
|
223
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.
|
|
@@ -2,12 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createRule = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const node_path_1 = require("node:path");
|
|
5
6
|
const create_rule_helper_1 = require("@markuplint/create-rule-helper");
|
|
6
7
|
const cli_color_1 = tslib_1.__importDefault(require("cli-color"));
|
|
7
8
|
const util_1 = require("../../util");
|
|
8
9
|
const install_module_1 = require("../init/install-module");
|
|
9
10
|
const prompt_1 = require("../prompt");
|
|
11
|
+
const icons = {
|
|
12
|
+
README: '📝',
|
|
13
|
+
index: '📜',
|
|
14
|
+
schema: '⚙️ ',
|
|
15
|
+
package: '🎁',
|
|
16
|
+
tsconfig: '💎',
|
|
17
|
+
};
|
|
10
18
|
async function createRule() {
|
|
19
|
+
var _a;
|
|
11
20
|
(0, util_1.write)((0, util_1.head)('Create a rule'));
|
|
12
21
|
util_1.write.break();
|
|
13
22
|
const firstChoices = [
|
|
@@ -21,7 +30,31 @@ async function createRule() {
|
|
|
21
30
|
message: 'What purpose do you create the rule for?',
|
|
22
31
|
choices: firstChoices,
|
|
23
32
|
});
|
|
24
|
-
const
|
|
33
|
+
const dirQuestion = purpose === 'ADD_TO_PROJECT' ? 'What is the directory name?' : 'What is the plugin name?';
|
|
34
|
+
const pluginName = purpose === 'CONTRIBUTE_TO_CORE' ? '' : await (0, prompt_1.input)(dirQuestion, /^[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)*$/i);
|
|
35
|
+
const ruleName = await (0, prompt_1.input)('What is the rule name?', /^[a-z][a-z0-9]*(?:-[a-z][a-z0-9]*)*$/i);
|
|
36
|
+
const core = purpose === 'CONTRIBUTE_TO_CORE'
|
|
37
|
+
? {
|
|
38
|
+
description: await (0, prompt_1.input)('Description:'),
|
|
39
|
+
category: await (0, prompt_1.select)({
|
|
40
|
+
message: 'Category:',
|
|
41
|
+
choices: [
|
|
42
|
+
{ name: 'Conformance checking', value: 'validation' },
|
|
43
|
+
{ name: 'Accessibility', value: 'a11y' },
|
|
44
|
+
{ name: 'Naming Convention', value: 'naming-convention' },
|
|
45
|
+
{ name: 'Maintainability', value: 'maintainability' },
|
|
46
|
+
{ name: 'Style', value: 'style' },
|
|
47
|
+
],
|
|
48
|
+
}),
|
|
49
|
+
severity: await (0, prompt_1.select)({
|
|
50
|
+
message: 'Severity:',
|
|
51
|
+
choices: [
|
|
52
|
+
{ name: 'error', value: 'error' },
|
|
53
|
+
{ name: 'warning', value: 'warning' },
|
|
54
|
+
],
|
|
55
|
+
}),
|
|
56
|
+
}
|
|
57
|
+
: undefined;
|
|
25
58
|
const lang = purpose === 'CONTRIBUTE_TO_CORE'
|
|
26
59
|
? 'TYPESCRIPT'
|
|
27
60
|
: await (0, prompt_1.select)({
|
|
@@ -32,27 +65,14 @@ async function createRule() {
|
|
|
32
65
|
],
|
|
33
66
|
});
|
|
34
67
|
const needTest = purpose === 'CONTRIBUTE_TO_CORE' ? true : await (0, prompt_1.confirm)('Do you need the test?', { initial: true });
|
|
35
|
-
const result = await (0, create_rule_helper_1.createRuleHelper)({ purpose,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
if (result.test) {
|
|
39
|
-
output(name, '🖍 ', 'index.spec', result.test);
|
|
40
|
-
}
|
|
41
|
-
if (result.rules) {
|
|
42
|
-
output(name, '🛡 ', 'rules', result.rules);
|
|
43
|
-
}
|
|
44
|
-
if (result.rulesTest) {
|
|
45
|
-
output(name, '🖍 ', 'rules.spec', result.rulesTest);
|
|
68
|
+
const result = await (0, create_rule_helper_1.createRuleHelper)({ purpose, pluginName, ruleName, lang, needTest, core });
|
|
69
|
+
for (const file of result.files) {
|
|
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));
|
|
46
71
|
}
|
|
47
|
-
if (result.
|
|
48
|
-
output(name, '⚙️ ', 'schema.json', result.schemaJson);
|
|
49
|
-
}
|
|
50
|
-
if (result.packageJson) {
|
|
51
|
-
output(name, '🎁', 'package.json', result.packageJson);
|
|
52
|
-
if (result.tsConfig) {
|
|
53
|
-
output(name, '💎', 'tsconfig.json', result.tsConfig);
|
|
54
|
-
}
|
|
72
|
+
if (result.dependencies.length) {
|
|
55
73
|
await (0, install_module_1.installModule)(result.dependencies);
|
|
74
|
+
}
|
|
75
|
+
if (result.devDependencies.length) {
|
|
56
76
|
await (0, install_module_1.installModule)(result.devDependencies, true);
|
|
57
77
|
}
|
|
58
78
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "markuplint",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "A linter for all markup developers",
|
|
5
5
|
"author": "Yusuke Hirao",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"execa": "5"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@markuplint/create-rule-helper": "3.0.0
|
|
29
|
-
"@markuplint/file-resolver": "3.0.0
|
|
30
|
-
"@markuplint/html-parser": "3.0.0
|
|
31
|
-
"@markuplint/html-spec": "3.0.0
|
|
28
|
+
"@markuplint/create-rule-helper": "3.0.0",
|
|
29
|
+
"@markuplint/file-resolver": "3.0.0",
|
|
30
|
+
"@markuplint/html-parser": "3.0.0",
|
|
31
|
+
"@markuplint/html-spec": "3.0.0",
|
|
32
32
|
"@markuplint/i18n": "3.0.0-rc.5",
|
|
33
33
|
"@markuplint/ml-ast": "3.0.0-rc.5",
|
|
34
|
-
"@markuplint/ml-config": "3.0.0
|
|
35
|
-
"@markuplint/ml-core": "3.0.0
|
|
36
|
-
"@markuplint/ml-spec": "3.0.0
|
|
37
|
-
"@markuplint/rules": "3.0.0
|
|
34
|
+
"@markuplint/ml-config": "3.0.0",
|
|
35
|
+
"@markuplint/ml-core": "3.0.0",
|
|
36
|
+
"@markuplint/ml-spec": "3.0.0",
|
|
37
|
+
"@markuplint/rules": "3.0.0",
|
|
38
38
|
"chokidar": "^3.5.3",
|
|
39
39
|
"cli-color": "^2.0.3",
|
|
40
40
|
"debug": "^4.3.4",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"tslib": "^2.4.1",
|
|
51
51
|
"uuid": "^9.0.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "51af6a64bb8da54376a138f19e3f15a2f759a967"
|
|
54
54
|
}
|