@markuplint/rules 2.4.2 → 3.0.0-alpha.66

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 (92) hide show
  1. package/README.md +1 -5
  2. package/lib/attr-duplication/index.js +10 -7
  3. package/lib/attr-equal-space-after/index.d.ts +1 -1
  4. package/lib/attr-equal-space-before/index.d.ts +1 -1
  5. package/lib/attr-spacing/index.d.ts +3 -3
  6. package/lib/attr-value-quotes/index.js +21 -25
  7. package/lib/case-sensitive-attr-name/index.d.ts +1 -5
  8. package/lib/case-sensitive-attr-name/index.js +51 -81
  9. package/lib/case-sensitive-tag-name/index.js +38 -30
  10. package/lib/character-reference/index.d.ts +2 -1
  11. package/lib/character-reference/index.js +5 -7
  12. package/lib/class-naming/index.js +11 -11
  13. package/lib/deprecated-attr/index.js +17 -18
  14. package/lib/deprecated-element/index.js +5 -7
  15. package/lib/disallowed-element/index.js +8 -9
  16. package/lib/doctype/index.js +7 -7
  17. package/lib/end-tag/index.js +4 -1
  18. package/lib/helper/aria/get-aria.d.ts +7 -0
  19. package/lib/helper/aria/get-aria.js +53 -0
  20. package/lib/helper/aria/get-computed-role.d.ts +10 -0
  21. package/lib/helper/aria/get-computed-role.js +24 -0
  22. package/lib/helper/aria/get-implicit-role.d.ts +7 -0
  23. package/lib/helper/aria/get-implicit-role.js +12 -0
  24. package/lib/helper/aria/get-permitted-roles.d.ts +14 -0
  25. package/lib/helper/aria/get-permitted-roles.js +26 -0
  26. package/lib/helper/aria/resolve-version.d.ts +2 -0
  27. package/lib/helper/aria/resolve-version.js +21 -0
  28. package/lib/helper/spec/aria-spec.d.ts +5 -0
  29. package/lib/helper/spec/aria-spec.js +12 -0
  30. package/lib/helper/spec/get-role-spec.d.ts +11 -0
  31. package/lib/helper/spec/get-role-spec.js +39 -0
  32. package/lib/helper/spec/html-spec.d.ts +2 -0
  33. package/lib/helper/spec/html-spec.js +14 -0
  34. package/lib/helpers.d.ts +10 -28
  35. package/lib/helpers.js +29 -149
  36. package/lib/id-duplication/index.js +4 -6
  37. package/lib/indentation/index.d.ts +3 -3
  38. package/lib/index.d.ts +14 -19
  39. package/lib/index.js +0 -8
  40. package/lib/ineffective-attr/index.js +19 -27
  41. package/lib/invalid-attr/index.js +83 -83
  42. package/lib/landmark-roles/index.d.ts +2 -2
  43. package/lib/landmark-roles/index.js +9 -9
  44. package/lib/no-boolean-attr-value/index.js +33 -34
  45. package/lib/no-default-value/index.js +20 -24
  46. package/lib/no-hard-code-id/index.js +9 -13
  47. package/lib/no-refer-to-non-existent-id/index.d.ts +4 -1
  48. package/lib/no-refer-to-non-existent-id/index.js +77 -83
  49. package/lib/no-use-event-handler-attr/index.js +20 -22
  50. package/lib/permitted-contents/index.d.ts +5 -2
  51. package/lib/permitted-contents/index.js +67 -68
  52. package/lib/permitted-contents/permitted-content.spec-to-regexp.d.ts +5 -5
  53. package/lib/permitted-contents/permitted-content.spec-to-regexp.js +19 -14
  54. package/lib/permitted-contents/unfold-content-models-to-tags.d.ts +2 -2
  55. package/lib/require-accessible-name/index.d.ts +5 -1
  56. package/lib/require-accessible-name/index.js +6 -3
  57. package/lib/required-attr/index.js +16 -25
  58. package/lib/required-element/index.d.ts +1 -1
  59. package/lib/required-element/index.js +6 -6
  60. package/lib/required-h1/index.d.ts +2 -2
  61. package/lib/required-h1/index.js +3 -3
  62. package/lib/wai-aria/checkings/abstract-role.d.ts +3 -0
  63. package/lib/wai-aria/checkings/abstract-role.js +22 -0
  64. package/lib/wai-aria/checkings/checking-required-owned-elements.d.ts +11 -0
  65. package/lib/wai-aria/checkings/checking-required-owned-elements.js +63 -0
  66. package/lib/wai-aria/checkings/default-value.d.ts +6 -0
  67. package/lib/wai-aria/checkings/default-value.js +17 -0
  68. package/lib/wai-aria/checkings/deprecated-props.d.ts +7 -0
  69. package/lib/wai-aria/checkings/deprecated-props.js +18 -0
  70. package/lib/wai-aria/checkings/disallowed-prop.d.ts +7 -0
  71. package/lib/wai-aria/checkings/disallowed-prop.js +22 -0
  72. package/lib/wai-aria/checkings/implicit-props.d.ts +7 -0
  73. package/lib/wai-aria/checkings/implicit-props.js +50 -0
  74. package/lib/wai-aria/checkings/implicit-role.d.ts +3 -0
  75. package/lib/wai-aria/checkings/implicit-role.js +21 -0
  76. package/lib/wai-aria/checkings/no-global-prop.d.ts +6 -0
  77. package/lib/wai-aria/checkings/no-global-prop.js +14 -0
  78. package/lib/wai-aria/checkings/non-existant-role.d.ts +3 -0
  79. package/lib/wai-aria/checkings/non-existant-role.js +28 -0
  80. package/lib/wai-aria/checkings/permitted-roles.d.ts +3 -0
  81. package/lib/wai-aria/checkings/permitted-roles.js +28 -0
  82. package/lib/wai-aria/checkings/required-prop.d.ts +9 -0
  83. package/lib/wai-aria/checkings/required-prop.js +27 -0
  84. package/lib/wai-aria/checkings/value.d.ts +7 -0
  85. package/lib/wai-aria/checkings/value.js +21 -0
  86. package/lib/wai-aria/index.d.ts +1 -8
  87. package/lib/wai-aria/index.js +56 -207
  88. package/lib/wai-aria/types.d.ts +11 -0
  89. package/lib/wai-aria/types.js +2 -0
  90. package/package.json +5 -5
  91. package/schema.json +0 -12
  92. package/tsconfig.tsbuildinfo +1 -1
