markuplint 2.0.0-rc.2 → 2.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.
@@ -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
+ });
@@ -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);
@@ -1,5 +1,5 @@
1
1
  export declare type InstallModuleResult = {
2
- success: boolean;
3
- alreadyExists: boolean;
2
+ success: boolean;
3
+ alreadyExists: boolean;
4
4
  };
5
5
  export declare function installModule(module: string[], dev?: boolean): Promise<InstallModuleResult>;
@@ -1,18 +1,23 @@
1
1
  declare type SelectQuestion<T> = {
2
- message: string;
3
- choices: {
4
- name: string;
5
- value: T;
6
- }[];
2
+ message: string;
3
+ choices: {
4
+ name: string;
5
+ value: T;
6
+ }[];
7
7
  };
8
8
  export declare function select<T>(question: SelectQuestion<T>): Promise<T>;
9
9
  export declare function multiSelect<T>(question: SelectQuestion<T>): Promise<T[]>;
10
10
  export declare function input<T extends string = string>(question: string, validation?: RegExp): Promise<T>;
11
- export declare function confirm(question: string, options?: {
12
- initial?: boolean;
13
- }): Promise<boolean>;
14
- export declare function confirmSequence<T extends string = string>(questions: {
15
- message: string;
16
- name: T;
17
- }[]): Promise<Record<T, boolean>>;
11
+ export declare function confirm(
12
+ question: string,
13
+ options?: {
14
+ initial?: boolean;
15
+ },
16
+ ): Promise<boolean>;
17
+ export declare function confirmSequence<T extends string = string>(
18
+ questions: {
19
+ message: string;
20
+ name: T;
21
+ }[],
22
+ ): Promise<Record<T, boolean>>;
18
23
  export {};
@@ -1,5 +1,5 @@
1
1
  export declare type GlobalSettings = {
2
- locale: string;
2
+ locale: string;
3
3
  };
4
4
  export declare function setGlobal(settings: Partial<GlobalSettings>): void;
5
5
  export declare function getGlobal(): Readonly<Partial<GlobalSettings>>;
