@markuplint/rules 3.3.1 → 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 (88) hide show
  1. package/lib/attr-check.d.ts +9 -19
  2. package/lib/attr-duplication/index.d.ts +1 -1
  3. package/lib/attr-value-quotes/index.d.ts +2 -2
  4. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  5. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  6. package/lib/character-reference/index.d.ts +1 -1
  7. package/lib/class-naming/index.d.ts +1 -1
  8. package/lib/create-message.d.ts +3 -12
  9. package/lib/create-message.js +2 -2
  10. package/lib/deprecated-attr/index.d.ts +1 -1
  11. package/lib/deprecated-element/index.d.ts +1 -1
  12. package/lib/disallowed-element/index.d.ts +1 -1
  13. package/lib/doctype/index.d.ts +2 -2
  14. package/lib/end-tag/index.d.ts +1 -1
  15. package/lib/helpers.d.ts +18 -35
  16. package/lib/helpers.js +19 -5
  17. package/lib/id-duplication/index.d.ts +1 -1
  18. package/lib/index.d.ts +70 -3
  19. package/lib/index.js +2 -1
  20. package/lib/ineffective-attr/index.d.ts +1 -1
  21. package/lib/invalid-attr/index.d.ts +13 -17
  22. package/lib/label-has-control/index.d.ts +1 -1
  23. package/lib/landmark-roles/index.d.ts +3 -3
  24. package/lib/landmark-roles/index.js +6 -2
  25. package/lib/no-boolean-attr-value/index.d.ts +1 -1
  26. package/lib/no-default-value/index.d.ts +1 -1
  27. package/lib/no-empty-palpable-content/index.d.ts +3 -3
  28. package/lib/no-hard-code-id/index.d.ts +1 -1
  29. package/lib/no-refer-to-non-existent-id/index.d.ts +4 -7
  30. package/lib/no-refer-to-non-existent-id/index.js +4 -0
  31. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  32. package/lib/permitted-contents/choice.d.ts +2 -7
  33. package/lib/permitted-contents/choice.js +3 -1
  34. package/lib/permitted-contents/complex-branch.d.ts +2 -7
  35. package/lib/permitted-contents/complex-branch.js +4 -2
  36. package/lib/permitted-contents/content-model.d.ts +1 -1
  37. package/lib/permitted-contents/content-model.js +6 -2
  38. package/lib/permitted-contents/count-pattern.d.ts +3 -17
  39. package/lib/permitted-contents/count-pattern.js +10 -3
  40. package/lib/permitted-contents/debug.browser.d.ts +15 -15
  41. package/lib/permitted-contents/debug.d.ts +1 -1
  42. package/lib/permitted-contents/index.d.ts +1 -1
  43. package/lib/permitted-contents/index.js +3 -1
  44. package/lib/permitted-contents/matches-selector.d.ts +2 -8
  45. package/lib/permitted-contents/matches-selector.js +3 -1
  46. package/lib/permitted-contents/order.d.ts +2 -7
  47. package/lib/permitted-contents/order.js +4 -2
  48. package/lib/permitted-contents/recursive-branch.d.ts +2 -7
  49. package/lib/permitted-contents/recursive-branch.js +5 -3
  50. package/lib/permitted-contents/represent-transparent-nodes.d.ts +3 -7
  51. package/lib/permitted-contents/represent-transparent-nodes.js +3 -1
  52. package/lib/permitted-contents/start.d.ts +2 -6
  53. package/lib/permitted-contents/start.js +3 -1
  54. package/lib/permitted-contents/transparent.d.ts +2 -2
  55. package/lib/permitted-contents/transparent.js +5 -3
  56. package/lib/permitted-contents/types.d.ts +31 -30
  57. package/lib/permitted-contents/utils.d.ts +44 -80
  58. package/lib/permitted-contents/utils.js +21 -7
  59. package/lib/placeholder-label-option/index.d.ts +1 -1
  60. package/lib/placeholder-label-option/index.js +6 -2
  61. package/lib/require-accessible-name/index.d.ts +2 -2
  62. package/lib/require-datetime/index.d.ts +2 -2
  63. package/lib/require-datetime/types.d.ts +2 -2
  64. package/lib/require-datetime/utils.d.ts +1 -1
  65. package/lib/require-datetime/utils.js +3 -1
  66. package/lib/required-attr/index.d.ts +3 -3
  67. package/lib/required-attr/index.js +14 -11
  68. package/lib/required-element/index.d.ts +2 -2
  69. package/lib/required-element/index.js +2 -1
  70. package/lib/required-h1/index.d.ts +3 -3
  71. package/lib/required-h1/index.js +3 -2
  72. package/lib/use-list/index.d.ts +3 -3
  73. package/lib/use-list/index.js +3 -2
  74. package/lib/wai-aria/checkings/default-value.d.ts +3 -7
  75. package/lib/wai-aria/checkings/deprecated-props.d.ts +4 -8
  76. package/lib/wai-aria/checkings/disallowed-prop.d.ts +4 -8
  77. package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
  78. package/lib/wai-aria/checkings/implicit-props.d.ts +4 -8
  79. package/lib/wai-aria/checkings/interaction-in-hidden.js +3 -1
  80. package/lib/wai-aria/checkings/no-global-prop.d.ts +3 -7
  81. package/lib/wai-aria/checkings/presentational-children.js +3 -1
  82. package/lib/wai-aria/checkings/required-owned-elements.d.ts +3 -7
  83. package/lib/wai-aria/checkings/required-owned-elements.js +6 -4
  84. package/lib/wai-aria/checkings/required-prop.d.ts +6 -12
  85. package/lib/wai-aria/checkings/value.d.ts +6 -10
  86. package/lib/wai-aria/index.d.ts +1 -1
  87. package/lib/wai-aria/types.d.ts +10 -10
  88. package/package.json +9 -8
