@markuplint/ml-core 5.0.0-alpha.0 → 5.0.0-alpha.2

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 (41) hide show
  1. package/ARCHITECTURE.ja.md +125 -5
  2. package/ARCHITECTURE.md +125 -5
  3. package/CHANGELOG.md +18 -0
  4. package/docs/ml-dom/attr.ja.md +1 -1
  5. package/docs/ml-dom/attr.md +1 -1
  6. package/docs/ml-dom/document.ja.md +7 -14
  7. package/docs/ml-dom/document.md +7 -14
  8. package/docs/ml-dom/element.ja.md +9 -24
  9. package/docs/ml-dom/element.md +9 -24
  10. package/docs/rule-system.ja.md +1 -1
  11. package/docs/rule-system.md +1 -1
  12. package/lib/fix-applier.d.ts +30 -0
  13. package/lib/fix-applier.js +70 -0
  14. package/lib/index.d.ts +2 -0
  15. package/lib/index.js +1 -0
  16. package/lib/ml-core.d.ts +14 -2
  17. package/lib/ml-core.js +25 -4
  18. package/lib/ml-dom/helper/get-indent.d.ts +0 -1
  19. package/lib/ml-dom/helper/get-indent.js +5 -18
  20. package/lib/ml-dom/node/attr.d.ts +2 -13
  21. package/lib/ml-dom/node/attr.js +6 -38
  22. package/lib/ml-dom/node/document.d.ts +2 -13
  23. package/lib/ml-dom/node/document.js +3 -41
  24. package/lib/ml-dom/node/element-close-tag.d.ts +1 -1
  25. package/lib/ml-dom/node/element-close-tag.js +2 -16
  26. package/lib/ml-dom/node/element.d.ts +2 -19
  27. package/lib/ml-dom/node/element.js +3 -62
  28. package/lib/ml-dom/token/token.d.ts +3 -18
  29. package/lib/ml-dom/token/token.js +7 -28
  30. package/lib/ml-rule/index.d.ts +1 -0
  31. package/lib/ml-rule/index.js +1 -0
  32. package/lib/ml-rule/ml-rule-context.d.ts +2 -30
  33. package/lib/ml-rule/ml-rule-context.js +15 -15
  34. package/lib/ml-rule/ml-rule.d.ts +6 -10
  35. package/lib/ml-rule/ml-rule.js +32 -33
  36. package/lib/ml-rule/rule-fixer.d.ts +25 -0
  37. package/lib/ml-rule/rule-fixer.js +32 -0
  38. package/lib/ml-rule/types.d.ts +1 -2
  39. package/lib/test/index.d.ts +1 -10
  40. package/lib/test/index.js +0 -11
  41. package/package.json +12 -12
@@ -2,7 +2,7 @@ import type { MLASTToken } from '@markuplint/ml-ast';
2
2
  /**
3
3
  * Represents a single token in the markuplint AST.
4
4
  * Wraps an AST token with positional information (line, column, offset)
5
- * and provides both raw and fixed string representations.
5
+ * and provides the raw string representation.
6
6
  *
7
7
  * @template A - The AST token type this token wraps
8
8
  */
@@ -40,12 +40,6 @@ export declare class MLToken<A extends MLASTToken = MLASTToken> {
40
40
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
41
41
  */
42
42
  get endOffset(): number;
43
- /**
44
- * The fixed (potentially modified) string content of this token.
45
- *
46
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
47
- */
48
- get fixed(): string;
49
43
  /**
50
44
  * The original raw string content of this token from the source.
51
45
  *
@@ -71,19 +65,10 @@ export declare class MLToken<A extends MLASTToken = MLASTToken> {
71
65
  */
72
66
  get startOffset(): number;
73
67
  /**
74
- * Replaces the fixed content of this token with the given string,
75
- * used when applying lint fixes.
76
- *
77
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
78
- * @param raw - The new string content to set as the fixed value
79
- */
80
- fix(raw: string): void;
81
- /**
82
- * Returns the string representation of this token.
68
+ * Returns the raw string representation of this token.
83
69
  *
84
70
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
85
- * @param fixed - When true, returns the fixed content; otherwise returns the original raw content
86
71
  * @returns The string content of this token
87
72
  */
88
- toString(fixed?: boolean): string;
73
+ toString(): string;
89
74
  }
