@markuplint/ml-core 3.4.0 → 3.5.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 (65) hide show
  1. package/lib/configs.js +1 -2
  2. package/lib/index.d.ts +1 -11
  3. package/lib/ml-core.d.ts +12 -23
  4. package/lib/ml-core.js +4 -4
  5. package/lib/ml-dom/helper/accname.js +15 -5
  6. package/lib/ml-dom/helper/create-node.d.ts +2 -5
  7. package/lib/ml-dom/helper/create-node.js +3 -1
  8. package/lib/ml-dom/helper/debug.js +6 -2
  9. package/lib/ml-dom/helper/getIndent.d.ts +7 -7
  10. package/lib/ml-dom/helper/getIndent.js +11 -3
  11. package/lib/ml-dom/helper/walkers.d.ts +5 -13
  12. package/lib/ml-dom/helper/walkers.js +3 -1
  13. package/lib/ml-dom/manipulations/child-node-methods.d.ts +7 -20
  14. package/lib/ml-dom/manipulations/child-node-methods.js +24 -6
  15. package/lib/ml-dom/manipulations/get-children.d.ts +2 -4
  16. package/lib/ml-dom/manipulations/get-children.js +3 -1
  17. package/lib/ml-dom/node/attr.d.ts +91 -91
  18. package/lib/ml-dom/node/attr.js +5 -1
  19. package/lib/ml-dom/node/block.d.ts +32 -32
  20. package/lib/ml-dom/node/block.js +14 -4
  21. package/lib/ml-dom/node/character-data.d.ts +53 -60
  22. package/lib/ml-dom/node/character-data.js +9 -3
  23. package/lib/ml-dom/node/child-node.d.ts +3 -8
  24. package/lib/ml-dom/node/child-node.js +3 -1
  25. package/lib/ml-dom/node/comment.d.ts +13 -16
  26. package/lib/ml-dom/node/document-fragment.d.ts +20 -23
  27. package/lib/ml-dom/node/document-type.d.ts +32 -35
  28. package/lib/ml-dom/node/document-type.js +14 -4
  29. package/lib/ml-dom/node/document.d.ts +1586 -1599
  30. package/lib/ml-dom/node/document.js +29 -7
  31. package/lib/ml-dom/node/dom-token-list.d.ts +26 -26
  32. package/lib/ml-dom/node/dom-token-list.js +3 -1
  33. package/lib/ml-dom/node/element.d.ts +1897 -1895
  34. package/lib/ml-dom/node/element.js +58 -14
  35. package/lib/ml-dom/node/named-node-map.d.ts +40 -45
  36. package/lib/ml-dom/node/named-node-map.js +9 -3
  37. package/lib/ml-dom/node/node-list.d.ts +4 -10
  38. package/lib/ml-dom/node/node-list.js +6 -2
  39. package/lib/ml-dom/node/node-store.d.ts +4 -4
  40. package/lib/ml-dom/node/node-store.js +8 -3
  41. package/lib/ml-dom/node/node.d.ts +472 -492
  42. package/lib/ml-dom/node/node.js +42 -14
  43. package/lib/ml-dom/node/parent-node.d.ts +58 -67
  44. package/lib/ml-dom/node/parent-node.js +9 -3
  45. package/lib/ml-dom/node/rule-mapper.d.ts +7 -7
  46. package/lib/ml-dom/node/rule-mapper.js +6 -2
  47. package/lib/ml-dom/node/text.d.ts +47 -50
  48. package/lib/ml-dom/node/types.d.ts +13 -69
  49. package/lib/ml-dom/node/unexpected-call-error.d.ts +2 -1
  50. package/lib/ml-dom/token/token.d.ts +44 -44
  51. package/lib/ml-rule/create-rule.d.ts +2 -2
  52. package/lib/ml-rule/create-test-rule.d.ts +4 -6
  53. package/lib/ml-rule/ml-rule-context.d.ts +49 -57
  54. package/lib/ml-rule/ml-rule-context.js +3 -1
  55. package/lib/ml-rule/ml-rule.d.ts +25 -27
  56. package/lib/ml-rule/ml-rule.js +30 -24
  57. package/lib/ml-rule/types.d.ts +16 -22
  58. package/lib/plugin/plugin.d.ts +1 -1
  59. package/lib/plugin/types.d.ts +7 -7
  60. package/lib/ruleset/index.d.ts +4 -4
  61. package/lib/ruleset/index.js +4 -4
  62. package/lib/test/index.d.ts +8 -20
  63. package/lib/types.d.ts +9 -8
  64. package/lib/utils/get-location-from-chars.d.ts +4 -9
  65. package/package.json +14 -12
