@markuplint/rules 3.13.0 → 4.0.0-alpha.2

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 (142) hide show
  1. package/lib/attr-check.js +14 -19
  2. package/lib/attr-duplication/index.js +3 -6
  3. package/lib/attr-value-quotes/index.js +5 -9
  4. package/lib/case-sensitive-attr-name/index.js +9 -13
  5. package/lib/case-sensitive-tag-name/index.js +2 -4
  6. package/lib/character-reference/index.js +6 -8
  7. package/lib/class-naming/index.js +9 -11
  8. package/lib/create-message.js +9 -16
  9. package/lib/debug.js +2 -6
  10. package/lib/deprecated-attr/index.js +6 -9
  11. package/lib/deprecated-element/index.js +3 -5
  12. package/lib/disallowed-element/index.js +2 -4
  13. package/lib/doctype/index.js +2 -4
  14. package/lib/end-tag/index.js +5 -8
  15. package/lib/helpers.d.ts +1 -1
  16. package/lib/helpers.js +17 -28
  17. package/lib/id-duplication/index.js +2 -4
  18. package/lib/index.d.ts +15 -15
  19. package/lib/index.js +63 -66
  20. package/lib/ineffective-attr/index.js +5 -7
  21. package/lib/invalid-attr/index.js +30 -33
  22. package/lib/label-has-control/index.js +2 -4
  23. package/lib/landmark-roles/index.js +3 -6
  24. package/lib/no-boolean-attr-value/index.js +6 -9
  25. package/lib/no-default-value/index.js +9 -12
  26. package/lib/no-empty-palpable-content/index.js +5 -7
  27. package/lib/no-hard-code-id/index.js +2 -4
  28. package/lib/no-refer-to-non-existent-id/index.js +26 -30
  29. package/lib/no-use-event-handler-attr/index.js +4 -6
  30. package/lib/permitted-contents/choice.d.ts +1 -1
  31. package/lib/permitted-contents/choice.js +13 -18
  32. package/lib/permitted-contents/complex-branch.d.ts +1 -1
  33. package/lib/permitted-contents/complex-branch.js +10 -14
  34. package/lib/permitted-contents/content-model.d.ts +1 -1
  35. package/lib/permitted-contents/content-model.js +5 -9
  36. package/lib/permitted-contents/count-pattern.d.ts +1 -1
  37. package/lib/permitted-contents/count-pattern.js +19 -24
  38. package/lib/permitted-contents/debug.browser.js +9 -12
  39. package/lib/permitted-contents/debug.d.ts +8 -1
  40. package/lib/permitted-contents/debug.js +12 -13
  41. package/lib/permitted-contents/index.d.ts +1 -1
  42. package/lib/permitted-contents/index.js +10 -13
  43. package/lib/permitted-contents/matches-selector.d.ts +1 -1
  44. package/lib/permitted-contents/matches-selector.js +12 -17
  45. package/lib/permitted-contents/order.d.ts +1 -1
  46. package/lib/permitted-contents/order.js +17 -22
  47. package/lib/permitted-contents/recursive-branch.d.ts +2 -2
  48. package/lib/permitted-contents/recursive-branch.js +9 -13
  49. package/lib/permitted-contents/represent-transparent-nodes.d.ts +1 -1
  50. package/lib/permitted-contents/represent-transparent-nodes.js +15 -20
  51. package/lib/permitted-contents/start.d.ts +1 -1
  52. package/lib/permitted-contents/start.js +13 -21
  53. package/lib/permitted-contents/transparent.d.ts +1 -1
  54. package/lib/permitted-contents/transparent.js +4 -9
  55. package/lib/permitted-contents/types.js +1 -2
  56. package/lib/permitted-contents/utils.d.ts +1 -1
  57. package/lib/permitted-contents/utils.js +55 -74
  58. package/lib/placeholder-label-option/index.js +5 -9
  59. package/lib/require-accessible-name/index.js +10 -13
  60. package/lib/require-datetime/index.d.ts +1 -1
  61. package/lib/require-datetime/index.js +6 -8
  62. package/lib/require-datetime/types.js +1 -2
  63. package/lib/require-datetime/utils.d.ts +1 -1
  64. package/lib/require-datetime/utils.js +4 -11
  65. package/lib/required-attr/index.js +8 -11
  66. package/lib/required-element/index.js +3 -6
  67. package/lib/required-h1/index.js +3 -6
  68. package/lib/use-list/index.js +6 -10
  69. package/lib/wai-aria/checkings/abstract-role.d.ts +1 -1
  70. package/lib/wai-aria/checkings/abstract-role.js +5 -10
  71. package/lib/wai-aria/checkings/default-value.d.ts +1 -1
  72. package/lib/wai-aria/checkings/default-value.js +2 -6
  73. package/lib/wai-aria/checkings/deprecated-props.d.ts +1 -1
  74. package/lib/wai-aria/checkings/deprecated-props.js +3 -8
  75. package/lib/wai-aria/checkings/disallowed-prop.d.ts +1 -1
  76. package/lib/wai-aria/checkings/disallowed-prop.js +7 -12
  77. package/lib/wai-aria/checkings/implicit-props.d.ts +1 -1
  78. package/lib/wai-aria/checkings/implicit-props.js +6 -11
  79. package/lib/wai-aria/checkings/implicit-role.d.ts +1 -1
  80. package/lib/wai-aria/checkings/implicit-role.js +4 -9
  81. package/lib/wai-aria/checkings/interaction-in-hidden.d.ts +1 -1
  82. package/lib/wai-aria/checkings/interaction-in-hidden.js +4 -8
  83. package/lib/wai-aria/checkings/no-global-prop.d.ts +1 -1
  84. package/lib/wai-aria/checkings/no-global-prop.js +2 -7
  85. package/lib/wai-aria/checkings/non-existent-role.d.ts +1 -1
  86. package/lib/wai-aria/checkings/non-existent-role.js +4 -9
  87. package/lib/wai-aria/checkings/permitted-roles.d.ts +1 -1
  88. package/lib/wai-aria/checkings/permitted-roles.js +4 -9
  89. package/lib/wai-aria/checkings/presentational-children.d.ts +1 -1
  90. package/lib/wai-aria/checkings/presentational-children.js +4 -9
  91. package/lib/wai-aria/checkings/required-owned-elements.d.ts +1 -1
  92. package/lib/wai-aria/checkings/required-owned-elements.js +4 -8
  93. package/lib/wai-aria/checkings/required-prop.d.ts +1 -1
  94. package/lib/wai-aria/checkings/required-prop.js +2 -7
  95. package/lib/wai-aria/checkings/value.d.ts +1 -1
  96. package/lib/wai-aria/checkings/value.js +4 -10
  97. package/lib/wai-aria/index.d.ts +1 -1
  98. package/lib/wai-aria/index.js +38 -40
  99. package/lib/wai-aria/types.js +1 -2
  100. package/package.json +17 -12
  101. package/test/attr-check.spec.js +0 -77
  102. package/test/attr-duplication/index.spec.js +0 -159
  103. package/test/attr-value-quotes/index.spec.js +0 -133
  104. package/test/case-sensitive-attr-name/index.spec.js +0 -65
  105. package/test/case-sensitive-tag-name/index.spec.js +0 -80
  106. package/test/character-reference/index.spec.js +0 -72
  107. package/test/class-naming/index.spec.js +0 -470
  108. package/test/create-message.spec.js +0 -497
  109. package/test/deprecated-attr/index.spec.js +0 -48
  110. package/test/deprecated-element/index.spec.js +0 -35
  111. package/test/disallowed-element/index.spec.js +0 -90
  112. package/test/doctype/index.spec.js +0 -50
  113. package/test/end-tag/index.spec.js +0 -162
  114. package/test/id-duplication/index.spec.js +0 -47
  115. package/test/ineffective-attr/index.spec.js +0 -31
  116. package/test/invalid-attr/index.spec.js +0 -1631
  117. package/test/label-has-control/index.spec.js +0 -29
  118. package/test/landmark-roles/index.spec.js +0 -187
  119. package/test/no-boolean-attr-value/index.spec.js +0 -41
  120. package/test/no-default-value/index.spec.js +0 -74
  121. package/test/no-empty-palpable-content/index.spec.js +0 -115
  122. package/test/no-hard-code-id/index.spec.js +0 -100
  123. package/test/no-refer-to-non-existent-id/index.spec.js +0 -254
  124. package/test/no-use-event-handler-attr/index.spec.js +0 -57
  125. package/test/permitted-contents/choice.spec.js +0 -174
  126. package/test/permitted-contents/count-pattern.spec.js +0 -308
  127. package/test/permitted-contents/index.spec.js +0 -1395
  128. package/test/permitted-contents/matches-selector.spec.js +0 -59
  129. package/test/permitted-contents/order.spec.js +0 -351
  130. package/test/permitted-contents/recursive-branch.spec.js +0 -41
  131. package/test/permitted-contents/represent-transparent-nodes.spec.js +0 -24
  132. package/test/permitted-contents/start.spec.js +0 -67
  133. package/test/placeholder-label-option/index.spec.js +0 -113
  134. package/test/require-accessible-name/index.spec.js +0 -444
  135. package/test/require-datetime/index.spec.js +0 -54
  136. package/test/require-datetime/utils.spec.js +0 -52
  137. package/test/required-attr/index.spec.js +0 -414
  138. package/test/required-element/index.spec.js +0 -188
  139. package/test/required-h1/index.spec.js +0 -69
  140. package/test/use-list/index.spec.js +0 -109
  141. package/test/wai-aria/checkings/value.spec.js +0 -33
  142. package/test/wai-aria/index.spec.js +0 -1203
