@markuplint/rules 3.8.0 → 3.10.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 (103) hide show
  1. package/lib/attr-duplication/index.d.ts +1 -3
  2. package/lib/attr-value-quotes/index.d.ts +2 -2
  3. package/lib/case-sensitive-attr-name/index.d.ts +1 -1
  4. package/lib/case-sensitive-tag-name/index.d.ts +1 -1
  5. package/lib/character-reference/index.d.ts +1 -1
  6. package/lib/class-naming/index.d.ts +1 -1
  7. package/lib/create-message.d.ts +2 -12
  8. package/lib/deprecated-attr/index.d.ts +1 -3
  9. package/lib/deprecated-element/index.d.ts +1 -3
  10. package/lib/disallowed-element/index.d.ts +1 -1
  11. package/lib/doctype/index.d.ts +2 -2
  12. package/lib/end-tag/index.d.ts +1 -1
  13. package/lib/helpers.d.ts +18 -39
  14. package/lib/id-duplication/index.d.ts +1 -3
  15. package/lib/index.d.ts +7 -7
  16. package/lib/ineffective-attr/index.d.ts +1 -3
  17. package/lib/invalid-attr/index.d.ts +31 -38
  18. package/lib/label-has-control/index.d.ts +1 -3
  19. package/lib/landmark-roles/index.d.ts +3 -3
  20. package/lib/no-boolean-attr-value/index.d.ts +1 -3
  21. package/lib/no-default-value/index.d.ts +1 -3
  22. package/lib/no-empty-palpable-content/index.d.ts +3 -3
  23. package/lib/no-hard-code-id/index.d.ts +1 -3
  24. package/lib/no-refer-to-non-existent-id/index.d.ts +4 -9
  25. package/lib/no-use-event-handler-attr/index.d.ts +2 -2
  26. package/lib/permitted-contents/choice.d.ts +1 -7
  27. package/lib/permitted-contents/complex-branch.d.ts +1 -7
  28. package/lib/permitted-contents/count-pattern.d.ts +2 -17
  29. package/lib/permitted-contents/debug.browser.d.ts +15 -15
  30. package/lib/permitted-contents/debug.d.ts +1 -1
  31. package/lib/permitted-contents/index.d.ts +1 -1
  32. package/lib/permitted-contents/matches-selector.d.ts +1 -6
  33. package/lib/permitted-contents/order.d.ts +1 -7
  34. package/lib/permitted-contents/recursive-branch.d.ts +1 -7
  35. package/lib/permitted-contents/represent-transparent-nodes.d.ts +3 -7
  36. package/lib/permitted-contents/start.d.ts +1 -6
  37. package/lib/permitted-contents/types.d.ts +29 -29
  38. package/lib/permitted-contents/utils.d.ts +1 -1
  39. package/lib/placeholder-label-option/index.d.ts +1 -1
  40. package/lib/require-accessible-name/index.d.ts +2 -2
  41. package/lib/require-datetime/index.d.ts +2 -2
  42. package/lib/require-datetime/types.d.ts +2 -2
  43. package/lib/required-attr/index.d.ts +3 -3
  44. package/lib/required-element/index.d.ts +2 -2
  45. package/lib/required-h1/index.d.ts +3 -3
  46. package/lib/use-list/index.d.ts +2 -2
  47. package/lib/wai-aria/checkings/_.d.ts +12 -6
  48. package/lib/wai-aria/checkings/default-value.d.ts +3 -7
  49. package/lib/wai-aria/checkings/deprecated-props.d.ts +4 -8
  50. package/lib/wai-aria/checkings/implicit-props.d.ts +4 -8
  51. package/lib/wai-aria/checkings/no-global-prop.d.ts +3 -7
  52. package/lib/wai-aria/checkings/required-owned-elements.d.ts +3 -7
  53. package/lib/wai-aria/checkings/required-prop copy.d.ts +12 -6
  54. package/lib/wai-aria/checkings/required-prop.d.ts +6 -12
  55. package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +12 -6
  56. package/lib/wai-aria/checkings/value.d.ts +6 -15
  57. package/lib/wai-aria/index.d.ts +1 -1
  58. package/lib/wai-aria/types.d.ts +10 -10
  59. package/lib/xxx/index.d.ts +2 -0
  60. package/lib/xxx/index.js +32 -0
  61. package/package.json +13 -15
  62. package/test/attr-check.spec.js +77 -0
  63. package/test/attr-duplication/index.spec.js +159 -0
  64. package/test/attr-value-quotes/index.spec.js +133 -0
  65. package/test/case-sensitive-attr-name/index.spec.js +65 -0
  66. package/test/case-sensitive-tag-name/index.spec.js +80 -0
  67. package/test/character-reference/index.spec.js +57 -0
  68. package/test/class-naming/index.spec.js +470 -0
  69. package/test/create-message.spec.js +497 -0
  70. package/test/deprecated-attr/index.spec.js +48 -0
  71. package/test/deprecated-element/index.spec.js +48 -0
  72. package/test/disallowed-element/index.spec.js +90 -0
  73. package/test/doctype/index.spec.js +50 -0
  74. package/test/end-tag/index.spec.js +162 -0
  75. package/test/id-duplication/index.spec.js +47 -0
  76. package/test/ineffective-attr/index.spec.js +31 -0
  77. package/test/invalid-attr/index.spec.js +1632 -0
  78. package/test/label-has-control/index.spec.js +29 -0
  79. package/test/landmark-roles/index.spec.js +187 -0
  80. package/test/no-boolean-attr-value/index.spec.js +41 -0
  81. package/test/no-default-value/index.spec.js +74 -0
  82. package/test/no-empty-palpable-content/index.spec.js +115 -0
  83. package/test/no-hard-code-id/index.spec.js +100 -0
  84. package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
  85. package/test/no-use-event-handler-attr/index.spec.js +57 -0
  86. package/test/permitted-contents/choice.spec.js +174 -0
  87. package/test/permitted-contents/count-pattern.spec.js +308 -0
  88. package/test/permitted-contents/index.spec.js +1371 -0
  89. package/test/permitted-contents/matches-selector.spec.js +59 -0
  90. package/test/permitted-contents/order.spec.js +351 -0
  91. package/test/permitted-contents/recursive-branch.spec.js +41 -0
  92. package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
  93. package/test/permitted-contents/start.spec.js +67 -0
  94. package/test/placeholder-label-option/index.spec.js +113 -0
  95. package/test/require-accessible-name/index.spec.js +446 -0
  96. package/test/require-datetime/index.spec.js +54 -0
  97. package/test/require-datetime/utils.spec.js +52 -0
  98. package/test/required-attr/index.spec.js +414 -0
  99. package/test/required-element/index.spec.js +188 -0
  100. package/test/required-h1/index.spec.js +69 -0
  101. package/test/use-list/index.spec.js +109 -0
  102. package/test/wai-aria/checkings/value.spec.js +33 -0
  103. package/test/wai-aria/index.spec.js +1173 -0
