@markuplint/rules 3.5.0 → 3.6.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 (84) hide show
  1. package/lib/attr-check.d.ts +1 -1
  2. package/lib/attr-check.js +19 -22
  3. package/lib/attr-duplication/index.d.ts +3 -1
  4. package/lib/attr-duplication/index.js +2 -1
  5. package/lib/attr-value-quotes/index.d.ts +2 -2
  6. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  7. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  8. package/lib/character-reference/index.d.ts +1 -1
  9. package/lib/class-naming/index.d.ts +1 -1
  10. package/lib/class-naming/index.js +2 -4
  11. package/lib/create-message.d.ts +12 -2
  12. package/lib/create-message.js +5 -4
  13. package/lib/deprecated-attr/index.d.ts +3 -1
  14. package/lib/deprecated-element/index.d.ts +3 -1
  15. package/lib/deprecated-element/index.js +2 -2
  16. package/lib/disallowed-element/index.d.ts +1 -1
  17. package/lib/doctype/index.d.ts +2 -2
  18. package/lib/end-tag/index.d.ts +1 -1
  19. package/lib/helpers.d.ts +0 -1
  20. package/lib/helpers.js +8 -9
  21. package/lib/id-duplication/index.d.ts +3 -1
  22. package/lib/index.d.ts +172 -67
  23. package/lib/ineffective-attr/index.d.ts +3 -1
  24. package/lib/ineffective-attr/index.js +2 -5
  25. package/lib/invalid-attr/index.d.ts +17 -13
  26. package/lib/invalid-attr/index.js +8 -8
  27. package/lib/label-has-control/index.d.ts +3 -1
  28. package/lib/landmark-roles/index.d.ts +3 -3
  29. package/lib/landmark-roles/index.js +1 -1
  30. package/lib/no-boolean-attr-value/index.d.ts +3 -1
  31. package/lib/no-default-value/index.d.ts +3 -1
  32. package/lib/no-empty-palpable-content/index.d.ts +3 -3
  33. package/lib/no-hard-code-id/index.d.ts +3 -1
  34. package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
  35. package/lib/no-refer-to-non-existent-id/index.js +4 -14
  36. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  37. package/lib/permitted-contents/choice.d.ts +7 -1
  38. package/lib/permitted-contents/complex-branch.d.ts +7 -1
  39. package/lib/permitted-contents/content-model.js +1 -1
  40. package/lib/permitted-contents/count-pattern.d.ts +17 -2
  41. package/lib/permitted-contents/count-pattern.js +1 -1
  42. package/lib/permitted-contents/debug.browser.d.ts +15 -15
  43. package/lib/permitted-contents/debug.d.ts +1 -1
  44. package/lib/permitted-contents/index.d.ts +1 -1
  45. package/lib/permitted-contents/index.js +5 -10
  46. package/lib/permitted-contents/matches-selector.d.ts +6 -1
  47. package/lib/permitted-contents/matches-selector.js +1 -1
  48. package/lib/permitted-contents/order.d.ts +7 -1
  49. package/lib/permitted-contents/order.js +4 -4
  50. package/lib/permitted-contents/recursive-branch.d.ts +7 -1
  51. package/lib/permitted-contents/represent-transparent-nodes.d.ts +7 -3
  52. package/lib/permitted-contents/represent-transparent-nodes.js +1 -1
  53. package/lib/permitted-contents/start.d.ts +6 -1
  54. package/lib/permitted-contents/start.js +1 -1
  55. package/lib/permitted-contents/types.d.ts +29 -29
  56. package/lib/permitted-contents/utils.d.ts +90 -41
  57. package/lib/permitted-contents/utils.js +3 -3
  58. package/lib/placeholder-label-option/index.d.ts +1 -1
  59. package/lib/placeholder-label-option/index.js +5 -4
  60. package/lib/require-accessible-name/index.d.ts +2 -2
  61. package/lib/require-datetime/index.d.ts +2 -2
  62. package/lib/require-datetime/types.d.ts +2 -2
  63. package/lib/require-datetime/utils.js +3 -2
  64. package/lib/required-attr/index.d.ts +3 -3
  65. package/lib/required-attr/index.js +4 -4
  66. package/lib/required-element/index.d.ts +2 -2
  67. package/lib/required-h1/index.d.ts +3 -3
  68. package/lib/use-list/index.d.ts +2 -2
  69. package/lib/use-list/index.js +4 -3
  70. package/lib/wai-aria/checkings/default-value.d.ts +7 -3
  71. package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
  72. package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
  73. package/lib/wai-aria/checkings/disallowed-prop.js +1 -1
  74. package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
  75. package/lib/wai-aria/checkings/implicit-props.js +3 -2
  76. package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
  77. package/lib/wai-aria/checkings/required-owned-elements.d.ts +7 -3
  78. package/lib/wai-aria/checkings/required-owned-elements.js +1 -1
  79. package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
  80. package/lib/wai-aria/checkings/value.d.ts +15 -6
  81. package/lib/wai-aria/checkings/value.js +3 -1
  82. package/lib/wai-aria/index.d.ts +1 -1
  83. package/lib/wai-aria/types.d.ts +10 -10
  84. package/package.json +8 -8
