@markuplint/rules 3.3.0 → 3.4.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 (70) hide show
  1. package/lib/attr-check.d.ts +19 -8
  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 +12 -2
  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 +35 -17
  16. package/lib/id-duplication/index.d.ts +1 -1
  17. package/lib/ineffective-attr/index.d.ts +1 -1
  18. package/lib/invalid-attr/index.d.ts +17 -13
  19. package/lib/label-has-control/index.d.ts +1 -1
  20. package/lib/landmark-roles/index.d.ts +3 -3
  21. package/lib/no-boolean-attr-value/index.d.ts +1 -1
  22. package/lib/no-default-value/index.d.ts +1 -1
  23. package/lib/no-empty-palpable-content/index.d.ts +3 -3
  24. package/lib/no-hard-code-id/index.d.ts +1 -1
  25. package/lib/no-refer-to-non-existent-id/index.d.ts +7 -4
  26. package/lib/no-refer-to-non-existent-id/index.js +4 -0
  27. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  28. package/lib/permitted-contents/choice.d.ts +7 -1
  29. package/lib/permitted-contents/complex-branch.d.ts +7 -1
  30. package/lib/permitted-contents/count-pattern.d.ts +17 -2
  31. package/lib/permitted-contents/count-pattern.js +2 -1
  32. package/lib/permitted-contents/debug.browser.d.ts +15 -15
  33. package/lib/permitted-contents/debug.d.ts +1 -1
  34. package/lib/permitted-contents/index.d.ts +1 -1
  35. package/lib/permitted-contents/matches-selector.d.ts +7 -1
  36. package/lib/permitted-contents/order.d.ts +7 -1
  37. package/lib/permitted-contents/order.js +1 -1
  38. package/lib/permitted-contents/recursive-branch.d.ts +7 -1
  39. package/lib/permitted-contents/represent-transparent-nodes.d.ts +7 -3
  40. package/lib/permitted-contents/start.d.ts +6 -1
  41. package/lib/permitted-contents/transparent.js +2 -2
  42. package/lib/permitted-contents/types.d.ts +29 -29
  43. package/lib/permitted-contents/utils.d.ts +72 -35
  44. package/lib/permitted-contents/utils.js +1 -1
  45. package/lib/placeholder-label-option/index.d.ts +1 -1
  46. package/lib/require-accessible-name/index.d.ts +2 -2
  47. package/lib/require-datetime/index.d.ts +2 -2
  48. package/lib/require-datetime/types.d.ts +2 -2
  49. package/lib/require-datetime/utils.js +3 -1
  50. package/lib/required-attr/index.d.ts +3 -3
  51. package/lib/required-attr/index.js +13 -10
  52. package/lib/required-element/index.d.ts +2 -2
  53. package/lib/required-element/index.js +2 -1
  54. package/lib/required-h1/index.d.ts +3 -3
  55. package/lib/required-h1/index.js +3 -2
  56. package/lib/use-list/index.d.ts +2 -2
  57. package/lib/use-list/index.js +3 -2
  58. package/lib/wai-aria/checkings/default-value.d.ts +7 -3
  59. package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
  60. package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
  61. package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
  62. package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
  63. package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
  64. package/lib/wai-aria/checkings/required-owned-elements.d.ts +7 -3
  65. package/lib/wai-aria/checkings/required-owned-elements.js +2 -2
  66. package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
  67. package/lib/wai-aria/checkings/value.d.ts +9 -5
  68. package/lib/wai-aria/index.d.ts +1 -1
  69. package/lib/wai-aria/types.d.ts +10 -10
  70. package/package.json +8 -6
@@ -3,49 +3,49 @@ import type { ContentModel, MLMLSpec } from '@markuplint/ml-spec';
3
3
  export type Element = _Element<TagRule[], Options>;
4
4
  export type ChildNode = _ChildNode<TagRule[], Options>;
5
5
  export type Specs = {
6
- cites: MLMLSpec['cites'];
7
- def: MLMLSpec['def'];
8
- specs: {
9
- name: string;
10
- contentModel: {
11
- contents: MLMLSpec['specs'][0]['contentModel']['contents'];
12
- };
13
- }[];
6
+ cites: MLMLSpec['cites'];
7
+ def: MLMLSpec['def'];
8
+ specs: {
9
+ name: string;
10
+ contentModel: {
11
+ contents: MLMLSpec['specs'][0]['contentModel']['contents'];
12
+ };
13
+ }[];
14
14
  };