@@ -2,12 +2,11 @@ import { getEndCol, getEndLine } from '@markuplint/parser-utils/location';
2
2
  /**
3
3
  * Represents a single token in the markuplint AST.
4
4
  * Wraps an AST token with positional information (line, column, offset)
5
- * and provides both raw and fixed string representations.
5
+ * and provides the raw string representation.
6
6
  *
7
7
  * @template A - The AST token type this token wraps
8
8
  */
9
9
  export class MLToken {
10
- #fixed;
11
10
  #raw;
12
11
  /**
13
12
  * The unique identifier for this token.
@@ -25,7 +24,6 @@ export class MLToken {
25
24
  constructor(astToken) {
26
25
  this._astToken = astToken;
27
26
  this.#raw = astToken.raw;
28
- this.#fixed = astToken.raw;
29
27
  this.uuid = astToken.uuid;
30
28
  }
31
29
  /**
@@ -34,7 +32,7 @@ export class MLToken {
34
32
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
35
33
  */
36
34
  get endCol() {
37
- return getEndCol(this.fixed, this.startCol);
35
+ return getEndCol(this.raw, this.startCol);
38
36
  }
39
37
  /**
40
38
  * The ending line number (1-based) of this token in the source.
@@ -42,7 +40,7 @@ export class MLToken {
42
40
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
43
41
  */
44
42
  get endLine() {
45
- return getEndLine(this.fixed, this.startLine);
43
+ return getEndLine(this.raw, this.startLine);
46
44
  }
47
45
  /**
48
46
  * The ending character offset (0-based) of this token in the source.
@@ -50,15 +48,7 @@ export class MLToken {
50
48
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
51
49
  */
52
50
  get endOffset() {
53
- return this.startOffset + this.fixed.length;
54
- }
55
- /**
56
- * The fixed (potentially modified) string content of this token.
57
- *
58
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
59
- */
60
- get fixed() {
61
- return this.#fixed;
51
+ return this.startOffset + this.raw.length;
62
52
  }
63
53
  /**
64
54
  * The original raw string content of this token from the source.
@@ -93,23 +83,12 @@ export class MLToken {
93
83
  return this._astToken.offset;
94
84
  }
95
85
  /**
96
- * Replaces the fixed content of this token with the given string,
97
- * used when applying lint fixes.
86
+ * Returns the raw string representation of this token.
98
87
  *
99
88
  * @implements `@markuplint/ml-core` API: `MLDOMToken`
100
- * @param raw - The new string content to set as the fixed value
101
- */
102
- fix(raw) {
103
- this.#fixed = raw;
104
- }
105
- /**
106
- * Returns the string representation of this token.
107
- *
108
- * @implements `@markuplint/ml-core` API: `MLDOMToken`
109
- * @param fixed - When true, returns the fixed content; otherwise returns the original raw content
110
89
  * @returns The string content of this token
111
90
  */
112
- toString(fixed = false) {
113
- return fixed ? this.#fixed : this.#raw;
91
+ toString() {
92
+ return this.#raw;
114
93
  }
115
94
  }
@@ -1,3 +1,4 @@
1
1
  export * from './create-rule.js';
2
2
  export * from './ml-rule.js';
3
+ export * from './rule-fixer.js';
3
4
  export * from './types.js';
@@ -1,3 +1,4 @@
1
1
  export * from './create-rule.js';
2
2
  export * from './ml-rule.js';
3
+ export * from './rule-fixer.js';
3
4
  export * from './types.js';
@@ -8,40 +8,12 @@ export declare class MLRuleContext<T extends RuleConfigValue, O extends PlainDat
8
8
  readonly locale: string;
9
9
  readonly translate: Translator;
10
10
  constructor(document: MLDocument<T, O>, locale: LocaleSet);
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
- })[];
11
+ get reports(): Report<T, O>[];
26
12
  provide(): {
27
13
  document: MLDocument<T, O>;
28
14
  translate: Translator;
29
15
  t: Translator;
30
- reports: ({
31
- message: string;
32
- line: number;
33
- col: number;
34
- raw: string;
35
- } | {
36
- message: string;
37
- scope: import("@markuplint/ml-config").Scope<T, O>;
38
- } | {
39
- message: string;
40
- scope: import("@markuplint/ml-config").Scope<T, O>;
41
- line: number;
42
- col: number;
43
- raw: string;
44
- })[];
16
+ reports: Report<T, O>[];
45
17
  report: {
46
18
  (report: Report<T, O>): undefined;
47
19
  (report: CheckerReport<T, O>): boolean;
@@ -3,6 +3,7 @@ export class MLRuleContext {
3
3
  document;
4
4
  locale;
5
5
  #reports = [];
6
+ #reportKeys = new Set();
6
7
  translate;
7
8
  constructor(
8
9
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
@@ -12,10 +13,7 @@ export class MLRuleContext {
12
13
  this.locale = locale.locale;
13
14
  }
14
15
  get reports() {
15
- return this.#reports.map(report => ({
16
- ...report,
17
- message: finish(report.message, this.locale),
18
- }));
16
+ return this.#reports;
19
17
  }
20
18
  provide() {
21
19
  return {
@@ -38,8 +36,13 @@ export class MLRuleContext {
38
36
  this._push(report);
39
37
  }
40
38
  _push(report) {
41
- if (!this.#reports.some(r => is(r, report))) {
42
- this.#reports.push(report);
39
+ const key = reportKey(report);
40
+ if (!this.#reportKeys.has(key)) {
41
+ this.#reportKeys.add(key);
42
+ this.#reports.push({
43
+ ...report,
44
+ message: finish(report.message, this.locale),
45
+ });
43
46
  }
44
47
  }
45
48
  }
@@ -51,15 +54,12 @@ function finish(message, locale = 'en') {
51
54
  }
52
55
  return message;
53
56
  }
