@markuplint/rules 3.12.0 → 4.0.0-alpha.1

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 (142) hide show
  1. package/lib/attr-check.js +14 -19
  2. package/lib/attr-duplication/index.js +3 -6
  3. package/lib/attr-value-quotes/index.js +5 -9
  4. package/lib/case-sensitive-attr-name/index.js +9 -13
  5. package/lib/case-sensitive-tag-name/index.js +2 -4
  6. package/lib/character-reference/index.js +6 -8
  7. package/lib/class-naming/index.js +9 -11
  8. package/lib/create-message.js +9 -16
  9. package/lib/debug.js +2 -6
  10. package/lib/deprecated-attr/index.js +6 -9
  11. package/lib/deprecated-element/index.js +3 -5
  12. package/lib/disallowed-element/index.js +2 -4
  13. package/lib/doctype/index.js +2 -4
  14. package/lib/end-tag/index.js +5 -8
  15. package/lib/helpers.d.ts +1 -1
  16. package/lib/helpers.js +17 -28
  17. package/lib/id-duplication/index.js +2 -4
  18. package/lib/index.d.ts +15 -15
  19. package/lib/index.js +63 -66
  20. package/lib/ineffective-attr/index.js +5 -7
  21. package/lib/invalid-attr/index.js +30 -33
  22. package/lib/label-has-control/index.js +2 -4
  23. package/lib/landmark-roles/index.js +3 -6
  24. package/lib/no-boolean-attr-value/index.js +6 -9
  25. package/lib/no-default-value/index.js +9 -12
  26. package/lib/no-empty-palpable-content/index.js +5 -7
  27. package/lib/no-hard-code-id/index.js +2 -4
  28. package/lib/no-refer-to-non-existent-id/index.js +26 -30
  29. package/lib/no-use-event-handler-attr/index.js +4 -6
  30. package/lib/permitted-contents/choice.d.ts +1 -1
  31. package/lib/permitted-contents/choice.js +13 -18
  32. package/lib/permitted-contents/complex-branch.d.ts +1 -1
  33. package/lib/permitted-contents/complex-branch.js +10 -14
  34. package/lib/permitted-contents/content-model.d.ts +1 -1
  35. package/lib/permitted-contents/content-model.js +5 -9
  36. package/lib/permitted-contents/count-pattern.d.ts +1 -1
  37. package/lib/permitted-contents/count-pattern.js +19 -24
  38. package/lib/permitted-contents/debug.browser.js +9 -12
  39. package/lib/permitted-contents/debug.d.ts +8 -1
  40. package/lib/permitted-contents/debug.js +12 -13
  41. package/lib/permitted-contents/index.d.ts +1 -1
  42. package/lib/permitted-contents/index.js +10 -13
  43. package/lib/permitted-contents/matches-selector.d.ts +1 -1
  44. package/lib/permitted-contents/matches-selector.js +12 -17
  45. package/lib/permitted-contents/order.d.ts +1 -1
  46. package/lib/permitted-contents/order.js +17 -22
  47. package/lib/permitted-contents/recursive-branch.d.ts +2 -2
  48. package/lib/permitted-contents/recursive-branch.js +9 -13
  49. package/lib/permitted-contents/represent-transparent-nodes.d.ts +1 -1
  50. package/lib/permitted-contents/represent-transparent-nodes.js +15 -20
  51. package/lib/permitted-contents/start.d.ts +1 -1
  52. package/lib/permitted-contents/start.js +13 -21
  53. package/lib/permitted-contents/transparent.d.ts +1 -1
  54. package/lib/permitted-contents/transparent.js +4 -9
  55. package/lib/permitted-contents/types.js +1 -2
  56. package/lib/permitted-contents/utils.d.ts +1 -1
  57. package/lib/permitted-contents/utils.js +55 -74
  58. package/lib/placeholder-label-option/index.js +5 -9
  59. package/lib/require-accessible-name/index.js +10 -13
  60. package/lib/require-datetime/index.d.ts +1 -1
  61. package/lib/require-datetime/index.js +6 -8
  62. package/lib/require-datetime/types.js +1 -2
  63. package/lib/require-datetime/utils.d.ts +1 -1
  64. package/lib/require-datetime/utils.js +4 -11
  65. package/lib/required-attr/index.js +8 -11
  66. package/lib/required-element/index.js +3 -6
  67. package/lib/required-h1/index.js +3 -6
  68. package/lib/use-list/index.js +6 -10
  69. package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
  70. package/lib/wai-aria/checkings/abstract-role.js +5 -10
  71. package/lib/wai-aria/checkings/default-value.d.ts +1 -1
  72. package/lib/wai-aria/checkings/default-value.js +2 -6
  73. package/lib/wai-aria/checkings/deprecated-props.d.ts +1 -1
  74. package/lib/wai-aria/checkings/deprecated-props.js +3 -8
  75. package/lib/wai-aria/checkings/disallowed-prop.d.ts +1 -1
  76. package/lib/wai-aria/checkings/disallowed-prop.js +7 -12
  77. package/lib/wai-aria/checkings/implicit-props.d.ts +1 -1
  78. package/lib/wai-aria/checkings/implicit-props.js +6 -11
  79. package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
  80. package/lib/wai-aria/checkings/implicit-role.js +4 -9
  81. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
  82. package/lib/wai-aria/checkings/interaction-in-hidden.js +4 -8
  83. package/lib/wai-aria/checkings/no-global-prop.d.ts +1 -1
  84. package/lib/wai-aria/checkings/no-global-prop.js +2 -7
  85. package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
  86. package/lib/wai-aria/checkings/non-existent-role.js +4 -9
  87. package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
  88. package/lib/wai-aria/checkings/permitted-roles.js +4 -9
  89. package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
  90. package/lib/wai-aria/checkings/presentational-children.js +4 -9
  91. package/lib/wai-aria/checkings/required-owned-elements.d.ts +1 -1
  92. package/lib/wai-aria/checkings/required-owned-elements.js +4 -8
  93. package/lib/wai-aria/checkings/required-prop.d.ts +1 -1
  94. package/lib/wai-aria/checkings/required-prop.js +2 -7
  95. package/lib/wai-aria/checkings/value.d.ts +1 -1
  96. package/lib/wai-aria/checkings/value.js +4 -10
  97. package/lib/wai-aria/index.d.ts +1 -1
  98. package/lib/wai-aria/index.js +38 -40
  99. package/lib/wai-aria/types.js +1 -2
  100. package/package.json +17 -12
  101. package/test/attr-check.spec.js +0 -77
  102. package/test/attr-duplication/index.spec.js +0 -159
  103. package/test/attr-value-quotes/index.spec.js +0 -133
  104. package/test/case-sensitive-attr-name/index.spec.js +0 -65
  105. package/test/case-sensitive-tag-name/index.spec.js +0 -80
  106. package/test/character-reference/index.spec.js +0 -72
  107. package/test/class-naming/index.spec.js +0 -470
  108. package/test/create-message.spec.js +0 -497
  109. package/test/deprecated-attr/index.spec.js +0 -48
  110. package/test/deprecated-element/index.spec.js +0 -35
  111. package/test/disallowed-element/index.spec.js +0 -90
  112. package/test/doctype/index.spec.js +0 -50
  113. package/test/end-tag/index.spec.js +0 -162
  114. package/test/id-duplication/index.spec.js +0 -47
  115. package/test/ineffective-attr/index.spec.js +0 -31
  116. package/test/invalid-attr/index.spec.js +0 -1641
  117. package/test/label-has-control/index.spec.js +0 -29
  118. package/test/landmark-roles/index.spec.js +0 -187
  119. package/test/no-boolean-attr-value/index.spec.js +0 -41
  120. package/test/no-default-value/index.spec.js +0 -74
  121. package/test/no-empty-palpable-content/index.spec.js +0 -115
  122. package/test/no-hard-code-id/index.spec.js +0 -100
  123. package/test/no-refer-to-non-existent-id/index.spec.js +0 -254
  124. package/test/no-use-event-handler-attr/index.spec.js +0 -57
  125. package/test/permitted-contents/choice.spec.js +0 -174
  126. package/test/permitted-contents/count-pattern.spec.js +0 -308
  127. package/test/permitted-contents/index.spec.js +0 -1395
  128. package/test/permitted-contents/matches-selector.spec.js +0 -59
  129. package/test/permitted-contents/order.spec.js +0 -351
  130. package/test/permitted-contents/recursive-branch.spec.js +0 -41
  131. package/test/permitted-contents/represent-transparent-nodes.spec.js +0 -24
  132. package/test/permitted-contents/start.spec.js +0 -67
  133. package/test/placeholder-label-option/index.spec.js +0 -113
  134. package/test/require-accessible-name/index.spec.js +0 -444
  135. package/test/require-datetime/index.spec.js +0 -54
  136. package/test/require-datetime/utils.spec.js +0 -52
  137. package/test/required-attr/index.spec.js +0 -414
  138. package/test/required-element/index.spec.js +0 -188
  139. package/test/required-h1/index.spec.js +0 -69
  140. package/test/use-list/index.spec.js +0 -109
  141. package/test/wai-aria/checkings/value.spec.js +0 -33
  142. package/test/wai-aria/index.spec.js +0 -1203