package/lib/i18n.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export declare function i18n(locale?: string): Promise<{
2
- locale: string;
3
- listFormat?: import("packages/@markuplint/i18n/src/types").ListFormat | undefined;
4
- keywords?: import("packages/@markuplint/i18n/src/types").LocalesKeywords | undefined;
5
- sentences?: import("packages/@markuplint/i18n/src/types").LocalesKeywords | undefined;
2
+ locale: string;
3
+ listFormat?: import('packages/@markuplint/i18n/src/types').ListFormat | undefined;
4
+ keywords?: import('packages/@markuplint/i18n/src/types').LocalesKeywords | undefined;
5
+ sentences?: import('packages/@markuplint/i18n/src/types').LocalesKeywords | undefined;
6
6
  }>;
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.simpleReporter = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const cli_color_1 = (0, tslib_1.__importDefault)(require("cli-color"));
6
- const utils_1 = require("./utils");
6
+ 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 simpleReporter(results, options) {
@@ -15,20 +15,20 @@ function simpleReporter(results, options) {
15
15
  for (const violation of results.violations) {
16
16
  sizes.line = Math.max(sizes.line, violation.line.toString(10).length);
17
17
  sizes.col = Math.max(sizes.col, violation.col.toString(10).length);
18
- const meg = (0, utils_1.messageToString)(violation.message, violation.reason);
19
- sizes.meg = Math.max(sizes.meg, (0, utils_1.w)(meg));
18
+ const meg = (0, util_1.messageToString)(violation.message, violation.reason);
19
+ sizes.meg = Math.max(sizes.meg, (0, util_1.w)(meg));
20
20
  }
21
21
  const out = [];
22
22
  if (results.violations.length) {
23
- out.push(`<${utils_1.markuplint}> ${cli_color_1.default.underline(results.filePath)}: ${loggerError('✗')}`);
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('⚠️');
26
- const meg = (0, utils_1.messageToString)(violation.message, violation.reason);
27
- out.push(` ${cli_color_1.default.cyan(`${(0, utils_1.p)(violation.line, sizes.line, true)}:${(0, utils_1.p)(violation.col, sizes.col)}`)} ${s} ${(0, utils_1.p)(meg, sizes.meg)} ${cli_color_1.default.xterm(8)(violation.ruleId)} `);
26
+ const meg = (0, util_1.messageToString)(violation.message, violation.reason);
27
+ out.push(` ${cli_color_1.default.cyan(`${(0, util_1.p)(violation.line, sizes.line, true)}:${(0, util_1.p)(violation.col, sizes.col)}`)} ${s} ${(0, util_1.p)(meg, sizes.meg)} ${cli_color_1.default.xterm(8)(violation.ruleId)} `);
28
28
  }
29
29
  }
30
30
  else if (!options.problemOnly) {
31
- out.push(`<${utils_1.markuplint}> ${cli_color_1.default.underline(results.filePath)}: ${cli_color_1.default.green('✓')}`);
31
+ out.push(`<${util_1.markuplint}> ${cli_color_1.default.underline(results.filePath)}: ${cli_color_1.default.green('✓')}`);
32
32
  }
33
33
  return out;
34
34
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.standardReporter = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const cli_color_1 = (0, tslib_1.__importDefault)(require("cli-color"));
6
- const utils_1 = require("./utils");
6
+ 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) {
@@ -15,8 +15,8 @@ function standardReporter(results, options) {
15
15
  for (const violation of results.violations) {
16
16
  sizes.line = Math.max(sizes.line, violation.line.toString(10).length);
17
17
  sizes.col = Math.max(sizes.col, violation.col.toString(10).length);
18
- const meg = (0, utils_1.messageToString)(violation.message, violation.reason);
19
- sizes.meg = Math.max(sizes.meg, (0, utils_1.w)(meg));
18
+ const meg = (0, util_1.messageToString)(violation.message, violation.reason);
19
+ sizes.meg = Math.max(sizes.meg, (0, util_1.w)(meg));
20
20
  }
21
21
  const out = [];
22
22
  if (results.violations.length) {
@@ -28,20 +28,20 @@ function standardReporter(results, options) {
28
28
  const before = line.substring(0, violation.col - 1);
29
29
  const after = line.substring(violation.col - 1 + violation.raw.length);
30
30
  const logger = violation.severity === 'error' ? loggerError : loggerWarning;
31
- const meg = (0, utils_1.messageToString)(violation.message, violation.reason);
32
- out.push(`<${utils_1.markuplint}> ${logger(`${violation.severity}: ${meg} (${violation.ruleId}) ${cli_color_1.default.underline(`${results.filePath}:${violation.line}:${violation.col}`)}`)}`);
31
+ const meg = (0, util_1.messageToString)(violation.message, violation.reason);
32
+ out.push(`<${util_1.markuplint}> ${logger(`${violation.severity}: ${meg} (${violation.ruleId}) ${cli_color_1.default.underline(`${results.filePath}:${violation.line}:${violation.col}`)}`)}`);
33
33
  if (violation.line - 1 > 0) {
34
- out.push(` ${cli_color_1.default.cyan((0, utils_1.p)(violation.line - 1, sizes.col, true))}: ${(0, utils_1.space)(prev)}`);
34
+ out.push(` ${cli_color_1.default.cyan((0, util_1.p)(violation.line - 1, sizes.col, true))}: ${(0, util_1.space)(prev)}`);
35
35
  }
36
- out.push(` ${cli_color_1.default.cyan((0, utils_1.p)(violation.line, sizes.col, true))}: ${(0, utils_1.space)(before)}${cli_color_1.default.bgRed(violation.raw)}${(0, utils_1.space)(after)}`);
36
+ out.push(` ${cli_color_1.default.cyan((0, util_1.p)(violation.line, sizes.col, true))}: ${(0, util_1.space)(before)}${cli_color_1.default.bgRed(violation.raw)}${(0, util_1.space)(after)}`);
37
37
  if (!options.color) {
38
- out.push(` ${(0, utils_1.invisibleSpace)(before)}${'^'.repeat(violation.raw.length)}${(0, utils_1.invisibleSpace)(after)}`);
38
+ out.push(` ${(0, util_1.invisibleSpace)(before)}${'^'.repeat(violation.raw.length)}${(0, util_1.invisibleSpace)(after)}`);
39
39
  }
40
- out.push(` ${cli_color_1.default.cyan((0, utils_1.p)(violation.line + 1, sizes.col, true))}: ${(0, utils_1.space)(next)}`);
40
+ out.push(` ${cli_color_1.default.cyan((0, util_1.p)(violation.line + 1, sizes.col, true))}: ${(0, util_1.space)(next)}`);
41
41
  }
42
42
  }
43
43
  else if (!options.problemOnly) {
44
- out.push(`<${utils_1.markuplint}> ${cli_color_1.default.green('passed')} ${cli_color_1.default.underline(results.filePath)}`);
44
+ out.push(`<${util_1.markuplint}> ${cli_color_1.default.green('passed')} ${cli_color_1.default.underline(results.filePath)}`);
45
45
  }
46
46
  return out;
47
47
  }
@@ -1,35 +1,53 @@
1
1
  import type { Target } from '@markuplint/file-resolver';
2
2
  import type { Config, RuleConfigValue, Rule, RegexSelector } from '@markuplint/ml-config';
3
3
  import type { AnyMLRule, RuleSeed } from '@markuplint/ml-core';
4
- export declare function mlTest(sourceCode: string, config: Config, rules?: AnyMLRule[], locale?: string, fix?: boolean): Promise<{
5
- violations: import("@markuplint/ml-config").Violation[];
6
- fixedCode: string;
4
+ export declare function mlTest(
5
+ sourceCode: string,
6
+ config: Config,
7
+ rules?: AnyMLRule[],
8
+ locale?: string,
9
+ fix?: boolean,
10
+ ): Promise<{
11
+ violations: import('@markuplint/ml-config').Violation[];
12
+ fixedCode: string;
7
13
  }>;
8
- export declare function mlRuleTest<T extends RuleConfigValue, O = null>(rule: RuleSeed<T, O>, sourceCode: string, config?: Omit<Config, 'rules' | 'nodeRules' | 'childNodeRules'> & {
9
- rule?: Rule<T, O>;
10
- nodeRule?: NodeRule<T, O>[];
11
- childNodeRule?: ChildNodeRule<T, O>[];
12
- }, fix?: boolean, locale?: string): Promise<{
13
- violations: import("@markuplint/ml-config").Violation[];
14
- fixedCode: string;
14
+ export declare function mlRuleTest<T extends RuleConfigValue, O = null>(
15
+ rule: RuleSeed<T, O>,
16
+ sourceCode: string,
17
+ config?: Omit<Config, 'rules' | 'nodeRules' | 'childNodeRules'> & {
18
+ rule?: Rule<T, O>;
19
+ nodeRule?: NodeRule<T, O>[];
20
+ childNodeRule?: ChildNodeRule<T, O>[];
21
+ },
22
+ fix?: boolean,
23
+ locale?: string,
24
+ ): Promise<{
25
+ violations: import('@markuplint/ml-config').Violation[];
26
+ fixedCode: string;
15
27
  }>;
16
- export declare function mlTestFile(target: Target, config?: Config, rules?: AnyMLRule[], locale?: string, fix?: boolean): Promise<{
17
- violations: import("@markuplint/ml-config").Violation[];
18
- fixedCode: string;
28
+ export declare function mlTestFile(
29
+ target: Target,
30
+ config?: Config,
31
+ rules?: AnyMLRule[],
32
+ locale?: string,
33
+ fix?: boolean,
34
+ ): Promise<{
35
+ violations: import('@markuplint/ml-config').Violation[];
36
+ fixedCode: string;
19
37
  }>;
20
38
  export interface NodeRule<T extends RuleConfigValue, O = void> {
21
- tagName?: string;
22
- selector?: string;
23
- regexSelector?: RegexSelector;
24
- categories?: string[];
25
- roles?: string[];
26
- obsolete?: boolean;
27
- rule?: Rule<T, O>;
39
+ tagName?: string;
40
+ selector?: string;
41
+ regexSelector?: RegexSelector;
42
+ categories?: string[];
43
+ roles?: string[];
44
+ obsolete?: boolean;
45
+ rule?: Rule<T, O>;
28
46
  }
29
47
  export interface ChildNodeRule<T extends RuleConfigValue, O = void> {
30
- tagName?: string;
31
- selector?: string;
32
- regexSelector?: RegexSelector;
33
- inheritance?: boolean;
34
- rule?: Rule<T, O>;
48
+ tagName?: string;
49
+ selector?: string;
50
+ regexSelector?: RegexSelector;
51
+ inheritance?: boolean;
52
+ rule?: Rule<T, O>;
35
53
  }
@@ -12,6 +12,7 @@ async function mlTest(sourceCode, config, rules, locale = 'en', fix = false) {
12
12
  rules,
13
13
  locale: locale !== null && locale !== void 0 ? locale : global.locale,
14
14
  fix,
15
+ ignoreExt: true,
15
16
  autoLoad: true,
16
17
  importPresetRules: !rules,
17
18
  });
@@ -76,6 +77,7 @@ async function mlTestFile(target, config, rules, locale, fix = false) {
76
77
  rules,
77
78
  locale: locale !== null && locale !== void 0 ? locale : global.locale,
78
79
  fix,
80
+ ignoreExt: true,
79
81
  noSearchConfig: !!config,
80
82
  autoLoad: true,
81
83
  importPresetRules: !rules,
package/lib/types.d.ts CHANGED
@@ -1,27 +1,27 @@
1
1
  import type { Config, 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
+ violations: Violation[];
5
+ filePath: string;
6
+ sourceCode: string;
7
+ fixedCode: string;
8
8
  }
9
9
  /**
10
10
  * @deprecated
11
11
  */
12
12
  export interface MLResultInfo_v1 {
13
- results: Violation[];
14
- filePath: string;
15
- sourceCode: string;
16
- fixedCode: string;
17
- document: Document<any, unknown> | null;
18
- parser: string;
19
- locale?: string;
20
- ruleset: Ruleset;
21
- configSet: {
22
- config: Config;
23
- files: string[];
24
- error: string[];
25
- };
13
+ results: Violation[];
14
+ filePath: string;
15
+ sourceCode: string;
16
+ fixedCode: string;
17
+ document: Document<any, unknown> | null;
18
+ parser: string;
19
+ locale?: string;
20
+ ruleset: Ruleset;
21
+ configSet: {
22
+ config: Config;
23
+ files: string[];
24
+ error: string[];
25
+ };
26
26
  }
27
27
  export declare type Nullable<T> = T | null | undefined;
package/lib/util.d.ts CHANGED
@@ -1,3 +1,19 @@
1
1
  import type { Nullable } from './types';
2
2
  export declare function nonNullableFilter<T>(item: Nullable<T>): item is T;
3
3
  export declare function uuid(): string;
4
+ export declare const markuplint: string;
5
+ export declare function write(message: string): void;
6
+ export declare namespace write {
7
+ var _a: () => boolean;
8
+ export { _a as break };
9
+ }
10
+ export declare function error(message: string): void;
11
+ export declare namespace error {
12
+ var exit: () => never;
13
+ }
14
+ export declare const head: (method: string, noColor?: boolean | undefined) => string;
15
+ export declare function p(s: number | string, pad: number, start?: boolean): string;
16
+ export declare function w(s: string): number;
17
+ export declare function space(str: string): string;
18
+ export declare function invisibleSpace(str: string): string;
19
+ export declare function messageToString(message: string, reason?: string): string;