@@ -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
  };
@@ -29,7 +29,7 @@ export declare function mergeHints(a: Readonly<Hints>, b: Readonly<Hints>): Part
29
29
  need?: string | undefined;
30
30
  }> | undefined;
31
31
  max?: number | undefined;
32
- 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/src").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
+ 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;
33
33
  transparent?: Element | undefined;
34
34
  }>;
35
35
  export declare function cleanObject<T extends Object>(object: T): Partial<T>;
@@ -1,2 +1,2 @@
1
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
1
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<boolean, undefined>>;
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: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, Option>>;
5
+ declare const _default: Readonly<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: 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,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
@@ -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: Readonly<import('@markuplint/ml-core').RuleSeed<RequiredAttributes, undefined>>;
6
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<RequiredAttributes, undefined>>;
7
7
  export default _default;
@@ -1,5 +1,5 @@
1
1
  type Options = {
2
- ignoreHasMutableContents: boolean;
2
+ ignoreHasMutableContents: boolean;
3
3
  };
4
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<string[], Options>>;
4
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<string[], Options>>;
5
5
  export default _default;
@@ -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: 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,6 +1,6 @@
1
1
  type Bullets = readonly string[];
2
2
  type Options = {
3
- spaceNeededBullets?: string[];
3
+ spaceNeededBullets?: string[];
4
4
  };