@@ -1,13 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.matchesSelector = void 0;
4
- const ml_spec_1 = require("@markuplint/ml-spec");
5
- const debug_1 = require("./debug");
6
- const utils_1 = require("./utils");
7
- function matchesSelector(query,
1
+ import { contentModelCategoryToTagNames } from '@markuplint/ml-spec';
2
+ import { cmLog } from './debug.js';
3
+ import { cleanObject, matches } from './utils.js';
4
+ export function matchesSelector(query,
8
5
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
6
  node, specs, depth) {
10
- const nodeLog = debug_1.cmLog.extend(`node#${depth}`);
7
+ const nodeLog = cmLog.extend(`node#${depth}`);
11
8
  const { selector, hasText, hasCustom } = optCondition(query, specs);
12
9
  if (node == null) {
13
10
  if (hasText) {
@@ -86,7 +83,7 @@ node, specs, depth) {
86
83
  hint: {},
87
84
  };
88
85
  }
89
- const result = (0, utils_1.matches)(selector, node, specs);
86
+ const result = matches(selector, node, specs);
90
87
  nodeLog('%s.matches(%s) => %s', node.raw, query, result.matched);
91
88
  if (result.matched) {
92
89
  return {
@@ -105,7 +102,7 @@ node, specs, depth) {
105
102
  unmatched: [node],
106
103
  zeroMatch: true,
107
104
  query,
108
- hint: (0, utils_1.cleanObject)({
105
+ hint: cleanObject({
109
106
  not: result.not,
110
107
  }),
111
108
  };
@@ -116,7 +113,7 @@ node, specs, depth) {
116
113
  unmatched: [node],
117
114
  zeroMatch: false,
118
115
  query,
119
- hint: (0, utils_1.cleanObject)({
116
+ hint: cleanObject({
120
117
  not: result.not,
121
118
  }),
122
119
  };
@@ -130,7 +127,6 @@ node, specs, depth) {
130
127
  hint: {},
131
128
  };
132
129
  }
133
- exports.matchesSelector = matchesSelector;
134
130
  const conditionWithoutSpecs = {
135
131
  '#custom': {
136
132
  selector: '#custom',
@@ -145,12 +141,11 @@ const conditionWithoutSpecs = {
145
141
  };
146
142
  const optConditionSpecsBaseCaches = new Map();
147
143
  function optCondition(query, specs) {
148
- var _a;
149
144
  const condWithoutSpecs = conditionWithoutSpecs[query];
150
145
  if (condWithoutSpecs) {
151
146
  return condWithoutSpecs;
152
147
  }
153
- const queryCaches = (_a = optConditionSpecsBaseCaches.get(specs)) !== null && _a !== void 0 ? _a : new Map();
148
+ const queryCaches = optConditionSpecsBaseCaches.get(specs) ?? new Map();
154
149
  const cached = queryCaches.get(query);
155
150
  if (cached) {
156
151
  return cached;
@@ -158,9 +153,9 @@ function optCondition(query, specs) {
158
153
  let hasCustom = false;
159
154
  let hasText = false;
160
155
  const selector = query.replace(/^(?::model\(([^)]+)\)|#([a-z-]+))(.*)$/, (_, $model, _model, $last) => {
161
- const _selectors = (0, ml_spec_1.contentModelCategoryToTagNames)(`#${$model !== null && $model !== void 0 ? $model : _model}`, specs.def);
156
+ const _selectors = contentModelCategoryToTagNames(`#${$model ?? _model}`, specs.def);
162
157
  if (_selectors.length === 0) {
163
- throw new Error(`${$model !== null && $model !== void 0 ? $model : _model} is empty`);
158
+ throw new Error(`${$model ?? _model} is empty`);
164
159
  }
165
160
  const selectors = [];
166
161
  for (const selector of _selectors) {
@@ -174,7 +169,7 @@ function optCondition(query, specs) {
174
169
  }
175
170
  selectors.push(selector);
176
171
  }
177
- return `:is(${selectors.join(',')})${$last !== null && $last !== void 0 ? $last : ''}`;
172
+ return `:is(${selectors.join(',')})${$last ?? ''}`;
178
173
  });
179
174
  const result = {
180
175
  selector,
@@ -1,4 +1,4 @@
1
- import type { ChildNode, Options, Result, Specs } from './types';
1
+ import type { ChildNode, Options, Result, Specs } from './types.js';
2
2
  import type { PermittedContentPattern } from '@markuplint/ml-spec';
3
3
  import type { ReadonlyDeep } from 'type-fest';
4
4
  /**
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.order = void 0;
4
- const helpers_1 = require("../helpers");
5
- const complex_branch_1 = require("./complex-branch");
6
- const debug_1 = require("./debug");
7
- const utils_1 = require("./utils");
1
+ import { deepCopy } from '../helpers.js';
2
+ import { complexBranch } from './complex-branch.js';
3
+ import { cmLog } from './debug.js';
4
+ import { Collection, mergeHints, modelLog } from './utils.js';
8
5
  /**
9
6
  * Check ordered array
10
7
  *
@@ -15,22 +12,21 @@ const utils_1 = require("./utils");
15
12
  * @param depth
16
13
  * @returns
17
14
  */
18
- function order(contents,
15
+ export function order(contents,
19
16
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
20
17
  nodes, specs, options, depth) {
21
- var _a, _b, _c, _d, _e;
22
- const orderLog = debug_1.cmLog.extend(`order#${depth}`);
23
- const btLog = debug_1.cmLog.extend(`backtrack#${depth}`);
24
- const patterns = (0, helpers_1.deepCopy)(contents);
25
- const collection = new utils_1.Collection(nodes);
26
- orderLog('Model:\n RegEx: %s\n Schema: %o', (0, utils_1.modelLog)(patterns, ''), patterns);
18
+ const orderLog = cmLog.extend(`order#${depth}`);
19
+ const btLog = cmLog.extend(`backtrack#${depth}`);
20
+ const patterns = deepCopy(contents);
21
+ const collection = new Collection(nodes);
22
+ orderLog('Model:\n RegEx: %s\n Schema: %o', modelLog(patterns, ''), patterns);
27
23
  orderLog('Starts: %s', collection);
28
24
  let result = undefined;
29
25
  let backtrackMode = false;
30
26
  let afterBacktrack = false;
31
27
  const unmatchedResults = [];
32
28
  while (patterns.length > 0 && patterns[0]) {
33
- result = (0, complex_branch_1.complexBranch)(patterns[0], collection.unmatched, specs, options, depth);
29
+ result = complexBranch(patterns[0], collection.unmatched, specs, options, depth);
34
30
  collection.addMatched(result.matched);
35
31
  if (result.type !== 'UNEXPECTED_EXTRA_NODE' && result.type !== 'MATCHED' && result.type !== 'MATCHED_ZERO') {
36
32
  unmatchedResults.push(result);
@@ -45,7 +41,7 @@ nodes, specs, options, depth) {
45
41
  if (!barelyMatchedResult) {
46
42
  throw new Error('Unreachable code');
47
43
  }
48
- orderLog('Result (%s): %s%s', result.type, collection.toString(true), ((_a = barelyMatchedResult.hint.missing) === null || _a === void 0 ? void 0 : _a.barelyMatchedElements) != null
44
+ orderLog('Result (%s): %s%s', result.type, collection.toString(true), barelyMatchedResult.hint.missing?.barelyMatchedElements != null
49
45
  ? `; But ${barelyMatchedResult.hint.missing.barelyMatchedElements} elements hit out of pattern`
50
46
  : '');
51
47
  return {
@@ -54,7 +50,7 @@ nodes, specs, options, depth) {
54
50
  unmatched: collection.unmatched,
55
51
  zeroMatch: barelyMatchedResult.zeroMatch,
56
52
  query: barelyMatchedResult.query,
57
- hint: (0, utils_1.mergeHints)(barelyMatchedResult.hint, {
53
+ hint: mergeHints(barelyMatchedResult.hint, {
58
54
  missing: {
59
55
  barelyMatchedElements: collection.matched.length,
60
56
  need: barelyMatchedResult.query,
@@ -81,8 +77,8 @@ nodes, specs, options, depth) {
81
77
  matched: collection.matched,
82
78
  unmatched: collection.unmatched,
83
79
  zeroMatch: false,
84
- query: (_b = result === null || result === void 0 ? void 0 : result.query) !== null && _b !== void 0 ? _b : 'N/A',
85
- hint: (_c = result === null || result === void 0 ? void 0 : result.hint) !== null && _c !== void 0 ? _c : {},
80
+ query: result?.query ?? 'N/A',
81
+ hint: result?.hint ?? {},
86
82
  };
87
83
  }
88
84
  const resultType = collection.matched.length > 0 ? 'MATCHED' : 'MATCHED_ZERO';
@@ -92,8 +88,7 @@ nodes, specs, options, depth) {
92
88
  matched: collection.matched,
93
89
  unmatched: collection.unmatched,
94
90
  zeroMatch: false,
95
- query: (_d = result === null || result === void 0 ? void 0 : result.query) !== null && _d !== void 0 ? _d : 'N/A',
96
- hint: (_e = result === null || result === void 0 ? void 0 : result.hint) !== null && _e !== void 0 ? _e : {},
91
+ query: result?.query ?? 'N/A',
92
+ hint: result?.hint ?? {},
97
93
  };
98
94
  }
99
- exports.order = order;
@@ -1,5 +1,5 @@
1
- import type { SelectorResult } from './matches-selector';
2
- import type { ChildNode, Options, Specs } from './types';
1
+ import type { SelectorResult } from './matches-selector.js';
2
+ import type { ChildNode, Options, Specs } from './types.js';
3
3
  import type { PermittedContentPattern, Model } from '@markuplint/ml-spec';
4
4
  import type { ReadonlyDeep } from 'type-fest';
5
5
  export declare function recursiveBranch(model: ReadonlyDeep<Model | PermittedContentPattern[]>, nodes: readonly ChildNode[], specs: Specs, options: Options, depth: number): SelectorResult;
@@ -1,22 +1,19 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.recursiveBranch = void 0;
4
- const matches_selector_1 = require("./matches-selector");
5
- const order_1 = require("./order");
6
- const utils_1 = require("./utils");
7
- function recursiveBranch(model,
1
+ import { matchesSelector } from './matches-selector.js';
2
+ import { order } from './order.js';
3
+ import { Collection, isModel } from './utils.js';
4
+ export function recursiveBranch(model,
8
5
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
9
6
  nodes, specs, options, depth) {
10
- if (!(0, utils_1.isModel)(model)) {
11
- return (0, order_1.order)(model, nodes, specs, options, depth + 1);
7
+ if (!isModel(model)) {
8
+ return order(model, nodes, specs, options, depth + 1);
12
9
  }
13
10
  if (typeof model === 'string') {
14
- return (0, matches_selector_1.matchesSelector)(model, nodes[0], specs, depth);
11
+ return matchesSelector(model, nodes[0], specs, depth);
15
12
  }
16
- const collection = new utils_1.Collection(nodes);
13
+ const collection = new Collection(nodes);
17
14
  let lastUnmatched = null;
18
15
  for (const query of model) {
19
- const result = (0, matches_selector_1.matchesSelector)(query, collection.unmatched[0], specs, depth);
16
+ const result = matchesSelector(query, collection.unmatched[0], specs, depth);
20
17
  collection.addMatched(result.matched);
21
18
  if (result.type === 'MATCHED' || result.type === 'MATCHED_ZERO') {
22
19
  return {
@@ -42,4 +39,3 @@ nodes, specs, options, depth) {
42
39
  }
43
40
  return lastUnmatched;
44
41
  }
45
- exports.recursiveBranch = recursiveBranch;
@@ -1,4 +1,4 @@
1
- import type { ChildNode, Options, Result, Specs } from './types';
1
+ import type { ChildNode, Options, Result, Specs } from './types.js';
2
2
  export declare const transparentMode: Map<ChildNode, true>;
3
3
  export declare function representTransparentNodes(nodes: ChildNode[], specs: Specs, options: Options): {
4
4
  nodes: ChildNode[];
@@ -1,17 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.representTransparentNodes = exports.transparentMode = void 0;
4
- const ml_spec_1 = require("@markuplint/ml-spec");
5
- const order_1 = require("./order");
6
- const utils_1 = require("./utils");
7
- exports.transparentMode = new Map();
8
- function representTransparentNodes(
1
+ import { getContentModel } from '@markuplint/ml-spec';
2
+ import { order } from './order.js';
3
+ import { Collection, getChildNodesWithoutWhitespaces, isTransparent, matches } from './utils.js';
4
+ export const transparentMode = new Map();
5
+ export function representTransparentNodes(
9
6
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
10
7
  nodes, specs, options) {
11
- var _a;
12
8
  const result = [];
13
9
  const errors = [];
14
- const parent = (_a = nodes[0]) === null || _a === void 0 ? void 0 : _a.parentElement;
10
+ const parent = nodes[0]?.parentElement;
15
11
  if (parent) {
16
12
  const { errors: parentErrors } = representTransparentNodes([parent], specs, options);
17
13
  errors.push(...parentErrors);
@@ -21,37 +17,37 @@ nodes, specs, options) {
21
17
  result.push(node);
22
18
  continue;
23
19
  }
24
- const models = (0, ml_spec_1.getContentModel)(node, specs.specs);
20
+ const models = getContentModel(node, specs.specs);
25
21
  if (models == null || typeof models === 'boolean') {
26
22
  result.push(node);
27
23
  continue;
28
24
  }
29
- const noTransparentModels = models.filter(m => !(0, utils_1.isTransparent)(m));
25
+ const noTransparentModels = models.filter(m => !isTransparent(m));
30
26
  if (noTransparentModels.length === models.length) {
31
27
  result.push(node);
32
28
  continue;
33
29
  }
34
- const collection = new utils_1.Collection((0, utils_1.getChildNodesWithoutWhitespaces)(node));
30
+ const collection = new Collection(getChildNodesWithoutWhitespaces(node));
35
31
  let unmatched;
36
32
  if (noTransparentModels.length > 0) {
37
- const result = (0, order_1.order)(noTransparentModels, collection.unmatched, specs, options, Infinity);
33
+ const result = order(noTransparentModels, collection.unmatched, specs, options, Infinity);
38
34
  unmatched = result.unmatched;
39
35
  }
40
36
  else {
41
37
  unmatched = collection.unmatched;
42
38
  }
43
- const transparent = models.find(m => (0, utils_1.isTransparent)(m));
44
- if (!transparent || !(0, utils_1.isTransparent)(transparent)) {
39
+ const transparent = models.find(m => isTransparent(m));
40
+ if (!transparent || !isTransparent(transparent)) {
45
41
  throw new Error('Unreachable code');
46
42
  }
47
43
  for (const _child of unmatched) {
48
44
  const child = _child;
49
- if (exports.transparentMode.has(child)) {
45
+ if (transparentMode.has(child)) {
50
46
  continue;
51
47
  }
52
- exports.transparentMode.set(child, true);
48
+ transparentMode.set(child, true);
53
49
  if (child.is(child.ELEMENT_NODE)) {
54
- const transparentCondMatched = (0, utils_1.matches)(transparent.transparent, child, specs);
50
+ const transparentCondMatched = matches(transparent.transparent, child, specs);
55
51
  if (!transparentCondMatched.matched) {
56
52
  errors.push({
57
53
  type: 'TRANSPARENT_MODEL_DISALLOWS',
@@ -75,4 +71,3 @@ nodes, specs, options) {
75
71
  errors,
76
72
  };
77
73
  }
78
- exports.representTransparentNodes = representTransparentNodes;
@@ -1,4 +1,4 @@
1
- import type { ContentModelResult, Element, Options, Specs } from './types';
1
+ import type { ContentModelResult, Element, Options, Specs } from './types.js';
2
2
  import type { ContentModel } from '@markuplint/ml-spec';
3
3
  import type { ReadonlyDeep } from 'type-fest';
4
4
  /**
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.start = void 0;
4
- const order_1 = require("./order");
5
- const represent_transparent_nodes_1 = require("./represent-transparent-nodes");
6
- const utils_1 = require("./utils");
1
+ import { order } from './order.js';
2
+ import { representTransparentNodes } from './represent-transparent-nodes.js';
3
+ import { getChildNodesWithoutWhitespaces } from './utils.js';
7
4
  /**
8
5
  * Check start
9
6
  *
@@ -13,10 +10,9 @@ const utils_1 = require("./utils");
13
10
  * @param options
14
11
  * @returns
15
12
  */
16
- function start(contents,
13
+ export function start(contents,
17
14
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
18
15
  el, specs, options) {
19
- var _a;
20
16
  if (contents === false) {
21
17
  if (el.childNodes.length > 0) {
22
18
  return [
@@ -48,26 +44,22 @@ el, specs, options) {
48
44
  },
49
45
  ];
50
46
  }
51
- const { nodes, errors } = (0, represent_transparent_nodes_1.representTransparentNodes)((0, utils_1.getChildNodesWithoutWhitespaces)(el), specs, options);
52
- const result = (0, order_1.order)(contents, nodes, specs, options, 0);
47
+ const { nodes, errors } = representTransparentNodes(getChildNodesWithoutWhitespaces(el), specs, options);
48
+ const result = order(contents, nodes, specs, options, 0);
53
49
  return [
54
50
  {
55
51
  type: result.type,
56
52
  scope: result.type === 'MISSING_NODE_REQUIRED' || result.type === 'MISSING_NODE_ONE_OR_MORE'
57
53
  ? el
58
- : (_a = result.unmatched[0]) !== null && _a !== void 0 ? _a : el,
54
+ : result.unmatched[0] ?? el,
59
55
  query: result.query,
60
56
  hint: result.hint,
61
57
  },
62
- ...errors.map(error => {
63
- var _a;
64
- return ({
65
- type: error.type,
66
- scope: (_a = error.unmatched[0]) !== null && _a !== void 0 ? _a : el,
67
- query: error.query,
68
- hint: error.hint,
69
- });
70
- }),
58
+ ...errors.map(error => ({
59
+ type: error.type,
60
+ scope: error.unmatched[0] ?? el,
61
+ query: error.query,
62
+ hint: error.hint,
63
+ })),
71
64
  ];
72
65
  }
73
- exports.start = start;
@@ -1,2 +1,2 @@
1
- import type { ChildNode, Result } from './types';
1
+ import type { ChildNode, Result } from './types.js';
2
2
  export declare function transparent(nodes: readonly ChildNode[]): Result;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transparent = void 0;
4
- const debug_1 = require("./debug");
5
- const transparentLog = debug_1.cmLog.extend('transparent');
6
- function transparent(
1
+ import { cmLog } from './debug.js';
2
+ const transparentLog = cmLog.extend('transparent');
3
+ export function transparent(
7
4
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
8
5
  nodes) {
9
- var _a, _b;
10
- if (nodes.length === 0 || ((_b = (_a = nodes[0]) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.parentElement)) {
6
+ if (nodes.length === 0 || nodes[0]?.parentElement?.parentElement) {
11
7
  transparentLog('Skipped');
12
8
  return {
13
9
  type: nodes.length === 0 ? 'MATCHED_ZERO' : 'MATCHED',
@@ -28,4 +24,3 @@ nodes) {
28
24
  hint: {},
29
25
  };
30
26
  }
31
- exports.transparent = transparent;
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types';
1
+ import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types.js';
2
2
  import type { PermittedContentPattern, PermittedContentChoice, PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentTransparent, PermittedContentZeroOrMore, Model } from '@markuplint/ml-spec';
3
3
  import type { ReadonlyDeep } from 'type-fest';
4
4
  export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];