@markuplint/rules 3.0.0-alpha.66 → 3.0.0-dev.176

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 (211) hide show
  1. package/README.md +10 -44
  2. package/lib/attr-check.d.ts +22 -10
  3. package/lib/attr-check.js +32 -23
  4. package/lib/attr-duplication/index.d.ts +3 -1
  5. package/lib/attr-duplication/index.js +3 -2
  6. package/lib/attr-value-quotes/index.d.ts +5 -5
  7. package/lib/attr-value-quotes/index.js +1 -1
  8. package/lib/case-sensitive-attr-name/index.d.ts +2 -2
  9. package/lib/case-sensitive-attr-name/index.js +3 -3
  10. package/lib/case-sensitive-tag-name/index.d.ts +2 -2
  11. package/lib/case-sensitive-tag-name/index.js +3 -3
  12. package/lib/character-reference/index.d.ts +1 -1
  13. package/lib/character-reference/index.js +1 -1
  14. package/lib/class-naming/index.d.ts +2 -2
  15. package/lib/class-naming/index.js +3 -5
  16. package/lib/create-message.d.ts +13 -2
  17. package/lib/create-message.js +9 -8
  18. package/lib/debug.d.ts +1 -1
  19. package/lib/debug.js +1 -1
  20. package/lib/deprecated-attr/index.d.ts +3 -1
  21. package/lib/deprecated-element/index.d.ts +3 -1
  22. package/lib/deprecated-element/index.js +4 -4
  23. package/lib/disallowed-element/index.d.ts +1 -1
  24. package/lib/doctype/index.d.ts +3 -3
  25. package/lib/doctype/index.js +2 -2
  26. package/lib/end-tag/index.d.ts +1 -1
  27. package/lib/end-tag/index.js +3 -18
  28. package/lib/helpers.d.ts +38 -47
  29. package/lib/helpers.js +42 -93
  30. package/lib/id-duplication/index.d.ts +3 -1
  31. package/lib/index.d.ts +242 -62
  32. package/lib/index.js +10 -1
  33. package/lib/ineffective-attr/index.d.ts +3 -1
  34. package/lib/ineffective-attr/index.js +3 -6
  35. package/lib/invalid-attr/index.d.ts +40 -12
  36. package/lib/invalid-attr/index.js +159 -28
  37. package/lib/label-has-control/index.d.ts +4 -0
  38. package/lib/label-has-control/index.js +28 -0
  39. package/lib/landmark-roles/index.d.ts +6 -6
  40. package/lib/landmark-roles/index.js +10 -6
  41. package/lib/no-boolean-attr-value/index.d.ts +3 -1
  42. package/lib/no-boolean-attr-value/index.js +1 -1
  43. package/lib/no-default-value/index.d.ts +3 -1
  44. package/lib/no-default-value/index.js +1 -1
  45. package/lib/no-empty-palpable-content/index.d.ts +6 -0
  46. package/lib/no-empty-palpable-content/index.js +42 -0
  47. package/lib/no-hard-code-id/index.d.ts +3 -1
  48. package/lib/no-hard-code-id/index.js +1 -1
  49. package/lib/no-refer-to-non-existent-id/index.d.ts +9 -4
  50. package/lib/no-refer-to-non-existent-id/index.js +65 -5
  51. package/lib/no-use-event-handler-attr/index.d.ts +3 -3
  52. package/lib/no-use-event-handler-attr/index.js +6 -6
  53. package/lib/permitted-contents/choice.d.ts +10 -0
  54. package/lib/permitted-contents/choice.js +72 -0
  55. package/lib/permitted-contents/complex-branch.d.ts +20 -0
  56. package/lib/permitted-contents/complex-branch.js +29 -0
  57. package/lib/permitted-contents/content-model.d.ts +2 -0
  58. package/lib/permitted-contents/content-model.js +53 -0
  59. package/lib/permitted-contents/count-pattern.d.ts +29 -0
  60. package/lib/permitted-contents/count-pattern.js +162 -0
  61. package/lib/permitted-contents/debug.browser.d.ts +30 -0
  62. package/lib/permitted-contents/debug.browser.js +14 -0
  63. package/lib/permitted-contents/debug.d.ts +3 -0
  64. package/lib/permitted-contents/debug.js +13 -0
  65. package/lib/permitted-contents/index.d.ts +2 -8
  66. package/lib/permitted-contents/index.js +76 -249
  67. package/lib/permitted-contents/matches-selector.d.ts +8 -0
  68. package/lib/permitted-contents/matches-selector.js +187 -0
  69. package/lib/permitted-contents/order.d.ts +20 -0
  70. package/lib/permitted-contents/order.js +99 -0
  71. package/lib/permitted-contents/recursive-branch.d.ts +11 -0
  72. package/lib/permitted-contents/recursive-branch.js +45 -0
  73. package/lib/permitted-contents/represent-transparent-nodes.d.ts +10 -0
  74. package/lib/permitted-contents/represent-transparent-nodes.js +78 -0
  75. package/lib/permitted-contents/start.d.ts +18 -0
  76. package/lib/permitted-contents/start.js +73 -0
  77. package/lib/permitted-contents/transparent.d.ts +2 -0
  78. package/lib/permitted-contents/transparent.js +31 -0
  79. package/lib/permitted-contents/types.d.ts +52 -0
  80. package/lib/permitted-contents/types.js +2 -0
  81. package/lib/permitted-contents/utils.d.ts +100 -0
  82. package/lib/permitted-contents/utils.js +302 -0
  83. package/lib/placeholder-label-option/index.d.ts +2 -0
  84. package/lib/placeholder-label-option/index.js +88 -0
  85. package/lib/require-accessible-name/index.d.ts +3 -3
  86. package/lib/require-accessible-name/index.js +12 -4
  87. package/lib/require-datetime/index.d.ts +6 -0
  88. package/lib/require-datetime/index.js +34 -0
  89. package/lib/require-datetime/types.d.ts +10 -0
  90. package/lib/require-datetime/types.js +2 -0
  91. package/lib/require-datetime/utils.d.ts +11 -0
  92. package/lib/require-datetime/utils.js +137 -0
  93. package/lib/required-attr/index.d.ts +5 -5
  94. package/lib/required-attr/index.js +20 -17
  95. package/lib/required-element/index.d.ts +3 -3
  96. package/lib/required-element/index.js +3 -2
  97. package/lib/required-h1/index.d.ts +3 -3
  98. package/lib/required-h1/index.js +4 -3
  99. package/lib/use-list/index.d.ts +4 -4
  100. package/lib/use-list/index.js +9 -7
  101. package/lib/wai-aria/checkings/_.d.ts +15 -0
  102. package/lib/wai-aria/checkings/_.js +27 -0
  103. package/lib/wai-aria/checkings/abstract-role.js +1 -1
  104. package/lib/wai-aria/checkings/default-value.d.ts +7 -3
  105. package/lib/wai-aria/checkings/deprecated-props.d.ts +8 -4
  106. package/lib/wai-aria/checkings/disallowed-prop.d.ts +8 -4
  107. package/lib/wai-aria/checkings/disallowed-prop.js +27 -3
  108. package/lib/wai-aria/checkings/implicit-props.d.ts +8 -4
  109. package/lib/wai-aria/checkings/implicit-props.js +3 -2
  110. package/lib/wai-aria/checkings/implicit-role.js +2 -2
  111. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +11 -0
  112. package/lib/wai-aria/checkings/interaction-in-hidden.js +49 -0
  113. package/lib/wai-aria/checkings/no-global-prop.d.ts +7 -3
  114. package/lib/wai-aria/checkings/{non-existant-role.d.ts → non-existent-role.d.ts} +1 -1
  115. package/lib/wai-aria/checkings/{non-existant-role.js → non-existent-role.js} +4 -4
  116. package/lib/wai-aria/checkings/permitted-roles.js +1 -1
  117. package/lib/wai-aria/checkings/presentational-children.d.ts +29 -0
  118. package/lib/wai-aria/checkings/presentational-children.js +62 -0
  119. package/lib/wai-aria/checkings/{checking-required-owned-elements.d.ts → required-owned-elements.d.ts} +7 -3
  120. package/lib/wai-aria/checkings/required-owned-elements.js +103 -0
  121. package/lib/wai-aria/checkings/required-prop copy.d.ts +15 -0
  122. package/lib/wai-aria/checkings/required-prop copy.js +27 -0
  123. package/lib/wai-aria/checkings/required-prop.d.ts +12 -6
  124. package/lib/wai-aria/checkings/unadopted-explicit-roles.d.ts +15 -0
  125. package/lib/wai-aria/checkings/unadopted-explicit-roles.js +17 -0
  126. package/lib/wai-aria/checkings/value.d.ts +19 -4
  127. package/lib/wai-aria/checkings/value.js +77 -5
  128. package/lib/wai-aria/index.d.ts +1 -1
  129. package/lib/wai-aria/index.js +27 -16
  130. package/lib/wai-aria/types.d.ts +11 -9
  131. package/lib/xxx/index.d.ts +2 -0
  132. package/lib/xxx/index.js +32 -0
  133. package/package.json +18 -12
  134. package/schema.json +12 -0
  135. package/test/attr-check.spec.js +77 -0
  136. package/test/attr-duplication/index.spec.js +159 -0
  137. package/test/attr-value-quotes/index.spec.js +133 -0
  138. package/test/case-sensitive-attr-name/index.spec.js +65 -0
  139. package/test/case-sensitive-tag-name/index.spec.js +80 -0
  140. package/test/character-reference/index.spec.js +57 -0
  141. package/test/class-naming/index.spec.js +470 -0
  142. package/test/create-message.spec.js +497 -0
  143. package/test/deprecated-attr/index.spec.js +48 -0
  144. package/test/deprecated-element/index.spec.js +48 -0
  145. package/test/disallowed-element/index.spec.js +90 -0
  146. package/test/doctype/index.spec.js +50 -0
  147. package/test/end-tag/index.spec.js +162 -0
  148. package/test/id-duplication/index.spec.js +47 -0
  149. package/test/ineffective-attr/index.spec.js +31 -0
  150. package/test/invalid-attr/index.spec.js +1632 -0
  151. package/test/label-has-control/index.spec.js +29 -0
  152. package/test/landmark-roles/index.spec.js +187 -0
  153. package/test/no-boolean-attr-value/index.spec.js +41 -0
  154. package/test/no-default-value/index.spec.js +74 -0
  155. package/test/no-empty-palpable-content/index.spec.js +115 -0
  156. package/test/no-hard-code-id/index.spec.js +100 -0
  157. package/test/no-refer-to-non-existent-id/index.spec.js +254 -0
  158. package/test/no-use-event-handler-attr/index.spec.js +57 -0
  159. package/test/permitted-contents/choice.spec.js +174 -0
  160. package/test/permitted-contents/count-pattern.spec.js +308 -0
  161. package/test/permitted-contents/index.spec.js +1371 -0
  162. package/test/permitted-contents/matches-selector.spec.js +59 -0
  163. package/test/permitted-contents/order.spec.js +351 -0
  164. package/test/permitted-contents/recursive-branch.spec.js +41 -0
  165. package/test/permitted-contents/represent-transparent-nodes.spec.js +24 -0
  166. package/test/permitted-contents/start.spec.js +67 -0
  167. package/test/placeholder-label-option/index.spec.js +113 -0
  168. package/test/require-accessible-name/index.spec.js +446 -0
  169. package/test/require-datetime/index.spec.js +54 -0
  170. package/test/require-datetime/utils.spec.js +52 -0
  171. package/test/required-attr/index.spec.js +414 -0
  172. package/test/required-element/index.spec.js +188 -0
  173. package/test/required-h1/index.spec.js +69 -0
  174. package/test/use-list/index.spec.js +109 -0
  175. package/test/wai-aria/checkings/value.spec.js +33 -0
  176. package/test/wai-aria/index.spec.js +1173 -0
  177. package/lib/__foo/index.d.ts +0 -2
  178. package/lib/__foo/index.js +0 -46
  179. package/lib/attr-equal-space-after/index.d.ts +0 -3
  180. package/lib/attr-equal-space-after/index.js +0 -90
  181. package/lib/attr-equal-space-before/index.d.ts +0 -3
  182. package/lib/attr-equal-space-before/index.js +0 -90
  183. package/lib/attr-spacing/index.d.ts +0 -6
  184. package/lib/attr-spacing/index.js +0 -100
  185. package/lib/helper/aria/get-aria.d.ts +0 -7
  186. package/lib/helper/aria/get-aria.js +0 -53
  187. package/lib/helper/aria/get-computed-role.d.ts +0 -10
  188. package/lib/helper/aria/get-computed-role.js +0 -24
  189. package/lib/helper/aria/get-implicit-role.d.ts +0 -7
  190. package/lib/helper/aria/get-implicit-role.js +0 -12
  191. package/lib/helper/aria/get-permitted-roles.d.ts +0 -14
  192. package/lib/helper/aria/get-permitted-roles.js +0 -26
  193. package/lib/helper/aria/resolve-version.d.ts +0 -2
  194. package/lib/helper/aria/resolve-version.js +0 -21
  195. package/lib/helper/spec/aria-spec.d.ts +0 -5
  196. package/lib/helper/spec/aria-spec.js +0 -12
  197. package/lib/helper/spec/get-role-spec.d.ts +0 -11
  198. package/lib/helper/spec/get-role-spec.js +0 -39
  199. package/lib/helper/spec/html-spec.d.ts +0 -2
  200. package/lib/helper/spec/html-spec.js +0 -14
  201. package/lib/indentation/index.d.ts +0 -7
  202. package/lib/indentation/index.js +0 -208
  203. package/lib/permitted-contents/array.combination.d.ts +0 -1
  204. package/lib/permitted-contents/array.combination.js +0 -33
  205. package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +0 -11
  206. package/lib/permitted-contents/permitted-content.spec-to-regexp.js +0 -230
  207. package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +0 -2
  208. package/lib/permitted-contents/unfold-content-models-to-tags.js +0 -8
  209. package/lib/wai-aria/checkings/checking-required-owned-elements.js +0 -63
  210. package/tsconfig.test.json +0 -3
  211. package/tsconfig.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -1,58 +1,24 @@