5
- declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Bullets, Options>>;
5
+ declare const _default: Readonly<import("@markuplint/ml-core").RuleSeed<Bullets, Options>>;
6
6
  export default _default;
@@ -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: readonly 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: readonly ARIAProperty[];
14
+ }
15
+ >;
@@ -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: readonly 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: readonly 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, Attribute } from '@markuplint/ml-spec';
4
- export declare const checkingImplicitProps: AttrChecker<
5
- boolean,
6
- Options,
7
- {
8
- propSpecs: readonly ARIAProperty[];
9
- attrSpecs: readonly Attribute[] | null;
10
- }
11
- >;
4
+ export declare const checkingImplicitProps: AttrChecker<boolean, Options, {
5
+ propSpecs: readonly ARIAProperty[];
6
+ attrSpecs: readonly Attribute[] | null;
7
+ }>;
@@ -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: readonly ARIAProperty[];
9
- }
10
- >;
4
+ export declare const checkingNoGlobalProp: AttrChecker<boolean, Options, {
5
+ propSpecs: readonly ARIAProperty[];
6
+ }>;
@@ -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
+ }>;
@@ -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: readonly 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: readonly ARIAProperty[];
14
+ }
15
+ >;
@@ -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: readonly 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,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 checkingUnadoptedExplicitRoles: ElementChecker<boolean, Options, {
5
- role?: (ARIARole & {
6
- isImplicit?: boolean;
7
- }) | null;
8
- propSpecs: readonly ARIAProperty[];
9
- }>;
4
+ export declare const checkingUnadoptedExplicitRoles: ElementChecker<
5
+ boolean,
6
+ Options,
7
+ {
8
+ role?:
9
+ | (ARIARole & {
10
+ isImplicit?: boolean;
11
+ })
12
+ | null;
13
+ propSpecs: readonly ARIAProperty[];
14
+ }
15
+ >;
@@ -1,22 +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: readonly 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(
18
- type: string,
19
- value: string,
20
- tokenEnum: readonly string[],
21
- booleanish?: boolean,
22
- ): 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: Readonly<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
  };
@@ -0,0 +1,2 @@
1
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, null>>;
2
+ export default _default;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ml_core_1 = require("@markuplint/ml-core");
4
+ exports.default = (0, ml_core_1.createRule)({
5
+ defaultValue: true,
6
+ defaultOptions: null,
7
+ async verify({ document, report, t }) {
8
+ // Element
9
+ await document.walkOn("Element", (el) => {
10
+ const raw = el.raw.trim();
11
+ if (/./i.test(raw)) {
12
+ report({
13
+ scope: el,
14
+ message: t("It is {0}", "issue"),
15
+ });
16
+ }
17
+ });
18
+ // Attribute
19
+ await document.walkOn("Attr", (attr) => {
20
+ var _a, _b, _c;
21
+ if (/./i.test(attr.name)) {
22
+ report({
23
+ scope: attr,
24
+ line: (_a = attr.nameNode) === null || _a === void 0 ? void 0 : _a.startLine,
25
+ col: (_b = attr.nameNode) === null || _b === void 0 ? void 0 : _b.startCol,
26
+ raw: (_c = attr.nameNode) === null || _c === void 0 ? void 0 : _c.raw,
27
+ message: t("It is {0}", "issue"),
28
+ });
29
+ }
30
+ });
31
+ },
32
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@markuplint/rules",
3
- "version": "3.8.0",
3
+ "version": "3.10.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,21 +20,19 @@
20
20
  "./lib/permitted-contents/debug.js": "./lib/permitted-contents/debug.browser.js"
21
21
  },
22
22
  "dependencies": {
23
- "@markuplint/html-spec": "3.7.0",
24
- "@markuplint/ml-core": "3.8.0",
25
- "@markuplint/ml-spec": "3.7.0",
26
- "@markuplint/selector": "3.7.0",
27
- "@markuplint/shared": "3.5.0",
28
- "@markuplint/types": "3.5.1",
29
- "@ungap/structured-clone": "^1.0.1",
23
+ "@markuplint/html-spec": "3.9.0",
24
+ "@markuplint/ml-core": "3.10.0",
25
+ "@markuplint/ml-spec": "3.9.0",
26
+ "@markuplint/selector": "3.9.0",
27
+ "@markuplint/shared": "3.6.0",
28
+ "@markuplint/types": "3.7.0",
29
+ "@types/debug": "^4.1.7",
30
+ "@ungap/structured-clone": "^1.2.0",
30
31
  "ansi-colors": "^4.1.3",
31
- "chrono-node": "^2.5.0",
32
+ "chrono-node": "^2.6.3",
32
33
  "debug": "^4.3.4",
33
- "tslib": "^2.4.1"
34
- },
35
- "devDependencies": {
36
- "@types/debug": "^4.1.7",
37
- "type-fest": "^3.6.1"
34
+ "tslib": "^2.5.0",
35
+ "type-fest": "^3.10.0"
38
36
  },
39
- "gitHead": "42b97b47d22b37437024e693a72a458e2963e261"
37
+ "gitHead": "af370797bfc887e5a5a2ff57fbaa8392ac98ead2"
40
38
  }