package/README.md CHANGED
@@ -33,21 +33,17 @@
33
33
 
34
34
  - [`class-naming`](./src/class-naming)
35
35
 
36
- ### Maintenability
36
+ ### Maintainability
37
37
 
38
38
  - [`no-hard-code-id`](./src/no-hard-code-id)
39
39
  - [`no-use-event-handler-attr`](./src/no-use-event-handler-attr)
40
40
 
41
41
  ### Style
42
42
 
43
- - [`attr-equal-space-after`](./src/attr-equal-space-after)
44
- - [`attr-equal-space-before`](./src/attr-equal-space-before)
45
- - [`attr-spacing`](./src/attr-spacing)
46
43
  - [`attr-value-quotes`](./src/attr-value-quotes)
47
44
  - [`case-sensitive-attr-name`](./src/case-sensitive-attr-name)
48
45
  - [`case-sensitive-tag-name`](./src/case-sensitive-tag-name)
49
46
  - [`end-tag`](./src/end-tag)
50
- - [`indentation`](./src/indentation)
51
47
  - [`no-boolean-attr-value`](./src/no-boolean-attr-value)
52
48
  - [`no-default-value`](./src/no-default-value)
53
49
 
@@ -6,19 +6,22 @@ exports.default = (0, ml_core_1.createRule)({
6
6
  const message = t('{0} is {1:c}', t('the {0}', 'attribute name'), 'duplicated');
7
7
  await document.walkOn('Element', node => {
8
8
  const attrNameStack = [];
9
- for (const attr of node.attributes) {
9
+ for (const attr of node.getAttributeTokens()) {
10
10
  if (attr.isDuplicatable) {
11
11
  continue;
12
12
  }
13
- const attrName = attr.getName();
14
- const name = node.isCustomElement ? attrName.potential : attrName.potential.toLowerCase();
13
+ const attrName = attr.name;
14
+ const name = node.isCustomElement ? attrName : attrName.toLowerCase();
15
15
  if (attrNameStack.includes(name)) {
16
+ const scope = attr.nameNode || attr;
16
17
  report({
17
- scope: node,
18
+ scope: {
19
+ rule: node.rule,
20
+ startLine: scope.startLine,
21
+ startCol: scope.startCol,
22
+ raw: scope.raw,
23
+ },
18
24
  message,
19
- line: attrName.line,
20
- col: attrName.col,
21
- raw: attrName.raw,
22
25
  });
23
26
  }
24
27
  else {
@@ -1,3 +1,3 @@
1
1
  declare type Value = 'always' | 'never' | 'always-single-line' | 'never-single-line';
2
- declare const _default: import("@markuplint/ml-core").RuleSeed<Value, null>;
2
+ declare const _default: import('@markuplint/ml-core').RuleSeed<Value, null>;
3
3
  export default _default;
@@ -1,3 +1,3 @@
1
1
  declare type Value = 'always' | 'never' | 'always-single-line' | 'never-single-line';
2
- declare const _default: import("@markuplint/ml-core").RuleSeed<Value, null>;
2
+ declare const _default: import('@markuplint/ml-core').RuleSeed<Value, null>;
3
3
  export default _default;
@@ -1,6 +1,6 @@
1
1
  export interface AttrSpasingOptions {
2
- lineBreak?: 'either' | 'always' | 'never';
3
- width?: number | false;
2
+ lineBreak?: 'either' | 'always' | 'never';
3
+ width?: number | false;
4
4
  }
5
- declare const _default: import("@markuplint/ml-core").RuleSeed<boolean, AttrSpasingOptions>;
5
+ declare const _default: import('@markuplint/ml-core').RuleSeed<boolean, AttrSpasingOptions>;
6
6
  export default _default;
@@ -8,34 +8,30 @@ const quoteList = {
8
8
  exports.default = (0, ml_core_1.createRule)({
9
9
  defaultServerity: 'warning',
10
10
  defaultValue: 'double',
11
- async verify(context) {
12
- await context.document.walkOn('Element', node => {
13
- const message = context.translate('{0} is must {1} on {2}', 'Attribute value', 'quote', `${node.rule.value} quotation mark`);
14
- for (const attr of node.attributes) {
15
- if (attr.attrType === 'ps-attr' || attr.isDynamicValue || attr.isDirective || attr.equal.raw === '') {
16
- continue;
17
- }
18
- const quote = attr.startQuote.raw;
19
- if (quote !== quoteList[node.rule.value]) {
20
- context.report({
21
- scope: node,
22
- message,
23
- line: attr.name.startLine,
24
- col: attr.name.startCol,
25
- raw: attr.raw.trim(),
26
- });
27
- }
11
+ async verify({ document, report, t }) {
12
+ await document.walkOn('Attr', attr => {
13
+ var _a, _b;
14
+ const message = t('{0} is must {1} on {2}', 'Attribute value', 'quote', `${attr.rule.value} quotation mark`);
15
+ if (attr.isDynamicValue || attr.isDirective || !attr.equal || ((_a = attr.equal) === null || _a === void 0 ? void 0 : _a.raw) === '') {
16
+ return;
17
+ }
18
+ const quote = (_b = attr.startQuote) === null || _b === void 0 ? void 0 : _b.raw;
19
+ if (quote !== quoteList[attr.rule.value]) {
20
+ report({
21
+ scope: attr,
22
+ message,
23
+ });
28
24
  }
29
25
  });
30
26
  },
31
- async fix(context) {
32
- await context.document.walkOn('Element', node => {
33
- for (const attr of node.attributes) {
34
- const quote = quoteList[node.rule.value];
35
- if (attr.attrType === 'html-attr' && quote && attr.startQuote && attr.startQuote.raw !== quote) {
36
- attr.startQuote.fix(quote);
37
- attr.endQuote.fix(quote);
38
- }
27
+ async fix({ document }) {
28
+ await document.walkOn('Attr', attr => {
29
+ var _a;
30
+ const quote = quoteList[attr.rule.value];
31
+ if (quote && attr.startQuote && attr.startQuote.raw !== quote) {
32
+ attr.startQuote.fix(quote);
33
+ // TODO: attr.endQuote = new MLToken(quote);
34
+ (_a = attr.endQuote) === null || _a === void 0 ? void 0 : _a.fix(quote);
39
35
  }
40
36
  });
41
37
  },
@@ -1,7 +1,3 @@
1
1
  export declare type Value = 'lower' | 'upper';
2
- /**
3
- * @deprecated
4
- */
5
- export declare type Value_v1 = 'no-upper' | 'no-lower';
6
- declare const _default: import("@markuplint/ml-core").RuleSeed<Value | Value_v1, null>;
2
+ declare const _default: import("@markuplint/ml-core").RuleSeed<Value, null>;
7
3
  export default _default;
@@ -5,102 +5,72 @@ exports.default = (0, ml_core_1.createRule)({
5
5
  defaultServerity: 'warning',
6
6
  defaultValue: 'lower',
7
7
  async verify({ document, report, t }) {
8
- await document.walkOn('Element', node => {
9
- if (node.isForeignElement || node.isCustomElement) {
8
+ await document.walkOn('Attr', attr => {
9
+ var _a, _b, _c, _d;
10
+ const el = attr.ownerElement;
11
+ if (el.isForeignElement || el.isCustomElement) {
10
12
  return;
11
13
  }
12
- let value;
13
- // Convert deprecated value
14
- switch (node.rule.value) {
15
- case 'no-lower':
16
- value = 'upper';
17
- break;
18
- case 'no-upper':
19
- value = 'lower';
20
- break;
21
- default:
22
- value = node.rule.value;
23
- }
24
- const ms = node.rule.severity === 'error' ? 'must' : 'should';
14
+ const value = attr.rule.value;
15
+ const ms = attr.rule.severity === 'error' ? 'must' : 'should';
25
16
  const deny = value === 'lower' ? /[A-Z]/ : /[a-z]/;
26
17
  const cases = value === 'lower' ? 'lower' : 'upper';
27
18
  const message = t(`{0} ${ms} be {1}`, t('{0} of {1}', 'attribute names', 'HTML elements'), `${cases}case`);
28
- const attrSpecs = (0, ml_core_1.getAttrSpecs)(node.nameWithNS, document.specs);
29
- for (const attr of node.attributes) {
30
- if (attr.attrType === 'ps-attr') {
31
- continue;
32
- }
33
- /**
34
- * Ignore when it has the potential name,
35
- * it Interprets `tabIndex` to `tabindex` in JSX for example.
36
- */
37
- if (attr.name.raw !== attr.potentialName) {
38
- continue;
39
- }
40
- const name = attr.getName();
41
- if (attrSpecs) {
42
- const spec = attrSpecs.find(spec => spec.name === name.raw);
43
- if (spec && spec.caseSensitive) {
44
- continue;
45
- }
46
- }
47
- if (deny.test(name.raw)) {
48
- report({
49
- scope: node,
50
- message,
51
- line: name.line,
52
- col: name.col,
53
- raw: name.raw,
54
- });
19
+ const attrSpecs = (0, ml_core_1.getAttrSpecs)(el, document.specs);
20
+ /**
21
+ * Ignore when it has the potential name,
22
+ * it Interprets `tabIndex` to `tabindex` in JSX for example.
23
+ */
24
+ if (((_a = attr.nameNode) === null || _a === void 0 ? void 0 : _a.raw) !== attr.name) {
25
+ return;
26
+ }
27
+ const name = attr.name;
28
+ if (attrSpecs) {
29
+ const spec = attrSpecs.find(spec => spec.name === name);
30
+ if (spec && spec.caseSensitive) {
31
+ return;
55
32
  }
56
33
  }
34
+ if (deny.test(name)) {
35
+ report({
36
+ scope: attr,
37
+ line: (_b = attr.nameNode) === null || _b === void 0 ? void 0 : _b.startLine,
38
+ col: (_c = attr.nameNode) === null || _c === void 0 ? void 0 : _c.startCol,
39
+ raw: (_d = attr.nameNode) === null || _d === void 0 ? void 0 : _d.raw,
40
+ message,
41
+ });
42
+ }
57
43
  });
58
44
  },
59
45
  async fix({ document }) {
60
- await document.walkOn('Element', node => {
61
- if (node.isForeignElement || node.isCustomElement) {
46
+ await document.walkOn('Attr', attr => {
47
+ var _a;
48
+ const el = attr.ownerElement;
49
+ if (el.isForeignElement || el.isCustomElement) {
62
50
  return;
63
51
  }
64
- const attrSpecs = (0, ml_core_1.getAttrSpecs)(node.nameWithNS, document.specs);
65
- let value;
66
- // Convert deprecated value
67
- switch (node.rule.value) {
68
- case 'no-lower':
69
- value = 'upper';
70
- break;
71
- case 'no-upper':
72
- value = 'lower';
73
- break;
74
- default:
75
- value = node.rule.value;
52
+ const attrSpecs = (0, ml_core_1.getAttrSpecs)(el, document.specs);
53
+ const value = attr.rule.value;
54
+ /**
55
+ * Ignore when it has the potential name,
56
+ * it Interprets `tabIndex` to `tabindex` in JSX for example.
57
+ */
58
+ if (((_a = attr.nameNode) === null || _a === void 0 ? void 0 : _a.raw) !== attr.name) {
59
+ return;
76
60
  }
77
- if (node.attributes) {
78
- for (const attr of node.attributes) {
79
- if (attr.attrType === 'ps-attr') {
80
- continue;
81
- }
82
- /**
83
- * Ignore when it has the potential name,
84
- * it Interprets `tabIndex` to `tabindex` in JSX for example.
85
- */
86
- if (attr.name.raw !== attr.potentialName) {
87
- continue;
88
- }
89
- const name = attr.getName();
90
- if (attrSpecs) {
91
- const spec = attrSpecs.find(spec => spec.name === name.raw);
92
- if (spec && spec.caseSensitive) {
93
- continue;
94
- }
95
- }
96
- if (value === 'lower') {
97
- attr.name.fix(attr.name.raw.toLowerCase());
98
- }
99
- else {
100
- attr.name.fix(attr.name.raw.toUpperCase());
101
- }
61
+ const name = attr.name;
62
+ if (attrSpecs) {
63
+ const spec = attrSpecs.find(spec => spec.name === name);
64
+ if (spec && spec.caseSensitive) {
65
+ return;
102
66
  }
103
67
  }
68
+ if (value === 'lower') {
69
+ attr.nameNode.fix(name.toLowerCase());
70
+ }
71
+ else {
72
+ attr.nameNode.fix(name.toUpperCase());
73
+ }
104
74
  });
105
75
  },
106
76
  });
@@ -5,41 +5,49 @@ exports.default = (0, ml_core_1.createRule)({
5
5
  defaultServerity: 'warning',
6
6
  defaultValue: 'lower',
7
7
  async verify({ document, report, t }) {
8
- await document.walk(node => {
9
- if ('fixNodeName' in node) {
10
- if (node.isForeignElement || node.isCustomElement || node.type === 'OmittedElement') {
11
- return;
12
- }
13
- const ms = node.rule.severity === 'error' ? 'must' : 'should';
14
- const deny = node.rule.value === 'lower' ? /[A-Z]/ : /[a-z]/;
15
- const message = t(`{0} ${ms} be {1}`, t('{0} of {1}', 'tag names', 'HTML elements'), `${node.rule.value}case`);
16
- if (deny.test(node.nodeName)) {
17
- const loc = node.getNameLocation();
18
- report({
19
- scope: node,
20
- message,
21
- line: loc.line,
22
- col: loc.col,
23
- raw: node.nodeName,
24
- });
25
- }
8
+ await document.walkOn('Element', el => {
9
+ if (el.isForeignElement || el.isCustomElement) {
10
+ return;
11
+ }
12
+ const ms = el.rule.severity === 'error' ? 'must' : 'should';
13
+ const deny = el.rule.value === 'lower' ? /[A-Z]/ : /[a-z]/;
14
+ const message = t(`{0} ${ms} be {1}`, t('{0} of {1}', 'tag names', 'HTML elements'), `${el.rule.value}case`);
15
+ if (deny.test(el.rawName)) {
16
+ const loc = el.getNameLocation();
17
+ report({
18
+ scope: el,
19
+ message,
20
+ line: loc.line,
21
+ col: loc.col,
22
+ raw: el.rawName,
23
+ });
24
+ }
25
+ const closeTag = el.closeTag;
26
+ if (closeTag && deny.test(closeTag.raw)) {
27
+ report({
28
+ scope: {
29
+ rule: el.rule,
30
+ startLine: closeTag.startLine,
31
+ startCol: closeTag.startCol,
32
+ raw: closeTag.raw,
33
+ },
34
+ message,
35
+ });
26
36
  }
27
37
  });
28
38
  },
29
39
  async fix({ document }) {
30
- await document.walk(node => {
31
- if ('fixNodeName' in node) {
32
- if (node.isForeignElement || node.isCustomElement) {
33
- return;
40
+ await document.walkOn('Element', el => {
41
+ if (el.isForeignElement || el.isCustomElement) {
42
+ return;
43
+ }
44
+ const deny = el.rule.value === 'lower' ? /[A-Z]/ : /[a-z]/;
45
+ if (deny.test(el.nodeName)) {
46
+ if (el.rule.value === 'lower') {
47
+ el.fixNodeName(el.nodeName.toLowerCase());
34
48
  }
35
- const deny = node.rule.value === 'lower' ? /[A-Z]/ : /[a-z]/;
36
- if (deny.test(node.nodeName)) {
37
- if (node.rule.value === 'lower') {
38
- node.fixNodeName(node.nodeName.toLowerCase());
39
- }
40
- else {
41
- node.fixNodeName(node.nodeName.toUpperCase());
42
- }
49
+ else {
50
+ el.fixNodeName(el.nodeName.toUpperCase());
43
51
  }
44
52
  }
45
53
  });
@@ -1,2 +1,3 @@
1
- declare const _default: import("@markuplint/ml-core").RuleSeed<import("@markuplint/ml-core").RuleConfigValue, null>;
1
+ import type { RuleConfigValue } from '@markuplint/ml-config';
2
+ declare const _default: import("@markuplint/ml-core").RuleSeed<RuleConfigValue, null>;
2
3
  export default _default;
@@ -26,17 +26,15 @@ exports.default = (0, ml_core_1.createRule)({
26
26
  const ms = severity === 'error' ? 'must' : 'should';
27
27
  const message = t(`{0} ${ms} {1}`, 'Illegal characters', 'escape in character reference');
28
28
  for (const attr of node.attributes) {
29
- if (attr.attrType === 'ps-attr' ||
30
- (attr.attrType === 'html-attr' && attr.isDynamicValue) ||
31
- (attr.attrType === 'html-attr' && attr.isDirective)) {
29
+ if (attr.isDynamicValue || attr.isDirective) {
32
30
  continue;
33
31
  }
34
- const value = attr.getValue();
32
+ const valueNode = attr.valueNode;
35
33
  targetNodes.push({
36
34
  scope: node,
37
- line: value.line,
38
- col: value.col,
39
- raw: value.raw,
35
+ line: valueNode === null || valueNode === void 0 ? void 0 : valueNode.startLine,
36
+ col: valueNode === null || valueNode === void 0 ? void 0 : valueNode.startCol,
37
+ raw: valueNode === null || valueNode === void 0 ? void 0 : valueNode.raw,
40
38
  message,
41
39
  });
42
40
  }
@@ -6,29 +6,29 @@ exports.default = (0, ml_core_1.createRule)({
6
6
  defaultServerity: 'warning',
7
7
  defaultValue: null,
8
8
  async verify({ document, report, t }) {
9
- await document.walkOn('Element', node => {
10
- if (!node.rule.value) {
9
+ await document.walkOn('Element', el => {
10
+ if (!el.rule.value) {
11
11
  return;
12
12
  }
13
- const classPatterns = Array.isArray(node.rule.value) ? node.rule.value : [node.rule.value];
14
- const attrs = node.getAttributeToken('class');
13
+ const classPatterns = Array.isArray(el.rule.value) ? el.rule.value : [el.rule.value];
14
+ const attrs = el.getAttributeToken('class');
15
15
  for (const attr of attrs) {
16
- if (attr.attrType === 'html-attr' && attr.isDynamicValue) {
16
+ if (attr.isDynamicValue) {
17
17
  continue;
18
18
  }
19
- const classAttr = attr.getValue();
20
- const classList = classAttr.potential
19
+ const classAttr = attr.valueNode;
20
+ const classList = attr.value
21
21
  .split(/\s+/g)
22
22
  .map(c => c.trim())
23
23
  .filter(c => c);
24
24
  for (const className of classList) {
25
25
  if (!classPatterns.some(pattern => (0, helpers_1.match)(className, pattern))) {
26
26
  report({
27
- scope: node,
27
+ scope: attr,
28
28
  message: t('{0} is unmatched with the below patterns: {1}', t('the "{0*}" {1}', className, 'class name'), `"${classPatterns.join('", "')}"`),
29
- line: classAttr.line,
30
- col: classAttr.col,
31
- raw: classAttr.raw,
29
+ line: classAttr === null || classAttr === void 0 ? void 0 : classAttr.startLine,
30
+ col: classAttr === null || classAttr === void 0 ? void 0 : classAttr.startCol,
31
+ raw: classAttr === null || classAttr === void 0 ? void 0 : classAttr.raw,
32
32
  });
33
33
  }
34
34
  }
@@ -3,27 +3,26 @@ 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
5
  async verify({ document, report, t }) {
6
- await document.walkOn('Element', element => {
7
- const attrSpecs = (0, ml_core_1.getAttrSpecs)(element.nameWithNS, document.specs);
6
+ await document.walkOn('Attr', attr => {
7
+ var _a, _b, _c;
8
+ const attrSpecs = (0, ml_core_1.getAttrSpecs)(attr.ownerElement, document.specs);
8
9
  if (!attrSpecs) {
9
10
  return;
10
11
  }
11
- for (const attr of element.attributes) {
12
- const name = attr.getName();
13
- const attrSpec = attrSpecs.find(item => item.name === name.potential);
14
- if (!attrSpec) {
15
- return;
16
- }
17
- if (attrSpec.deprecated || attrSpec.obsolete) {
18
- const message = t('{0} is {1:c}', t('the "{0*}" {1}', name.potential, 'attribute'), attrSpec.obsolete ? 'obsolete' : 'deprecated');
19
- report({
20
- scope: element,
21
- message,
22
- line: name.line,
23
- col: name.col,
24
- raw: name.raw,
25
- });
26
- }
12
+ const name = attr.name;
13
+ const attrSpec = attrSpecs.find(item => item.name === name);
14
+ if (!attrSpec) {
15
+ return;
16
+ }
17
+ if (attrSpec.deprecated || attrSpec.obsolete) {
18
+ const message = t('{0} is {1:c}', t('the "{0*}" {1}', name, 'attribute'), attrSpec.obsolete ? 'obsolete' : 'deprecated');
19
+ report({
20
+ scope: attr,
21
+ line: (_a = attr.nameNode) === null || _a === void 0 ? void 0 : _a.startLine,
22
+ col: (_b = attr.nameNode) === null || _b === void 0 ? void 0 : _b.startCol,
23
+ raw: (_c = attr.nameNode) === null || _c === void 0 ? void 0 : _c.raw,
24
+ message,
25
+ });
27
26
  }
28
27
  });
29
28
  },
@@ -1,19 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const html_spec_1 = tslib_1.__importDefault(require("@markuplint/html-spec"));
5
3
  const ml_core_1 = require("@markuplint/ml-core");
6
- const ml_spec_1 = require("@markuplint/ml-spec");
7
4
  exports.default = (0, ml_core_1.createRule)({
8
5
  async verify({ document, report, t }) {
9
6
  await document.walkOn('Element', el => {
10
- const ns = el.ns;
11
- if (!(ns === 'html' || ns === 'svg') || el.isCustomElement) {
7
+ if (!(el.namespaceURI === 'http://www.w3.org/1999/xhtml' ||
8
+ el.namespaceURI === 'http://www.w3.org/2000/svg') ||
9
+ el.isCustomElement) {
12
10
  return;
13
11
  }
14
- const spec = (0, ml_spec_1.getSpecByTagName)(el.nameWithNS, html_spec_1.default);
12
+ const spec = (0, ml_core_1.getSpec)(el, document.specs);
15
13
  if (spec && (spec.obsolete || spec.deprecated || spec.nonStandard)) {
16
- const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.nodeName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete ? 'obsolete' : 'non-standard');
14
+ const message = t('{0} is {1:c}', t('the "{0*}" {1}', el.localName, 'element'), spec.deprecated ? 'deprecated' : spec.obsolete ? 'obsolete' : 'non-standard');
17
15
  report({
18
16
  scope: el,
19
17
  message,
@@ -3,31 +3,30 @@ 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
5
  defaultValue: [],
6
- defaultOptions: null,
7
- async verify({ document, report, t, globalRule }) {
8
- for (const query of globalRule.value) {
9
- const elements = document.matchNodes(query);
10
- for (const el of elements) {
6
+ async verify({ document, report, t }) {
7
+ for (const query of document.rule.value) {
8
+ const elements = document.querySelectorAll(query);
9
+ elements.forEach(el => {
11
10
  const message = t('{0} is disallowed', t('the "{0*}" {1}', query, 'element'));
12
11
  report({
13
12
  scope: el,
14
13
  message,
15
14
  });
16
- }
15
+ });
17
16
  }
18
17
  await document.walkOn('Element', el => {
19
- if (el.rule.value === globalRule.value) {
18
+ if (el.rule.value === document.rule.value) {
20
19
  return;
21
20
  }
22
21
  for (const query of el.rule.value) {
23
22
  const elements = el.querySelectorAll(query);
24
- for (const el of elements) {
23
+ elements.forEach(el => {
25
24
  const message = t('{0} is disallowed', t('the "{0*}" {1}', query, 'element'));
26
25
  report({
27
26
  scope: el,
28
27
  message,
29
28
  });
30
- }
29
+ });
31
30
  }
32
31
  });
33
32
  },
@@ -6,14 +6,14 @@ exports.default = (0, ml_core_1.createRule)({
6
6
  defaultOptions: {
7
7
  denyObsolateType: true,
8
8
  },
9
- verify(context) {
10
- if (context.document.isFragment) {
9
+ verify({ document, report, t }) {
10
+ if (document.isFragment) {
11
11
  return;
12
12
  }
13
- const doctype = context.document.doctype;
13
+ const doctype = document.doctype;
14
14
  if (!doctype) {
15
- context.report({
16
- message: context.translate('Require {0}', 'doctype'),
15
+ report({
16
+ message: t('Require {0}', 'doctype'),
17
17
  line: 1,
18
18
  col: 1,
19
19
  raw: '',
@@ -21,9 +21,9 @@ exports.default = (0, ml_core_1.createRule)({
21
21
  return;
22
22
  }
23
23
  if ((doctype.name.toLowerCase() === 'html' && doctype.publicId) || doctype.systemId) {
24
- context.report({
24
+ report({
25
25
  scope: doctype,
26
- message: context.translate('Never {0} {1}', 'declarate', 'obsolete doctype'),
26
+ message: t('Never {0} {1}', 'declarate', 'obsolete doctype'),
27
27
  });
28
28
  }
29
29
  },
@@ -25,7 +25,10 @@ exports.default = (0, ml_core_1.createRule)({
25
25
  }
26
26
  await document.walkOn('Element', el => {
27
27
  var _a;
28
- if (voidElements.some(vE => vE === el.nodeName.toLowerCase())) {
28
+ if (el.isOmitted) {
29
+ return;
30
+ }
31
+ if (voidElements.some(vE => vE === el.localName)) {
29
32
  return;
30
33
  }
31
34
  if (el.closeTag != null) {
@@ -0,0 +1,7 @@
1
+ import type { Element } from '@markuplint/ml-core';
2
+ import type { ARIA, ARIAVersion, MLMLSpec } from '@markuplint/ml-spec';
3
+ export declare function getARIA(
4
+ specs: Readonly<MLMLSpec>,
5
+ el: Element<any, any>,
6
+ version: ARIAVersion,
7
+ ): Omit<ARIA, ARIAVersion | 'conditions'> | null;