@@ -1,6 +1,6 @@
1
1
  import type { Lang } from './types';
2
2
  type Options = {
3
- langs?: Lang[];
3
+ langs?: Lang[];
4
4
  };
5
- declare const _default: 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,8 +1,8 @@
1
1
  export type DateTimeKey = 'year' | 'month' | 'day' | 'hour' | 'minute' | 'second' | 'ms';
2
2
  export type DateTimeData = Partial<Record<DateTimeKey, number>>;
3
3
  export type DateTime = {
4
- datetime: DateTimeData;
5
- zone?: number;
4
+ datetime: DateTimeData;
5
+ zone?: number;
6
6
  };
7
7
  /**
8
8
  * @see https://github.com/wanasit/chrono#locales
@@ -7,5 +7,5 @@ import type { DateTime, Lang } from './types';
7
7
  * @param base Reference date for a test
8
8
  * @returns
9
9
  */
10
- export declare function parseADatetime(content: string, langs: Lang[], base?: Date): DateTime | null;
10
+ export declare function parseADatetime(content: string, langs: readonly Lang[], base?: Readonly<Date>): DateTime | null;
11
11
  export declare function getCandidateDatetimeString(content: string, langs?: Lang[]): string | null;
@@ -98,13 +98,15 @@ function toDatetimeString(date) {
98
98
  }