package/lib/configs.js CHANGED
@@ -22,11 +22,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
22
22
  __setModuleDefault(result, mod);
23
23
  return result;
24
24
  };
25
- var _a;
26
25
  Object.defineProperty(exports, "__esModule", { value: true });
27
26
  exports.getPreset = void 0;
28
27
  async function getPreset(name) {
29
- const json = await (_a = `@markuplint/config-presets/preset.${name}.json`, Promise.resolve().then(() => __importStar(require(_a)))).catch(() => new Error());
28
+ const json = await Promise.resolve(`${`@markuplint/config-presets/preset.${name}.json`}`).then(s => __importStar(require(s))).catch(() => new Error());
30
29
  if (json instanceof Error) {
31
30
  throw new ReferenceError(`Preset markuplint:${name} is not found`);
32
31
  }
package/lib/index.d.ts CHANGED
@@ -1,15 +1,5 @@
1
1
  export { RuleInfo, RuleConfig, RuleConfigValue } from '@markuplint/ml-config';
2
- export {
3
- ariaSpecs,
4
- contentModelCategoryToTagNames,
5
- getAttrSpecs,
6
- getComputedRole,
7
- getImplicitRole,
8
- getPermittedRoles,
9
- getRoleSpec,
10
- getSpec,
11
- resolveNamespace,
12
- } from '@markuplint/ml-spec';
2
+ export { ariaSpecs, contentModelCategoryToTagNames, getAttrSpecs, getComputedRole, getImplicitRole, getPermittedRoles, getRoleSpec, getSpec, resolveNamespace, } from '@markuplint/ml-spec';
13
3
  export { default as Ruleset } from './ruleset';
14
4
  export { enableDebug } from './debug';
15
5
  export { getIndent } from './ml-dom/helper/getIndent';
package/lib/ml-core.d.ts CHANGED
@@ -1,30 +1,19 @@
1
1
  import type { MLFabric } from './types';
2
- import type { RuleConfigValue, Violation } from '@markuplint/ml-config';
2
+ import type { PlainData, RuleConfigValue, Violation } from '@markuplint/ml-config';
3
3
  import { ParserError } from '@markuplint/parser-utils';
4
4
  import { Document } from './ml-dom';
5
5
  export type MLCoreParams = {
6
- sourceCode: string;
7
- filename: string;
8
- debug?: boolean;
6
+ readonly sourceCode: string;
7
+ readonly filename: string;
8
+ readonly debug?: boolean;
9
9
  } & MLFabric;
10
10
  export declare class MLCore {
11
- #private;
12
- constructor({
13
- parser,
14
- sourceCode,
15
- ruleset,
16
- rules,
17
- locale,
18
- schemas,
19
- parserOptions,
20
- pretenders,
21
- filename,
22
- debug,
23
- }: MLCoreParams);
24
- get document(): ParserError | Document<RuleConfigValue, unknown>;
25
- setCode(sourceCode: string): void;
26
- update({ parser, ruleset, rules, locale, schemas, parserOptions }: Partial<MLFabric>): void;
27
- verify(fix?: boolean): Promise<Violation[]>;
28
- private _createDocument;
29
- private _parse;
11
+ #private;
12
+ constructor({ parser, sourceCode, ruleset, rules, locale, schemas, parserOptions, pretenders, filename, debug, }: MLCoreParams);
13
+ get document(): ParserError | Document<RuleConfigValue, PlainData>;
14
+ setCode(sourceCode: string): void;
15
+ update({ parser, ruleset, rules, locale, schemas, parserOptions }: Partial<MLFabric>): void;
16
+ verify(fix?: boolean): Promise<Violation[]>;
17
+ private _createDocument;
18
+ private _parse;
30
19
  }
package/lib/ml-core.js CHANGED
@@ -35,8 +35,8 @@ class MLCore {
35
35
  tslib_1.__classPrivateFieldSet(this, _MLCore_locale, locale, "f");
36
36
  tslib_1.__classPrivateFieldSet(this, _MLCore_schemas, schemas, "f");
37
37
  tslib_1.__classPrivateFieldSet(this, _MLCore_filename, filename, "f");
38
- tslib_1.__classPrivateFieldSet(this, _MLCore_rules, rules, "f");
39
- tslib_1.__classPrivateFieldSet(this, _MLCore_pretenders, pretenders, "f");
38
+ tslib_1.__classPrivateFieldSet(this, _MLCore_rules, rules.slice(), "f");
39
+ tslib_1.__classPrivateFieldSet(this, _MLCore_pretenders, pretenders.slice(), "f");
40
40
  this._parse();
41
41
  this._createDocument();
42
42
  }
@@ -49,14 +49,14 @@ class MLCore {
49
49
  this._createDocument();
50
50
  }
51
51
  update({ parser, ruleset, rules, locale, schemas, parserOptions }) {
52
- var _a, _b, _c;
52
+ var _a, _b, _c, _d;
53
53
  tslib_1.__classPrivateFieldSet(this, _MLCore_parser, parser !== null && parser !== void 0 ? parser : tslib_1.__classPrivateFieldGet(this, _MLCore_parser, "f"), "f");
54
54
  tslib_1.__classPrivateFieldSet(this, _MLCore_ruleset, {
55
55
  rules: (_a = ruleset === null || ruleset === void 0 ? void 0 : ruleset.rules) !== null && _a !== void 0 ? _a : tslib_1.__classPrivateFieldGet(this, _MLCore_ruleset, "f").rules,
56
56
  nodeRules: (_b = ruleset === null || ruleset === void 0 ? void 0 : ruleset.nodeRules) !== null && _b !== void 0 ? _b : tslib_1.__classPrivateFieldGet(this, _MLCore_ruleset, "f").nodeRules,
57
57
  childNodeRules: (_c = ruleset === null || ruleset === void 0 ? void 0 : ruleset.childNodeRules) !== null && _c !== void 0 ? _c : tslib_1.__classPrivateFieldGet(this, _MLCore_ruleset, "f").childNodeRules,
58
58
  }, "f");
59
- tslib_1.__classPrivateFieldSet(this, _MLCore_rules, rules !== null && rules !== void 0 ? rules : tslib_1.__classPrivateFieldGet(this, _MLCore_rules, "f"), "f");
59
+ tslib_1.__classPrivateFieldSet(this, _MLCore_rules, (_d = rules === null || rules === void 0 ? void 0 : rules.slice()) !== null && _d !== void 0 ? _d : tslib_1.__classPrivateFieldGet(this, _MLCore_rules, "f"), "f");
60
60
  tslib_1.__classPrivateFieldSet(this, _MLCore_locale, locale !== null && locale !== void 0 ? locale : tslib_1.__classPrivateFieldGet(this, _MLCore_locale, "f"), "f");
61
61
  tslib_1.__classPrivateFieldSet(this, _MLCore_schemas, schemas !== null && schemas !== void 0 ? schemas : tslib_1.__classPrivateFieldGet(this, _MLCore_schemas, "f"), "f");
62
62
  if (parserOptions &&
@@ -4,7 +4,9 @@ exports.getAccname = void 0;
4
4
  const ml_spec_1 = require("@markuplint/ml-spec");
5
5
  const debug_1 = require("../../debug");
6
6
  const accnameLog = debug_1.log.extend('accname');
7
- function getAccname(el, version) {
7
+ function getAccname(
8
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
+ el, version) {
8
10
  let accname = safeGet(el);
9
11
  if (accname) {
10
12
  return accname;
@@ -32,7 +34,9 @@ function getAccname(el, version) {
32
34
  return '';
33
35
  }
34
36
  exports.getAccname = getAccname;
35
- function safeGet(el) {
37
+ function safeGet(
38
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
39
+ el) {
36
40
  try {
37
41
  const name = (0, ml_spec_1.getAccname)(el);
38
42
  return name;
@@ -43,7 +47,9 @@ function safeGet(el) {
43
47
  return '';
44
48
  }
45
49
  }
46
- function getAccnameFromPretender(el) {
50
+ function getAccnameFromPretender(
51
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
52
+ el) {
47
53
  var _a, _b;
48
54
  if (((_a = el.pretenderContext) === null || _a === void 0 ? void 0 : _a.type) === 'pretender' && ((_b = el.pretenderContext.aria) === null || _b === void 0 ? void 0 : _b.name)) {
49
55
  if (typeof el.pretenderContext.aria.name === 'boolean') {
@@ -57,10 +63,14 @@ function getAccnameFromPretender(el) {
57
63
  }
58
64
  return '';
59
65
  }
60
- function isHidden(el) {
66
+ function isHidden(
67
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
68
+ el) {
61
69
  return el.getAttribute('aria-hidden') === 'true' || el.hasAttribute('hidden');
62
70
  }
63
- function isFromContent(el, version) {
71
+ function isFromContent(
72
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
73
+ el, version) {
64
74
  var _a;
65
75
  const role = (0, ml_spec_1.getComputedRole)(el.ownerMLDocument.specs, el, version);
66
76
  return !!((_a = role.role) === null || _a === void 0 ? void 0 : _a.accessibleNameFromContent);
@@ -1,8 +1,5 @@
1
1
  import type { MLDocument } from '../node/document';
2
2
  import type { MappedNode } from '../node/types';
3
3
  import type { MLASTAbstractNode } from '@markuplint/ml-ast';
4
- import type { RuleConfigValue } from '@markuplint/ml-config';
5
- export declare function createNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O = null>(
6
- astNode: N,
7
- document: MLDocument<T, O>,
8
- ): MappedNode<N, T, O>;
4
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
5
+ export declare function createNode<N extends MLASTAbstractNode, T extends RuleConfigValue, O extends PlainData = undefined>(astNode: N, document: MLDocument<T, O>): MappedNode<N, T, O>;
@@ -6,7 +6,9 @@ const comment_1 = require("../node/comment");
6
6
  const document_type_1 = require("../node/document-type");
7
7
  const element_1 = require("../node/element");
8
8
  const text_1 = require("../node/text");
9
- function createNode(astNode, document) {
9
+ function createNode(astNode,
10
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
11
+ document) {
10
12
  const _astNode = astNode;
11
13
  switch (_astNode.type) {
12
14
  case 'doctype': {
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.nodeListToDebugMaps = void 0;
4
- function nodeListToDebugMaps(nodeList, withAttr = false) {
4
+ function nodeListToDebugMaps(
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ nodeList, withAttr = false) {
5
7
  return nodeList
6
8
  .map(n => {
7
9
  const r = [];
@@ -26,7 +28,9 @@ function nodeListToDebugMaps(nodeList, withAttr = false) {
26
28
  .flat();
27
29
  }
28
30
  exports.nodeListToDebugMaps = nodeListToDebugMaps;
29
- function attributesToDebugMaps(attributes) {
31
+ function attributesToDebugMaps(
32
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
33
+ attributes) {
30
34
  return attributes
31
35
  .map(n => {
32
36
  const r = [
@@ -7,12 +7,12 @@ import type { MLText } from '../node/text';
7
7
  */
8
8
  export declare function getIndent(node: MLNode<any, any>): MLDOMIndentation | null;
9
9
  declare class MLDOMIndentation {
10
- #private;
11
- readonly line: number;
12
- constructor(originTextNode: MLText<any, any>, raw: string, line: number, parentNode: MLNode<any, any>);
13
- get raw(): string;
14
- get type(): 'tab' | 'space' | 'mixed' | 'none';
15
- get width(): number;
16
- fix(raw: string): void;
10
+ #private;
11
+ readonly line: number;
12
+ constructor(originTextNode: MLText<any, any>, raw: string, line: number, parentNode: MLNode<any, any>);
13
+ get raw(): string;
14
+ get type(): 'tab' | 'space' | 'mixed' | 'none';
15
+ get width(): number;
16
+ fix(raw: string): void;
17
17
  }
18
18
  export {};
@@ -8,7 +8,9 @@ const tslib_1 = require("tslib");
8
8
  * @deprecated
9
9
  * @param node
10
10
  */
11
- function getIndent(node) {
11
+ function getIndent(
12
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
13
+ node) {
12
14
  const prevToken = node.prevToken;
13
15
  if (!prevToken) {
14
16
  return null;
@@ -51,7 +53,11 @@ function getIndent(node) {
51
53
  }
52
54
  exports.getIndent = getIndent;
53
55
  class MLDOMIndentation {
54
- constructor(originTextNode, raw, line, parentNode) {
56
+ constructor(
57
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
58
+ originTextNode, raw, line,
59
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
60
+ parentNode) {
55
61
  _MLDOMIndentation_fixed.set(this, void 0);
56
62
  _MLDOMIndentation_node.set(this, void 0);
57
63
  _MLDOMIndentation_parent.set(this, void 0);
@@ -95,6 +101,8 @@ class MLDOMIndentation {
95
101
  }
96
102
  }
97
103
  _MLDOMIndentation_fixed = new WeakMap(), _MLDOMIndentation_node = new WeakMap(), _MLDOMIndentation_parent = new WeakMap();
98
- function isFirstToken(node) {
104
+ function isFirstToken(
105
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
106
+ node) {
99
107
  return !node.prevToken;
100
108
  }
@@ -1,14 +1,6 @@
1
1
  import type { MLNode } from '../node/node';
2
- import type { RuleConfigValue } from '@markuplint/ml-config';
3
- export type Walker<T extends RuleConfigValue, O = null, N = MLNode<T, O>> = (
4
- node: N,
5
- ) => void | Promise<void> | Promise<void>[];
6
- export type SyncWalker<T extends RuleConfigValue, O = null, N = MLNode<T, O>> = (node: N) => void;
7
- export declare function syncWalk<T extends RuleConfigValue, O = null>(
8
- nodeList: ReadonlyArray<MLNode<T, O>>,
9
- walker: SyncWalker<T, O>,
10
- ): void;
11
- export declare function sequentialWalker<T extends RuleConfigValue, O = null, N = MLNode<T, O>>(
12
- list: ReadonlyArray<N>,
13
- walker: Walker<T, O, N>,
14
- ): Promise<void>;
2
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
3
+ export type Walker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>> = (node: N) => void | Promise<void> | Promise<void>[];
4
+ export type SyncWalker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>> = (node: N) => void;
5
+ export declare function syncWalk<T extends RuleConfigValue, O extends PlainData = undefined>(nodeList: ReadonlyArray<MLNode<T, O>>, walker: SyncWalker<T, O>): void;
6
+ export declare function sequentialWalker<T extends RuleConfigValue, O extends PlainData = undefined, N = MLNode<T, O>>(list: ReadonlyArray<N>, walker: Walker<T, O, N>): Promise<void>;
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.sequentialWalker = exports.syncWalk = void 0;
4
- function syncWalk(nodeList, walker) {
4
+ function syncWalk(
5
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
6
+ nodeList, walker) {
5
7
  for (const node of nodeList) {
6
8
  if (node.is(node.ELEMENT_NODE) || node.is(node.MARKUPLINT_PREPROCESSOR_BLOCK)) {
7
9
  syncWalk(Array.from(node.childNodes), walker);
@@ -1,46 +1,33 @@
1
1
  import type { MLElement } from '../node/element';
2
2
  import type { MLNode } from '../node/node';
3
- import type { RuleConfigValue } from '@markuplint/ml-config';
3
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
4
  /**
5
5
  *
6
6
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
7
7
  */
8
- export declare function before<T extends RuleConfigValue, O = null>(
9
- node: MLNode<T, O>,
10
- ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>
11
- ): void;
8
+ export declare function before<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
12
9
  /**
13
10
  *
14
11
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
15
12
  */
16
- export declare function after<T extends RuleConfigValue, O = null>(
17
- node: MLNode<T, O>,
18
- ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>
19
- ): void;
13
+ export declare function after<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
20
14
  /**
21
15
  *
22
16
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
23
17
  */
24
- export declare function replaceWith<T extends RuleConfigValue, O = null>(
25
- node: MLNode<T, O>,
26
- ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>
27
- ): void;
18
+ export declare function replaceWith<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>, ...additionalNodes: ReadonlyArray<MLNode<T, O> | string>): void;
28
19
  /**
29
20
  *
30
21
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
31
22
  */
32
- export declare function remove<T extends RuleConfigValue, O = null>(node: MLNode<T, O>): void;
23
+ export declare function remove<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): void;
33
24
  /**
34
25
  *
35
26
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
36
27
  */
37
- export declare function previousElementSibling<T extends RuleConfigValue, O = null>(
38
- node: MLNode<T, O>,
39
- ): MLElement<T, O> | null;
28
+ export declare function previousElementSibling<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): MLElement<T, O> | null;
40
29
  /**
41
30
  *
42
31
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
43
32
  */
44
- export declare function nextElementSibling<T extends RuleConfigValue, O = null>(
45
- node: MLNode<T, O>,
46
- ): MLElement<T, O> | null;
33
+ export declare function nextElementSibling<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): MLElement<T, O> | null;
@@ -7,7 +7,11 @@ const unexpected_call_error_1 = tslib_1.__importDefault(require("../node/unexpec
7
7
  *
8
8
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-before%E2%91%A0
9
9
  */
10
- function before(node, ...additionalNodes) {
10
+ function before(
11
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
12
+ node,
13
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
14
+ ...additionalNodes) {
11
15
  throw new unexpected_call_error_1.default('Not supported "before" method');
12
16
  }
13
17
  exports.before = before;
@@ -15,7 +19,11 @@ exports.before = before;
15
19
  *
16
20
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-after%E2%91%A0
17
21
  */
18
- function after(node, ...additionalNodes) {
22
+ function after(
23
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
24
+ node,
25
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
26
+ ...additionalNodes) {
19
27
  throw new unexpected_call_error_1.default('Not supported "after" method');
20
28
  }
21
29
  exports.after = after;
@@ -23,7 +31,11 @@ exports.after = after;
23
31
  *
24
32
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-replacewith%E2%91%A0
25
33
  */
26
- function replaceWith(node, ...additionalNodes) {
34
+ function replaceWith(
35
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
36
+ node,
37
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
38
+ ...additionalNodes) {
27
39
  throw new unexpected_call_error_1.default('Not supported "replaceWith" method');
28
40
  }
29
41
  exports.replaceWith = replaceWith;
@@ -31,7 +43,9 @@ exports.replaceWith = replaceWith;
31
43
  *
32
44
  * @see https://dom.spec.whatwg.org/#ref-for-dom-childnode-remove%E2%91%A0
33
45
  */
34
- function remove(node) {
46
+ function remove(
47
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
48
+ node) {
35
49
  throw new unexpected_call_error_1.default('Not supported "remove" method');
36
50
  }
37
51
  exports.remove = remove;
@@ -39,7 +53,9 @@ exports.remove = remove;
39
53
  *
40
54
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-previouselementsibling%E2%91%A0
41
55
  */
42
- function previousElementSibling(node) {
56
+ function previousElementSibling(
57
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
58
+ node) {
43
59
  var _a, _b;
44
60
  let prevNode = node.prevNode;
45
61
  while (prevNode) {
@@ -57,7 +73,9 @@ exports.previousElementSibling = previousElementSibling;
57
73
  *
58
74
  * @see https://dom.spec.whatwg.org/#ref-for-dom-nondocumenttypechildnode-nextelementsibling%E2%91%A0
59
75
  */
60
- function nextElementSibling(node) {
76
+ function nextElementSibling(
77
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
78
+ node) {
61
79
  var _a, _b;
62
80
  let nextNode = node.nextNode;
63
81
  while (nextNode) {
@@ -1,6 +1,4 @@
1
1
  import type { MLElement } from '../node/element';
2
2
  import type { MLNode } from '../node/node';
3
- import type { RuleConfigValue } from '@markuplint/ml-config';
4
- export declare function getChildren<T extends RuleConfigValue, O = null>(
5
- node: MLNode<T, O>,
6
- ): HTMLCollectionOf<MLElement<T, O>>;
3
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
4
+ export declare function getChildren<T extends RuleConfigValue, O extends PlainData = undefined>(node: MLNode<T, O>): HTMLCollectionOf<MLElement<T, O>>;
@@ -2,7 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getChildren = void 0;
4
4
  const node_list_1 = require("../node/node-list");
5
- function getChildren(node) {
5
+ function getChildren(
6
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
7
+ node) {
6
8
  return (0, node_list_1.toHTMLCollection)(Array.from(node.childNodes).filter((child) => {
7
9
  return child.nodeType === child.ELEMENT_NODE;
8
10
  }));
@@ -1,98 +1,98 @@
1
1
  import type { MLElement } from './element';
2
2
  import type { AttributeNodeType } from './types';
3
3
  import type { MLASTAttr } from '@markuplint/ml-ast';
4
- import type { RuleConfigValue } from '@markuplint/ml-config';
4
+ import type { PlainData, RuleConfigValue } from '@markuplint/ml-config';
5
5
  import { MLToken } from '../token/token';
6
6
  import { MLDomTokenList } from './dom-token-list';
7
7
  import { MLNode } from './node';
8
- export declare class MLAttr<T extends RuleConfigValue, O = null> extends MLNode<T, O, MLASTAttr> implements Attr {
9
- #private;
10
- readonly candidate?: string;
11
- readonly endQuote: MLToken | null;
12
- readonly equal: MLToken | null;
13
- readonly isDirective?: true;
14
- readonly isDuplicatable: boolean;
15
- readonly isDynamicValue?: true;
16
- readonly nameNode: MLToken | null;
17
- /**
18
- * @implements DOM API: `Attr`
19
- * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
20
- */
21
- readonly ownerElement: MLElement<T, O>;
22
- readonly spacesAfterEqual: MLToken | null;
23
- readonly spacesBeforeEqual: MLToken | null;
24
- readonly spacesBeforeName: MLToken | null;
25
- readonly startQuote: MLToken | null;
26
- readonly valueNode: MLToken | null;
27
- /**
28
- * Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
29
- *
30
- * @default "string"
31
- * @implements `@markuplint/ml-core` API: `MLAttr`
32
- */
33
- readonly valueType: 'string' | 'number' | 'boolean' | 'code';
34
- constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
35
- /**
36
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
37
- *
38
- * @unsupported
39
- * @implements DOM API: `Attr`
40
- * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
41
- */
42
- get localName(): string;
43
- /**
44
- *
45
- * @implements DOM API: `Attr`
46
- * @see https://dom.spec.whatwg.org/#dom-attr-name
47
- */
48
- get name(): string;
49
- /**
50
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
51
- *
52
- * @unsupported
53
- * @implements DOM API: `Attr`
54
- * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
55
- */
56
- get namespaceURI(): string | null;
57
- /**
58
- * Returns a string appropriate for the type of node as `Attr`
59
- *
60
- * @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
61
- */
62
- get nodeName(): string;
63
- /**
64
- * Returns a number appropriate for the type of `Attr`
65
- */
66
- get nodeType(): AttributeNodeType;
67
- get nodeValue(): string;
68
- /**
69
- * **IT THROWS AN ERROR WHEN CALLING THIS.**
70
- *
71
- * @unsupported
72
- * @implements DOM API: `Attr`
73
- * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
74
- */
75
- get prefix(): string | null;
76
- /**
77
- * @implements `@markuplint/ml-core` API: `MLAttr`
78
- */
79
- get rule(): import('@markuplint/ml-config').RuleInfo<T, O>;
80
- /**
81
- * @implements DOM API: `Attr`
82
- * @see https://dom.spec.whatwg.org/#dom-attr-specified
83
- */
84
- get specified(): true;
85
- /**
86
- * @implements `@markuplint/ml-core` API: `MLAttr`
87
- */
88
- get tokenList(): MLDomTokenList | null;
89
- /**
90
- * @implements DOM API: `Attr`
91
- * @see https://dom.spec.whatwg.org/#dom-attr-value
92
- */
93
- get value(): string;
94
- /**
95
- * @implements `@markuplint/ml-core` API: `MLAttr`
96
- */
97
- toNormalizeString(): string;
8
+ export declare class MLAttr<T extends RuleConfigValue, O extends PlainData = undefined> extends MLNode<T, O, MLASTAttr> implements Attr {
9
+ #private;
10
+ readonly candidate?: string;
11
+ readonly endQuote: MLToken | null;
12
+ readonly equal: MLToken | null;
13
+ readonly isDirective?: true;
14
+ readonly isDuplicatable: boolean;
15
+ readonly isDynamicValue?: true;
16
+ readonly nameNode: MLToken | null;
17
+ /**
18
+ * @implements DOM API: `Attr`
19
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-node-previoussibling%E2%91%A0
20
+ */
21
+ readonly ownerElement: MLElement<T, O>;
22
+ readonly spacesAfterEqual: MLToken | null;
23
+ readonly spacesBeforeEqual: MLToken | null;
24
+ readonly spacesBeforeName: MLToken | null;
25
+ readonly startQuote: MLToken | null;
26
+ readonly valueNode: MLToken | null;
27
+ /**
28
+ * Returns the "string" if HTML syntax. Otherwise, returns a type in its syntax.
29
+ *
30
+ * @default "string"
31
+ * @implements `@markuplint/ml-core` API: `MLAttr`
32
+ */
33
+ readonly valueType: 'string' | 'number' | 'boolean' | 'code';
34
+ constructor(astToken: MLASTAttr, ownElement: MLElement<T, O>);
35
+ /**
36
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
37
+ *
38
+ * @unsupported
39
+ * @implements DOM API: `Attr`
40
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-localname
41
+ */
42
+ get localName(): string;
43
+ /**
44
+ *
45
+ * @implements DOM API: `Attr`
46
+ * @see https://dom.spec.whatwg.org/#dom-attr-name
47
+ */
48
+ get name(): string;
49
+ /**
50
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
51
+ *
52
+ * @unsupported
53
+ * @implements DOM API: `Attr`
54
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-namespaceuri
55
+ */
56
+ get namespaceURI(): string | null;
57
+ /**
58
+ * Returns a string appropriate for the type of node as `Attr`
59
+ *
60
+ * @see https://dom.spec.whatwg.org/#ref-for-attr%E2%91%A4
61
+ */
62
+ get nodeName(): string;
63
+ /**
64
+ * Returns a number appropriate for the type of `Attr`
65
+ */
66
+ get nodeType(): AttributeNodeType;
67
+ get nodeValue(): string;
68
+ /**
69
+ * **IT THROWS AN ERROR WHEN CALLING THIS.**
70
+ *
71
+ * @unsupported
72
+ * @implements DOM API: `Attr`
73
+ * @see https://dom.spec.whatwg.org/#ref-for-dom-attr-prefix
74
+ */
75
+ get prefix(): string | null;
76
+ /**
77
+ * @implements `@markuplint/ml-core` API: `MLAttr`
78
+ */
79
+ get rule(): import("@markuplint/ml-config").RuleInfo<T, O>;
80
+ /**
81
+ * @implements DOM API: `Attr`
82
+ * @see https://dom.spec.whatwg.org/#dom-attr-specified
83
+ */
84
+ get specified(): true;
85
+ /**
86
+ * @implements `@markuplint/ml-core` API: `MLAttr`
87
+ */
88
+ get tokenList(): MLDomTokenList | null;
89
+ /**
90
+ * @implements DOM API: `Attr`
91
+ * @see https://dom.spec.whatwg.org/#dom-attr-value
92
+ */
93
+ get value(): string;
94
+ /**
95
+ * @implements `@markuplint/ml-core` API: `MLAttr`
96
+ */
97
+ toNormalizeString(): string;
98
98
  }
@@ -9,7 +9,11 @@ const dom_token_list_1 = require("./dom-token-list");
9
9
  const node_1 = require("./node");
10
10
  const unexpected_call_error_1 = tslib_1.__importDefault(require("./unexpected-call-error"));
11
11
  class MLAttr extends node_1.MLNode {
12
- constructor(astToken, ownElement) {
12
+ constructor(
13
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
14
+ astToken,
15
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
16
+ ownElement) {
13
17
  var _a;
14
18
  super(astToken, ownElement.ownerMLDocument);
15
19
  this.endQuote = null;