@@ -1,50 +0,0 @@
1
- const { mlRuleTest } = require('markuplint');
2
-
3
- const rule = require('../../lib/doctype').default;
4
-
5
- test('valid', async () => {
6
- const { violations } = await mlRuleTest(
7
- rule,
8
- `
9
- <!doctype html>
10
- <html></html>
11
- `,
12
- );
13
- expect(violations.length).toBe(0);
14
- });
15
-
16
- test('missing doctype', async () => {
17
- const { violations } = await mlRuleTest(rule, '<html></html>');
18
- expect(violations).toStrictEqual([
19
- {
20
- severity: 'error',
21
- message: 'Require doctype',
22
- line: 1,
23
- col: 1,
24
- raw: '',
25
- },
26
- ]);
27
- });
28
-
29
- test('document fragment', async () => {
30
- const { violations } = await mlRuleTest(rule, '<div></div>');
31
- expect(violations.length).toBe(0);
32
- });
33
-
34
- test('obsolete doctypes', async () => {
35
- const { violations } = await mlRuleTest(
36
- rule,
37
- `
38
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
39
- <div></div>
40
- `,
41
- { rule: 'always' },
42
- );
43
- expect(violations[0]).toStrictEqual({
44
- severity: 'error',
45
- raw: '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
46
- line: 2,
47
- col: 3,
48
- message: 'Never declare obsolete doctype',
49
- });
50
- });
@@ -1,162 +0,0 @@
1
- const { mlRuleTest } = require('markuplint');
2
-
3
- const rule = require('../../lib/end-tag').default;
4
-
5
- it('basic', async () => {
6
- expect((await mlRuleTest(rule, '<html><body></body></html>')).violations.length).toBe(0);
7
- expect((await mlRuleTest(rule, '<html><body></body>')).violations).toStrictEqual([
8
- {
9
- severity: 'warning',
10
- line: 1,
11
- col: 1,
12
- message: 'Missing the end tag',
13
- raw: '<html>',
14
- },
15
- ]);
16
- });
17
-
18
- it('HTML', async () => {
19
- expect((await mlRuleTest(rule, '<div><span><span /></div>')).violations).toStrictEqual([
20
- {
21
- severity: 'warning',
22
- line: 1,
23
- col: 6,
24
- message: 'Missing the end tag',
25
- raw: '<span>',
26
- },
27
- {
28
- severity: 'warning',
29
- line: 1,
30
- col: 12,
31
- message: 'Missing the end tag',
32
- raw: '<span />',
33
- },
34
- ]);
35
- });
36
-
37
- it('HTML', async () => {
38
- expect((await mlRuleTest(rule, '<div><img><img /></div>')).violations).toStrictEqual([]);
39
- });
40
-
41
- it('SVG', async () => {
42
- expect(
43
- (
44
- await mlRuleTest(
45
- rule,
46
- `<svg>
47
- <defs>
48
- <clipPath>
49
- <circle />
50
- <circle></circle>
51
- </clipPath>
52
- </defs>
53
- </svg>`,
54
- )
55
- ).violations,
56
- ).toStrictEqual([]);
57
- });
58
-
59
- it('pug', async () => {
60
- expect(
61
- (
62
- await mlRuleTest(
63
- rule,
64
- `html
65
- body
66
- p text`,
67
- {
68
- parser: {
69
- '.*': '@markuplint/pug-parser',
70
- },
71
- },
72
- )
73
- ).violations.length,
74
- ).toBe(0);
75
- });
76
-
77
- it('React', async () => {
78
- expect(
79
- (
80
- await mlRuleTest(rule, '<div><span><span /></div>', {
81
- parser: {
82
- '.*': '@markuplint/jsx-parser',
83
- },
84
- })
85
- ).violations,
86
- ).toStrictEqual([
87
- {
88
- severity: 'error',
89
- line: 1,
90
- col: 6,
91
- message: "JSX element 'span' has no corresponding closing tag.",
92
- raw: '',
93
- },
94
- ]);
95
- });
96
-
97
- it('Vue', async () => {
98
- expect(
99
- (
100
- await mlRuleTest(rule, '<template><div><span><span /></div></template>', {
101
- parser: {
102
- '.*': '@markuplint/vue-parser',
103
- },
104
- })
105
- ).violations,
106
- ).toStrictEqual([
107
- {
108
- severity: 'warning',
109
- line: 1,
110
- col: 16,
111
- message: 'Missing the end tag',
112
- raw: '<span>',
113
- },
114
- ]);
115
- });
116
-
117
- it('Svelte', async () => {
118
- expect(
119
- (
120
- await mlRuleTest(rule, '<div><span><span /></div>', {
121
- parser: {
122
- '.*': '@markuplint/svelte-parser',
123
- },
124
- })
125
- ).violations,
126
- ).toStrictEqual([
127
- {
128
- severity: 'warning',
129
- line: 1,
130
- col: 6,
131
- message: 'Missing the end tag',
132
- raw: '<span>',
133
- },
134
- ]);
135
- });
136
-
137
- it('Astro', async () => {
138
- expect(
139
- (
140
- await mlRuleTest(rule, '<div><span><span /></div>', {
141
- parser: {
142
- '.*': '@markuplint/astro-parser',
143
- },
144
- })
145
- ).violations,
146
- ).toStrictEqual([
147
- {
148
- severity: 'warning',
149
- line: 1,
150
- col: 1,
151
- message: 'Missing the end tag',
152
- raw: '<div>',
153
- },
154
- {
155
- severity: 'warning',
156
- line: 1,
157
- col: 6,
158
- message: 'Missing the end tag',
159
- raw: '<span>',
160
- },
161
- ]);
162
- });
@@ -1,47 +0,0 @@
1
- const { mlRuleTest } = require('markuplint');
2
-
3
- const rule = require('../../lib/id-duplication').default;
4
-
5
- test('id-duplication', async () => {
6
- const { violations } = await mlRuleTest(rule, '<div id="a"><p id="a"></p></div>');
7
- expect(violations).toStrictEqual([
8
- {
9
- severity: 'error',
10
- message: 'The value of the "id" attribute is duplicated',
11
- line: 1,
12
- col: 16,
13
- raw: 'id="a"',
14
- },
15
- ]);
16
- });
17
-
18
- test('id-duplication', async () => {
19
- const { violations } = await mlRuleTest(rule, '<div id="a"></div>');
20
- expect(violations.length).toBe(0);
21
- });
22
-
23
- test('id-duplication', async () => {
24
- const { violations } = await mlRuleTest(rule, '<div id="a"></div><div id="a"></div><div id="a"></div>');
25
- expect(violations.length).toBe(2);
26
- });
27
-
28
- test('id-duplication', async () => {
29
- const { violations } = await mlRuleTest(rule, '<div id="a"></div><div id="b"></div><div id="c"></div>');
30
- expect(violations.length).toBe(0);
31
- });
32
-
33
- test('in Vue', async () => {
34
- const { violations } = await mlRuleTest(
35
- rule,
36
- `<template>
37
- <div v-if="bool"><span :id="uuid"></span></div>
38
- <div v-else><span :id="uuid"></span></div>
39
- </template>`,
40
- {
41
- parser: {
42
- '.*': '@markuplint/vue-parser',
43
- },
44
- },
45
- );
46
- expect(violations.length).toBe(0);
47
- });
@@ -1,31 +0,0 @@
1
- const { mlRuleTest } = require('markuplint');
2
-
3
- const rule = require('../../lib/ineffective-attr').default;
4
-
5
- test('script[defer]', async () => {
6
- const { violations } = await mlRuleTest(rule, '<script defer>const foo = "foo";</script>');
7
-
8
- expect(violations).toStrictEqual([
9
- {
10
- severity: 'warning',
11
- line: 1,
12
- col: 9,
13
- message: 'The "defer" attribute is ineffective. It doesn\'t need the attribute',
14
- raw: 'defer',
15
- },
16
- ]);
17
- });
18
-
19
- test('script[src][type=module][defer]', async () => {
20
- const { violations } = await mlRuleTest(rule, '<script type="module" src="path/to" defer></script>');
21
-
22
- expect(violations).toStrictEqual([
23
- {
24
- severity: 'warning',
25
- line: 1,
26
- col: 37,
27
- message: 'The "defer" attribute is ineffective. It doesn\'t need the attribute',
28
- raw: 'defer',
29
- },
30
- ]);
31
- });