markuplint 2.0.0-rc.1 → 2.0.0-rc.6

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 CHANGED
@@ -30,18 +30,25 @@ Usage
30
30
  $ <stdout> | markuplint
31
31
 
32
32
  Options
33
- --config-file, -c FILE_PATH Ruleset file path.
34
- --fix, Fix HTML.
35
- --format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
36
- --no-color, Output no color.
37
- --problem-only, -p Output only problems, without passeds.
38
- --verbose Output with detailed information.
39
-
40
- --help, -h Show help.
41
- --version, -v Show version.
33
+ --config, -c FILE_PATH A configuration file path.
34
+ --fix, Fix HTML.
35
+ --format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
36
+ --no-search-config No search a configure file automatically.
37
+ --ignore-ext Evaluate files that are received even though the type of extension.
38
+ --no-import-preset-rules No import preset rules.
39
+ --locale Locale of the message of violation. Default is an OS setting.
40
+ --no-color, Output no color.
41
+ --problem-only, -p Output only problems, without passeds.
42
+ --verbose Output with detailed information.
43
+
44
+ --init Initialize settings interactively.
45
+ --create-rule Add the scaffold of a custom rule.
46
+
47
+ --help, -h Show help.
48
+ --version, -v Show version.
42
49
 
43
50
  Examples
44
- $ markuplint verifyee.html --ruleset path/to/.markuplintrc
51
+ $ markuplint verifyee.html --config path/to/.markuplintrc
45
52
  $ cat verifyee.html | markuplint
46
53
  ```
47
54
 
@@ -113,6 +113,10 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
113
113
  fileLog('Resolved Config: %O', configSet.config);
114
114
  fileLog('Resolved Plugins: %O', configSet.plugins);
115
115
  fileLog('Resolve Errors: %O', configSet.errs);
116
+ if (!(await (0, tslib_1.__classPrivateFieldGet)(this, _MLEngine_file, "f").isFile())) {
117
+ this.emit('log', 'file-no-exists', `The file doesn't exist or it is not a file: ${(0, tslib_1.__classPrivateFieldGet)(this, _MLEngine_file, "f").path}`);
118
+ return null;
119
+ }
116
120
  // Exclude
117
121
  const excludeFiles = configSet.config.excludeFiles || [];
118
122
  for (const excludeFile of excludeFiles) {
@@ -122,9 +126,9 @@ class MLEngine extends strict_event_emitter_1.StrictEventEmitter {
122
126
  }
123
127
  }
124
128
  const { parser, parserOptions, matched } = await this.resolveParser(configSet);
125
- // Ext Matching
126
- if (((_a = (0, tslib_1.__classPrivateFieldGet)(this, _MLEngine_options, "f")) === null || _a === void 0 ? void 0 : _a.extMatch) && !matched && !(0, tslib_1.__classPrivateFieldGet)(this, _MLEngine_file, "f").path.match(/\.html?$/i)) {
127
- this.emit('log', 'extension-matching', `${(0, tslib_1.__classPrivateFieldGet)(this, _MLEngine_file, "f").path}`);
129
+ const checkingExt = !((_a = (0, tslib_1.__classPrivateFieldGet)(this, _MLEngine_options, "f")) === null || _a === void 0 ? void 0 : _a.ignoreExt);
130
+ if (checkingExt && !matched) {
131
+ this.emit('log', 'ext-unmatched', `Avoided linting because a file is unmatched by the extension: ${(0, tslib_1.__classPrivateFieldGet)(this, _MLEngine_file, "f").path}`);
128
132
  return null;
129
133
  }
130
134
  const ruleset = this.resolveRuleset(configSet);
@@ -10,7 +10,7 @@ export declare type APIOptions = {
10
10
  noSearchConfig?: boolean;
11
11
  locale?: string;
12
12
  fix?: boolean;
13
- extMatch?: boolean;
13
+ ignoreExt?: boolean;
14
14
  rules?: AnyMLRule[];
15
15
  importPresetRules?: boolean;
16
16
  /**
package/lib/api/v1.d.ts CHANGED
@@ -48,13 +48,4 @@ export declare function lint_v1(options: {
48
48
  * Locale
49
49
  */
50
50
  locale?: string;
51
- /**
52
- * Confirm the extension of the target file to the regexp of parser plugins.
53
- * It doesn't run the linting if it doesn't match.
54
- * If you don't set a parser plugin and the target file is HTML, It confirms the regexp as `/\.html?$/i`.
55
- * Default is false.
56
- *
57
- * @default false
58
- */
59
- extMatch?: boolean;
60
51
  }): Promise<import("..").MLResultInfo[]>;