15
15
  export type ContentModelResult = {
16
- type: MatchedReason | UnmatchedReason;
17
- scope: ChildNode;
18
- query: Result['query'];
19
- hint: Result['hint'];
16
+ type: MatchedReason | UnmatchedReason;
17
+ scope: ChildNode;
18
+ query: Result['query'];
19
+ hint: Result['hint'];
20
20
  };
21
21
  export type Result<T extends string = MatchedReason> = {
22
- type: MatchedReason | UnmatchedReason | T;
23
- matched: ChildNode[];
24
- unmatched: ChildNode[];
25
- zeroMatch: boolean;
26
- query: string;
27
- hint: Hints;
22
+ type: MatchedReason | UnmatchedReason | T;
23
+ matched: ChildNode[];
24
+ unmatched: ChildNode[];
25
+ zeroMatch: boolean;
26
+ query: string;
27
+ hint: Hints;
28
28
  };
29
29
  export type Hints = {
30
- max?: number;
31
- not?: ChildNode;
32
- transparent?: Element;
33
- missing?: {
34
- barelyMatchedElements?: number;
35
- need?: string;
36
- };
30
+ max?: number;
31
+ not?: ChildNode;
32
+ transparent?: Element;
33
+ missing?: {
34
+ barelyMatchedElements?: number;
35
+ need?: string;
36
+ };
37
37
  };
38
38
  export type MatchedReason = 'MATCHED' | 'MATCHED_ZERO';
39
39
  export type UnmatchedReason = 'NOTHING' | 'UNEXPECTED_EXTRA_NODE' | 'TRANSPARENT_MODEL_DISALLOWS' | MissingNodeReason;
40
40
  export type MissingNodeReason = 'MISSING_NODE_REQUIRED' | 'MISSING_NODE_ONE_OR_MORE';
41
41
  export type RepeatSign = '' | '?' | '+' | '*' | `{${number},${number}}`;
42
42
  export type TransparentModel = {
43
- el: Element;
44
- additionalCondition: string;
43
+ el: Element;
44
+ additionalCondition: string;
45
45
  };
46
46
  export type TagRule = {
47
- tag: string;
47
+ tag: string;
48
48
  } & ContentModel;
49
49
  export type Options = {
50
- ignoreHasMutableChildren: boolean;
50
+ ignoreHasMutableChildren: boolean;
51
51
  };
@@ -1,50 +1,87 @@
1
1
  import type { ChildNode, Element, Hints, MissingNodeReason, RepeatSign, Specs } from './types';
2
- import type { PermittedContentPattern, PermittedContentChoice, PermittedContentOneOrMore, PermittedContentOptional, PermittedContentRequire, PermittedContentTransparent, PermittedContentZeroOrMore, Model } from '@markuplint/ml-spec';
2
+ import type {
3
+ PermittedContentPattern,
4
+ PermittedContentChoice,
5
+ PermittedContentOneOrMore,
6
+ PermittedContentOptional,
7
+ PermittedContentRequire,
8
+ PermittedContentTransparent,
9
+ PermittedContentZeroOrMore,
10
+ Model,
11
+ } from '@markuplint/ml-spec';
3
12
  export declare function getChildNodesWithoutWhitespaces(el: Element): ChildNode[];
4
13
  export declare function isModel(model: Model | PermittedContentPattern[]): model is Model;
5
- export declare function matches(selector: string, node: ChildNode, specs: Specs): {
6
- matched: boolean;
7
- not?: undefined;
8
- } | {
9
- matched: boolean;
10
- not: ChildNode | undefined;
11
- };
14
+ export declare function matches(
15
+ selector: string,
16
+ node: ChildNode,
17
+ specs: Specs,
18
+ ):
19
+ | {
20
+ matched: boolean;
21
+ not?: undefined;
22
+ }
23
+ | {
24
+ matched: boolean;
25
+ not: ChildNode | undefined;
26
+ };
12
27
  export declare function isRequire(content: PermittedContentPattern): content is PermittedContentRequire;
13
28
  export declare function isOptional(content: PermittedContentPattern): content is PermittedContentOptional;
14
29
  export declare function isOneOrMore(content: PermittedContentPattern): content is PermittedContentOneOrMore;