@@ -9,7 +9,7 @@ exports.default = (0, ml_core_1.createRule)({
9
9
  defaultOptions: {},
10
10
  async verify({ document, report, t }) {
11
11
  await document.walkOn('Attr', attr => {
12
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
12
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
13
13
  // Default
14
14
  const allowToAddPropertiesForPretender = (_a = attr.rule.options.allowToAddPropertiesForPretender) !== null && _a !== void 0 ? _a : true;
15
15
  if (attr.isDirective) {
@@ -33,7 +33,7 @@ exports.default = (0, ml_core_1.createRule)({
33
33
  }
34
34
  const valueNode = attr.valueNode;
35
35
  const value = attr.value;
36
- if (attr.rule.options.ignoreAttrNamePrefix) {
36
+ if (attr.rule.options.ignoreAttrNamePrefix != null) {
37
37
  const ignoreAttrNamePrefixes = Array.isArray(attr.rule.options.ignoreAttrNamePrefix)
38
38
  ? attr.rule.options.ignoreAttrNamePrefix
39
39
  : [attr.rule.options.ignoreAttrNamePrefix];
@@ -75,7 +75,7 @@ exports.default = (0, ml_core_1.createRule)({
75
75
  log('Checking %s[%s="%s"]', attr.nodeName, name, value);
76
76
  invalid = (0, helpers_1.isValidAttr)(t, name, value, attr.isDynamicValue || false, attr.ownerElement, attrSpecs, log);
77
77
  }
78
- if (invalid) {
78
+ if (invalid !== false) {
79
79
  switch (invalid.invalidType) {
80
80
  case 'disallowed-attr': {
81
81
  report({
@@ -92,15 +92,15 @@ exports.default = (0, ml_core_1.createRule)({
92
92
  scope: attr,
93
93
  message: invalid.message,
94
94
  line: ((_b = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startLine) !== null && _b !== void 0 ? _b : 0) + ((_d = (_c = invalid.loc) === null || _c === void 0 ? void 0 : _c.line) !== null && _d !== void 0 ? _d : 0),
95
- col: ((_e = invalid.loc) === null || _e === void 0 ? void 0 : _e.line)
96
- ? ((_f = invalid.loc) === null || _f === void 0 ? void 0 : _f.col) + 1
97
- : ((_g = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startCol) !== null && _g !== void 0 ? _g : 0) + ((_j = (_h = invalid.loc) === null || _h === void 0 ? void 0 : _h.col) !== null && _j !== void 0 ? _j : 0),
98
- raw: (_l = (_k = invalid.loc) === null || _k === void 0 ? void 0 : _k.raw) !== null && _l !== void 0 ? _l : value,
95
+ col: invalid.loc && invalid.loc.line > 0
96
+ ? ((_e = invalid.loc) === null || _e === void 0 ? void 0 : _e.col) + 1
97
+ : ((_f = valueNode === null || valueNode === void 0 ? void 0 : valueNode.startCol) !== null && _f !== void 0 ? _f : 0) + ((_h = (_g = invalid.loc) === null || _g === void 0 ? void 0 : _g.col) !== null && _h !== void 0 ? _h : 0),
98
+ raw: (_k = (_j = invalid.loc) === null || _j === void 0 ? void 0 : _j.raw) !== null && _k !== void 0 ? _k : value,
99
99
  });
100
100
  break;
101
101
  }
102
102
  case 'non-existent': {
103
- if (allowToAddPropertiesForPretender && ((_m = attr.ownerElement.pretenderContext) === null || _m === void 0 ? void 0 : _m.type) === 'origin') {
103
+ if (allowToAddPropertiesForPretender && ((_l = attr.ownerElement.pretenderContext) === null || _l === void 0 ? void 0 : _l.type) === 'origin') {
104
104
  return;
105
105
  }
106
106
  const spec = (0, ml_core_1.getSpec)(attr.ownerElement, document.specs.specs);
@@ -1,2 +1,4 @@
1
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
1
+ declare const _default: Readonly<
2
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
+ >;
2
4
  export default _default;
@@ -1,8 +1,8 @@
1
1
  type Options = {
2
- ignoreRoles: Roles[];
3
- labelEachArea: boolean;
2
+ ignoreRoles: Roles[];
3
+ labelEachArea: boolean;
4
4
  };
5
5
  type TopLevelRoles = 'banner' | 'main' | 'complementary' | 'contentinfo';
6
6
  type Roles = TopLevelRoles | 'form' | 'navigation' | 'region';
7
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
7
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Options>>;
8
8
  export default _default;
@@ -116,7 +116,7 @@ roleset) {
116
116
  function hasLabel(
117
117
  // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
118
118
  el) {
119
- const hasHeading = !!el.querySelectorAll('h1, h2, h3, h4, h5, h6').length;
119
+ const hasHeading = el.querySelectorAll('h1, h2, h3, h4, h5, h6').length > 0;
120
120
  if (hasHeading && el.matches('[aria-labelledby]')) {
121
121
  return true;
122
122
  }
@@ -1,2 +1,4 @@
1
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
1
+ declare const _default: Readonly<
2
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
+ >;
2
4
  export default _default;
@@ -1,2 +1,4 @@
1
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
1
+ declare const _default: Readonly<
2
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
+ >;
2
4
  export default _default;
@@ -1,6 +1,6 @@
1
1
  type Options = {
2
- extendsExposableElements?: boolean;
3
- ignoreIfAriaBusy?: boolean;
2
+ extendsExposableElements?: boolean;
3
+ ignoreIfAriaBusy?: boolean;
4
4
  };
5
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
5
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Options>>;
6
6
  export default _default;
@@ -1,2 +1,4 @@
1
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, undefined>>;
1
+ declare const _default: Readonly<
2
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
+ >;
2
4
  export default _default;
@@ -1,6 +1,11 @@
1
1
  import type { ARIAVersion } from '@markuplint/ml-spec';
2
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, {
3
- ariaVersion: ARIAVersion;
4
- fragmentRefersNameAttr: boolean;
5
- }>>;
2
+ declare const _default: Readonly<
3
+ import('@markuplint/ml-core').RuleSeed<
4
+ import('@markuplint/ml-core').RuleConfigValue,
5
+ {
6
+ ariaVersion: ARIAVersion;
7
+ fragmentRefersNameAttr: boolean;
8
+ }
9
+ >
10
+ >;
6
11
  export default _default;
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ml_core_1 = require("@markuplint/ml-core");
4
+ const shared_1 = require("@markuplint/shared");
4
5
  const HYPERLINK_SELECTOR = 'a[href], area[href]';
5
6
  exports.default = (0, ml_core_1.createRule)({
6
7
  defaultOptions: {
@@ -25,7 +26,7 @@ exports.default = (0, ml_core_1.createRule)({
25
26
  hasDynamicId = true;
26
27
  }
27
28
  if (attr.valueType !== 'code') {
28
- idList.add(attr.value);
29
+ idList.add((0, shared_1.decodeEntities)(attr.value));
29
30
  }
30
31
  });
31
32
  if (hasDynamicId) {
@@ -40,7 +41,7 @@ exports.default = (0, ml_core_1.createRule)({
40
41
  hasDynamicName = true;
41
42
  }
42
43
  if (attr.valueType !== 'code') {
43
- nameList.add(attr.value);
44
+ nameList.add((0, shared_1.decodeEntities)(attr.value));
44
45
  }
45
46
  });
46
47
  await document.walkOn('Attr', attr => {
@@ -140,7 +141,7 @@ exports.default = (0, ml_core_1.createRule)({
140
141
  if (rawFragment == null) {
141
142
  return;
142
143
  }
143
- const decodedFragment = decode(rawFragment);
144
+ const decodedFragment = (0, shared_1.decodeHref)(rawFragment);
144
145
  // > 2. If fragment is the empty string, then return the special value top of the document.
145
146
  // >
146
147
  // > 9. If decodedFragment is an ASCII case-insensitive match for the string top, then return the top of the document.
@@ -160,14 +161,3 @@ exports.default = (0, ml_core_1.createRule)({
160
161
  });
161
162
  },
162
163
  });
163
- function decode(fragment) {
164
- try {
165
- return decodeURI(fragment);
166
- }
167
- catch (e) {
168
- if (e instanceof URIError) {
169
- return fragment;
170
- }
171
- throw e;
172
- }
173
- }
@@ -1,5 +1,5 @@
1
1
  type Options = {
2
- ignore?: string | string[];
2
+ ignore?: string | string[];
3
3
  };
4
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
4
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Options>>;
5
5
  export default _default;
@@ -1,4 +1,10 @@
1
1
  import type { ChildNode, Options, Result, Specs } from './types';
2
2
  import type { PermittedContentChoice } from '@markuplint/ml-spec';
3
3
  import type { ReadonlyDeep } from 'type-fest';
4
- export declare function choice(pattern: ReadonlyDeep<PermittedContentChoice>, elements: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
4
+ export declare function choice(
5
+ pattern: ReadonlyDeep<PermittedContentChoice>,
6
+ elements: readonly ChildNode[],
7
+ specs: Specs,
8
+ options: Options,
9
+ depth: number,
10
+ ): Result;
@@ -11,4 +11,10 @@ import type { ReadonlyDeep } from 'type-fest';
11
11
  * @param depth
12
12
  * @returns
13
13
  */
14
- export declare function complexBranch(pattern: ReadonlyDeep<PermittedContentPattern>, elements: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
14
+ export declare function complexBranch(
15
+ pattern: ReadonlyDeep<PermittedContentPattern>,
16
+ elements: readonly ChildNode[],
17
+ specs: Specs,
18
+ options: Options,
19
+ depth: number,
20
+ ): Result;
@@ -30,7 +30,7 @@ el, rules) {
30
30
  }
31
31
  const caches = new Map();
32
32
  function cachedSpecs(specs, rules) {
33
- if (!rules.length) {
33
+ if (rules.length === 0) {
34
34
  return specs;
35
35
  }
36
36
  const key = JSON.stringify(rules);
@@ -1,5 +1,10 @@
1
1
  import type { ChildNode, Options, Result, Specs } from './types';
2
- import type { PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentZeroOrMore } from '@markuplint/ml-spec';
2
+ import type {
3
+ PermittedContentOneOrMore,
4
+ PermittedContentOptional,
5
+ PermittedContentRequire,
6
+ PermittedContentZeroOrMore,
7
+ } from '@markuplint/ml-spec';
3
8
  import type { ReadonlyDeep } from 'type-fest';
4
9
  /**
5
10
  * Check count
@@ -11,4 +16,14 @@ import type { ReadonlyDeep } from 'type-fest';
11
16
  * @param depth
12
17
  * @returns
13
18
  */
14
- export declare function countPattern(pattern: ReadonlyDeep<PermittedContentOneOrMore> | ReadonlyDeep<PermittedContentOptional> | ReadonlyDeep<PermittedContentRequire> | ReadonlyDeep<PermittedContentZeroOrMore>, elements: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
19
+ export declare function countPattern(
20
+ pattern:
21
+ | ReadonlyDeep<PermittedContentOneOrMore>
22
+ | ReadonlyDeep<PermittedContentOptional>
23
+ | ReadonlyDeep<PermittedContentRequire>
24
+ | ReadonlyDeep<PermittedContentZeroOrMore>,
25
+ elements: readonly ChildNode[],
26
+ specs: Specs,
27
+ options: Options,
28
+ depth: number,
29
+ ): Result;
@@ -121,7 +121,7 @@ elements, specs, options, depth) {
121
121
  },
122
122
  }),
123
123
  };
124
- if (!prevResult && collection.unmatched.length) {
124
+ if (collection.unmatched.length > 0) {
125
125
  prevResult = matchedResult;
126
126
  ptLog('continue⤴️ (add prev)');
127
127
  continue;
@@ -1,30 +1,30 @@
1
1
  /// <reference types="debug" />
2
- export declare const cmLog: import("debug").Debugger;
2
+ export declare const cmLog: import('debug').Debugger;
3
3
  export declare const bgGreen: {
4
- (): void;
5
- bold(): void;
4
+ (): void;
5
+ bold(): void;
6
6
  };
7
7
  export declare const green: {
8
- (): void;
9
- bold(): void;
8
+ (): void;
9
+ bold(): void;
10
10
  };
11
11
  export declare const bgRed: {
12
- (): void;
13
- bold(): void;
12
+ (): void;
13
+ bold(): void;
14
14
  };
15
15
  export declare const bgBlue: {
16
- (): void;
17
- bold(): void;
16
+ (): void;
17
+ bold(): void;
18
18
  };
19
19
  export declare const blue: {
20
- (): void;
21
- bold(): void;
20
+ (): void;
21
+ bold(): void;
22
22
  };
23
23
  export declare const bgMagenta: {
24
- (): void;
25
- bold(): void;
24
+ (): void;
25
+ bold(): void;
26
26
  };
27
27
  export declare const cyan: {
28
- (): void;
29
- bold(): void;
28
+ (): void;
29
+ bold(): void;
30
30
  };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="debug" />
2
- export declare const cmLog: import("debug").Debugger;
2
+ export declare const cmLog: import('debug').Debugger;
3
3
  export { bgGreen, green, bgRed, bgBlue, blue, bgMagenta, cyan } from 'ansi-colors';
@@ -1,3 +1,3 @@
1
1
  import type { Options, TagRule } from './types';
2
- declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<TagRule[], Options>>;
2
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<TagRule[], Options>>;
3
3
  export default _default;
@@ -11,22 +11,17 @@ exports.default = (0, ml_core_1.createRule)({
11
11
  async verify({ document, report, t }) {
12
12
  await document.walkOn('Element', el => {
13
13
  var _a, _b, _c;
14
- if (!el.rule.value) {
15
- return;
16
- }
17
14
  if (el.rule.options.ignoreHasMutableChildren && el.hasMutableChildren()) {
18
15
  return;
19
16
  }
20
17
  const results = (0, content_model_1.contentModel)(el, el.rule.value, el.rule.options);
21
18
  for (const { type, scope, query, hint } of results) {
22
19
  let message = '';
23
- if (hint) {
24
- if (hint.max != null) {
25
- message =
26
- t('there is more content than it needs') +
27
- t('. ') +
28
- t('the max number of elements required is {0}', `${hint.max}`);
29
- }
20
+ if (hint.max != null) {
21
+ message =
22
+ t('there is more content than it needs') +
23
+ t('. ') +
24
+ t('the max number of elements required is {0}', `${hint.max}`);
30
25
  }
31
26
  switch (type) {
32
27
  case 'MATCHED':
@@ -1,3 +1,8 @@
1
1
  import type { ChildNode, Result, Specs } from './types';
2
2
  export type SelectorResult = Result<'UNMATCHED_SELECTOR_BUT_MAY_EMPTY' | 'MISSING_NODE' | 'UNMATCHED_SELECTORS'>;
3
- export declare function matchesSelector(query: string, node: ChildNode | undefined, specs: Specs, depth: number): SelectorResult;
3
+ export declare function matchesSelector(
4
+ query: string,
5
+ node: ChildNode | undefined,
6
+ specs: Specs,
7
+ depth: number,
8
+ ): SelectorResult;
@@ -14,7 +14,7 @@ node, specs, depth) {
14
14
  nodeLog('<#text>.matches(%s) => ""', query);
15
15
  return {
16
16
  type: 'MATCHED_ZERO',
17
- matched: node ? [node] : [],
17
+ matched: [],
18
18
  unmatched: [],
19
19
  zeroMatch: true,
20
20
  query,
@@ -11,4 +11,10 @@ import type { ReadonlyDeep } from 'type-fest';
11
11
  * @param depth
12
12
  * @returns
13
13
  */
14
- export declare function order(contents: ReadonlyDeep<PermittedContentPattern[]>, nodes: readonly ChildNode[], specs: Specs, options: Options, depth: number): Result;
14
+ export declare function order(
15
+ contents: ReadonlyDeep<PermittedContentPattern[]>,
16
+ nodes: readonly ChildNode[],
17
+ specs: Specs,
18
+ options: Options,
19
+ depth: number,
20
+ ): Result;
@@ -29,7 +29,7 @@ nodes, specs, options, depth) {
29
29
  let backtrackMode = false;
30
30
  let afterBacktrack = false;
31
31
  const unmatchedResults = [];
32
- while (patterns.length && patterns[0]) {
32
+ while (patterns.length > 0 && patterns[0]) {
33
33
  result = (0, complex_branch_1.complexBranch)(patterns[0], collection.unmatched, specs, options, depth);
34
34
  collection.addMatched(result.matched);
35
35
  if (result.type !== 'UNEXPECTED_EXTRA_NODE' && result.type !== 'MATCHED' && result.type !== 'MATCHED_ZERO') {
@@ -45,7 +45,7 @@ nodes, specs, options, depth) {
45
45
  if (!barelyMatchedResult) {
46
46
  throw new Error('Unreachable code');
47
47
  }
48
- orderLog('Result (%s): %s%s', result.type, collection.toString(true), ((_a = barelyMatchedResult.hint.missing) === null || _a === void 0 ? void 0 : _a.barelyMatchedElements)
48
+ orderLog('Result (%s): %s%s', result.type, collection.toString(true), ((_a = barelyMatchedResult.hint.missing) === null || _a === void 0 ? void 0 : _a.barelyMatchedElements) != null
49
49
  ? `; But ${barelyMatchedResult.hint.missing.barelyMatchedElements} elements hit out of pattern`
50
50
  : '');
51
51
  return {
@@ -74,7 +74,7 @@ nodes, specs, options, depth) {
74
74
  }
75
75
  patterns.shift();
76
76
  }
77
- if (collection.unmatched.length) {
77
+ if (collection.unmatched.length > 0) {
78
78
  orderLog('Result (UNEXPECTED_EXTRA_NODE): %s', collection.toString(true));
79
79
  return {
80
80
  type: 'UNEXPECTED_EXTRA_NODE',
@@ -85,7 +85,7 @@ nodes, specs, options, depth) {
85
85
  hint: (_c = result === null || result === void 0 ? void 0 : result.hint) !== null && _c !== void 0 ? _c : {},
86
86
  };
87
87
  }
88
- const resultType = collection.matched.length ? 'MATCHED' : 'MATCHED_ZERO';
88
+ const resultType = collection.matched.length > 0 ? 'MATCHED' : 'MATCHED_ZERO';
89
89
  orderLog('Result (%s): %s', resultType, collection.toString(true));
90
90
  return {
91
91
  type: resultType,
@@ -2,4 +2,10 @@ import type { SelectorResult } from './matches-selector';
2
2
  import type { ChildNode, Options, Specs } from './types';
3
3
  import type { PermittedContentPattern, Model } from '@markuplint/ml-spec';
4
4
  import type { ReadonlyDeep } from 'type-fest';
5
- export declare function recursiveBranch(model: ReadonlyDeep<Model | PermittedContentPattern[]>, nodes: readonly ChildNode[], specs: Specs, options: Options, depth: number): SelectorResult;
5
+ export declare function recursiveBranch(
6
+ model: ReadonlyDeep<Model | PermittedContentPattern[]>,
7
+ nodes: readonly ChildNode[],
8
+ specs: Specs,
9
+ options: Options,
10
+ depth: number,
11
+ ): SelectorResult;
@@ -1,6 +1,10 @@
1
1
  import type { ChildNode, Options, Result, Specs } from './types';
2
2
  export declare const transparentMode: Map<ChildNode, true>;
3
- export declare function representTransparentNodes(nodes: ChildNode[], specs: Specs, options: Options): {
4
- nodes: ChildNode[];
5
- errors: Result[];
3
+ export declare function representTransparentNodes(
4
+ nodes: ChildNode[],
5
+ specs: Specs,
6
+ options: Options,
7
+ ): {
8
+ nodes: ChildNode[];
9
+ errors: Result[];
6
10
  };
@@ -33,7 +33,7 @@ nodes, specs, options) {
33
33
  }
34
34
  const collection = new utils_1.Collection((0, utils_1.getChildNodesWithoutWhitespaces)(node));
35
35
  let unmatched;
36
- if (noTransparentModels.length) {
36
+ if (noTransparentModels.length > 0) {
37
37
  const result = (0, order_1.order)(noTransparentModels, collection.unmatched, specs, options, Infinity);
38
38
  unmatched = result.unmatched;
39
39
  }
@@ -10,4 +10,9 @@ import type { ReadonlyDeep } from 'type-fest';
10
10
  * @param options
11
11
  * @returns
12
12
  */
13
- export declare function start(contents: ReadonlyDeep<ContentModel['contents']>, el: Element, specs: Specs, options: Options): ContentModelResult[];
13
+ export declare function start(
14
+ contents: ReadonlyDeep<ContentModel['contents']>,
15
+ el: Element,
16
+ specs: Specs,
17
+ options: Options,
18
+ ): ContentModelResult[];
@@ -18,7 +18,7 @@ function start(contents,
18
18
  el, specs, options) {
19
19
  var _a;
20
20
  if (contents === false) {
21
- if (el.childNodes.length) {
21
+ if (el.childNodes.length > 0) {
22
22
  return [
23
23
  {
24
24
  type: 'NOTHING',
@@ -4,49 +4,49 @@ import type { ReadonlyDeep } from 'type-fest';
4
4
  export type Element = _Element<TagRule[], Options>;
5
5
  export type ChildNode = _ChildNode<TagRule[], Options>;
6
6
  export type Specs = {
7
- readonly cites: MLMLSpec['cites'];
8
- readonly def: MLMLSpec['def'];
9
- readonly specs: readonly {
10
- readonly name: string;
11
- readonly contentModel: {
12
- readonly contents: MLMLSpec['specs'][0]['contentModel']['contents'];
13
- };
14
- }[];
7
+ readonly cites: MLMLSpec['cites'];
8
+ readonly def: MLMLSpec['def'];
9
+ readonly specs: readonly {
10
+ readonly name: string;
11
+ readonly contentModel: {
12
+ readonly contents: MLMLSpec['specs'][0]['contentModel']['contents'];
13
+ };
14
+ }[];
15
15
  };
16
16
  export type ContentModelResult = {
17
- type: MatchedReason | UnmatchedReason;
18
- scope: ChildNode;
19
- query: Result['query'];
20
- hint: Result['hint'];
17
+ type: MatchedReason | UnmatchedReason;
18
+ scope: ChildNode;
19
+ query: Result['query'];
20
+ hint: Result['hint'];
21
21
  };
22
22
  export type Result<T extends string = MatchedReason> = {
23
- type: MatchedReason | UnmatchedReason | T;
24
- matched: ChildNode[];
25
- unmatched: ChildNode[];
26
- zeroMatch: boolean;
27
- query: string;
28
- hint: Hints;
23
+ type: MatchedReason | UnmatchedReason | T;
24
+ matched: ChildNode[];
25
+ unmatched: ChildNode[];
26
+ zeroMatch: boolean;
27
+ query: string;
28
+ hint: Hints;
29
29
  };
30
30
  export type Hints = {
31
- max?: number;
32
- not?: ChildNode;
33
- transparent?: Element;
34
- missing?: {
35
- barelyMatchedElements?: number;
36
- need?: string;
37
- };
31
+ max?: number;
32
+ not?: ChildNode;
33
+ transparent?: Element;
34
+ missing?: {
35
+ barelyMatchedElements?: number;
36
+ need?: string;
37
+ };
38
38
  };
39
39
  export type MatchedReason = 'MATCHED' | 'MATCHED_ZERO';
40
40
  export type UnmatchedReason = 'NOTHING' | 'UNEXPECTED_EXTRA_NODE' | 'TRANSPARENT_MODEL_DISALLOWS' | MissingNodeReason;
41
41
  export type MissingNodeReason = 'MISSING_NODE_REQUIRED' | 'MISSING_NODE_ONE_OR_MORE';
42
42
  export type RepeatSign = '' | '?' | '+' | '*' | `{${number},${number}}`;
43
43
  export type TransparentModel = {
44
- el: Element;
45
- additionalCondition: string;
44
+ el: Element;
45
+ additionalCondition: string;
46
46
  };
47
47
  export type TagRule = {
48
- readonly tag: string;
48
+ readonly tag: string;
49
49
  } & ReadonlyDeep<ContentModel>;
50
50
  export type Options = {
51
- readonly ignoreHasMutableChildren: boolean;
51
+ readonly ignoreHasMutableChildren: boolean;
52
52
  };