99
99
  function parseTryMultipleLangs(content, langs, base) {
100
100
  for (const lang of langs) {
101
- // eslint-disable-next-line import/namespace
102
101
  const results = chrono[lang].casual.parse(content, base);
103
102
  // Is not multiple datetime contents
104
103
  if (results.length < 1) {
105
104
  continue;
106
105
  }
107
106
  const result = results[0];
107
+ if (!result) {
108
+ continue;
109
+ }
108
110
  // Is not a range or period
109
111
  if (result.end) {
110
112
  continue;
@@ -1,7 +1,7 @@
1
1
  type RequiredAttributes = string | (string | Attr)[];
2
2
  type Attr = {
3
- name: string;
4
- value: string | string[];
3
+ name: string;
4
+ value: string | string[];
5
5
  };
6
- declare const _default: import('@markuplint/ml-core').RuleSeed<RequiredAttributes, null>;
6
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<RequiredAttributes, undefined>>;
7
7
  export default _default;
@@ -6,6 +6,7 @@ exports.default = (0, ml_core_1.createRule)({
6
6
  defaultValue: [],
7
7
  async verify({ document, report, t }) {
8
8
  await document.walkOn('Element', el => {
9
+ var _a;
9
10
  if (el.hasSpreadAttr) {
10
11
  return;
11
12
  }
@@ -54,7 +55,7 @@ exports.default = (0, ml_core_1.createRule)({
54
55
  invalid = (0, helpers_1.attrMatches)(el, spec.condition) && didntHave;
55
56
  }
56
57
  else if (spec.required) {
57
- const selector = Array.isArray(spec.required) ? spec.required.join(',') : spec.required;
58
+ const selector = typeof spec.required === 'string' ? spec.required : spec.required.join(',');
58
59
  invalid = el.matches(selector) && didntHave;
59
60
  }
60
61
  if (invalid) {
@@ -71,17 +72,19 @@ exports.default = (0, ml_core_1.createRule)({
71
72
  const expects = spec.values.length === 1 ? t(spec.values) : t('either {0}', t(spec.values));
72
73
  const message = t('{0} expects {1}', t('the "{0*}" {1}', spec.name, 'attribute'), expects);
73
74
  const attrToken = el.getAttributeToken(spec.name);
74
- const valueToken = attrToken[0].valueNode;
75
+ const valueToken = (_a = attrToken[0]) === null || _a === void 0 ? void 0 : _a.valueNode;
75
76
  const token = valueToken || attrToken[0];
76
- report({
77
- scope: {
78
- rule: el.rule,
79
- raw: token.raw,
80
- startCol: token.startCol,
81
- startLine: token.startLine,
82
- },
83
- message,
84
- });
77
+ if (token) {
78
+ report({
79
+ scope: {
80
+ rule: el.rule,
81
+ raw: token.raw,
82
+ startCol: token.startCol,
83
+ startLine: token.startLine,
84
+ },
85
+ message,
86
+ });
87
+ }
85
88
  }
86
89
  }
87
90
  }
@@ -1,5 +1,5 @@
1
1
  type Options = {
2
- ignoreHasMutableContents: boolean;
2
+ ignoreHasMutableContents: boolean;
3
3
  };
4
- declare const _default: import('@markuplint/ml-core').RuleSeed<string[], Options>;
4
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<string[], Options>>;
5
5
  export default _default;
@@ -7,6 +7,7 @@ exports.default = (0, ml_core_1.createRule)({
7
7
  ignoreHasMutableContents: true,
8
8
  },
9
9
  async verify({ document, report, t }) {
10
+ var _a, _b;
10
11
  const hasMutableContent = document.nodeList.some(n => n.is(n.ELEMENT_NODE) && n.hasMutableChildren());
11
12
  if (!hasMutableContent) {
12
13
  for (const query of document.rule.value) {
@@ -17,7 +18,7 @@ exports.default = (0, ml_core_1.createRule)({
17
18
  message,
18
19
  line: 1,
19
20
  col: 1,
20
- raw: document.nodeList[0].raw.slice(0, 1),
21
+ raw: (_b = (_a = document.nodeList[0]) === null || _a === void 0 ? void 0 : _a.raw.slice(0, 1)) !== null && _b !== void 0 ? _b : '',
21
22
  });
22
23
  }
23
24
  }
@@ -1,6 +1,6 @@
1
1
  export interface Options {
2
- 'expected-once': boolean;
3
- 'in-document-fragment': boolean;
2
+ 'expected-once': boolean;
3
+ 'in-document-fragment': boolean;
4
4
  }
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
5
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
6
6
  export default _default;
@@ -7,6 +7,7 @@ exports.default = (0, ml_core_1.createRule)({
7
7
  'in-document-fragment': false,
8
8
  },
9
9
  async verify({ document, report, t }) {
10
+ var _a, _b;
10
11
  const h1Stack = [];
11
12
  if (document.nodeList.length === 0) {
12
13
  return;
@@ -25,10 +26,10 @@ exports.default = (0, ml_core_1.createRule)({
25
26
  message,
26
27
  line: 1,
27
28
  col: 1,
28
- raw: document.nodeList[0].raw.slice(0, 1),
29
+ raw: (_b = (_a = document.nodeList[0]) === null || _a === void 0 ? void 0 : _a.raw.slice(0, 1)) !== null && _b !== void 0 ? _b : '',
29
30
  });
30
31
  }
31
- else if (document.rule.options['expected-once'] && h1Stack.length > 1) {
32
+ else if (document.rule.options['expected-once'] && h1Stack.length > 1 && h1Stack[1]) {
32
33
  const message = t('{0} is {1:c}', t('the "{0*}" {1}', 'h1', 'element'), 'duplicated');
33
34
  report({
34
35
  message,
@@ -1,6 +1,6 @@
1
- type Bullets = string[];
1
+ type Bullets = readonly string[];
2
2
  type Options = {
3
- spaceNeededBullets?: string[];
3
+ spaceNeededBullets?: string[];
4
4
  };
5
- declare const _default: import('@markuplint/ml-core').RuleSeed<Bullets, Options>;
5
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<Bullets, Options>>;
6
6
  export default _default;
@@ -78,15 +78,16 @@ exports.default = (0, ml_core_1.createRule)({
78
78
  },
79
79
  });
80
80
  function isMayListItem(text, bullets, spaceNeededBullets) {
81
+ var _a;
81
82
  const textArray = Array.from(text);
82
- const firstLetter = textArray[0];
83
+ const firstLetter = (_a = textArray[0]) !== null && _a !== void 0 ? _a : '';
83
84
  const isBullet = bullets.includes(firstLetter);
84
85
  const needSpace = spaceNeededBullets.includes(firstLetter);
85
86
  const continuous = firstLetter === textArray[1];
86
87
  if (continuous) {
87
88
  return false;
88
89
  }
89
- if (isBullet && needSpace) {
90
+ if (isBullet && needSpace && text[1]) {
90
91
  const secondLetter = text[1];
91
92
  const isSpace = /^\s$/.test(secondLetter);
92
93
  return isSpace;
@@ -1,10 +1,6 @@
1
1
  import type { Options } from '../types';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty } from '@markuplint/ml-spec';
4
- export declare const checkingDefaultValue: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- propSpecs: ARIAProperty[];
9
- }
10
- >;
4
+ export declare const checkingDefaultValue: AttrChecker<boolean, Options, {
5
+ propSpecs: readonly ARIAProperty[];
6
+ }>;
@@ -1,11 +1,7 @@
1
1
  import type { Options } from '../types';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
4
- export declare const checkingDeprecatedProps: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- role: ARIARole | null;
9
- propSpecs: ARIAProperty[];
10
- }
11
- >;
4
+ export declare const checkingDeprecatedProps: AttrChecker<boolean, Options, {
5
+ role: ARIARole | null;
6
+ propSpecs: readonly ARIAProperty[];
7
+ }>;
@@ -1,11 +1,7 @@
1
1
  import type { Options } from '../types';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
4
- export declare const checkingDisallowedProp: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- role: ARIARole | null;
9
- propSpecs: ARIAProperty[];
10
- }
11
- >;
4
+ export declare const checkingDisallowedProp: AttrChecker<boolean, Options, {
5
+ role: ARIARole | null;
6
+ propSpecs: readonly ARIAProperty[];
7
+ }>;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkingDisallowedProp = void 0;
4
+ const ml_spec_1 = require("@markuplint/ml-spec");
4
5
  const checkingDisallowedProp = ({ attr, role, propSpecs }) => t => {
5
- var _a;
6
+ var _a, _b, _c, _d;
6
7
  if (!role) {
7
8
  return;
8
9
  }
@@ -10,13 +11,36 @@ const checkingDisallowedProp = ({ attr, role, propSpecs }) => t => {
10
11
  return;
11
12
  }
12
13
  const statesAndProp = role.ownedProperties.find(p => p.name === attr.name);
14
+ const propSpec = propSpecs.find(p => p.name === attr.name);
15
+ const elAriaSpec = (0, ml_spec_1.getARIA)(attr.ownerMLDocument.specs, attr.ownerElement.localName, attr.ownerElement.namespaceURI, attr.rule.options.version, attr.ownerElement.matches.bind(attr.ownerElement));
16
+ if ((elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) && ((_a = elAriaSpec === null || elAriaSpec === void 0 ? void 0 : elAriaSpec.properties) === null || _a === void 0 ? void 0 : _a.without)) {
17
+ for (const ignore of elAriaSpec.properties.without) {
18
+ if (ignore.name === attr.name) {
19
+ return {
20
+ scope: attr,
21
+ message: t('{0:c} on {1}', t(ignore.type === 'must-not'
22
+ ? '{0} must not {1}'
23
+ : ignore.type === 'should-not'
24
+ ? '{0} should not {1}'
25
+ : '{0} is not recommended to {1}',
26
+ // {0}
27
+ t('the "{0*}" {1}', attr.name, `ARIA ${(_b = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _b !== void 0 ? _b : 'property'}`),
28
+ // {1}
29
+ 'use'), t('the "{0*}" {1}', attr.ownerElement.localName, 'element')) +
30
+ (ignore.alt
31
+ ? t('. ') +
32
+ t('{0} if you {1} {2}', t(ignore.alt.method === 'remove-attr' ? 'Remove {0}' : 'Add {0}', t('the "{0*}" {1}', ignore.alt.target, 'attribute')), 'use', t('the {0}', `ARIA ${(_c = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _c !== void 0 ? _c : 'property'}`))
33
+ : ''),
34
+ };
35
+ }
36
+ }
37
+ }
13
38
  if (statesAndProp) {
14
39
  return;
15
40
  }
16
- const propSpec = propSpecs.find(p => p.name === attr.name);
17
41
  return {
18
42
  scope: attr,
19
- message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0*}" {1}', attr.name, `ARIA ${(_a = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _a !== void 0 ? _a : 'property'}`), 'disallowed'), t('the "{0*}" {1}', role.name, 'role')),
43
+ message: t('{0:c} on {1}', t('{0} is {1:c}', t('the "{0*}" {1}', attr.name, `ARIA ${(_d = propSpec === null || propSpec === void 0 ? void 0 : propSpec.type) !== null && _d !== void 0 ? _d : 'property'}`), 'disallowed'), t('the "{0*}" {1}', role.name, 'role')),
20
44
  };
21
45
  };
22
46
  exports.checkingDisallowedProp = checkingDisallowedProp;
@@ -1,11 +1,7 @@
1
1
  import type { Options } from '../types';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty, Attribute } from '@markuplint/ml-spec';
4
- export declare const checkingImplicitProps: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- propSpecs: ARIAProperty[];
9
- attrSpecs: Attribute[] | null;
10
- }
11
- >;
4
+ export declare const checkingImplicitProps: AttrChecker<boolean, Options, {
5
+ propSpecs: readonly ARIAProperty[];
6
+ attrSpecs: readonly Attribute[] | null;
7
+ }>;
@@ -34,7 +34,9 @@ const checkingInteractionInHidden = ({ el }) => t => {
34
34
  };
35
35
  };
36
36
  exports.checkingInteractionInHidden = checkingInteractionInHidden;
37
- function getClosestAriaHidden(el) {
37
+ function getClosestAriaHidden(
38
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
39
+ el) {
38
40
  let current = el;
39
41
  while (current) {
40
42
  const ariaHidden = current.getAttributeNode('aria-hidden');
@@ -1,10 +1,6 @@
1
1
  import type { Options } from '../types';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty } from '@markuplint/ml-spec';
4
- export declare const checkingNoGlobalProp: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- propSpecs: ARIAProperty[];
9
- }
10
- >;
4
+ export declare const checkingNoGlobalProp: AttrChecker<boolean, Options, {
5
+ propSpecs: readonly ARIAProperty[];
6
+ }>;
@@ -46,7 +46,9 @@ const checkingPresentationalChildren = ({ el }) => t => {
46
46
  };
47
47
  };
48
48
  exports.checkingPresentationalChildren = checkingPresentationalChildren;
49
- function getAncestorHasPresentationalChildren(el) {
49
+ function getAncestorHasPresentationalChildren(
50
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
51
+ el) {
50
52
  var _a;
51
53
  let current = el.parentElement;
52
54
  while (current) {
@@ -6,10 +6,6 @@ import type { ARIARole } from '@markuplint/ml-spec';
6
6
  *
7
7
  * @see https://w3c.github.io/aria/#mustContain
8
8
  */
9
- export declare const checkingRequiredOwnedElements: ElementChecker<
10
- boolean,
11
- Options,
12
- {
13
- role?: ARIARole | null;
14
- }
15
- >;
9
+ export declare const checkingRequiredOwnedElements: ElementChecker<boolean, Options, {
10
+ role?: ARIARole | null;
11
+ }>;
@@ -34,7 +34,7 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
34
34
  return [child, 'BUSY'];
35
35
  }
36
36
  const computedChild = (0, ml_spec_1.getComputedRole)(child.ownerMLDocument.specs, child, child.rule.options.version);
37
- if (role.requiredOwnedElements.some(ownedRole => (0, ml_spec_1.isRequiredOwnedElement)(computedChild, ownedRole, child.ownerMLDocument.specs, child.rule.options.version))) {
37
+ if (role.requiredOwnedElements.some(ownedRole => (0, ml_spec_1.isRequiredOwnedElement)(computedChild.el, computedChild.role, ownedRole, child.ownerMLDocument.specs, child.rule.options.version))) {
38
38
  return [child, 'REQUIRED'];
39
39
  }
40
40
  return [child, 'OTHER'];
@@ -78,20 +78,22 @@ const checkingRequiredOwnedElements = ({ el, role }) => t => {
78
78
  if (mayBeBeforeCreated(el)) {
79
79
  return {
80
80
  scope: el,
81
- message: t('{0}. Or, {1}', t('require {0}', role.requiredOwnedElements.length === 1
81
+ message: t('{0}. Or, {1}', t('require {0}', role.requiredOwnedElements.length === 1 && role.requiredOwnedElements[0]
82
82
  ? t('the "{0*}" {1}', role.requiredOwnedElements[0], 'role')
83
83
  : t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`), t('require {0}', 'aria-busy="true"')),
84
84
  };
85
85
  }
86
86
  return {
87
87
  scope: el,
88
- message: t('{0} expects {1}', t('the "{0*}" {1}', role.name, 'role'), role.requiredOwnedElements.length === 1
88
+ message: t('{0} expects {1}', t('the "{0*}" {1}', role.name, 'role'), role.requiredOwnedElements.length === 1 && role.requiredOwnedElements[0]
89
89
  ? t('the "{0*}" {1}', role.requiredOwnedElements[0], 'role')
90
90
  : t('the {0}', 'roles') + `: ${t(role.requiredOwnedElements)}`),
91
91
  };
92
92
  };
93
93
  exports.checkingRequiredOwnedElements = checkingRequiredOwnedElements;
94
- function mayBeBeforeCreated(el) {
94
+ function mayBeBeforeCreated(
95
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly-parameter-types
96
+ el) {
95
97
  if (el.isEmpty()) {
96
98
  return true;
97
99
  }
@@ -1,15 +1,9 @@
1
1
  import type { Options } from '../types';
2
2
  import type { ElementChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
4
- export declare const checkingRequiredProp: ElementChecker<
5
- boolean,
6
- Options,
7
- {
8
- role?:
9
- | (ARIARole & {
10
- isImplicit?: boolean;
11
- })
12
- | null;
13
- propSpecs: ARIAProperty[];
14
- }
15
- >;
4
+ export declare const checkingRequiredProp: ElementChecker<boolean, Options, {
5
+ role?: (ARIARole & {
6
+ isImplicit?: boolean;
7
+ }) | null;
8
+ propSpecs: readonly ARIAProperty[];
9
+ }>;
@@ -1,17 +1,13 @@
1
1
  import type { Options } from '../types';
2
2
  import type { AttrChecker } from '@markuplint/ml-core';
3
3
  import type { ARIAProperty, ARIARole } from '@markuplint/ml-spec';
4
- export declare const checkingValue: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- role?: ARIARole | null;
9
- propSpecs: ARIAProperty[];
10
- booleanish?: boolean;
11
- }
12
- >;
4
+ export declare const checkingValue: AttrChecker<boolean, Options, {
5
+ role?: ARIARole | null;
6
+ propSpecs: readonly ARIAProperty[];
7
+ booleanish?: boolean;
8
+ }>;
13
9
  /**
14
10
  *
15
11
  * @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
16
12
  */
17
- export declare function checkAriaValue(type: string, value: string, tokenEnum: string[], booleanish?: boolean): boolean;
13
+ export declare function checkAriaValue(type: string, value: string, tokenEnum: readonly string[], booleanish?: boolean): boolean;
@@ -1,3 +1,3 @@
1
1
  import type { Options } from './types';
2
- declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
2
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, Options>>;
3
3
  export default _default;
@@ -1,13 +1,13 @@
1
1
  import type { ARIAVersion } from '@markuplint/ml-spec';
2
2
  export type Options = {
3
- checkingValue: boolean;
4
- checkingDeprecatedProps: boolean;
5
- permittedAriaRoles: boolean;
6
- checkingRequiredOwnedElements: boolean;
7
- checkingPresentationalChildren: boolean;
8
- checkingInteractionInHidden: boolean;
9
- disallowSetImplicitRole: boolean;
10
- disallowSetImplicitProps: boolean;
11
- disallowDefaultValue: boolean;
12
- version: ARIAVersion;
3
+ checkingValue: boolean;
4
+ checkingDeprecatedProps: boolean;
5
+ permittedAriaRoles: boolean;
6
+ checkingRequiredOwnedElements: boolean;
7
+ checkingPresentationalChildren: boolean;
8
+ checkingInteractionInHidden: boolean;
9
+ disallowSetImplicitRole: boolean;
10
+ disallowSetImplicitProps: boolean;
11
+ disallowDefaultValue: boolean;
12
+ version: ARIAVersion;
13
13
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/rules",
3
- "version": "3.3.1",
3
+ "version": "3.5.0",
4
4
  "description": "Built-in rules of markuplint",
5
5
  "repository": "git@github.com:markuplint/markuplint.git",
6
6
  "author": "Yusuke Hirao <yusukehirao@me.com>",
@@ -20,11 +20,11 @@
20
20
  "./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
21
21
  },
22
22
  "dependencies": {
23
- "@markuplint/html-spec": "3.3.1",
24
- "@markuplint/ml-core": "3.3.1",
25
- "@markuplint/ml-spec": "3.3.0",
26
- "@markuplint/selector": "3.3.0",
27
- "@markuplint/types": "3.2.0",
23
+ "@markuplint/html-spec": "3.5.0",
24
+ "@markuplint/ml-core": "3.5.0",
25
+ "@markuplint/ml-spec": "3.5.0",
26
+ "@markuplint/selector": "3.5.0",
27
+ "@markuplint/types": "3.4.0",
28
28
  "@ungap/structured-clone": "^1.0.1",
29
29
  "ansi-colors": "^4.1.3",
30
30
  "chrono-node": "^2.5.0",
@@ -33,7 +33,8 @@
33
33
  "tslib": "^2.4.1"
34
34
  },
35
35
  "devDependencies": {
36
- "@types/debug": "^4.1.7"
36
+ "@types/debug": "^4.1.7",
37
+ "type-fest": "^3.6.1"
37
38
  },
38
- "gitHead": "f19e7de726cf01d53342bc5513c30da75d28da63"
39
+ "gitHead": "0c47b2c2722f6823a17f36edbab98486275f8ab4"
39
40
  }