@markuplint/ml-core 4.13.2 → 4.13.3

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 (80) hide show
  1. package/ARCHITECTURE.ja.md +467 -0
  2. package/ARCHITECTURE.md +467 -0
  3. package/CHANGELOG.md +3 -3
  4. package/README.md +5 -0
  5. package/SKILL.md +61 -0
  6. package/docs/linting-pipeline.ja.md +303 -0
  7. package/docs/linting-pipeline.md +303 -0
  8. package/docs/maintenance.ja.md +210 -0
  9. package/docs/maintenance.md +210 -0
  10. package/docs/ml-dom/attr.ja.md +95 -0
  11. package/docs/ml-dom/attr.md +95 -0
  12. package/docs/ml-dom/block.ja.md +272 -0
  13. package/docs/ml-dom/block.md +272 -0
  14. package/docs/ml-dom/document.ja.md +141 -0
  15. package/docs/ml-dom/document.md +141 -0
  16. package/docs/ml-dom/element.ja.md +176 -0
  17. package/docs/ml-dom/element.md +176 -0
  18. package/docs/ml-dom/helpers.ja.md +203 -0
  19. package/docs/ml-dom/helpers.md +203 -0
  20. package/docs/ml-dom/node.ja.md +200 -0
  21. package/docs/ml-dom/node.md +200 -0
  22. package/docs/ml-dom/others.ja.md +119 -0
  23. package/docs/ml-dom/others.md +119 -0
  24. package/docs/ml-dom/overview.ja.md +102 -0
  25. package/docs/ml-dom/overview.md +102 -0
  26. package/docs/ml-dom/pretender.ja.md +269 -0
  27. package/docs/ml-dom/pretender.md +269 -0
  28. package/docs/ml-dom/rule-mapping.ja.md +371 -0
  29. package/docs/ml-dom/rule-mapping.md +371 -0
  30. package/docs/ml-dom.ja.md +18 -0
  31. package/docs/ml-dom.md +18 -0
  32. package/docs/rule-system.ja.md +270 -0
  33. package/docs/rule-system.md +270 -0
  34. package/lib/convert-ruleset.d.ts +7 -0
  35. package/lib/convert-ruleset.js +7 -0
  36. package/lib/debug.d.ts +4 -0
  37. package/lib/debug.js +4 -0
  38. package/lib/ml-core.d.ts +36 -0
  39. package/lib/ml-core.js +29 -0
  40. package/lib/ml-dom/helper/get-indent.d.ts +4 -1
  41. package/lib/ml-dom/helper/get-indent.js +4 -1
  42. package/lib/ml-dom/node/attr.d.ts +65 -4
  43. package/lib/ml-dom/node/attr.js +53 -4
  44. package/lib/ml-dom/node/block.d.ts +21 -0
  45. package/lib/ml-dom/node/block.js +14 -0
  46. package/lib/ml-dom/node/child-node.d.ts +9 -0
  47. package/lib/ml-dom/node/child-node.js +9 -0
  48. package/lib/ml-dom/node/comment.d.ts +7 -0
  49. package/lib/ml-dom/node/comment.js +7 -0
  50. package/lib/ml-dom/node/document-fragment.d.ts +8 -0
  51. package/lib/ml-dom/node/document-fragment.js +8 -0
  52. package/lib/ml-dom/node/document-type.d.ts +22 -0
  53. package/lib/ml-dom/node/document-type.js +13 -0
  54. package/lib/ml-dom/node/document.d.ts +74 -4
  55. package/lib/ml-dom/node/document.js +57 -2
  56. package/lib/ml-dom/node/element.d.ts +136 -2
  57. package/lib/ml-dom/node/element.js +115 -2
  58. package/lib/ml-dom/node/node.d.ts +16 -0
  59. package/lib/ml-dom/node/node.js +16 -0
  60. package/lib/ml-dom/node/text.d.ts +12 -0
  61. package/lib/ml-dom/node/text.js +12 -0
  62. package/lib/ml-dom/node/types.d.ts +68 -0
  63. package/lib/ml-dom/token/token.d.ts +42 -0
  64. package/lib/ml-dom/token/token.js +36 -0
  65. package/lib/ml-rule/create-rule.d.ts +9 -0
  66. package/lib/ml-rule/create-rule.js +9 -0
  67. package/lib/ml-rule/ml-rule.d.ts +33 -0
  68. package/lib/ml-rule/ml-rule.js +30 -0
  69. package/lib/ml-rule/types.d.ts +41 -0
  70. package/lib/plugin/plugin.d.ts +8 -0
  71. package/lib/plugin/plugin.js +8 -0
  72. package/lib/plugin/types.d.ts +21 -0
  73. package/lib/ruleset/index.d.ts +10 -0
  74. package/lib/ruleset/index.js +7 -0
  75. package/lib/test/index.d.ts +42 -1
  76. package/lib/test/index.js +35 -1
  77. package/lib/types.d.ts +8 -0
  78. package/lib/violation-collector.d.ts +33 -0
  79. package/lib/violation-collector.js +33 -0
  80. package/package.json +12 -12
