markuplint 3.3.0 → 3.3.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.
package/README.md CHANGED
@@ -121,6 +121,7 @@ Need [Sponsors❤️‍🔥](https://github.com/sponsors/markuplint)
121
121
 
122
122
  [<img width="36" src="https://avatars.githubusercontent.com/u/91733847" alt="Tokitake" />](https://github.com/Tokitake)
123
123
  [<img width="36" src="https://avatars.githubusercontent.com/u/1996642" alt="yamanoku" />](https://github.com/yamanoku)
124
+ [<img width="36" src="https://avatars.githubusercontent.com/u/6581173" alt="miita" />](https://github.com/mikimhk)
124
125
 
125
126
  ## Thanks
126
127
 
@@ -4,27 +4,27 @@ import type { MLFile, Target } from '@markuplint/file-resolver';
4
4
  import type { Document, RuleConfigValue } from '@markuplint/ml-core';
5
5
  import { StrictEventEmitter } from 'strict-event-emitter';
6
6
  type MLEngineOptions = {
7
- debug?: boolean;
8
- watch?: boolean;
7
+ debug?: boolean;
8
+ watch?: boolean;
9
9
  };
10
10
  export default class MLEngine extends StrictEventEmitter<MLEngineEventMap> {
11
- #private;
12
- static toMLFile(target: Target): Promise<MLFile>;
13
- constructor(file: MLFile, options?: APIOptions & MLEngineOptions);
14
- get document(): Document<RuleConfigValue, unknown> | null;
15
- close(): Promise<void>;
16
- exec(): Promise<MLResultInfo | null>;
17
- setCode(code: string): Promise<void>;
18
- watchMode(enable: boolean): void;
19
- private createCore;
20
- private i18n;
21
- private onChange;
22
- private provide;
23
- private resolveConfig;
24
- private resolveParser;
25
- private resolveRules;
26
- private resolveRuleset;
27
- private resolveSchemas;
28
- private setup;
11
+ #private;
12
+ static toMLFile(target: Target): Promise<MLFile>;
13
+ constructor(file: MLFile, options?: APIOptions & MLEngineOptions);
14
+ get document(): Document<RuleConfigValue, unknown> | null;
15
+ close(): Promise<void>;
16
+ exec(): Promise<MLResultInfo | null>;
17
+ setCode(code: string): Promise<void>;
18
+ watchMode(enable: boolean): void;
19
+ private createCore;
20
+ private i18n;
21
+ private onChange;
22
+ private provide;
23
+ private resolveConfig;
24
+ private resolveParser;
25
+ private resolveRules;
26
+ private resolveRuleset;
27
+ private resolveSchemas;
28
+ private setup;
29
29
  }
30
30
  export {};
@@ -4,41 +4,48 @@ import type { MLMarkupLanguageParser, ParserOptions } from '@markuplint/ml-ast';
4
4
  import type { Config, Pretender, Violation } from '@markuplint/ml-config';
5
5
  import type { AnyMLRule, MLSchema, Ruleset } from '@markuplint/ml-core';
6
6
  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;
16
- /**
17
- * @deprecated
18
- */
19
- autoLoad?: boolean;
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
20
  };
21
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[];
22
+ ruleset: Ruleset;
23
+ rules: AnyMLRule[];
24
+ schemas: MLSchema;
25
+ parser: MLMarkupLanguageParser;
26
+ parserOptions: ParserOptions;
27
+ pretenders: Pretender[];
28
+ locale: LocaleSet;
29
+ configErrors?: Error[];
30
30
  };
31
31
  export type MLEngineEventMap = {
32
- log: (phase: string, message: string) => void;
33
- config: (filePath: string, config: ConfigSet, message?: string) => void;
34
- exclude: (filePath: string, setting: string, message?: string) => void;
35
- parser: (filePath: string, parser: string, message?: string) => void;
36
- ruleset: (filePath: string, ruleset: Ruleset, message?: string) => void;
37
- schemas: (filePath: string, schemas: MLSchema, message?: string) => void;
38
- rules: (filePath: string, rules: AnyMLRule[], message?: string) => void;
39
- i18n: (filePath: string, locale: LocaleSet, message?: string) => void;
40
- code: (filePath: string, sourceCode: string, message?: string) => void;
41
- lint: (filePath: string, sourceCode: string, violations: Violation[], fixedCode: string, debug: string[] | null, message?: string) => void;
42
- 'lint-error': (filePath: string, sourceCode: string, error: Error) => void;
43
- 'config-errors': (filePath: string, errors: Error[]) => void;
32
+ log: (phase: string, message: string) => void;
33
+ config: (filePath: string, config: ConfigSet, message?: string) => void;
34
+ exclude: (filePath: string, setting: string, message?: string) => void;
35
+ parser: (filePath: string, parser: string, message?: string) => void;
36
+ ruleset: (filePath: string, ruleset: Ruleset, message?: string) => void;
37
+ schemas: (filePath: string, schemas: MLSchema, message?: string) => void;
38
+ rules: (filePath: string, rules: AnyMLRule[], message?: string) => void;
39
+ i18n: (filePath: string, locale: LocaleSet, message?: string) => void;
40
+ code: (filePath: string, sourceCode: string, message?: string) => void;
41
+ lint: (
42
+ filePath: string,
43
+ sourceCode: string,
44
+ violations: Violation[],
45
+ fixedCode: string,
46
+ debug: string[] | null,
47
+ message?: string,
48
+ ) => void;
49
+ 'lint-error': (filePath: string, sourceCode: string, error: Error) => void;
50
+ 'config-errors': (filePath: string, errors: Error[]) => void;
44
51
  };
package/lib/api/v1.d.ts CHANGED
@@ -6,46 +6,46 @@ import type { MLRule } from '@markuplint/ml-core';
6
6
  * @returns
7
7
  */
8
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("..").MLResultInfo[]>;
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('..').MLResultInfo[]>;
@@ -1,56 +1,57 @@
1
1
  import meow from 'meow';
2
- export declare const help = "\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";
2
+ export declare const help =
3
+ '\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';
3
4
  export declare const cli: meow.Result<{
4
- config: {
5
- type: "string";
6
- alias: string;
7
- };
8
- fix: {
9
- type: "boolean";
10
- default: false;
11
- };
12
- format: {
13
- type: "string";
14
- alias: string;
15
- };
16
- searchConfig: {
17
- type: "boolean";
18
- default: true;
19
- };
20
- ignoreExt: {
21
- type: "boolean";
22
- default: false;
23
- };
24
- importPresetRules: {
25
- type: "boolean";
26
- default: true;
27
- };
28
- locale: {
29
- type: "string";
30
- };
31
- color: {
32
- type: "boolean";
33
- default: true;
34
- };
35
- problemOnly: {
36
- type: "boolean";
37
- alias: string;
38
- default: false;
39
- };
40
- verbose: {
41
- type: "boolean";
42
- default: false;
43
- };
44
- init: {
45
- type: "boolean";
46
- default: false;
47
- };
48
- createRule: {
49
- type: "boolean";
50
- default: false;
51
- };
52
- search: {
53
- type: "string";
54
- };
5
+ config: {
6
+ type: 'string';
7
+ alias: string;
8
+ };
9
+ fix: {
10
+ type: 'boolean';
11
+ default: false;
12
+ };
13
+ format: {
14
+ type: 'string';
15
+ alias: string;
16
+ };
17
+ searchConfig: {
18
+ type: 'boolean';
19
+ default: true;
20
+ };
21
+ ignoreExt: {
22
+ type: 'boolean';
23
+ default: false;
24
+ };
25
+ importPresetRules: {
26
+ type: 'boolean';
27
+ default: true;
28
+ };
29
+ locale: {
30
+ type: 'string';
31
+ };
32
+ color: {
33
+ type: 'boolean';
34
+ default: true;
35
+ };
36
+ problemOnly: {
37
+ type: 'boolean';
38
+ alias: string;
39
+ default: false;
40
+ };
41
+ verbose: {
42
+ type: 'boolean';
43
+ default: false;
44
+ };
45
+ init: {
46
+ type: 'boolean';
47
+ default: false;
48
+ };
49
+ createRule: {
50
+ type: 'boolean';
51
+ default: false;
52
+ };
53
+ search: {
54
+ type: 'string';
55
+ };
55
56
  }>;
56
57
  export type CLIOptions = typeof cli.flags;
@@ -1,7 +1,7 @@
1
1
  import type { Langs } from './types';
2
2
  export type InstallModuleResult = {
3
- success: boolean;
4
- alreadyExists: boolean;
3
+ success: boolean;
4
+ alreadyExists: boolean;
5
5
  };
6
6
  export declare function selectModules(selectedLangs: Langs[]): string[];
7
7
  export declare function installModule(module: string[], dev?: boolean): Promise<InstallModuleResult>;
@@ -1,8 +1,20 @@
1
- export type Langs = 'jsx' | 'vue' | 'svelte' | 'astro' | 'pug' | 'php' | 'smarty' | 'erb' | 'ejs' | 'mustache' | 'nunjucks' | 'liquid';
1
+ export type Langs =
2
+ | 'jsx'
3
+ | 'vue'
4
+ | 'svelte'
5
+ | 'astro'
6
+ | 'pug'
7
+ | 'php'
8
+ | 'smarty'
9
+ | 'erb'
10
+ | 'ejs'
11
+ | 'mustache'
12
+ | 'nunjucks'
13
+ | 'liquid';
2
14
  export type Category = 'validation' | 'a11y' | 'naming-convention' | 'style' | 'maintainability';
3
15
  export type RuleSettingMode = Category[] | 'recommended' | 'none';
4
16
  export type DefaultRules = Record<string, Rule>;
5
17
  export type Rule = {
6
- category: Category;
7
- defaultValue: boolean | string | number;
18
+ category: Category;
19
+ defaultValue: boolean | string | number;
8
20
  };
@@ -1,18 +1,23 @@
1
1
  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 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>>;
@@ -1,33 +1,51 @@
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, Partial<O>>;
10
- nodeRule?: NodeRule<T, Partial<O>>[];
11
- childNodeRule?: ChildNodeRule<T, Partial<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, Partial<O>>;
19
+ nodeRule?: NodeRule<T, Partial<O>>[];
20
+ childNodeRule?: ChildNodeRule<T, Partial<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
- selector?: string;
22
- regexSelector?: RegexSelector;
23
- categories?: string[];
24
- roles?: string[];
25
- obsolete?: boolean;
26
- rule?: Rule<T, O>;
39
+ selector?: string;
40
+ regexSelector?: RegexSelector;
41
+ categories?: string[];
42
+ roles?: string[];
43
+ obsolete?: boolean;
44
+ rule?: Rule<T, O>;
27
45
  }
28
46
  export interface ChildNodeRule<T extends RuleConfigValue, O = void> {
29
- selector?: string;
30
- regexSelector?: RegexSelector;
31
- inheritance?: boolean;
32
- rule?: Rule<T, O>;
47
+ selector?: string;
48
+ regexSelector?: RegexSelector;
49
+ inheritance?: boolean;
50
+ rule?: Rule<T, O>;
33
51
  }
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 type Nullable<T> = T | null | undefined;
package/lib/util.d.ts CHANGED
@@ -4,12 +4,12 @@ export declare function uuid(): string;
4
4
  export declare const markuplint: string;
5
5
  export declare function write(message: string): void;
6
6
  export declare namespace write {
7
- var _a: () => boolean;
8
- export { _a as break };
7
+ var _a: () => boolean;
8
+ export { _a as break };
9
9
  }
10
10
  export declare function error(message: string): void;
11
11
  export declare namespace error {
12
- var exit: () => never;
12
+ var exit: () => never;
13
13
  }
14
14
  export declare const head: (method: string, noColor?: boolean) => string;
15
15
  export declare function p(s: number | string, pad: number, start?: boolean): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "markuplint",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "A linter for all markup developers",
5
5
  "author": "Yusuke Hirao",
6
6
  "license": "MIT",
@@ -28,16 +28,16 @@
28
28
  "execa": "5"
29
29
  },