15
30
  export declare function isZeroOrMore(content: PermittedContentPattern): content is PermittedContentZeroOrMore;
16
31
  export declare function isChoice(content: PermittedContentPattern): content is PermittedContentChoice;
17
32
  export declare function isTransparent(content: PermittedContentPattern): content is PermittedContentTransparent;
18
- export declare function normalizeModel(pattern: PermittedContentRequire | PermittedContentOptional | PermittedContentOneOrMore | PermittedContentZeroOrMore): {
19
- model: PermittedContentPattern[] | Model;
20
- min: number;
21
- max: number;
22
- repeat: RepeatSign;
23
- missingType: MissingNodeReason | undefined;
33
+ export declare function normalizeModel(
34
+ pattern:
35
+ | PermittedContentRequire
36
+ | PermittedContentOptional
37
+ | PermittedContentOneOrMore
38
+ | PermittedContentZeroOrMore,
39
+ ): {
40
+ model: PermittedContentPattern[] | Model;
41
+ min: number;
42
+ max: number;
43
+ repeat: RepeatSign;
44
+ missingType: MissingNodeReason | undefined;
24
45
  };
25
- export declare function mergeHints(a: Hints, b: Hints): Partial<{
26
- missing: Partial<{
27
- barelyMatchedElements?: number | undefined;
28
- need?: string | undefined;
29
- }> | undefined;
30
- max?: number | undefined;
31
- not?: import("packages/@markuplint/ml-core/lib").DocumentType<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib/ml-dom/node/character-data").MLCharacterData<import("./types").TagRule[], import("./types").Options, import("packages/@markuplint/ml-ast/lib").MLASTAbstractNode> | import("packages/@markuplint/ml-core/lib").Element<import("./types").TagRule[], import("./types").Options> | import("packages/@markuplint/ml-core/lib").Block<import("./types").TagRule[], import("./types").Options> | undefined;
32
- transparent?: Element | undefined;
46
+ export declare function mergeHints(
47
+ a: Hints,
48
+ b: Hints,
49
+ ): Partial<{
50
+ missing:
51
+ | Partial<{
52
+ barelyMatchedElements?: number | undefined;
53
+ need?: string | undefined;
54
+ }>
55
+ | undefined;
56
+ max?: number | undefined;
57
+ not?:
58
+ | import('packages/@markuplint/ml-core/lib').DocumentType<
59
+ import('./types').TagRule[],
60
+ import('./types').Options
61
+ >
62
+ | import('packages/@markuplint/ml-core/lib/ml-dom/node/character-data').MLCharacterData<
63
+ import('./types').TagRule[],
64
+ import('./types').Options,
65
+ import('packages/@markuplint/ml-ast/lib').MLASTAbstractNode
66
+ >
67
+ | import('packages/@markuplint/ml-core/lib').Element<import('./types').TagRule[], import('./types').Options>
68
+ | import('packages/@markuplint/ml-core/lib').Block<import('./types').TagRule[], import('./types').Options>
69
+ | undefined;
70
+ transparent?: Element | undefined;
33
71
  }>;
34
72
  export declare function cleanObject<T extends Object>(object: T): Partial<T>;
35
73
  export declare class Collection {
36
- #private;
37
- constructor(origin: readonly ChildNode[]);
38
- get matched(): ChildNode[];
39
- get matchedCount(): number;
40
- get nodes(): ChildNode[];
41
- get unmatched(): ChildNode[];
42
- addMatched(nodes: ChildNode[]): boolean;
43
- back(): void;
44
- lock(): void;
45
- max(max: number): void;
46
- toString(highlightExtraNodes?: boolean): string;
47
- }
48
- export declare class UnsupportedError extends Error {
74
+ #private;
75
+ constructor(origin: readonly ChildNode[]);
76
+ get matched(): ChildNode[];
77
+ get matchedCount(): number;
78
+ get nodes(): ChildNode[];
79
+ get unmatched(): ChildNode[];
80
+ addMatched(nodes: ChildNode[]): boolean;
81
+ back(): void;
82
+ lock(): void;
83
+ max(max: number): void;
84
+ toString(highlightExtraNodes?: boolean): string;
49
85
  }
86
+ export declare class UnsupportedError extends Error {}
50
87
  export declare function modelLog(model: Model | PermittedContentPattern[], repeat: RepeatSign): string;
@@ -268,7 +268,7 @@ function modelLog(model, repeat) {
268
268
  }
269
269
  exports.modelLog = modelLog;
270
270
  function orderLog(order, repeat) {
271
- return order.length === 1
271
+ return order.length === 1 && order[0]
272
272
  ? markRepeat(patternLog(order[0]), repeat)
273
273
  : markRepeat(order.map(pattern => patternLog(pattern)).join(''), repeat);
274
274
  }
@@ -1,2 +1,2 @@
1
- declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, null>;
1
+ declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, null>;
2
2
  export default _default;
@@ -1,6 +1,6 @@
1
1
  import type { ARIAVersion } from '@markuplint/ml-spec';
2
2
  type Option = {
3
- ariaVersion: ARIAVersion;
3
+ ariaVersion: ARIAVersion;
4
4
  };
5
- declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, Option>;
5
+ declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, Option>;
6
6
  export default _default;
@@ -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: 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
@@ -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: import('@markuplint/ml-core').RuleSeed<RequiredAttributes, null>;
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
  }
@@ -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: 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: 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
1
  type Bullets = 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: 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,6 +1,10 @@
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<boolean, Options, {
5
- propSpecs: ARIAProperty[];
6
- }>;
4
+ export declare const checkingDefaultValue: AttrChecker<
5
+ boolean,
6
+ Options,
7
+ {
8
+ propSpecs: ARIAProperty[];
9
+ }
10
+ >;
@@ -1,7 +1,11 @@
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<boolean, Options, {
5
- role: ARIARole | null;
6
- propSpecs: ARIAProperty[];
7
- }>;
4
+ export declare const checkingDeprecatedProps: AttrChecker<
5
+ boolean,
6
+ Options,
7
+ {
8
+ role: ARIARole | null;
9
+ propSpecs: ARIAProperty[];
10
+ }
11
+ >;
@@ -1,7 +1,11 @@
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<boolean, Options, {
5
- role: ARIARole | null;
6
- propSpecs: ARIAProperty[];
7
- }>;
4
+ export declare const checkingDisallowedProp: AttrChecker<
5
+ boolean,
6
+ Options,
7
+ {
8
+ role: ARIARole | null;
9
+ propSpecs: ARIAProperty[];
10
+ }
11
+ >;
@@ -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,7 +1,11 @@
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<boolean, Options, {
5
- propSpecs: ARIAProperty[];
6
- attrSpecs: Attribute[] | null;
7
- }>;
4
+ export declare const checkingImplicitProps: AttrChecker<
5
+ boolean,
6
+ Options,
7
+ {
8
+ propSpecs: ARIAProperty[];
9
+ attrSpecs: Attribute[] | null;
10
+ }
11
+ >;
@@ -1,6 +1,10 @@
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<boolean, Options, {
5
- propSpecs: ARIAProperty[];
6
- }>;
4
+ export declare const checkingNoGlobalProp: AttrChecker<
5
+ boolean,
6
+ Options,
7
+ {
8
+ propSpecs: ARIAProperty[];
9
+ }
10
+ >;
@@ -6,6 +6,10 @@ 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<boolean, Options, {
10
- role?: ARIARole | null;
11
- }>;
9
+ export declare const checkingRequiredOwnedElements: ElementChecker<
10
+ boolean,
11
+ Options,
12
+ {
13
+ role?: ARIARole | null;
14
+ }
15
+ >;
@@ -78,14 +78,14 @@ 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
  };
@@ -1,9 +1,15 @@
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<boolean, Options, {
5
- role?: (ARIARole & {
6
- isImplicit?: boolean;
7
- }) | null;
8
- propSpecs: ARIAProperty[];
9
- }>;
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
+ >;
@@ -1,11 +1,15 @@
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<boolean, Options, {
5
- role?: ARIARole | null;
6
- propSpecs: ARIAProperty[];
7
- booleanish?: boolean;
8
- }>;
4
+ export declare const checkingValue: AttrChecker<
5
+ boolean,
6
+ Options,
7
+ {
8
+ role?: ARIARole | null;
9
+ propSpecs: ARIAProperty[];
10
+ booleanish?: boolean;
11
+ }
12
+ >;
9
13
  /**
10
14
  *
11
15
  * @see https://www.w3.org/TR/wai-aria-1.2/#propcharacteristic_value
@@ -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: import('@markuplint/ml-core').RuleSeed<boolean, Options>;
3
3
  export default _default;