package/lib/test/index.js CHANGED
@@ -2,6 +2,15 @@ import { parser } from '@markuplint/html-parser';
2
2
  import spec from '@markuplint/html-spec';
3
3
  import { convertRuleset } from '../convert-ruleset.js';
4
4
  import { MLDocument } from '../ml-dom/node/document.js';
5
+ /**
6
+ * Parses markup source code and returns a test document for use in rule tests.
7
+ *
8
+ * @template T - The rule config value type
9
+ * @template O - The rule options type
10
+ * @param sourceCode - The markup source code to parse
11
+ * @param options - Options for parser, config, specs, and pretenders
12
+ * @returns A parsed MLDocument instance
13
+ */
5
14
  export function createTestDocument(sourceCode, options) {
6
15
  const ast = options?.parser
7
16
  ? 'parser' in options.parser
@@ -12,14 +21,37 @@ export function createTestDocument(sourceCode, options) {
12
21
  const document = new MLDocument(ast, ruleset, [options?.specs ?? {}, {}]);
13
22
  return document;
14
23
  }
24
+ /**
25
+ * Parses markup source code and returns the flat list of AST nodes.
26
+ *
27
+ * @param sourceCode - The markup source code to parse
28
+ * @param options - Options for parser, config, specs, and pretenders
29
+ * @returns A readonly array of all nodes in the parsed document
30
+ */
15
31
  export function createTestNodeList(sourceCode, options) {
16
32
  const document = createTestDocument(sourceCode, options);
17
33
  return document.nodeList;
18
34
  }
35
+ /**
36
+ * Parses markup source code and returns the flat list of tokens.
37
+ *
38
+ * @param sourceCode - The markup source code to parse
39
+ * @param options - Options for parser, config, specs, and pretenders
40
+ * @returns A readonly array of all tokens in the parsed document
41
+ */
19
42
  export function createTestTokenList(sourceCode, options) {
20
43
  const document = createTestDocument(sourceCode, options);
21
44
  return document.getTokenList();
22
45
  }
46
+ /**
47
+ * Parses markup source code and returns the first element node.
48
+ * Throws if the source does not produce an element as its first node.
49
+ *
50
+ * @param sourceCode - The markup source code containing an element
51
+ * @param options - Options for parser, config, specs, and pretenders
52
+ * @returns The first element in the parsed document
53
+ * @throws {TypeError} If the first node is not an element
54
+ */
23
55
  export function createTestElement(sourceCode, options) {
24
56
  const document = createTestDocument(sourceCode, options);
25
57
  const el = document.nodeList[0];
@@ -29,7 +61,9 @@ export function createTestElement(sourceCode, options) {
29
61
  throw new TypeError(`Could not parse it to be an element from: ${sourceCode}`);
30
62
  }
31
63
  /**
32
- * for test suite
64
+ * Returns the default HTML spec as a schema tuple for use in test suites.
65
+ *
66
+ * @returns A single-element tuple containing the HTML specification
33
67
  */
34
68
  export function dummySchemas() {
35
69
  return [spec];
package/lib/types.d.ts CHANGED
@@ -4,7 +4,15 @@ import type { LocaleSet } from '@markuplint/i18n';
4
4
  import type { MLParser, ParserOptions } from '@markuplint/ml-ast';
5
5
  import type { Pretender, SeverityOptions } from '@markuplint/ml-config';
6
6
  import type { ExtendedSpec, MLMLSpec } from '@markuplint/ml-spec';
7
+ /**
8
+ * A tuple of the base HTML/ARIA specification and zero or more
9
+ * framework-specific extended specs (e.g. React, Vue, Svelte).
10
+ */
7
11
  export type MLSchema = readonly [MLMLSpec, ...ExtendedSpec[]];
12
+ /**
13
+ * The set of dependencies required by {@link MLCore} to perform linting.
14
+ * Includes the parser, ruleset, rules, locale, schemas, and other settings.
15
+ */
8
16
  export type MLFabric = {
9
17
  readonly parser: Readonly<MLParser>;
10
18
  readonly ruleset: Partial<Readonly<Ruleset>>;
@@ -1,12 +1,45 @@
1
1
  import type { Violation } from '@markuplint/ml-config';
2
+ /**
3
+ * Collects and manages lint violations across multiple files.
4
+ * Supports a maximum violation count to stop collecting early.
5
+ */
2
6
  export declare class ViolationCollector {
3
7
  #private;
8
+ /**
9
+ * @param maxCount - Maximum number of violations to collect; 0 means unlimited
10
+ */
4
11
  constructor(maxCount?: number);
12
+ /**
13
+ * Adds violations associated with a specific file path.
14
+ * Stops collecting once the maximum count is reached.
15
+ *
16
+ * @param filePath - The file that produced these violations
17
+ * @param violations - The violations to add
18
+ * @returns The current total number of collected violations
19
+ */
5
20
  pushWithFile(filePath: string, ...violations: readonly Violation[]): number;
21
+ /**
22
+ * The total number of collected violations.
23
+ */
6
24
  get length(): number;
25
+ /**
26
+ * Whether the collector has reached its maximum count and will no longer accept violations.
27
+ *
28
+ * @returns `true` if the collector is locked
29
+ */
7
30
  isLocked(): boolean;
31
+ /**
32
+ * Returns a copy of all collected violations as an array.
33
+ *
34
+ * @returns An array of violations with their associated file paths
35
+ */
8
36
  toArray(): (Violation & {
9
37
  filePath: string;
10
38
  })[];
39
+ /**
40
+ * Groups collected violations by their file path.
41
+ *
42
+ * @returns A Map from file path to an array of violations for that file
43
+ */
11
44
  groupByFile(): Map<string, Violation[]>;
12
45
  }
@@ -10,7 +10,14 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
12
  var _ViolationCollector_violations, _ViolationCollector_maxCount, _ViolationCollector_locked;
13
+ /**
14
+ * Collects and manages lint violations across multiple files.
15
+ * Supports a maximum violation count to stop collecting early.
16
+ */
13
17
  export class ViolationCollector {
18
+ /**
19
+ * @param maxCount - Maximum number of violations to collect; 0 means unlimited
20
+ */
14
21
  constructor(maxCount = 0) {
15
22
  _ViolationCollector_violations.set(this, []);
16
23
  _ViolationCollector_maxCount.set(this, 0);
@@ -18,6 +25,14 @@ export class ViolationCollector {
18
25
  __classPrivateFieldSet(this, _ViolationCollector_maxCount, maxCount, "f");
19
26
  __classPrivateFieldSet(this, _ViolationCollector_locked, false, "f");
20
27
  }
28
+ /**
29
+ * Adds violations associated with a specific file path.
30
+ * Stops collecting once the maximum count is reached.
31
+ *
32
+ * @param filePath - The file that produced these violations
33
+ * @param violations - The violations to add
34
+ * @returns The current total number of collected violations
35
+ */
21
36
  pushWithFile(filePath, ...violations) {
22
37
  if (__classPrivateFieldGet(this, _ViolationCollector_locked, "f")) {
23
38
  return __classPrivateFieldGet(this, _ViolationCollector_violations, "f").length;
@@ -31,15 +46,33 @@ export class ViolationCollector {
31
46
  }
32
47
  return __classPrivateFieldGet(this, _ViolationCollector_violations, "f").length;
33
48
  }
49
+ /**
50
+ * The total number of collected violations.
51
+ */
34
52
  get length() {
35
53
  return __classPrivateFieldGet(this, _ViolationCollector_violations, "f").length;
36
54
  }
55
+ /**
56
+ * Whether the collector has reached its maximum count and will no longer accept violations.
57
+ *
58
+ * @returns `true` if the collector is locked
59
+ */
37
60
  isLocked() {
38
61
  return __classPrivateFieldGet(this, _ViolationCollector_locked, "f");
39
62
  }
63
+ /**
64
+ * Returns a copy of all collected violations as an array.
65
+ *
66
+ * @returns An array of violations with their associated file paths
67
+ */
40
68
  toArray() {
41
69
  return [...__classPrivateFieldGet(this, _ViolationCollector_violations, "f")];
42
70
  }
71
+ /**
72
+ * Groups collected violations by their file path.
73
+ *
74
+ * @returns A Map from file path to an array of violations for that file
75
+ */
43
76
  groupByFile() {
44
77
  const grouped = new Map();
45
78
  for (const violation of __classPrivateFieldGet(this, _ViolationCollector_violations, "f")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/ml-core",
3
- "version": "4.13.2",
3
+ "version": "4.13.3",
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>",
@@ -27,20 +27,20 @@
27
27
  "./lib/configs.js": "./lib/configs.browser.js"
28
28
  },
29
29
  "dependencies": {
30
- "@markuplint/config-presets": "4.5.13",
31
- "@markuplint/html-parser": "4.6.22",
32
- "@markuplint/html-spec": "4.16.1",
33
- "@markuplint/i18n": "4.7.0",
34
- "@markuplint/ml-ast": "4.4.10",
35
- "@markuplint/ml-config": "4.8.14",
36
- "@markuplint/ml-spec": "4.10.1",
37
- "@markuplint/parser-utils": "4.8.10",
38
- "@markuplint/selector": "4.7.7",
39
- "@markuplint/shared": "4.4.12",
30
+ "@markuplint/config-presets": "4.5.14",
31
+ "@markuplint/html-parser": "4.6.23",
32
+ "@markuplint/html-spec": "4.17.0",
33
+ "@markuplint/i18n": "4.7.1",
34
+ "@markuplint/ml-ast": "4.4.11",
35
+ "@markuplint/ml-config": "4.8.15",
36
+ "@markuplint/ml-spec": "4.10.2",
37
+ "@markuplint/parser-utils": "4.8.11",
38
+ "@markuplint/selector": "4.7.8",
39
+ "@markuplint/shared": "4.4.13",
40
40
  "@types/debug": "4.1.12",
41
41
  "debug": "4.4.3",
42
42
  "is-plain-object": "5.0.0",
43
43
  "type-fest": "4.41.0"
44
44
  },
45
- "gitHead": "6213ea30269ef404f030e67bbcc7fc7443ec1060"
45
+ "gitHead": "193ee7c1262bbed95424e38efdf1a8e56ff049f4"
46
46
  }