30
30
  "dependencies": {
31
- "@markuplint/create-rule-helper": "3.3.0",
32
- "@markuplint/file-resolver": "3.3.0",
33
- "@markuplint/html-parser": "3.3.0",
34
- "@markuplint/html-spec": "3.3.0",
31
+ "@markuplint/create-rule-helper": "3.3.1",
32
+ "@markuplint/file-resolver": "3.3.1",
33
+ "@markuplint/html-parser": "3.3.1",
34
+ "@markuplint/html-spec": "3.3.1",
35
35
  "@markuplint/i18n": "3.3.0",
36
36
  "@markuplint/ml-ast": "3.0.0",
37
37
  "@markuplint/ml-config": "3.3.0",
38
- "@markuplint/ml-core": "3.3.0",
38
+ "@markuplint/ml-core": "3.3.1",
39
39
  "@markuplint/ml-spec": "3.3.0",
40
- "@markuplint/rules": "3.3.0",
40
+ "@markuplint/rules": "3.3.1",
41
41
  "chokidar": "^3.5.3",
42
42
  "cli-color": "^2.0.3",
43
43
  "debug": "^4.3.4",
@@ -55,5 +55,5 @@
55
55
  "tslib": "^2.4.1",
56
56
  "uuid": "^9.0.0"
57
57
  },
58
- "gitHead": "791fb22a4df7acb985ced3808923fba0cd95c28a"
58
+ "gitHead": "f19e7de726cf01d53342bc5513c30da75d28da63"
59
59
  }