1
1
  # @markuplint/rules
2
2
 
3
3
  [![npm version](https://badge.fury.io/js/%40markuplint%2Frules.svg)](https://www.npmjs.com/package/@markuplint/rules)
4
- [![Build Status](https://travis-ci.org/markuplint/markuplint.svg?branch=main)](https://travis-ci.org/markuplint/markuplint)
5
- [![Coverage Status](https://coveralls.io/repos/github/markuplint/markuplint/badge.svg?branch=main)](https://coveralls.io/github/markuplint/markuplint?branch=main)
6
4
 
7
- ## Rules
5
+ **Built-in rules**
8
6
 
9
- ### Conformance checking
7
+ ## Documentation
10
8
 
11
- - [`attr-duplication`](./src/attr-duplication)
12
- - [`character-reference`](./src/character-reference)
13
- - [`deprecated-attr`](./src/deprecated-attr)
14
- - [`deprecated-element`](./src/deprecated-element)
15
- - [`disallowed-element`](./src/disallowed-element)
16
- - [`doctype`](./src/doctype)
17
- - [`id-duplication`](./src/id-duplication)
18
- - [`ineffective-attr`](./src/ineffective-attr)
19
- - [`invalid-attr`](./src/invalid-attr)
20
- - [`permitted-contents`](./src/permitted-contents)
21
- - [`required-attr`](./src/required-attr)
22
- - [`required-element`](./src/required-element)
23
-
24
- ### Accessibility
25
-
26
- - [`landmark-roles`](./src/landmark-roles)
27
- - [`no-refer-to-non-existent-id`](./src/no-refer-to-non-existent-id)
28
- - [`required-h1`](./src/required-h1)
29
- - [`use-list`](./src/use-list)
30
- - [`wai-aria`](./src/wai-aria)
31
-
32
- ### Naming Convention
33
-
34
- - [`class-naming`](./src/class-naming)
35
-
36
- ### Maintainability
37
-
38
- - [`no-hard-code-id`](./src/no-hard-code-id)
39
- - [`no-use-event-handler-attr`](./src/no-use-event-handler-attr)
40
-
41
- ### Style
42
-
43
- - [`attr-value-quotes`](./src/attr-value-quotes)
44
- - [`case-sensitive-attr-name`](./src/case-sensitive-attr-name)
45
- - [`case-sensitive-tag-name`](./src/case-sensitive-tag-name)
46
- - [`end-tag`](./src/end-tag)
47
- - [`no-boolean-attr-value`](./src/no-boolean-attr-value)
48
- - [`no-default-value`](./src/no-default-value)
9
+ - [Rules](https://markuplint.dev/rules/)
49
10
 
50
11
  ## Install
51
12
 
52
- Generally, you **don't have to install** this package because markuplint dependents it defaultly.
13
+ [`markuplint`](https://www.npmjs.com/package/markuplint) package includes this package.
53
14
 
54
- ```sh
15
+ <details>
16
+ <summary>If you are installing purposely, how below:</summary>
17
+
18
+ ```shell
55
19
  $ npm install -D @markuplint/rules
56
20
 
57
21
  $ yarn add -D @markuplint/rules
58
22
  ```
23
+
24
+ </details>
@@ -1,14 +1,15 @@
1
1
  import type { Translator } from '@markuplint/i18n';
2
2
  import type { Attribute as AttrSpec, AttributeType } from '@markuplint/ml-spec';
3
- declare type Invalid = {
4
- invalidType: 'non-existent' | 'invalid-value';
5
- message: string;
6
- loc?: Loc;
3
+ import type { ReadonlyDeep } from 'type-fest';
4
+ type Invalid = {
5
+ invalidType: 'non-existent' | 'invalid-value' | 'disallowed-attr';
6
+ message: string;
7
+ loc?: Loc;
7
8
  };
8
- declare type Loc = {
9
- raw: string;
10
- line: number;
11
- col: number;
9
+ type Loc = {
10
+ raw: string;
11
+ line: number;
12
+ col: number;
12
13
  };
13
14
  /**
14
15
  * Use in rules `invalid-attr` and `wai-aria`
@@ -18,6 +19,17 @@ declare type Loc = {
18
19
  * @param isCustomRule
19
20
  * @param spec
20
21
  */
21
- export declare function attrCheck(t: Translator, name: string, value: string, isCustomRule: boolean, spec?: AttrSpec): Invalid | false;
22
- export declare function valueCheck(t: Translator, name: string, value: string, type: AttributeType): string | [string, Loc] | false;
22
+ export declare function attrCheck(
23
+ t: Translator,
24
+ name: string,
25
+ value: string,
26
+ isCustomRule: boolean,
27
+ spec?: AttrSpec,
28
+ ): Invalid | false;
29
+ export declare function valueCheck(
30
+ t: Translator,
31
+ name: string,
32
+ value: string,
33
+ type: ReadonlyDeep<AttributeType>,
34
+ ): [string, Loc] | false;
23
35
  export {};
package/lib/attr-check.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.valueCheck = exports.attrCheck = void 0;
4
+ const shared_1 = require("@markuplint/shared");
4
5
  const types_1 = require("@markuplint/types");
5
6
  const create_message_1 = require("./create-message");
6
7
  const debug_1 = require("./debug");
@@ -22,8 +23,14 @@ function attrCheck(t, name, value, isCustomRule, spec) {
22
23
  // Ignore checking because ARIA attributes are check on another rule
23
24
  return false;
24
25
  }
26
+ // @see https://www.w3.org/TR/adapt/
27
+ // It is an experimental
28
+ if (/^adapt-.+$/.test(name)) {
29
+ // Ignore checking because "adapt-*" attribute is any type
30
+ return false;
31
+ }
25
32
  }
26
- // Existance
33
+ // Existence
27
34
  if (!spec) {
28
35
  (0, debug_1.log)('The "%s" attribute DOES\'NT EXIST in the spec', name);
29
36
  return {
@@ -41,35 +48,37 @@ function attrCheck(t, name, value, isCustomRule, spec) {
41
48
  t('Did you mean "{0*}"?', spec.name),
42
49
  };
43
50
  }
44
- const types = Array.isArray(spec.type) ? spec.type : [spec.type];
51
+ if (spec.noUse) {
52
+ return {
53
+ invalidType: 'disallowed-attr',
54
+ message: t('{0} is {1:c}', t('the "{0*}" {1}', name, 'attribute'), 'disallowed'),
55
+ };
56
+ }
57
+ const types = (0, shared_1.toNonNullableArrayFromItemOrArray)(spec.type);
45
58
  const invalidList = types.map(type => {
46
- if (!type) {
47
- (0, debug_1.log)('attrCheck: %o', arguments);
48
- throw new Error('type is empty in spec');
49
- }
50
59
  const invalid = valueCheck(t, name, value, type);
51
- if (invalid) {
52
- if (typeof invalid === 'string') {
53
- return {
54
- invalidType: 'invalid-value',
55
- message: invalid,
56
- };
57
- }
58
- else {
59
- return {
60
- invalidType: 'invalid-value',
61
- message: invalid[0],
62
- loc: invalid[1],
63
- };
64
- }
60
+ if (invalid === false) {
61
+ return false;
62
+ }
63
+ if (typeof invalid === 'string') {
64
+ return {
65
+ invalidType: 'invalid-value',
66
+ message: invalid,
67
+ };
68
+ }
69
+ else {
70
+ return {
71
+ invalidType: 'invalid-value',
72
+ message: invalid[0],
73
+ loc: invalid[1],
74
+ };
65
75
  }
66
- return false;
67
76
  });
68
- if (invalidList.some(i => !i)) {
77
+ if (invalidList.some(i => i === false)) {
69
78
  return false;
70
79
  }
71
80
  const invalid = invalidList.find(i => i);
72
- return invalid || false;
81
+ return invalid !== null && invalid !== void 0 ? invalid : false;
73
82
  }
74
83
  exports.attrCheck = attrCheck;
75
84
  function valueCheck(t, name, value, type) {
@@ -1,2 +1,4 @@
1
- declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
1
+ declare const _default: Readonly<
2
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
+ >;
2
4
  export default _default;
@@ -5,15 +5,16 @@ exports.default = (0, ml_core_1.createRule)({
5
5
  async verify({ document, report, t }) {
6
6
  const message = t('{0} is {1:c}', t('the {0}', 'attribute name'), 'duplicated');
7
7
  await document.walkOn('Element', node => {
8
+ var _a;
8
9
  const attrNameStack = [];
9
10
  for (const attr of node.getAttributeTokens()) {
10
11
  if (attr.isDuplicatable) {
11
12
  continue;
12
13
  }
13
14
  const attrName = attr.name;
14
- const name = node.isCustomElement ? attrName : attrName.toLowerCase();
15
+ const name = node.elementType === 'html' ? attrName.toLowerCase() : attrName;
15
16
  if (attrNameStack.includes(name)) {
16
- const scope = attr.nameNode || attr;
17
+ const scope = (_a = attr.nameNode) !== null && _a !== void 0 ? _a : attr;
17
18
  report({
18
19
  scope: {
19
20
  rule: node.rule,
@@ -1,7 +1,7 @@
1
- export declare type Type = 'double' | 'single';
2
- export declare type Quote = '"' | "'";
3
- export declare type QuoteMap = {
4
- [P in Type]: Quote;
1
+ export type Type = 'double' | 'single';
2
+ export type Quote = '"' | "'";
3
+ export type QuoteMap = {
4
+ [P in Type]: Quote;
5
5
  };
6
- declare const _default: import("@markuplint/ml-core").RuleSeed<Type, null>;
6
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Type, undefined>>;
7
7
  export default _default;
@@ -6,7 +6,7 @@ const quoteList = {
6
6
  single: "'",
7
7
  };
8
8
  exports.default = (0, ml_core_1.createRule)({
9
- defaultServerity: 'warning',
9
+ defaultSeverity: 'warning',
10
10
  defaultValue: 'double',
11
11
  async verify({ document, report, t }) {
12
12
  await document.walkOn('Attr', attr => {
@@ -1,3 +1,3 @@
1
- export declare type Value = 'lower' | 'upper';
2
- declare const _default: import("@markuplint/ml-core").RuleSeed<Value, null>;
1
+ export type Value = 'lower' | 'upper';
2
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Value, undefined>>;
3
3
  export default _default;
@@ -2,13 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ml_core_1 = require("@markuplint/ml-core");
4
4
  exports.default = (0, ml_core_1.createRule)({
5
- defaultServerity: 'warning',
5
+ defaultSeverity: 'warning',
6
6
  defaultValue: 'lower',
7
7
  async verify({ document, report, t }) {
8
8
  await document.walkOn('Attr', attr => {
9
9
  var _a, _b, _c, _d;
10
10
  const el = attr.ownerElement;
11
- if (el.isForeignElement || el.isCustomElement) {
11
+ if (el.isForeignElement || el.elementType !== 'html') {
12
12
  return;
13
13
  }
14
14
  const value = attr.rule.value;
@@ -46,7 +46,7 @@ exports.default = (0, ml_core_1.createRule)({
46
46
  await document.walkOn('Attr', attr => {
47
47
  var _a;
48
48
  const el = attr.ownerElement;
49
- if (el.isForeignElement || el.isCustomElement) {
49
+ if (el.isForeignElement || el.elementType !== 'html') {
50
50
  return;
51
51
  }
52
52
  const attrSpecs = (0, ml_core_1.getAttrSpecs)(el, document.specs);
@@ -1,3 +1,3 @@
1
- export declare type Value = 'lower' | 'upper';
2
- declare const _default: import("@markuplint/ml-core").RuleSeed<Value, null>;
1
+ export type Value = 'lower' | 'upper';
2
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Value, undefined>>;
3
3
  export default _default;
@@ -2,11 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ml_core_1 = require("@markuplint/ml-core");
4
4
  exports.default = (0, ml_core_1.createRule)({
5
- defaultServerity: 'warning',
5
+ defaultSeverity: 'warning',
6
6
  defaultValue: 'lower',
7
7
  async verify({ document, report, t }) {
8
8
  await document.walkOn('Element', el => {
9
- if (el.isForeignElement || el.isCustomElement) {
9
+ if (el.isForeignElement || el.elementType !== 'html') {
10
10
  return;
11
11
  }
12
12
  const ms = el.rule.severity === 'error' ? 'must' : 'should';
@@ -38,7 +38,7 @@ exports.default = (0, ml_core_1.createRule)({
38
38
  },
39
39
  async fix({ document }) {
40
40
  await document.walkOn('Element', el => {
41
- if (el.isForeignElement || el.isCustomElement) {
41
+ if (el.isForeignElement || el.elementType !== 'html') {
42
42
  return;
43
43
  }
44
44
  const deny = el.rule.value === 'lower' ? /[A-Z]/ : /[a-z]/;
@@ -1,3 +1,3 @@
1
1
  import type { RuleConfigValue } from '@markuplint/ml-config';
2
- declare const _default: import("@markuplint/ml-core").RuleSeed<RuleConfigValue, null>;
2
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<RuleConfigValue, undefined>>;
3
3
  export default _default;
@@ -40,7 +40,7 @@ exports.default = (0, ml_core_1.createRule)({
40
40
  }
41
41
  });
42
42
  for (const targetNode of targetNodes) {
43
- if (!('scope' in targetNode && 'line' in targetNode)) {
43
+ if (!('scope' in targetNode && 'line' in targetNode && targetNode.line != null)) {
44
44
  continue;
45
45
  }
46
46
  const escapedText = targetNode.raw.replace(/&(?:[a-z]+|#[0-9]+|x[0-9]);/gi, $0 => '*'.repeat($0.length));
@@ -1,3 +1,3 @@
1
- export declare type Value = string | string[] | null;
2
- declare const _default: import("@markuplint/ml-core").RuleSeed<Value, null>;
1
+ export type Value = string | string[] | null;
2
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<Value, undefined>>;
3
3
  export default _default;
@@ -1,16 +1,14 @@
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 helpers_1 = require("../helpers");
5
6
  exports.default = (0, ml_core_1.createRule)({
6
- defaultServerity: 'warning',
7
+ defaultSeverity: 'warning',
7
8
  defaultValue: null,
8
9
  async verify({ document, report, t }) {
9
10
  await document.walkOn('Element', el => {
10
- if (!el.rule.value) {
11
- return;
12
- }
13
- const classPatterns = Array.isArray(el.rule.value) ? el.rule.value : [el.rule.value];
11
+ const classPatterns = (0, shared_1.toNoEmptyStringArrayFromStringOrArray)(el.rule.value).filter(className => className && typeof className === 'string');
14
12
  const attrs = el.getAttributeToken('class');
15
13
  for (const attr of attrs) {
16
14
  if (attr.isDynamicValue) {
@@ -1,5 +1,16 @@
1
1
  import type { Translator } from '@markuplint/i18n';
2
2
  import type { AttributeType } from '@markuplint/ml-spec';
3
3
  import type { UnmatchedResult } from '@markuplint/types';
4
- export declare function createMessageValueExpected(t: Translator, baseTarget: string, type: AttributeType, matches: UnmatchedResult): string;
5
- export declare function __createMessageValueExpected(t: Translator, baseTarget: string, expected: string | null, matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candicate' | 'ref' | 'extra'>): string;
4
+ import type { ReadonlyDeep } from 'type-fest';
5
+ export declare function createMessageValueExpected(
6
+ t: Translator,
7
+ baseTarget: string,
8
+ type: ReadonlyDeep<AttributeType>,
9
+ matches: UnmatchedResult,
10
+ ): string;
11
+ export declare function __createMessageValueExpected(
12
+ t: Translator,
13
+ baseTarget: string,
14
+ expected: string | null,
15
+ matches: Pick<UnmatchedResult, 'partName' | 'reason' | 'raw' | 'candidate' | 'ref' | 'extra'>,
16
+ ): string;
@@ -22,11 +22,12 @@ function createMessageValueExpected(t, baseTarget, type, matches) {
22
22
  }
23
23
  exports.createMessageValueExpected = createMessageValueExpected;
24
24
  function __createMessageValueExpected(t, baseTarget, expected, matches) {
25
+ var _a;
25
26
  let target = baseTarget;
26
27
  let reasonPart;
27
28
  let expectPart;
28
29
  let unnecessaryPart;
29
- let candicatePart;
30
+ let candidatePart;
30
31
  let expectOrNeed = 'expects';
31
32
  if (matches.partName) {
32
33
  if (matches.partName === 'the content of the list') {
@@ -51,7 +52,7 @@ function __createMessageValueExpected(t, baseTarget, expected, matches) {
51
52
  break;
52
53
  }
53
54
  case 'extra-token': {
54
- const token = matches.partName || 'token';
55
+ const token = (_a = matches.partName) !== null && _a !== void 0 ? _a : 'token';
55
56
  reasonPart = t('Found {0}', t('extra {0}', token)) + ' ' + t([matches.raw]);
56
57
  if (matches.extra) {
57
58
  const extra = expectValueToWord(t, matches.extra, 'Any');
@@ -188,10 +189,10 @@ function __createMessageValueExpected(t, baseTarget, expected, matches) {
188
189
  }
189
190
  }
190
191
  }
191
- if (matches.candicate) {
192
- candicatePart = t('Did you mean "{0*}"?', matches.candicate);
192
+ if (matches.candidate) {
193
+ candidatePart = t('Did you mean "{0*}"?', matches.candidate);
193
194
  }
194
- let message = [reasonPart, unnecessaryPart, expectPart, candicatePart].filter(s => s).join(t('. '));
195
+ let message = [reasonPart, unnecessaryPart, expectPart, candidatePart].filter(s => s).join(t('. '));
195
196
  if (matches.ref) {
196
197
  message += ` (${matches.ref})`;
197
198
  }
@@ -201,7 +202,7 @@ exports.__createMessageValueExpected = __createMessageValueExpected;
201
202
  function createExpectedObject(type, matches, t) {
202
203
  var _a;
203
204
  const expectedObject = [];
204
- if ((_a = matches.expects) === null || _a === void 0 ? void 0 : _a.length) {
205
+ if (matches.expects && matches.expects.length > 0) {
205
206
  expectedObject.push(...matches.expects.map(expect => {
206
207
  return expectValueToWord(t, expect, type);
207
208
  }));
@@ -221,7 +222,7 @@ function createExpectedObject(type, matches, t) {
221
222
  ? null
222
223
  : 1 < expectedObject.length
223
224
  ? t('either {0}', t(expectedObject))
224
- : expectedObject[0];
225
+ : (_a = expectedObject[0]) !== null && _a !== void 0 ? _a : null;
225
226
  return expects;
226
227
  }
227
228
  function expectValueToWord(t, expect, type) {
@@ -232,7 +233,7 @@ function expectValueToWord(t, expect, type) {
232
233
  return expect.value ? `%${expect.value}%` : '';
233
234
  case 'format':
234
235
  return t('the {0} format', expect.value);
235
- case 'regxp':
236
+ case 'regexp':
236
237
  return t('{0} ({1})', 'regular expression', expect.value);
237
238
  case 'syntax':
238
239
  if ((0, types_1.isKeyword)(type) && type[0] === '<') {
package/lib/debug.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import debug from 'debug';
2
- export declare type Log = debug.Debugger;
2
+ export type Log = debug.Debugger;
3
3
  export declare const log: debug.Debugger;
package/lib/debug.js CHANGED
@@ -3,4 +3,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.log = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const debug_1 = tslib_1.__importDefault(require("debug"));
6
- exports.log = (0, debug_1.default)('markuplint-rules');
6
+ exports.log = (0, debug_1.default)('ml-rules');
@@ -1,2 +1,4 @@
1
- declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
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: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
1
+ declare const _default: Readonly<
2
+ import('@markuplint/ml-core').RuleSeed<import('@markuplint/ml-core').RuleConfigValue, undefined>
3
+ >;
2
4
  export default _default;
@@ -6,12 +6,12 @@ exports.default = (0, ml_core_1.createRule)({
6
6
  await document.walkOn('Element', el => {
7
7
  if (!(el.namespaceURI === 'http://www.w3.org/1999/xhtml' ||
8
8
  el.namespaceURI === 'http://www.w3.org/2000/svg') ||
9
- el.isCustomElement) {
9
+ el.elementType !== 'html') {
10
10
  return;
11
11
  }
12
- const spec = (0, ml_core_1.getSpec)(el, document.specs);
13
- if (spec && (spec.obsolete || spec.deprecated || spec.nonStandard)) {
14
- const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete ? 'obsolete' : 'non-standard');
12
+ const spec = (0, ml_core_1.getSpec)(el, document.specs.specs);
13
+ if (spec && (spec.obsolete != null || spec.deprecated || spec.nonStandard)) {
14
+ const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete != null ? 'obsolete' : 'non-standard');
15
15
  report({
16
16
  scope: el,
17
17
  message,
@@ -1,2 +1,2 @@
1
- declare const _default: import("@markuplint/ml-core").RuleSeed<string[], null>;
1
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<string[], undefined>>;
2
2
  export default _default;
@@ -1,5 +1,5 @@
1
- declare type Option = {
2
- denyObsolateType: boolean;
1
+ type Option = {
2
+ denyObsoleteType: boolean;
3
3
  };
4
- declare const _default: import("@markuplint/ml-core").RuleSeed<"always", Option>;
4
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<'always', Option>>;
5
5
  export default _default;
@@ -4,7 +4,7 @@ const ml_core_1 = require("@markuplint/ml-core");
4
4
  exports.default = (0, ml_core_1.createRule)({
5
5
  defaultValue: 'always',
6
6
  defaultOptions: {
7
- denyObsolateType: true,
7
+ denyObsoleteType: true,
8
8
  },
9
9
  verify({ document, report, t }) {
10
10
  if (document.isFragment) {
@@ -23,7 +23,7 @@ exports.default = (0, ml_core_1.createRule)({
23
23
  if ((doctype.name.toLowerCase() === 'html' && doctype.publicId) || doctype.systemId) {
24
24
  report({
25
25
  scope: doctype,
26
- message: t('Never {0} {1}', 'declarate', 'obsolete doctype'),
26
+ message: t('Never {0} {1}', 'declare', 'obsolete doctype'),
27
27
  });
28
28
  }
29
29
  },
@@ -1,2 +1,2 @@
1
- declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, null>;
1
+ declare const _default: Readonly<import('@markuplint/ml-core').RuleSeed<boolean, undefined>>;
2
2
  export default _default;
@@ -1,24 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const ml_core_1 = require("@markuplint/ml-core");
4
- const voidElements = [
5
- 'area',
6
- 'base',
7
- 'br',
8
- 'col',
9
- 'embed',
10
- 'hr',
11
- 'img',
12
- 'input',
13
- 'link',
14
- 'meta',
15
- 'param',
16
- 'source',
17
- 'track',
18
- 'wbr',
19
- ];
4
+ const ml_spec_1 = require("@markuplint/ml-spec");
20
5
  exports.default = (0, ml_core_1.createRule)({
21
- defaultServerity: 'warning',
6
+ defaultSeverity: 'warning',
22
7
  async verify({ document, report, t }) {
23
8
  if (document.endTag === 'never') {
24
9
  return;
@@ -28,7 +13,7 @@ exports.default = (0, ml_core_1.createRule)({
28
13
  if (el.isOmitted) {
29
14
  return;
30
15
  }
31
- if (voidElements.some(vE => vE === el.localName)) {
16
+ if ((0, ml_spec_1.isVoidElement)(el)) {
32
17
  return;
33
18
  }
34
19
  if (el.closeTag != null) {