package/lib/api/v1.js CHANGED
@@ -40,7 +40,6 @@ async function lint_v1(options) {
40
40
  noSearchConfig: !options.files,
41
41
  rules: options.rules,
42
42
  autoLoad: (_a = options.rulesAutoResolve) !== null && _a !== void 0 ? _a : true,
43
- extMatch: options.extMatch,
44
43
  locale: options.locale,
45
44
  });
46
45
  return result;
@@ -1,25 +1,32 @@
1
1
  import meow from 'meow';
2
- export declare const help = "\nUsage\n\t$ markuplint <HTML file pathes (glob format)>\n\t$ <stdout> | markuplint\n\nOptions\n\t--config-file, -c FILE_PATH Ruleset file path.\n\t--fix, Fix HTML.\n\t--format, -f FORMAT Output format. Support \"JSON\", \"Simple\" and \"Standard\". Default: \"Standard\".\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 --ruleset path/to/.markuplintrc\n\t$ cat verifyee.html | markuplint\n";
2
+ 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";
3
3
  export declare const cli: meow.Result<{
4
- init: {
5
- type: "boolean";
6
- default: false;
4
+ config: {
5
+ type: "string";
6
+ alias: string;
7
7
  };
8
- createRule: {
8
+ fix: {
9
9
  type: "boolean";
10
10
  default: false;
11
11
  };
12
- configFile: {
12
+ format: {
13
13
  type: "string";
14
14
  alias: string;
15
15
  };
16
- fix: {
16
+ searchConfig: {
17
+ type: "boolean";
18
+ default: true;
19
+ };
20
+ ignoreExt: {
17
21
  type: "boolean";
18
22
  default: false;
19
23
  };
20
- format: {
24
+ importPresetRules: {
25
+ type: "boolean";
26
+ default: true;
27
+ };
28
+ locale: {
21
29
  type: "string";
22
- alias: string;
23
30
  };
24
31
  color: {
25
32
  type: "boolean";
@@ -34,5 +41,13 @@ export declare const cli: meow.Result<{
34
41
  type: "boolean";
35
42
  default: false;
36
43
  };
44
+ init: {
45
+ type: "boolean";
46
+ default: false;
47
+ };
48
+ createRule: {
49
+ type: "boolean";
50
+ default: false;
51
+ };
37
52
  }>;
38
53
  export declare type CLIOptions = typeof cli.flags;
@@ -9,34 +9,30 @@ Usage
9
9
  $ <stdout> | markuplint
10
10
 
11
11
  Options
12
- --config-file, -c FILE_PATH Ruleset file path.
13
- --fix, Fix HTML.
14
- --format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
15
- --no-color, Output no color.
16
- --problem-only, -p Output only problems, without passeds.
17
- --verbose Output with detailed information.
12
+ --config, -c FILE_PATH A configuration file path.
13
+ --fix, Fix HTML.
14
+ --format, -f FORMAT Output format. Support "JSON", "Simple" and "Standard". Default: "Standard".
15
+ --no-search-config No search a configure file automatically.
16
+ --ignore-ext Evaluate files that are received even though the type of extension.
17
+ --no-import-preset-rules No import preset rules.
18
+ --locale Locale of the message of violation. Default is an OS setting.
19
+ --no-color, Output no color.
20
+ --problem-only, -p Output only problems, without passeds.
21
+ --verbose Output with detailed information.
18
22
 
19
- --init Initialize settings interactively.
20
- --create-rule Add the scaffold of a custom rule.
23
+ --init Initialize settings interactively.
24
+ --create-rule Add the scaffold of a custom rule.
21
25
 
22
- --help, -h Show help.
23
- --version, -v Show version.
26
+ --help, -h Show help.
27
+ --version, -v Show version.
24
28
 
25
29
  Examples
26
- $ markuplint verifyee.html --ruleset path/to/.markuplintrc
30
+ $ markuplint verifyee.html --config path/to/.markuplintrc
27
31
  $ cat verifyee.html | markuplint
28
32
  `;
29
33
  exports.cli = (0, meow_1.default)(exports.help, {
30
34
  flags: {
31
- init: {
32
- type: 'boolean',
33
- default: false,
34
- },
35
- createRule: {
36
- type: 'boolean',
37
- default: false,
38
- },
39
- configFile: {
35
+ config: {
40
36
  type: 'string',
41
37
  alias: 'c',
42
38
  },
@@ -48,6 +44,21 @@ exports.cli = (0, meow_1.default)(exports.help, {
48
44
  type: 'string',
49
45
  alias: 'f',
50
46
  },
47
+ searchConfig: {
48
+ type: 'boolean',
49
+ default: true,
50
+ },
51
+ ignoreExt: {
52
+ type: 'boolean',
53
+ default: false,
54
+ },
55
+ importPresetRules: {
56
+ type: 'boolean',
57
+ default: true,
58
+ },
59
+ locale: {
60
+ type: 'string',
61
+ },
51
62
  color: {
52
63
  type: 'boolean',
53
64
  default: true,
@@ -61,5 +72,13 @@ exports.cli = (0, meow_1.default)(exports.help, {
61
72
  type: 'boolean',
62
73
  default: false,
63
74
  },
75
+ init: {
76
+ type: 'boolean',
77
+ default: false,
78
+ },
79
+ createRule: {
80
+ type: 'boolean',
81
+ default: false,
82
+ },
64
83
  },
65
84
  });
@@ -1,3 +1,3 @@
1
1
  import type { CLIOptions } from './bootstrap';
2
2
  import type { Target } from '@markuplint/file-resolver';
3
- export declare function command(files: Target[], options: CLIOptions): Promise<void>;
3
+ export declare function command(files: Target[], options: CLIOptions): Promise<boolean>;
@@ -10,19 +10,36 @@ const debug_1 = require("../debug");
10
10
  const output_1 = require("./output");
11
11
  async function command(files, options) {
12
12
  const fix = options.fix;
13
- const configFile = options.configFile && path_1.default.join(process.cwd(), options.configFile);
13
+ const configFile = options.config && path_1.default.join(process.cwd(), options.config);
14
+ const locale = options.locale;
15
+ const searchConfig = options.searchConfig;
16
+ const ignoreExt = options.ignoreExt;
17
+ const importPresetRules = options.importPresetRules;
18
+ const verbose = options.verbose;
14
19
  const fileList = await (0, file_resolver_1.resolveFiles)(files);
15
20
  if (debug_1.log.enabled) {
16
21
  (0, debug_1.log)('File list: %O', fileList.map(f => f.path));
17
22
  (0, debug_1.log)('Config: %s', configFile || 'N/A');
18
23
  (0, debug_1.log)('Fix option: %s', fix);
19
24
  }
25
+ let hasError = false;
20
26
  for (const file of fileList) {
21
- const engine = new api_1.MLEngine(file, { configFile });
27
+ const engine = new api_1.MLEngine(file, {
28
+ configFile,
29
+ fix,
30
+ locale,
31
+ noSearchConfig: !searchConfig,
32
+ ignoreExt,
33
+ importPresetRules,
34
+ debug: verbose,
35
+ });
22
36
  const result = await engine.exec();
23
37
  if (!result) {
24
38
  continue;
25
39
  }
40
+ if (!hasError && result.violations.length) {
41
+ hasError = true;
42
+ }
26
43
  if (fix) {
27
44
  (0, debug_1.log)('Overwrite file: %s', result.filePath);
28
45
  await fs_1.promises.writeFile(result.filePath, result.fixedCode, { encoding: 'utf8' });
@@ -33,5 +50,6 @@ async function command(files, options) {
33
50
  await (0, output_1.output)(result, options);
34
51
  }
35
52
  }
53
+ return hasError;
36
54
  }
37
55
  exports.command = command;
@@ -4,9 +4,12 @@ exports.createRule = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const create_rule_helper_1 = require("@markuplint/create-rule-helper");
6
6
  const cli_color_1 = (0, tslib_1.__importDefault)(require("cli-color"));
7
+ const util_1 = require("../../util");
7
8
  const install_module_1 = require("../init/install-module");
8
9
  const prompt_1 = require("../prompt");
9
10
  async function createRule() {
11
+ (0, util_1.write)((0, util_1.head)('Create a rule'));
12
+ util_1.write.break();
10
13
  const purpose = await (0, prompt_1.select)({
11
14
  message: 'What purpose do you create the rule for?',
12
15
  choices: [
@@ -49,5 +52,5 @@ function output(name, icon, title, path) {
49
52
  const _marker = cli_color_1.default.xterm(39)('✔') + ' ';
50
53
  const _title = (icon, title) => `${icon} ` + cli_color_1.default.bold(`${name}/${title}`);
51
54
  const _file = (path) => ' ' + cli_color_1.default.cyanBright(path);
52
- process.stdout.write(_marker + _title(icon, title) + _file(path) + '\n');
55
+ (0, util_1.write)(_marker + _title(icon, title) + _file(path));
53
56
  }
@@ -0,0 +1 @@
1
+ export declare const head: string;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.head = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const cli_color_1 = (0, tslib_1.__importDefault)(require("cli-color"));
6
+ const strip_ansi_1 = (0, tslib_1.__importDefault)(require("strip-ansi"));
7
+ const logo = `<${cli_color_1.default.xterm(39)('✔')}>`;
8
+ const markuplint = `markup${cli_color_1.default.xterm(39)('lint')}`;
9
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
10
+ const version = require('../../package.json').version;
11
+ const box = (lines, { width = 40, padding = 1, center = false, noColor = false }) => {
12
+ const bt = `┌${'─'.repeat(width - 2)}┐`;
13
+ const pd = `│${' '.repeat(width - 2)}│`;
14
+ const bb = `└${'─'.repeat(width - 2)}┘`;
15
+ const texts = lines.map(line => {
16
+ const nc = (0, strip_ansi_1.default)(line);
17
+ const length = nc.length;
18
+ const pad = width - 2 - 1 - length;
19
+ const pad2 = Math.floor(pad / 2);
20
+ const padD = pad % 2;
21
+ const padl = center ? pad2 : 0;
22
+ const padr = center ? pad2 + padD : pad;
23
+ const text = noColor ? nc : line;
24
+ return `│ ${' '.repeat(padl)}${text}${' '.repeat(padr)}│`;
25
+ });
26
+ const result = [bt, pd, ...texts, pd, bb];
27
+ return result.join('\n');
28
+ };
29
+ exports.head = box([`${logo} ${markuplint}`, cli_color_1.default.blackBright(`v${version}`), '', cli_color_1.default.bold('Initialization')], {
30
+ center: true,
31
+ });
package/lib/cli/index.js CHANGED
@@ -33,21 +33,21 @@ const init_1 = require("./init");
33
33
  }
34
34
  const files = bootstrap_1.cli.input;
35
35
  if (files.length) {
36
- await (0, command_1.command)(files, bootstrap_1.cli.flags).catch(err => {
36
+ const hasError = await (0, command_1.command)(files, bootstrap_1.cli.flags).catch(err => {
37
37
  throw err;
38
38
  // process.exit(1);
39
39
  });
40
- process.exit(0);
40
+ process.exit(hasError ? 1 : 0);
41
41
  }
42
42
  if (usePipe()) {
43
43
  (0, get_stdin_1.default)()
44
44
  .then(async (stdin) => {
45
45
  if (stdin) {
46
- await (0, command_1.command)([{ sourceCode: stdin }], bootstrap_1.cli.flags).catch(err => {
46
+ const hasError = await (0, command_1.command)([{ sourceCode: stdin }], bootstrap_1.cli.flags).catch(err => {
47
47
  process.stderr.write(err + '\n');
48
48
  process.exit(1);
49
49
  });
50
- process.exit(0);
50
+ process.exit(hasError ? 1 : 0);
51
51
  }
52
52
  // result is empty
53
53
  bootstrap_1.cli.showHelp(1);
@@ -6,6 +6,7 @@ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
6
  const path_1 = (0, tslib_1.__importDefault)(require("path"));
7
7
  const util_1 = (0, tslib_1.__importDefault)(require("util"));
8
8
  const ml_config_1 = require("@markuplint/ml-config");
9
+ const util_2 = require("../../util");
9
10
  const prompt_1 = require("../prompt");
10
11
  const install_module_1 = require("./install-module");
11
12
  const writeFile = util_1.default.promisify(fs_1.default.writeFile);
@@ -28,10 +29,43 @@ const defaultRules = {
28
29
  category: 'validation',
29
30
  default: true,
30
31
  },
32
+ 'attr-equal-space-after': {
33
+ category: 'style',
34
+ default: true,
35
+ },
36
+ 'attr-equal-space-before': {
37
+ category: 'style',
38
+ default: true,
39
+ },
40
+ 'attr-spacing': {
41
+ category: 'style',
42
+ default: true,
43
+ },
44
+ 'attr-value-quotes': {
45
+ category: 'style',
46
+ default: true,
47
+ },
48
+ 'case-sensitive-attr-name': {
49
+ category: 'style',
50
+ default: true,
51
+ },
52
+ 'case-sensitive-attr-value': {
53
+ category: 'style',
54
+ default: true,
55
+ },
56
+ 'case-sensitive-tag-name': {
57
+ category: 'style',
58
+ default: true,
59
+ },
31
60
  'character-reference': {
32
61
  category: 'validation',
33
62
  default: true,
34
63
  },
64
+ 'class-naming': {
65
+ category: 'naming-convention',
66
+ default: false,
67
+ recommendedValue: '/.+/',
68
+ },
35
69
  'deprecated-attr': {
36
70
  category: 'validation',
37
71
  default: true,
@@ -40,19 +74,28 @@ const defaultRules = {
40
74
  category: 'validation',
41
75
  default: true,
42
76
  },
77
+ 'disallowed-element': {
78
+ category: 'validation',
79
+ default: false,
80
+ },
43
81
  doctype: {
44
82
  category: 'validation',
45
83
  default: true,
46
84
  },
47
- 'id-duplication': {
48
- category: 'validation',
85
+ 'end-tag': {
86
+ category: 'style',
49
87
  default: true,
50
88
  },
51
- 'permitted-contents': {
89
+ 'id-duplication': {
52
90
  category: 'validation',
53
91
  default: true,
54
92
  },
55
- 'required-attr': {
93
+ indentation: {
94
+ category: 'style',
95
+ default: false,
96
+ recommendedValue: 2,
97
+ },
98
+ 'ineffective-attr': {
56
99
  category: 'validation',
57
100
  default: true,
58
101
  },
@@ -64,52 +107,52 @@ const defaultRules = {
64
107
  category: 'a11y',
65
108
  default: true,
66
109
  },
67
- 'required-h1': {
68
- category: 'a11y',
110
+ 'no-boolean-attr-value': {
111
+ category: 'style',
69
112
  default: true,
70
113
  },
71
- 'wai-aria': {
72
- category: 'a11y',
114
+ 'no-default-value': {
115
+ category: 'style',
73
116
  default: true,
74
117
  },
75
- 'class-naming': {
76
- category: 'naming-convention',
77
- default: false,
78
- recommendedValue: '/.+/',
79
- },
80
- 'attr-equal-space-after': {
118
+ 'no-hard-code-id': {
81
119
  category: 'style',
82
120
  default: true,
83
121
  },
84
- 'attr-equal-space-before': {
85
- category: 'style',
122
+ 'no-refer-to-non-existent-id': {
123
+ category: 'a11y',
86
124
  default: true,
87
125
  },
88
- 'attr-spacing': {
126
+ 'no-use-event-handler-attr': {
89
127
  category: 'style',
90
128
  default: true,
91
129
  },
92
- 'attr-value-quotes': {
93
- category: 'style',
130
+ 'permitted-contents': {
131
+ category: 'validation',
94
132
  default: true,
95
133
  },
96
- 'case-sensitive-attr-name': {
97
- category: 'style',
134
+ 'required-attr': {
135
+ category: 'validation',
98
136
  default: true,
99
137
  },
100
- 'case-sensitive-tag-name': {
101
- category: 'style',
138
+ 'required-element': {
139
+ category: 'validation',
102
140
  default: true,
103
141
  },
104
- indentation: {
105
- category: 'style',
106
- default: false,
107
- recommendedValue: 2,
142
+ 'required-h1': {
143
+ category: 'a11y',
144
+ default: true,
145
+ },
146
+ 'wai-aria': {
147
+ category: 'a11y',
148
+ default: true,
108
149
  },
109
150
  };
110
151
  const extRExp = {
152
+ jsx: '\\.[jt]sx?$',
111
153
  vue: '\\.vue$',
112
154
  svelte: '\\.svelte$',
155
+ astro: '\\.astro',
113
156
  pug: '\\.pug$',
114
157
  php: '\\.php$',
115
158
  erb: '\\.erb$',
@@ -120,14 +163,15 @@ const extRExp = {
120
163
  };
121
164
  async function initialize() {
122
165
  let config = {};
123
- write('markuplit initialization');
124
- write.break();
166
+ (0, util_2.write)((0, util_2.head)('Initialization'));
167
+ util_2.write.break();
125
168
  const langs = await (0, prompt_1.multiSelect)({
126
169
  message: 'Which do you use template engines?',
127
170
  choices: [
128
171
  { name: 'React (JSX)', value: 'jsx' },
129
172
  { name: 'Vue', value: 'vue' },
130
173
  { name: 'Svelte', value: 'svelte' },
174
+ { name: 'Astro', value: 'astro' },
131
175
  { name: 'Pug', value: 'pug' },
132
176
  { name: 'PHP', value: 'php' },
133
177
  { name: 'eRuby', value: 'erb' },
@@ -139,13 +183,8 @@ async function initialize() {
139
183
  });
140
184
  const autoInstall = await (0, prompt_1.confirm)('May I install them automatically?');
141
185
  const customize = await (0, prompt_1.confirm)('Do you customize rules?');
142
- if (langs && langs.length) {
143
- config.parser = {};
144
- }
145
186
  for (const lang of langs) {
146
- if (!config.parser) {
147
- continue;
148
- }
187
+ config.parser = config.parser || {};
149
188
  // @ts-ignore
150
189
  const ext = extRExp[lang];
151
190
  if (!ext) {
@@ -155,14 +194,14 @@ async function initialize() {
155
194
  if (lang === 'vue') {
156
195
  config = (0, ml_config_1.mergeConfig)(config, {
157
196
  specs: {
158
- '/\\.vue$/i': '@markuplint/vue-spec',
197
+ '\\.vue$': '@markuplint/vue-spec',
159
198
  },
160
199
  });
161
200
  }
162
201
  if (lang === 'jsx') {
163
202
  config = (0, ml_config_1.mergeConfig)(config, {
164
203
  specs: {
165
- '/\\.[jt]sx?$/i': '@markuplint/react-spec',
204
+ '\\.[jt]sx?$': '@markuplint/react-spec',
166
205
  },
167
206
  });
168
207
  }
@@ -191,18 +230,24 @@ async function initialize() {
191
230
  }
192
231
  }
193
232
  else {
194
- config.rules = {};
195
- const ruleNames = Object.keys(defaultRules);
196
- for (const ruleName of ruleNames) {
197
- const rule = defaultRules[ruleName];
198
- config.rules[ruleName] = rule.default;
233
+ const recommended = await (0, prompt_1.confirm)('Does it import the recommended config?');
234
+ if (recommended) {
235
+ config.extends = [...(config.extends || []), 'markuplint:recommended'];
236
+ }
237
+ else {
238
+ config.rules = {};
239
+ const ruleNames = Object.keys(defaultRules);
240
+ for (const ruleName of ruleNames) {
241
+ const rule = defaultRules[ruleName];
242
+ config.rules[ruleName] = rule.default;
243
+ }
199
244
  }
200
245
  }
201
246
  const filePath = path_1.default.resolve(process.cwd(), '.markuplintrc');
202
247
  await writeFile(filePath, JSON.stringify(config, null, 2), { encoding: 'utf-8' });
203
- write(`✨Created: ${filePath}`);
248
+ (0, util_2.write)(`✨Created: ${filePath}`);
204
249
  if (autoInstall) {
205
- write('Install automatically');
250
+ (0, util_2.write)('Install automatically');
206
251
  const modules = ['markuplint', ...langs.map(lang => `@markuplint/${lang}-parser`)];
207
252
  if (langs.includes('vue')) {
208
253
  modules.push('@markuplint/vue-spec');
@@ -212,23 +257,15 @@ async function initialize() {
212
257
  }
213
258
  const result = await (0, install_module_1.installModule)(modules, true).catch(e => new Error(e));
214
259
  if (result instanceof Error) {
215
- error.exit();
260
+ util_2.error.exit();
216
261
  return;
217
262
  }
218
263
  if (result.alreadyExists) {
219
- write('Modules are installed already.');
264
+ (0, util_2.write)('Modules are installed already.');
220
265
  }
221
266
  else {
222
- write('✨ Success');
267
+ (0, util_2.write)('✨ Success');
223
268
  }
224
269
  }
225
270
  }
226
271
  exports.initialize = initialize;
227
- function write(message) {
228
- process.stdout.write(message + '\n');
229
- }
230
- write.break = () => process.stdout.write('\n');
231
- function error(message) {
232
- process.stderr.write(message + '\n');
233
- }
234
- error.exit = () => process.exit(1);