54
- function is(r1, r2) {
55
- if ('col' in r1 && 'col' in r2) {
56
- return r1.col === r2.col && r1.line === r2.line && r1.message === r2.message && r1.raw === r2.raw;
57
+ function reportKey(report) {
58
+ if ('col' in report && report.col != null) {
59
+ return `${report.line}:${report.col}:${report.message}:${report.raw}`;
57
60
  }
58
- if ('scope' in r1) {
59
- if (!('scope' in r2)) {
60
- return false;
61
- }
62
- return r1.scope === r2.scope && r1.message === r2.message;
61
+ if ('scope' in report) {
62
+ return `${report.scope.startLine}:${report.scope.startCol}:${report.message}`;
63
63
  }
64
- return false;
64
+ return report.message;
65
65
  }
@@ -12,7 +12,7 @@ import type { GlobalRuleInfo, SpecConformance, PlainData, Rule, RuleConfigValue,
12
12
  export declare class MLRule<T extends RuleConfigValue, O extends PlainData = undefined> {
13
13
  #private;
14
14
  /**
15
- * For virtual rules, the name of the base rule whose verify/fix logic is reused.
15
+ * For virtual rules, the name of the base rule whose verify logic is reused.
16
16
  * When set, violations report this as `ruleId` for backwards compatibility.
17
17
  */
18
18
  readonly baseRuleId?: string;
@@ -37,24 +37,19 @@ export declare class MLRule<T extends RuleConfigValue, O extends PlainData = und
37
37
  readonly groupName?: string;
38
38
  });
39
39
  /**
40
- * Creates a virtual rule that reuses this rule's verify/fix logic
40
+ * Creates a virtual rule that reuses this rule's verify logic
41
41
  * under a different name (alias). Used by named nodeRules to produce
42
42
  * independent rule instances that can be individually configured.
43
43
  *
44
44
  * @param aliasName - The alias name (must contain `/`)
45
45
  * @param options - Override options for the virtual rule
46
- * @returns A new MLRule instance sharing the same verify/fix logic
46
+ * @returns A new MLRule instance sharing the same verify logic
47
47
  */
48
48
  createAlias(aliasName: string, options?: {
49
49
  readonly defaultSeverity?: Severity;
50
50
  readonly specConformance?: SpecConformance;
51
51
  readonly groupName?: string;
52
52
  }): MLRule<T, O>;
53
- /**
54
- * The following getter is unused internally,
55
- * only for extending from 3rd party library
56
- */
57
- protected get f(): RuleSeed<T, O>['fix'];
58
53
  /**
59
54
  * The following getter is unused internally,
60
55
  * only for extending from 3rd party library
@@ -78,12 +73,13 @@ export declare class MLRule<T extends RuleConfigValue, O extends PlainData = und
78
73
  */
79
74
  optimizeOption(configSettings: Rule<T, O> | null | undefined): RuleInfo<T, O>;
80
75
  /**
81
- * Executes this rule's verify (and optionally fix) function against a document,
76
+ * Executes this rule's verify function against a document,
82
77
  * then collects and returns the resulting violations.
78
+ * When `fix` is true, fix callbacks on reports are executed to produce {@link FixData}.
83
79
  *
84
80
  * @param document - The parsed document to verify
85
81
  * @param locale - The locale set for translating violation messages
86
- * @param fix - Whether to also run the fix function
82
+ * @param fix - Whether to execute fix callbacks and attach FixData to violations
87
83
  * @returns An array of violations found by this rule
88
84
  */
89
85
  verify(document: MLDocument<T, O>, locale: LocaleSet, fix: boolean): Promise<Violation[]>;
@@ -1,7 +1,9 @@
1
- import { deleteUndefProp } from '@markuplint/ml-config';
2
1
  // @ts-ignore
3
2
  import { isPlainObject } from 'is-plain-object';
3
+ import { RuleFixer } from './rule-fixer.js';
4
4
  import { MLRuleContext } from './ml-rule-context.js';
5
+ // Stateless — safe to share across all rule instances
6
+ const sharedFixer = new RuleFixer();
5
7
  /**
6
8
  * Represents a single markuplint rule that can verify documents and report violations.
7
9
  *
@@ -10,14 +12,13 @@ import { MLRuleContext } from './ml-rule-context.js';
10
12
  */
11
13
  export class MLRule {
12
14
  /**
13
- * For virtual rules, the name of the base rule whose verify/fix logic is reused.
15
+ * For virtual rules, the name of the base rule whose verify logic is reused.
14
16
  * When set, violations report this as `ruleId` for backwards compatibility.
15
17
  */
16
18
  baseRuleId;
17
19
  defaultOptions;
18
20
  defaultSeverity;
19
21
  defaultValue;
20
- #f;
21
22
  /**
22
23
  * For multi-entry named nodeRules, the group name shared by all derived virtual rules.
23
24
  * Allows `rules["groupName"]: false` to disable all rules in the group.
@@ -42,16 +43,15 @@ export class MLRule {
42
43
  this.defaultValue = (o.defaultValue === undefined ? true : o.defaultValue);
43
44
  this.defaultOptions = o.defaultOptions;
44
45
  this.#v = o.verify;
45
- this.#f = o.fix;
46
46
  }
47
47
  /**
48
- * Creates a virtual rule that reuses this rule's verify/fix logic
48
+ * Creates a virtual rule that reuses this rule's verify logic
49
49
  * under a different name (alias). Used by named nodeRules to produce
50
50
  * independent rule instances that can be individually configured.
51
51
  *
52
52
  * @param aliasName - The alias name (must contain `/`)
53
53
  * @param options - Override options for the virtual rule
54
- * @returns A new MLRule instance sharing the same verify/fix logic
54
+ * @returns A new MLRule instance sharing the same verify logic
55
55
  */
56
56
  createAlias(aliasName, options) {
57
57
  return new MLRule({
@@ -63,16 +63,8 @@ export class MLRule {
63
63
  defaultValue: this.defaultValue,
64
64
  defaultOptions: this.defaultOptions,
65
65
  verify: this.#v,
66
- fix: this.#f,
67
66
  });
68
67
  }
69
- /**
70
- * The following getter is unused internally,
71
- * only for extending from 3rd party library
72
- */
73
- get f() {
74
- return this.#f;
75
- }
76
68
  /**
77
69
  * The following getter is unused internally,
78
70
  * only for extending from 3rd party library
@@ -135,12 +127,13 @@ export class MLRule {
135
127
  };
136
128
  }
137
129
  /**
138
- * Executes this rule's verify (and optionally fix) function against a document,
130
+ * Executes this rule's verify function against a document,
139
131
  * then collects and returns the resulting violations.
132
+ * When `fix` is true, fix callbacks on reports are executed to produce {@link FixData}.
140
133
  *
141
134
  * @param document - The parsed document to verify
142
135
  * @param locale - The locale set for translating violation messages
143
- * @param fix - Whether to also run the fix function
136
+ * @param fix - Whether to execute fix callbacks and attach FixData to violations
144
137
  * @returns An array of violations found by this rule
145
138
  */
146
139
  async verify(
@@ -150,13 +143,19 @@ export class MLRule {
150
143
  const context = new MLRuleContext(document, locale);
151
144
  const providableContext = context.provide();
152
145
  await this.#v(providableContext);
153
- if (this.#f && fix) {
154
- await this.#f(providableContext);
155
- }
156
146
  const ruleId = this.baseRuleId ?? this.name;
157
147
  // Only include name and specConformance for virtual rules (named nodeRules)
158
148
  const aliasName = this.baseRuleId ? this.name : undefined;
159
- const violation = context.reports.map(report => {
149
+ const violations = context.reports.map(report => {
150
+ // Execute fix callback if fix mode is enabled
151
+ let fixData;
152
+ if (fix && report.fix) {
153
+ const edits = report.fix(sharedFixer);
154
+ const editArray = Array.isArray(edits) ? edits : [edits];
155
+ if (editArray.length > 0) {
156
+ fixData = { edits: editArray };
157
+ }
158
+ }
160
159
  if ('scope' in report) {
161
160
  let line = report.scope.startLine;
162
161
  let col = report.scope.startCol;
@@ -166,36 +165,36 @@ export class MLRule {
166
165
  col = report.col;
167
166
  raw = report.raw;
168
167
  }
169
- const violation = {
168
+ return {
170
169
  severity: report.scope.rule.severity,
171
170
  message: report.message,
172
171
  line,
173
172
  col,
174
173
  raw,
175
174
  ruleId,
176
- name: aliasName,
177
- specConformance: this.specConformance,
178
- reason: report.scope.rule.reason ?? document.rule.reason,
175
+ ...(aliasName != null && { name: aliasName }),
176
+ ...(this.specConformance != null && { specConformance: this.specConformance }),
177
+ ...((report.scope.rule.reason ?? document.rule.reason)
178
+ ? { reason: report.scope.rule.reason ?? document.rule.reason }
179
+ : {}),
180
+ ...(fixData != null && { fix: fixData }),
179
181
  };
180
- deleteUndefProp(violation);
181
- return violation;
182
182
  }
183
- const violation = {
183
+ return {
184
184
  severity: document.rule.severity,
185
185
  message: report.message,
186
186
  line: report.line,
187
187
  col: report.col,
188
188
  raw: report.raw,
189
189
  ruleId,
190
- name: aliasName,
191
- specConformance: this.specConformance,
192
- reason: document.rule.reason,
190
+ ...(aliasName != null && { name: aliasName }),
191
+ ...(this.specConformance != null && { specConformance: this.specConformance }),
192
+ ...(document.rule.reason ? { reason: document.rule.reason } : {}),
193
+ ...(fixData != null && { fix: fixData }),
193
194
  };
194
- deleteUndefProp(violation);
195
- return violation;
196
195
  });
197
196
  document.setRule(null);
198
- return violation;
197
+ return violations;
199
198
  }
200
199
  _optimize(rules, ruleName) {
201
200
  const rule = (rules?.[ruleName] ?? false);
@@ -0,0 +1,25 @@
1
+ import type { IRuleFixer, TextEdit } from '@markuplint/ml-config';
2
+ /**
3
+ * Stateless implementation of {@link IRuleFixer}.
4
+ * Provides helper methods for building {@link TextEdit} objects
5
+ * inside rule fix callbacks.
6
+ */
7
+ export declare class RuleFixer implements IRuleFixer {
8
+ replaceText(token: {
9
+ readonly startOffset: number;
10
+ readonly raw: string;
11
+ }, text: string): TextEdit;
12
+ replaceRange(range: readonly [number, number], text: string): TextEdit;
13
+ insertBefore(token: {
14
+ readonly startOffset: number;
15
+ }, text: string): TextEdit;
16
+ insertAfter(token: {
17
+ readonly startOffset: number;
18
+ readonly raw: string;
19
+ }, text: string): TextEdit;
20
+ remove(token: {
21
+ readonly startOffset: number;
22
+ readonly raw: string;
23
+ }): TextEdit;
24
+ removeRange(range: readonly [number, number]): TextEdit;
25
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Stateless implementation of {@link IRuleFixer}.
3
+ * Provides helper methods for building {@link TextEdit} objects
4
+ * inside rule fix callbacks.
5
+ */
6
+ export class RuleFixer {
7
+ replaceText(token, text) {
8
+ return {
9
+ range: [token.startOffset, token.startOffset + token.raw.length],
10
+ text,
11
+ };
12
+ }
13
+ replaceRange(range, text) {
14
+ return { range, text };
15
+ }
16
+ insertBefore(token, text) {
17
+ return { range: [token.startOffset, token.startOffset], text };
18
+ }
19
+ insertAfter(token, text) {
20
+ const end = token.startOffset + token.raw.length;
21
+ return { range: [end, end], text };
22
+ }
23
+ remove(token) {
24
+ return {
25
+ range: [token.startOffset, token.startOffset + token.raw.length],
26
+ text: '',
27
+ };
28
+ }
29
+ removeRange(range) {
30
+ return { range, text: '' };
31
+ }
32
+ }
@@ -3,7 +3,7 @@ import type { Attr, Element } from '../ml-dom/index.js';
3
3
  import type { Translator } from '@markuplint/i18n';
4
4
  import type { PlainData, Report, RuleConfigValue, Severity } from '@markuplint/ml-config';
5
5
  /**
6
- * The definition of a markuplint rule, including verification logic, optional fix logic,
6
+ * The definition of a markuplint rule, including verification logic
7
7
  * and default configuration values.
8
8
  *
9
9
  * @template T - The type of the rule's configuration value (defaults to boolean)
@@ -17,7 +17,6 @@ export type RuleSeed<T extends RuleConfigValue = boolean, O extends PlainData =
17
17
  readonly defaultValue?: T;
18
18
  readonly defaultOptions?: O;
19
19
  verify(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
20
- fix?(context: ReturnType<MLRuleContext<T, O>['provide']>): void | Promise<void>;
21
20
  };
22
21
  /**
23
22
  * A generic checker function that produces a violation report from parameters.
@@ -1,7 +1,6 @@
1
1
  import type { MLElement } from '../ml-dom/node/element.js';
2
2
  import type { MLNode } from '../ml-dom/node/node.js';
3
- import type { MLToken } from '../ml-dom/token/token.js';
4
- import type { MLASTNode, MLASTToken, MLParser } from '@markuplint/ml-ast';
3
+ import type { MLASTNode, MLParser } from '@markuplint/ml-ast';
5
4
  import type { Config, PlainData, Pretender, RuleConfigValue } from '@markuplint/ml-config';
6
5
  import type { MLMLSpec } from '@markuplint/ml-spec';
7
6
  import { MLDocument } from '../ml-dom/node/document.js';
@@ -38,14 +37,6 @@ export declare function createTestDocument<T extends RuleConfigValue = any, O ex
38
37
  * @returns A readonly array of all nodes in the parsed document
39
38
  */
40
39
  export declare function createTestNodeList(sourceCode: string, options?: CreateTestOptions): readonly MLNode<any, any, MLASTNode>[];
41
- /**
42
- * Parses markup source code and returns the flat list of tokens.
43
- *
44
- * @param sourceCode - The markup source code to parse
45
- * @param options - Options for parser, config, specs, and pretenders
46
- * @returns A readonly array of all tokens in the parsed document
47
- */
48
- export declare function createTestTokenList(sourceCode: string, options?: CreateTestOptions): readonly MLToken<MLASTToken>[];
49
40
  /**
50
41
  * Parses markup source code and returns the first element node.
51
42
  * Throws if the source does not produce an element as its first node.
package/lib/test/index.js CHANGED
@@ -35,17 +35,6 @@ export function createTestNodeList(sourceCode, options) {
35
35
  const document = createTestDocument(sourceCode, options);
36
36
  return document.nodeList;
37
37
  }
38
- /**
39
- * Parses markup source code and returns the flat list of tokens.
40
- *
41
- * @param sourceCode - The markup source code to parse
42
- * @param options - Options for parser, config, specs, and pretenders
43
- * @returns A readonly array of all tokens in the parsed document
44
- */
45
- export function createTestTokenList(sourceCode, options) {
46
- const document = createTestDocument(sourceCode, options);
47
- return document.getTokenList();
48
- }
49
38
  /**
50
39
  * Parses markup source code and returns the first element node.
51
40
  * Throws if the source does not produce an element as its first node.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-core",
3
- "version": "5.0.0-alpha.0",
3
+ "version": "5.0.0-alpha.2",
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>",
@@ -30,20 +30,20 @@
30
30
  "./lib/configs.js": "./lib/configs.browser.js"
31
31
  },
32
32
  "dependencies": {
33
- "@markuplint/config-presets": "5.0.0-alpha.0",
34
- "@markuplint/html-parser": "5.0.0-alpha.0",
35
- "@markuplint/html-spec": "5.0.0-alpha.0",
36
- "@markuplint/i18n": "5.0.0-alpha.0",
37
- "@markuplint/ml-ast": "5.0.0-alpha.0",
38
- "@markuplint/ml-config": "5.0.0-alpha.0",
39
- "@markuplint/ml-spec": "5.0.0-alpha.0",
40
- "@markuplint/parser-utils": "5.0.0-alpha.0",
41
- "@markuplint/selector": "5.0.0-alpha.0",
42
- "@markuplint/shared": "5.0.0-alpha.0",
33
+ "@markuplint/config-presets": "5.0.0-alpha.2",
34
+ "@markuplint/html-parser": "5.0.0-alpha.2",
35
+ "@markuplint/html-spec": "5.0.0-alpha.2",
36
+ "@markuplint/i18n": "5.0.0-alpha.2",
37
+ "@markuplint/ml-ast": "5.0.0-alpha.2",
38
+ "@markuplint/ml-config": "5.0.0-alpha.2",
39
+ "@markuplint/ml-spec": "5.0.0-alpha.2",
40
+ "@markuplint/parser-utils": "5.0.0-alpha.2",
41
+ "@markuplint/selector": "5.0.0-alpha.2",
42
+ "@markuplint/shared": "5.0.0-alpha.2",
43
43
  "@types/debug": "4.1.12",
44
44
  "debug": "4.4.3",
45
45
  "is-plain-object": "5.0.0",
46
46
  "type-fest": "5.4.4"
47
47
  },
48
- "gitHead": "13dcfc84ec83d87360c720e253383b60767e1b56"
48
+ "gitHead": "31ccf1e81443ea3f93597d287595211f1823ddcf"
49
49
  }