@@ -0,0 +1,77 @@
1
+ const { translator } = require('@markuplint/i18n');
2
+ const { i18n } = require('markuplint');
3
+
4
+ const { valueCheck } = require('../lib/attr-check');
5
+
6
+ let t;
7
+
8
+ beforeAll(async () => {
9
+ const locale = await i18n('en');
10
+ t = translator(locale);
11
+ });
12
+
13
+ test('OneCodePointChar List', () => {
14
+ expect(
15
+ valueCheck(t, 'accesskey', '@ 12', {
16
+ token: 'OneCodePointChar',
17
+ separator: 'space',
18
+ unique: true,
19
+ }),
20
+ ).toStrictEqual([
21
+ 'the "accesskey" attribute expects space-separated list. the the content of the list part includes unexpected characters. It expects one code point character (https://html.spec.whatwg.org/multipage/interaction.html#the-accesskey-attribute)',
22
+ {
23
+ col: 2,
24
+ line: 0,
25
+ raw: '12',
26
+ },
27
+ ]);
28
+ });
29
+
30
+ test('BrowsingContextNameOrKeyword', () => {
31
+ expect(valueCheck(t, 'target', '', 'BrowsingContextNameOrKeyword')).toStrictEqual([
32
+ 'the "target" attribute must not be empty. It expects either "_blank", "_self", "_parent", "_top", "browsing context name" (https://html.spec.whatwg.org/multipage/browsers.html#valid-browsing-context-name-or-keyword)',
33
+ {
34
+ col: 0,
35
+ line: 0,
36
+ raw: '',
37
+ },
38
+ ]);
39
+ });
40
+
41
+ test('BCP47', () => {
42
+ expect(valueCheck(t, 'lang', '', 'BCP47')).toStrictEqual([
43
+ 'the "lang" attribute must not be empty. It expects the BCP47 format (https://tools.ietf.org/rfc/bcp/bcp47.html)',
44
+ {
45
+ col: 0,
46
+ line: 0,
47
+ raw: '',
48
+ },
49
+ ]);
50
+ });
51
+
52
+ test('DateTime', () => {
53
+ expect(valueCheck(t, 'datetime', '200-1-1', 'DateTime')).toStrictEqual([
54
+ 'the year part of the "datetime" attribute expects four or more digits (https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value)',
55
+ {
56
+ col: 0,
57
+ line: 0,
58
+ raw: '200',
59
+ },
60
+ ]);
61
+ expect(valueCheck(t, 'datetime', '2000-1-1', 'DateTime')).toStrictEqual([
62
+ 'the month part of the "datetime" attribute expects two digits (https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value)',
63
+ {
64
+ col: 5,
65
+ line: 0,
66
+ raw: '1',
67
+ },
68
+ ]);
69
+ expect(valueCheck(t, 'datetime', '00:00:00.0000', 'DateTime')).toStrictEqual([
70
+ 'the fractional part part of the "datetime" attribute expects one to three digits (https://html.spec.whatwg.org/multipage/text-level-semantics.html#datetime-value)',
71
+ {
72
+ col: 9,
73
+ line: 0,
74
+ raw: '0000',
75
+ },
76
+ ]);
77
+ });