@markuplint/ml-core 2.0.0 → 2.1.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/ml-core.d.ts +11 -11
- package/lib/ml-dom/document.d.ts +70 -66
- package/lib/ml-dom/document.js +23 -0
- package/lib/ml-dom/helper/accname.d.ts +2 -0
- package/lib/ml-dom/helper/accname.js +18 -0
- package/lib/ml-dom/helper/create-node.d.ts +1 -5
- package/lib/ml-dom/helper/debug.d.ts +1 -4
- package/lib/ml-dom/helper/debug.js +1 -1
- package/lib/ml-dom/helper/getIndent.d.ts +7 -7
- package/lib/ml-dom/helper/mapped-nodes.d.ts +3 -51
- package/lib/ml-dom/helper/match-selector.d.ts +6 -10
- package/lib/ml-dom/helper/node-store.d.ts +3 -6
- package/lib/ml-dom/helper/selector.d.ts +4 -4
- package/lib/ml-dom/helper/walkers.d.ts +2 -7
- package/lib/ml-dom/index.d.ts +1 -10
- package/lib/ml-dom/rule-mapper.d.ts +7 -7
- package/lib/ml-dom/tokens/abstract-element.d.ts +41 -40
- package/lib/ml-dom/tokens/abstract-element.js +16 -2
- package/lib/ml-dom/tokens/attribute.d.ts +38 -36
- package/lib/ml-dom/tokens/attribute.js +12 -7
- package/lib/ml-dom/tokens/comment.d.ts +4 -5
- package/lib/ml-dom/tokens/comment.js +4 -0
- package/lib/ml-dom/tokens/doctype.d.ts +9 -10
- package/lib/ml-dom/tokens/doctype.js +4 -0
- package/lib/ml-dom/tokens/element-close-tag.d.ts +17 -19
- package/lib/ml-dom/tokens/element-close-tag.js +1 -0
- package/lib/ml-dom/tokens/element.d.ts +15 -18
- package/lib/ml-dom/tokens/node.d.ts +30 -23
- package/lib/ml-dom/tokens/node.js +30 -15
- package/lib/ml-dom/tokens/omitted-element.d.ts +4 -7
- package/lib/ml-dom/tokens/preprocessor-specific-attribute.d.ts +20 -20
- package/lib/ml-dom/tokens/preprocessor-specific-block.d.ts +5 -8
- package/lib/ml-dom/tokens/text.d.ts +8 -9
- package/lib/ml-dom/tokens/text.js +4 -0
- package/lib/ml-dom/tokens/token.d.ts +13 -13
- package/lib/ml-dom/types.d.ts +13 -35
- package/lib/ml-rule/create-test-rule.d.ts +3 -5
- package/lib/ml-rule/ml-rule-context.d.ts +44 -52
- package/lib/ml-rule/ml-rule.d.ts +23 -33
- package/lib/ml-rule/types.d.ts +5 -5
- package/lib/plugin/types.d.ts +5 -5
- package/lib/ruleset/index.d.ts +4 -4
- package/lib/test/index.d.ts +5 -14
- package/lib/types.d.ts +6 -6
- package/lib/utils/get-location-from-chars.d.ts +4 -9
- package/markuplint-recommended.json +1 -0
- package/package.json +3 -2
- package/tsconfig.tsbuildinfo +1 -1
package/lib/ml-dom/types.d.ts
CHANGED
|
@@ -1,49 +1,27 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
MLDOMComment,
|
|
3
|
-
MLDOMDoctype,
|
|
4
|
-
MLDOMElement,
|
|
5
|
-
MLDOMElementCloseTag,
|
|
6
|
-
MLDOMOmittedElement,
|
|
7
|
-
MLDOMPreprocessorSpecificBlock,
|
|
8
|
-
MLDOMText,
|
|
9
|
-
} from './tokens';
|
|
1
|
+
import type { MLDOMComment, MLDOMDoctype, MLDOMElement, MLDOMElementCloseTag, MLDOMOmittedElement, MLDOMPreprocessorSpecificBlock, MLDOMText } from './tokens';
|
|
10
2
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
11
3
|
export interface IMLDOMDoctype extends IMLDOMNode {
|
|
12
|
-
|
|
4
|
+
type: 'Doctype';
|
|
13
5
|
}
|
|
14
6
|
export interface IMLDOMElement extends IMLDOMNode {
|
|
15
|
-
|
|
7
|
+
type: 'Element';
|
|
16
8
|
}
|
|
17
9
|
export interface IMLDOMElementCloseTag extends IMLDOMNode {
|
|
18
|
-
|
|
10
|
+
type: 'ElementCloseTag';
|
|
19
11
|
}
|
|
20
12
|
export interface IMLDOMOmittedElement extends IMLDOMNode {
|
|
21
|
-
|
|
13
|
+
type: 'OmittedElement';
|
|
22
14
|
}
|
|
23
15
|
export interface IMLDOMComment extends IMLDOMNode {
|
|
24
|
-
|
|
16
|
+
type: 'Comment';
|
|
25
17
|
}
|
|
26
18
|
export interface IMLDOMText extends IMLDOMNode {
|
|
27
|
-
|
|
19
|
+
type: 'Text';
|
|
28
20
|
}
|
|
29
21
|
export interface IMLDOMPreprocessorSpecificBlock extends IMLDOMNode {
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
export interface IMLDOMNode {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
| MLDOMElementCloseTag<T, O>
|
|
37
|
-
| MLDOMOmittedElement<T, O>
|
|
38
|
-
| MLDOMComment<T, O>
|
|
39
|
-
| MLDOMPreprocessorSpecificBlock<T, O>
|
|
40
|
-
| MLDOMText<T, O>;
|
|
41
|
-
export declare type NodeType =
|
|
42
|
-
| 'Doctype'
|
|
43
|
-
| 'Element'
|
|
44
|
-
| 'ElementCloseTag'
|
|
45
|
-
| 'OmittedElement'
|
|
46
|
-
| 'Comment'
|
|
47
|
-
| 'Text'
|
|
48
|
-
| 'Node'
|
|
49
|
-
| 'PSBlock';
|
|
22
|
+
type: 'PSBlock';
|
|
23
|
+
}
|
|
24
|
+
export interface IMLDOMNode {
|
|
25
|
+
}
|
|
26
|
+
export declare type AnonymousNode<T extends RuleConfigValue, O = null> = MLDOMDoctype<T, O> | MLDOMElement<T, O> | MLDOMElementCloseTag<T, O> | MLDOMOmittedElement<T, O> | MLDOMComment<T, O> | MLDOMPreprocessorSpecificBlock<T, O> | MLDOMText<T, O>;
|
|
27
|
+
export declare type NodeType = 'Doctype' | 'Element' | 'ElementCloseTag' | 'OmittedElement' | 'Comment' | 'Text' | 'Node' | 'PSBlock';
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import type { RuleSeed } from './types';
|
|
2
2
|
import type { RuleConfigValue } from '@markuplint/ml-config';
|
|
3
3
|
import { MLRule } from './ml-rule';
|
|
4
|
-
export declare function createRule<T extends RuleConfigValue, O = null>(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
): MLRule<T, O>;
|
|
4
|
+
export declare function createRule<T extends RuleConfigValue, O = null>(seed: RuleSeed<T, O> & {
|
|
5
|
+
name: string;
|
|
6
|
+
}): MLRule<T, O>;
|
|
@@ -2,56 +2,48 @@ import type Document from '../ml-dom/document';
|
|
|
2
2
|
import type { LocaleSet, Translator } from '@markuplint/i18n';
|
|
3
3
|
import type { Report, RuleConfigValue, RuleInfo } from '@markuplint/ml-config';
|
|
4
4
|
export declare class MLRuleContext<T extends RuleConfigValue, O = null> {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
scope: import('@markuplint/ml-config').Scope<T, O>;
|
|
50
|
-
line: number;
|
|
51
|
-
col: number;
|
|
52
|
-
raw: string;
|
|
53
|
-
}
|
|
54
|
-
)[];
|
|
55
|
-
report: (report: Report<T, O>) => void;
|
|
56
|
-
};
|
|
5
|
+
#private;
|
|
6
|
+
readonly document: Document<T, O>;
|
|
7
|
+
readonly globalRule: RuleInfo<T, O>;
|
|
8
|
+
readonly translate: Translator;
|
|
9
|
+
readonly locale: string;
|
|
10
|
+
constructor(document: Document<T, O>, locale: LocaleSet, rule: RuleInfo<T, O>);
|
|
11
|
+
get reports(): ({
|
|
12
|
+
message: string;
|
|
13
|
+
line: number;
|
|
14
|
+
col: number;
|
|
15
|
+
raw: string;
|
|
16
|
+
} | {
|
|
17
|
+
message: string;
|
|
18
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
19
|
+
} | {
|
|
20
|
+
message: string;
|
|
21
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
22
|
+
line: number;
|
|
23
|
+
col: number;
|
|
24
|
+
raw: string;
|
|
25
|
+
})[];
|
|
26
|
+
report(report: Report<T, O>): void;
|
|
27
|
+
provide(): {
|
|
28
|
+
document: Document<T, O>;
|
|
29
|
+
translate: Translator;
|
|
30
|
+
t: Translator;
|
|
31
|
+
globalRule: RuleInfo<T, O>;
|
|
32
|
+
reports: ({
|
|
33
|
+
message: string;
|
|
34
|
+
line: number;
|
|
35
|
+
col: number;
|
|
36
|
+
raw: string;
|
|
37
|
+
} | {
|
|
38
|
+
message: string;
|
|
39
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
40
|
+
} | {
|
|
41
|
+
message: string;
|
|
42
|
+
scope: import("@markuplint/ml-config").Scope<T, O>;
|
|
43
|
+
line: number;
|
|
44
|
+
col: number;
|
|
45
|
+
raw: string;
|
|
46
|
+
})[];
|
|
47
|
+
report: (report: Report<T, O>) => void;
|
|
48
|
+
};
|
|
57
49
|
}
|
package/lib/ml-rule/ml-rule.d.ts
CHANGED
|
@@ -2,39 +2,29 @@ import type { Ruleset } from '..';
|
|
|
2
2
|
import type Document from '../ml-dom/document';
|
|
3
3
|
import type { RuleSeed } from './types';
|
|
4
4
|
import type { LocaleSet } from '@markuplint/i18n';
|
|
5
|
-
import type {
|
|
6
|
-
GlobalRuleInfo,
|
|
7
|
-
RuleConfig,
|
|
8
|
-
RuleConfigValue,
|
|
9
|
-
RuleInfo,
|
|
10
|
-
Rules,
|
|
11
|
-
Severity,
|
|
12
|
-
Violation,
|
|
13
|
-
} from '@markuplint/ml-config';
|
|
5
|
+
import type { GlobalRuleInfo, RuleConfig, RuleConfigValue, RuleInfo, Rules, Severity, Violation } from '@markuplint/ml-config';
|
|
14
6
|
export declare class MLRule<T extends RuleConfigValue, O = null> {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
_optimize(rules: Rules | undefined, ruleName: string): RuleInfo<T, O>;
|
|
38
|
-
optimizeOption(configSettings: T | RuleConfig<T, O> | undefined): RuleInfo<T, O>;
|
|
7
|
+
#private;
|
|
8
|
+
readonly name: string;
|
|
9
|
+
readonly defaultServerity: Severity;
|
|
10
|
+
readonly defaultValue: T;
|
|
11
|
+
readonly defaultOptions: O;
|
|
12
|
+
/**
|
|
13
|
+
* The following getter is unused internally,
|
|
14
|
+
* only for extending from 3rd party library
|
|
15
|
+
*/
|
|
16
|
+
protected get v(): RuleSeed<T, O>['verify'];
|
|
17
|
+
/**
|
|
18
|
+
* The following getter is unused internally,
|
|
19
|
+
* only for extending from 3rd party library
|
|
20
|
+
*/
|
|
21
|
+
protected get f(): RuleSeed<T, O>['fix'];
|
|
22
|
+
constructor(o: RuleSeed<T, O> & {
|
|
23
|
+
name: string;
|
|
24
|
+
});
|
|
25
|
+
verify(document: Document<T, O>, locale: LocaleSet, globalRule: RuleInfo<T, O>, fix: boolean): Promise<Violation[]>;
|
|
26
|
+
getRuleInfo(ruleSet: Ruleset, ruleName: string): GlobalRuleInfo<T, O>;
|
|
27
|
+
_optimize(rules: Rules | undefined, ruleName: string): RuleInfo<T, O>;
|
|
28
|
+
optimizeOption(configSettings: T | RuleConfig<T, O> | undefined): RuleInfo<T, O>;
|
|
39
29
|
}
|
|
40
30
|
export declare type AnyMLRule = MLRule<RuleConfigValue, unknown>;
|
package/lib/ml-rule/types.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { MLRuleContext } from './ml-rule-context';
|
|
2
2
|
import type { RuleConfigValue, Severity } from '@markuplint/ml-config';
|
|
3
3
|
export declare type RuleSeed<T extends RuleConfigValue = boolean, O = null> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
defaultServerity?: Severity;
|
|
5
|
+
defaultValue?: T;
|
|
6
|
+
defaultOptions?: O;
|
|
7
|
+
verify(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
|
|
8
|
+
fix?(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
|
|
9
9
|
};
|
|
10
10
|
export declare type AnyRuleSeed = RuleSeed<any, any>;
|
package/lib/plugin/types.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AnyRuleSeed } from '../ml-rule';
|
|
2
2
|
import type { Config } from '@markuplint/ml-config';
|
|
3
3
|
export declare type Plugin = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
name: string;
|
|
5
|
+
rules?: Record<string, AnyRuleSeed>;
|
|
6
|
+
configs?: Record<string, Config>;
|
|
7
7
|
};
|
|
8
8
|
export declare type PluginCreator<S extends CreatePluginSettings> = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
name: string;
|
|
10
|
+
create(setting: S): Omit<Plugin, 'name'>;
|
|
11
11
|
};
|
|
12
12
|
export declare type CreatePluginSettings = Record<string, unknown>;
|
package/lib/ruleset/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ChildNodeRule, Config, NodeRule, Rules } from '@markuplint/ml-config';
|
|
2
2
|
export default class Ruleset {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
readonly rules: Readonly<Rules>;
|
|
4
|
+
readonly nodeRules: ReadonlyArray<NodeRule>;
|
|
5
|
+
readonly childNodeRules: ReadonlyArray<ChildNodeRule>;
|
|
6
|
+
constructor(config: Config);
|
|
7
7
|
}
|
package/lib/test/index.d.ts
CHANGED
|
@@ -3,21 +3,12 @@ import type { Config, RuleConfigValue } from '@markuplint/ml-config';
|
|
|
3
3
|
import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
4
4
|
import { Document } from '../ml-dom';
|
|
5
5
|
export declare type CreateTestOptions = {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
config?: Config;
|
|
7
|
+
parser?: MLMarkupLanguageParser;
|
|
8
8
|
};
|
|
9
|
-
export declare function createTestDocument<T extends RuleConfigValue = any, O = any>(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
): Document<T, O>;
|
|
13
|
-
export declare function createTestNodeList(
|
|
14
|
-
sourceCode: string,
|
|
15
|
-
options?: CreateTestOptions,
|
|
16
|
-
): readonly import('../ml-dom').AnonymousNode<any, any>[];
|
|
17
|
-
export declare function createTestElement(
|
|
18
|
-
sourceCode: string,
|
|
19
|
-
options?: CreateTestOptions,
|
|
20
|
-
): import('../ml-dom').Element<any, any>;
|
|
9
|
+
export declare function createTestDocument<T extends RuleConfigValue = any, O = any>(sourceCode: string, options?: CreateTestOptions): Document<T, O>;
|
|
10
|
+
export declare function createTestNodeList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom").AnonymousNode<any, any>[];
|
|
11
|
+
export declare function createTestElement(sourceCode: string, options?: CreateTestOptions): import("../ml-dom").Element<any, any>;
|
|
21
12
|
/**
|
|
22
13
|
* for test suite
|
|
23
14
|
*/
|
package/lib/types.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ import type { ParserOptions } from '@markuplint/ml-config';
|
|
|
6
6
|
import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
|
|
7
7
|
export declare type MLSchema = Readonly<[MLMLSpec, ...ExtendedSpec[]]>;
|
|
8
8
|
export declare type MLFabric = {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
parser: MLMarkupLanguageParser;
|
|
10
|
+
ruleset: Partial<Ruleset>;
|
|
11
|
+
rules: AnyMLRule[];
|
|
12
|
+
locale: LocaleSet;
|
|
13
|
+
schemas: MLSchema;
|
|
14
|
+
parserOptions: ParserOptions;
|
|
15
15
|
};
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
interface Location {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
line: number;
|
|
3
|
+
col: number;
|
|
4
|
+
raw: string;
|
|
5
5
|
}
|
|
6
|
-
export declare function getLocationFromChars(
|
|
7
|
-
searches: string[],
|
|
8
|
-
text: string,
|
|
9
|
-
currentLine: number,
|
|
10
|
-
currentCol: number,
|
|
11
|
-
): Location[];
|
|
6
|
+
export declare function getLocationFromChars(searches: string[], text: string, currentLine: number, currentCol: number): Location[];
|
|
12
7
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@markuplint/ml-core",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "The core module of markuplint",
|
|
5
5
|
"repository": "git@github.com:markuplint/markuplint.git",
|
|
6
6
|
"author": "Yusuke Hirao <yusukehirao@me.com>",
|
|
@@ -23,6 +23,7 @@
|
|
|
23
23
|
"@markuplint/ml-spec": "2.0.0",
|
|
24
24
|
"@markuplint/parser-utils": "2.0.0",
|
|
25
25
|
"debug": "^4.3.3",
|
|
26
|
+
"dom-accessibility-api": "^0.5.13",
|
|
26
27
|
"postcss-selector-parser": "^6.0.9",
|
|
27
28
|
"tslib": "^2.3.1"
|
|
28
29
|
},
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"@markuplint/html-parser": "2.0.0",
|
|
31
32
|
"@types/debug": "^4.1.7"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "b76084dbdb538119a29fd07b19110ef7d3a44670"
|
|
34
35
|
}
|