@markuplint/ml-core 3.3.0 → 3.4.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.
Files changed (45) hide show
  1. package/lib/index.d.ts +11 -1
  2. package/lib/ml-core.d.ts +22 -11
  3. package/lib/ml-dom/helper/create-node.d.ts +4 -1
  4. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  5. package/lib/ml-dom/helper/walkers.d.ts +11 -3
  6. package/lib/ml-dom/helper/walkers.js +1 -0
  7. package/lib/ml-dom/manipulations/child-node-methods.d.ts +18 -5
  8. package/lib/ml-dom/manipulations/get-children.d.ts +3 -1
  9. package/lib/ml-dom/node/attr.d.ts +89 -89
  10. package/lib/ml-dom/node/block.d.ts +30 -30
  11. package/lib/ml-dom/node/character-data.d.ts +59 -52
  12. package/lib/ml-dom/node/child-node.d.ts +6 -1
  13. package/lib/ml-dom/node/comment.d.ts +15 -12
  14. package/lib/ml-dom/node/document-fragment.d.ts +22 -19
  15. package/lib/ml-dom/node/document-type.d.ts +34 -31
  16. package/lib/ml-dom/node/document.d.ts +1600 -1586
  17. package/lib/ml-dom/node/document.js +12 -0
  18. package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
  19. package/lib/ml-dom/node/dom-token-list.js +5 -5
  20. package/lib/ml-dom/node/element.d.ts +1894 -1888
  21. package/lib/ml-dom/node/named-node-map.d.ts +44 -39
  22. package/lib/ml-dom/node/named-node-map.js +2 -1
  23. package/lib/ml-dom/node/node-list.d.ts +9 -3
  24. package/lib/ml-dom/node/node-list.js +17 -2
  25. package/lib/ml-dom/node/node-store.d.ts +3 -3
  26. package/lib/ml-dom/node/node.d.ts +492 -472
  27. package/lib/ml-dom/node/node.js +4 -2
  28. package/lib/ml-dom/node/parent-node.d.ts +66 -57
  29. package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
  30. package/lib/ml-dom/node/rule-mapper.js +3 -0
  31. package/lib/ml-dom/node/text.d.ts +49 -46
  32. package/lib/ml-dom/node/types.d.ts +67 -11
  33. package/lib/ml-dom/node/unexpected-call-error.d.ts +1 -2
  34. package/lib/ml-dom/token/token.d.ts +44 -44
  35. package/lib/ml-rule/create-test-rule.d.ts +5 -3
  36. package/lib/ml-rule/ml-rule-context.d.ts +56 -48
  37. package/lib/ml-rule/ml-rule.d.ts +25 -23
  38. package/lib/ml-rule/types.d.ts +19 -13
  39. package/lib/plugin/types.d.ts +5 -5
  40. package/lib/ruleset/index.d.ts +4 -4
  41. package/lib/test/index.d.ts +19 -7
  42. package/lib/test/index.js +1 -1
  43. package/lib/types.d.ts +7 -7
  44. package/lib/utils/get-location-from-chars.d.ts +9 -4
  45. package/package.json +9 -7
@@ -1,30 +1,32 @@
1
+ import type { RuleSeed } from './types';
1
2
  import type { Ruleset } from '..';
2
3
  import type { MLDocument } from '../ml-dom/node/document';
3
- import type { RuleSeed } from './types';
4
4
  import type { LocaleSet } from '@markuplint/i18n';
5
5
  import type { GlobalRuleInfo, RuleConfig, RuleConfigValue, RuleInfo, Severity, Violation } from '@markuplint/ml-config';
6
6
  export declare class MLRule<T extends RuleConfigValue, O = null> {
7
- #private;
8
- readonly defaultOptions: O;
9
- readonly defaultSeverity: Severity;
10
- readonly defaultValue: T;
11
- readonly name: string;
12
- constructor(o: RuleSeed<T, O> & {
13
- name: string;
14
- });
15
- /**
16
- * The following getter is unused internally,
17
- * only for extending from 3rd party library
18
- */
19
- protected get f(): RuleSeed<T, O>['fix'];
20
- /**
21
- * The following getter is unused internally,
22
- * only for extending from 3rd party library
23
- */
24
- protected get v(): RuleSeed<T, O>['verify'];
25
- getRuleInfo(ruleSet: Ruleset, ruleName: string): GlobalRuleInfo<T, O>;
26
- optimizeOption(configSettings: T | RuleConfig<T, O> | undefined): RuleInfo<T, O>;
27
- verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
28
- private _optimize;
7
+ #private;
8
+ readonly defaultOptions: O;
9
+ readonly defaultSeverity: Severity;
10
+ readonly defaultValue: T;
11
+ readonly name: string;
12
+ constructor(
13
+ o: RuleSeed<T, O> & {
14
+ name: string;
15
+ },
16
+ );
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
+ /**
23
+ * The following getter is unused internally,
24
+ * only for extending from 3rd party library
25
+ */
26
+ protected get v(): RuleSeed<T, O>['verify'];
27
+ getRuleInfo(ruleSet: Ruleset, ruleName: string): GlobalRuleInfo<T, O>;
28
+ optimizeOption(configSettings: T | RuleConfig<T, O> | undefined): RuleInfo<T, O>;
29
+ verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
30
+ private _optimize;
29
31
  }
30
32
  export type AnyMLRule = MLRule<RuleConfigValue, unknown>;
@@ -1,20 +1,26 @@
1
- import type { Attr, Element } from '../ml-dom';
2
1
  import type { MLRuleContext } from './ml-rule-context';
2
+ import type { Attr, Element } from '../ml-dom';
3
3
  import type { Translator } from '@markuplint/i18n';
4
4
  import type { Report, RuleConfigValue, Severity } from '@markuplint/ml-config';
5
5
  export type RuleSeed<T extends RuleConfigValue = boolean, O = null> = {
6
- defaultSeverity?: Severity;
7
- defaultValue?: T;
8
- defaultOptions?: O;
9
- verify(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
10
- fix?(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
6
+ defaultSeverity?: Severity;
7
+ defaultValue?: T;
8
+ defaultOptions?: O;
9
+ verify(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
10
+ fix?(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
11
11
  };
12
- export type Checker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (params: P) => CheckerReport<T, O>;
13
- export type ElementChecker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (params: P & {
14
- el: Element<T, O>;
15
- }) => CheckerReport<T, O>;
16
- export type AttrChecker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (params: P & {
17
- attr: Attr<T, O>;
18
- }) => CheckerReport<T, O>;
12
+ export type Checker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (
13
+ params: P,
14
+ ) => CheckerReport<T, O>;
15
+ export type ElementChecker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (
16
+ params: P & {
17
+ el: Element<T, O>;
18
+ },
19
+ ) => CheckerReport<T, O>;
20
+ export type AttrChecker<T extends RuleConfigValue, O = null, P extends Record<string, unknown> = {}> = (
21
+ params: P & {
22
+ attr: Attr<T, O>;
23
+ },
24
+ ) => CheckerReport<T, O>;
19
25
  export type CheckerReport<T extends RuleConfigValue, O = null> = (t: Translator) => Report<T, O> | undefined | null;
20
26
  export type AnyRuleSeed = RuleSeed<any, any>;
@@ -1,12 +1,12 @@
1
1
  import type { AnyRuleSeed } from '../ml-rule';
2
2
  import type { Config } from '@markuplint/ml-config';
3
3
  export type Plugin = {
4
- name: string;
5
- rules?: Record<string, AnyRuleSeed>;
6
- configs?: Record<string, Config>;
4
+ name: string;
5
+ rules?: Record<string, AnyRuleSeed>;
6
+ configs?: Record<string, Config>;
7
7
  };
8
8
  export type PluginCreator<S extends CreatePluginSettings> = {
9
- name: string;
10
- create(setting: S): Omit<Plugin, 'name'>;
9
+ name: string;
10
+ create(setting: S): Omit<Plugin, 'name'>;
11
11
  };
12
12
  export type CreatePluginSettings = Record<string, unknown>;
@@ -1,7 +1,7 @@
1
1
  import type { ChildNodeRule, Config, NodeRule, Rules } from '@markuplint/ml-config';
2
2
  export default class Ruleset {
3
- readonly childNodeRules: ReadonlyArray<ChildNodeRule>;
4
- readonly nodeRules: ReadonlyArray<NodeRule>;
5
- readonly rules: Readonly<Rules>;
6
- constructor(config: Config);
3
+ readonly childNodeRules: ReadonlyArray<ChildNodeRule>;
4
+ readonly nodeRules: ReadonlyArray<NodeRule>;
5
+ readonly rules: Readonly<Rules>;
6
+ constructor(config: Config);
7
7
  }
@@ -3,14 +3,26 @@ 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 type CreateTestOptions = {
6
- config?: Config;
7
- parser?: MLMarkupLanguageParser;
8
- specs?: MLMLSpec;
6
+ config?: Config;
7
+ parser?: MLMarkupLanguageParser;
8
+ specs?: MLMLSpec;
9
9
  };
10
- export declare function createTestDocument<T extends RuleConfigValue = any, O = any>(sourceCode: string, options?: CreateTestOptions): Document<T, O>;
11
- export declare function createTestNodeList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/node/node").MLNode<any, any, import("@markuplint/ml-ast").MLASTAbstractNode>[];
12
- export declare function createTestTokenList(sourceCode: string, options?: CreateTestOptions): readonly import("../ml-dom/token/token").MLToken<import("@markuplint/ml-ast").MLToken>[];
13
- export declare function createTestElement(sourceCode: string, options?: CreateTestOptions): import("../ml-dom").Element<any, any>;
10
+ export declare function createTestDocument<T extends RuleConfigValue = any, O = any>(
11
+ sourceCode: string,
12
+ options?: CreateTestOptions,
13
+ ): Document<T, O>;
14
+ export declare function createTestNodeList(
15
+ sourceCode: string,
16
+ options?: CreateTestOptions,
17
+ ): readonly import('../ml-dom/node/node').MLNode<any, any, import('@markuplint/ml-ast').MLASTAbstractNode>[];
18
+ export declare function createTestTokenList(
19
+ sourceCode: string,
20
+ options?: CreateTestOptions,
21
+ ): readonly import('../ml-dom/token/token').MLToken<import('@markuplint/ml-ast').MLToken>[];
22
+ export declare function createTestElement(
23
+ sourceCode: string,
24
+ options?: CreateTestOptions,
25
+ ): import('../ml-dom').Element<any, any>;
14
26
  /**
15
27
  * for test suite
16
28
  */
package/lib/test/index.js CHANGED
@@ -27,7 +27,7 @@ exports.createTestTokenList = createTestTokenList;
27
27
  function createTestElement(sourceCode, options) {
28
28
  const document = createTestDocument(sourceCode, options);
29
29
  const el = document.nodeList[0];
30
- if (el.is(el.ELEMENT_NODE)) {
30
+ if (el && el.is(el.ELEMENT_NODE)) {
31
31
  return el;
32
32
  }
33
33
  throw TypeError(`Could not parse it to be an element from: ${sourceCode}`);
package/lib/types.d.ts CHANGED
@@ -6,11 +6,11 @@ import type { Pretender } from '@markuplint/ml-config';
6
6
  import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
7
7
  export type MLSchema = Readonly<[MLMLSpec, ...ExtendedSpec[]]>;
8
8
  export type MLFabric = {
9
- parser: MLMarkupLanguageParser;
10
- ruleset: Partial<Ruleset>;
11
- rules: AnyMLRule[];
12
- locale: LocaleSet;
13
- schemas: MLSchema;
14
- parserOptions: ParserOptions;
15
- pretenders: Pretender[];
9
+ parser: MLMarkupLanguageParser;
10
+ ruleset: Partial<Ruleset>;
11
+ rules: AnyMLRule[];
12
+ locale: LocaleSet;
13
+ schemas: MLSchema;
14
+ parserOptions: ParserOptions;
15
+ pretenders: Pretender[];
16
16
  };
@@ -1,7 +1,12 @@
1
1
  interface Location {
2
- line: number;
3
- col: number;
4
- raw: string;
2
+ line: number;
3
+ col: number;
4
+ raw: string;
5
5
  }
6
- export declare function getLocationFromChars(searches: string[], text: string, currentLine: number, currentCol: number): Location[];
6
+ export declare function getLocationFromChars(
7
+ searches: string[],
8
+ text: string,
9
+ currentLine: number,
10
+ currentCol: number,
11
+ ): Location[];
7
12
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-core",
3
- "version": "3.3.0",
3
+ "version": "3.4.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>",
@@ -24,12 +24,14 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@markuplint/config-presets": "3.3.0",
27
- "@markuplint/i18n": "3.3.0",
27
+ "@markuplint/html-parser": "3.4.0",
28
+ "@markuplint/html-spec": "3.4.0",
29
+ "@markuplint/i18n": "3.4.0",
28
30
  "@markuplint/ml-ast": "3.0.0",
29
- "@markuplint/ml-config": "3.3.0",
30
- "@markuplint/ml-spec": "3.3.0",
31
- "@markuplint/parser-utils": "3.3.0",
32
- "@markuplint/selector": "3.3.0",
31
+ "@markuplint/ml-config": "3.4.0",
32
+ "@markuplint/ml-spec": "3.4.0",
33
+ "@markuplint/parser-utils": "3.4.0",
34
+ "@markuplint/selector": "3.4.0",
33
35
  "debug": "^4.3.4",
34
36
  "tslib": "^2.4.1"
35
37
  },
@@ -37,5 +39,5 @@
37
39
  "@markuplint/html-parser": "3.3.0",
38
40
  "@types/debug": "^4.1.7"
39
41
  },
40
- "gitHead": "791fb22a4df7acb985ced3808923fba0cd95c28a"
42
+ "gitHead": "a83e0f5f214a9bbcc0286b9e269074ddca6189e7"
41
43
  }