@markuplint/rules 3.12.0 → 4.0.0-alpha.1

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 -1641
  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,497 +0,0 @@
1
- const { translator } = require('@markuplint/i18n');
2
- const { i18n } = require('markuplint');
3
-
4
- const { __createMessageValueExpected } = require('../lib/create-message');
5
-
6
- let t;
7
-
8
- beforeAll(async () => {
9
- const locale = await i18n('en');
10
- t = translator(locale);
11
- });
12
-
13
- // TODO: doesnt-exist-in-enum
14
-
15
- describe('duplicated', () => {
16
- test('expects: without, partName: without', () => {
17
- expect(
18
- __createMessageValueExpected(t, 'A', '', {
19
- ref: 'REF',
20
- raw: 'RAW',
21
- reason: 'duplicated',
22
- }),
23
- ).toBe('A is duplicated (REF)');
24
- });
25
-
26
- test('expects: without, partName: with', () => {
27
- expect(
28
- __createMessageValueExpected(t, 'A', '', {
29
- ref: 'REF',
30
- raw: 'RAW',
31
- reason: 'duplicated',
32
- partName: 'C',
33
- }),
34
- ).toBe('the C part of A is duplicated (REF)');
35
- });
36
-
37
- test('expects: with, partName: without', () => {
38
- expect(
39
- __createMessageValueExpected(t, 'A', 'B', {
40
- ref: 'REF',
41
- raw: 'RAW',
42
- reason: 'duplicated',
43
- }),
44
- ).toBe('A is duplicated. It expects B (REF)');
45
- });
46
-
47
- test('expects: with, partName: with', () => {
48
- expect(
49
- __createMessageValueExpected(t, 'A', 'B', {
50
- ref: 'REF',
51
- raw: 'RAW',
52
- reason: 'duplicated',
53
- partName: 'C',
54
- }),
55
- ).toBe('the C part of A is duplicated. It expects B (REF)');
56
- });
57
- });
58
-
59
- describe('empty-token', () => {
60
- test('expects: without, partName: without', () => {
61
- expect(
62
- __createMessageValueExpected(t, 'A', '', {
63
- ref: 'REF',
64
- raw: 'RAW',
65
- reason: 'empty-token',
66
- }),
67
- ).toBe('A must not be empty (REF)');
68
- });
69
-
70
- test('expects: without, partName: with', () => {
71
- expect(
72
- __createMessageValueExpected(t, 'A', '', {
73
- ref: 'REF',
74
- raw: 'RAW',
75
- reason: 'empty-token',
76
- partName: 'C',
77
- }),
78
- ).toBe('the C part of A must not be empty (REF)');
79
- });
80
-
81
- test('expects: with, partName: without', () => {
82
- expect(
83
- __createMessageValueExpected(t, 'A', 'B', {
84
- ref: 'REF',
85
- raw: 'RAW',
86
- reason: 'empty-token',
87
- }),
88
- ).toBe('A must not be empty. It expects B (REF)');
89
- });
90
-
91
- test('expects: with, partName: with', () => {
92
- expect(
93
- __createMessageValueExpected(t, 'A', 'B', {
94
- ref: 'REF',
95
- raw: 'RAW',
96
- reason: 'empty-token',
97
- partName: 'C',
98
- }),
99
- ).toBe('the C part of A must not be empty. It expects B (REF)');
100
- });
101
- });
102
-
103
- describe('extra-token', () => {
104
- test('expects: without, partName: without', () => {
105
- expect(
106
- __createMessageValueExpected(t, 'A', '', {
107
- ref: 'REF',
108
- raw: 'RAW',
109
- reason: 'extra-token',
110
- }),
111
- ).toBe('Found extra token "RAW" (REF)');
112
- });
113
-
114
- test('expects: without, partName: with', () => {
115
- expect(
116
- __createMessageValueExpected(t, 'A', '', {
117
- ref: 'REF',
118
- raw: 'RAW',
119
- reason: 'extra-token',
120
- partName: 'C',
121
- }),
122
- ).toBe('Found extra C "RAW" (REF)');
123
- });
124
-
125
- test('expects: with, partName: without', () => {
126
- expect(
127
- __createMessageValueExpected(t, 'A', 'B', {
128
- ref: 'REF',
129
- raw: 'RAW',
130
- reason: 'extra-token',
131
- }),
132
- ).toBe('Found extra token "RAW". A expects B (REF)');
133
- });
134
-
135
- test('expects: with, partName: with', () => {
136
- expect(
137
- __createMessageValueExpected(t, 'A', 'B', {
138
- ref: 'REF',
139
- raw: 'RAW',
140
- reason: 'extra-token',
141
- partName: 'C',
142
- }),
143
- ).toBe('Found extra C "RAW". the C part of A expects B (REF)');
144
- });
145
- });
146
-
147
- describe('illegal-combination', () => {
148
- test('expects: without, partName: without', () => {
149
- expect(
150
- __createMessageValueExpected(t, 'A', '', {
151
- ref: 'REF',
152
- raw: 'RAW',
153
- reason: 'illegal-combination',
154
- }),
155
- ).toBe('Found an illegal combination (REF)');
156
- });
157
-
158
- test('expects: without, partName: with', () => {
159
- expect(
160
- __createMessageValueExpected(t, 'A', '', {
161
- ref: 'REF',
162
- raw: 'RAW',
163
- reason: 'illegal-combination',
164
- partName: 'C',
165
- }),
166
- ).toBe('Found an illegal combination (REF)');
167
- });
168
-
169
- test('expects: with, partName: without', () => {
170
- expect(
171
- __createMessageValueExpected(t, 'A', 'B', {
172
- ref: 'REF',
173
- raw: 'RAW',
174
- reason: 'illegal-combination',
175
- }),
176
- ).toBe('Found an illegal combination. A expects B (REF)');
177
- });
178
-
179
- test('expects: with, partName: with', () => {
180
- expect(
181
- __createMessageValueExpected(t, 'A', 'B', {
182
- ref: 'REF',
183
- raw: 'RAW',
184
- reason: 'illegal-combination',
185
- partName: 'C',
186
- }),
187
- ).toBe('Found an illegal combination. the C part of A expects B (REF)');
188
- });
189
- });
190
-
191
- describe('missing-comma', () => {
192
- test('expects: without, partName: without', () => {
193
- expect(
194
- __createMessageValueExpected(t, 'A', '', {
195
- ref: 'REF',
196
- raw: 'RAW',
197
- reason: 'missing-comma',
198
- }),
199
- ).toBe('Missing a comma (REF)');
200
- });
201
-
202
- test('expects: without, partName: with', () => {
203
- expect(
204
- __createMessageValueExpected(t, 'A', '', {
205
- ref: 'REF',
206
- raw: 'RAW',
207
- reason: 'missing-comma',
208
- partName: 'C',
209
- }),
210
- ).toBe('Missing a comma in the C part (REF)');
211
- });
212
-
213
- test('expects: with, partName: without', () => {
214
- expect(
215
- __createMessageValueExpected(t, 'A', 'B', {
216
- ref: 'REF',
217
- raw: 'RAW',
218
- reason: 'missing-comma',
219
- }),
220
- ).toBe('Missing a comma. A expects B (REF)');
221
- });
222
-
223
- test('expects: with, partName: with', () => {
224
- expect(
225
- __createMessageValueExpected(t, 'A', 'B', {
226
- ref: 'REF',
227
- raw: 'RAW',
228
- reason: 'missing-comma',
229
- partName: 'C',
230
- }),
231
- ).toBe('Missing a comma in the C part. It expects B (REF)');
232
- });
233
- });
234
-
235
- describe('missing-token', () => {
236
- test('expects: without, partName: without', () => {
237
- expect(
238
- __createMessageValueExpected(t, 'A', '', {
239
- ref: 'REF',
240
- raw: 'RAW',
241
- reason: 'missing-token',
242
- }),
243
- ).toBe('Missing a token (REF)');
244
- });
245
-
246
- test('expects: without, partName: with', () => {
247
- expect(
248
- __createMessageValueExpected(t, 'A', '', {
249
- ref: 'REF',
250
- raw: 'RAW',
251
- reason: 'missing-token',
252
- partName: 'C',
253
- }),
254
- ).toBe('Missing the C part. A needs the C part (REF)');
255
- });
256
-
257
- test('expects: with, partName: without', () => {
258
- expect(
259
- __createMessageValueExpected(t, 'A', 'B', {
260
- ref: 'REF',
261
- raw: 'RAW',
262
- reason: 'missing-token',
263
- }),
264
- ).toBe('Missing a token. A needs B (REF)');
265
- });
266
-
267
- test('expects: with, partName: with', () => {
268
- expect(
269
- __createMessageValueExpected(t, 'A', 'B', {
270
- ref: 'REF',
271
- raw: 'RAW',
272
- reason: 'missing-token',
273
- partName: 'C',
274
- }),
275
- ).toBe('Missing the C part. the C part of A needs B (REF)');
276
- });
277
- });
278
-
279
- describe('unexpected-comma', () => {
280
- test('expects: without, partName: without', () => {
281
- expect(
282
- __createMessageValueExpected(t, 'A', '', {
283
- ref: 'REF',
284
- raw: 'RAW',
285
- reason: 'unexpected-comma',
286
- }),
287
- ).toBe('Found unexpected comma (REF)');
288
- });
289
-
290
- test('expects: without, partName: with', () => {
291
- expect(
292
- __createMessageValueExpected(t, 'A', '', {
293
- ref: 'REF',
294
- raw: 'RAW',
295
- reason: 'unexpected-comma',
296
- partName: 'C',
297
- }),
298
- ).toBe('Found unexpected comma (REF)');
299
- });
300
-
301
- test('expects: with, partName: without', () => {
302
- expect(
303
- __createMessageValueExpected(t, 'A', 'B', {
304
- ref: 'REF',
305
- raw: 'RAW',
306
- reason: 'unexpected-comma',
307
- }),
308
- ).toBe('Found unexpected comma. A expects B (REF)');
309
- });
310
-
311
- test('expects: with, partName: with', () => {
312
- expect(
313
- __createMessageValueExpected(t, 'A', 'B', {
314
- ref: 'REF',
315
- raw: 'RAW',
316
- reason: 'unexpected-comma',
317
- partName: 'C',
318
- }),
319
- ).toBe('Found unexpected comma. the C part of A expects B (REF)');
320
- });
321
- });
322
-
323
- describe('unexpected-newline', () => {
324
- test('expects: without, partName: without', () => {
325
- expect(
326
- __createMessageValueExpected(t, 'A', '', {
327
- ref: 'REF',
328
- raw: 'RAW',
329
- reason: 'unexpected-newline',
330
- }),
331
- ).toBe('Found unexpected newline (REF)');
332
- });
333
-
334
- test('expects: without, partName: with', () => {
335
- expect(
336
- __createMessageValueExpected(t, 'A', '', {
337
- ref: 'REF',
338
- raw: 'RAW',
339
- reason: 'unexpected-newline',
340
- partName: 'C',
341
- }),
342
- ).toBe('Found unexpected newline (REF)');
343
- });
344
-
345
- test('expects: with, partName: without', () => {
346
- expect(
347
- __createMessageValueExpected(t, 'A', 'B', {
348
- ref: 'REF',
349
- raw: 'RAW',
350
- reason: 'unexpected-newline',
351
- }),
352
- ).toBe('Found unexpected newline. A expects B (REF)');
353
- });
354
-
355
- test('expects: with, partName: with', () => {
356
- expect(
357
- __createMessageValueExpected(t, 'A', 'B', {
358
- ref: 'REF',
359
- raw: 'RAW',
360
- reason: 'unexpected-newline',
361
- partName: 'C',
362
- }),
363
- ).toBe('Found unexpected newline. the C part of A expects B (REF)');
364
- });
365
- });
366
-
367
- describe('unexpected-space', () => {
368
- test('expects: without, partName: without', () => {
369
- expect(
370
- __createMessageValueExpected(t, 'A', '', {
371
- ref: 'REF',
372
- raw: 'RAW',
373
- reason: 'unexpected-space',
374
- }),
375
- ).toBe('Found unexpected whitespace (REF)');
376
- });
377
-
378
- test('expects: without, partName: with', () => {
379
- expect(
380
- __createMessageValueExpected(t, 'A', '', {
381
- ref: 'REF',
382
- raw: 'RAW',
383
- reason: 'unexpected-space',
384
- partName: 'C',
385
- }),
386
- ).toBe('Found unexpected whitespace (REF)');
387
- });
388
-
389
- test('expects: with, partName: without', () => {
390
- expect(
391
- __createMessageValueExpected(t, 'A', 'B', {
392
- ref: 'REF',
393
- raw: 'RAW',
394
- reason: 'unexpected-space',
395
- }),
396
- ).toBe('Found unexpected whitespace. A expects B (REF)');
397
- });
398
-
399
- test('expects: with, partName: with', () => {
400
- expect(
401
- __createMessageValueExpected(t, 'A', 'B', {
402
- ref: 'REF',
403
- raw: 'RAW',
404
- reason: 'unexpected-space',
405
- partName: 'C',
406
- }),
407
- ).toBe('Found unexpected whitespace. the C part of A expects B (REF)');
408
- });
409
- });
410
-
411
- describe('unexpected-token', () => {
412
- test('expects: without, partName: without', () => {
413
- expect(
414
- __createMessageValueExpected(t, 'A', '', {
415
- ref: 'REF',
416
- raw: 'RAW',
417
- reason: 'unexpected-token',
418
- }),
419
- ).toBe('It includes unexpected characters (REF)');
420
- });
421
-
422
- test('expects: without, partName: with', () => {
423
- expect(
424
- __createMessageValueExpected(t, 'A', '', {
425
- ref: 'REF',
426
- raw: 'RAW',
427
- reason: 'unexpected-token',
428
- partName: 'C',
429
- }),
430
- ).toBe('the C part includes unexpected characters (REF)');
431
- });
432
-
433
- test('expects: with, partName: without', () => {
434
- expect(
435
- __createMessageValueExpected(t, 'A', 'B', {
436
- ref: 'REF',
437
- raw: 'RAW',
438
- reason: 'unexpected-token',
439
- }),
440
- ).toBe('It includes unexpected characters. A expects B (REF)');
441
- });
442
-
443
- test('expects: with, partName: with', () => {
444
- expect(
445
- __createMessageValueExpected(t, 'A', 'B', {
446
- ref: 'REF',
447
- raw: 'RAW',
448
- reason: 'unexpected-token',
449
- partName: 'C',
450
- }),
451
- ).toBe('the C part includes unexpected characters. It expects B (REF)');
452
- });
453
- });
454
-
455
- describe('out-of-range-length-digit', () => {
456
- test('expects: without, partName: without', () => {
457
- expect(
458
- __createMessageValueExpected(t, 'A', '', {
459
- ref: 'REF',
460
- raw: 'RAW',
461
- reason: { type: 'out-of-range-length-digit', gte: 4 },
462
- }),
463
- ).toBe('A expects four or more digits (REF)');
464
- });
465
-
466
- test('expects: without, partName: with', () => {
467
- expect(
468
- __createMessageValueExpected(t, 'A', '', {
469
- ref: 'REF',
470
- raw: 'RAW',
471
- reason: { type: 'out-of-range-length-digit', gte: 4 },
472
- partName: 'C',
473
- }),
474
- ).toBe('the C part of A expects four or more digits (REF)');
475
- });
476
-
477
- test('expects: with, partName: without', () => {
478
- expect(
479
- __createMessageValueExpected(t, 'A', 'B', {
480
- ref: 'REF',
481
- raw: 'RAW',
482
- reason: { type: 'out-of-range-length-digit', gte: 4 },
483
- }),
484
- ).toBe('A expects four or more digits and B (REF)');
485
- });
486
-
487
- test('expects: with, partName: with', () => {
488
- expect(
489
- __createMessageValueExpected(t, 'A', 'B', {
490
- ref: 'REF',
491
- raw: 'RAW',
492
- reason: { type: 'out-of-range-length-digit', gte: 4 },
493
- partName: 'C',
494
- }),
495
- ).toBe('the C part of A expects four or more digits and B (REF)');
496
- });
497
- });
@@ -1,48 +0,0 @@
1
- const { mlRuleTest } = require('markuplint');
2
-
3
- const rule = require('../../lib/deprecated-attr').default;
4
-
5
- test('deprecated attribute', async () => {
6
- const { violations } = await mlRuleTest(rule, '<img align="top">');
7
- expect(violations).toStrictEqual([
8
- {
9
- severity: 'error',
10
- line: 1,
11
- col: 6,
12
- raw: 'align',
13
- message: 'The "align" attribute is deprecated',
14
- },
15
- ]);
16
- });
17
-
18
- test('deprecated global attribute', async () => {
19
- const { violations } = await mlRuleTest(rule, '<img xml:lang="en-US">');
20
- expect(violations).toStrictEqual([
21
- {
22
- severity: 'error',
23
- line: 1,
24
- col: 6,
25
- raw: 'xml:lang',
26
- message: 'The "xml:lang" attribute is deprecated',
27
- },
28
- ]);
29
- });
30
-
31
- test('svg', async () => {
32
- const { violations } = await mlRuleTest(
33
- rule,
34
- `<svg viewBox="0 0 160 40" xmlns="http://www.w3.org/2000/svg">
35
- <a xlink:href="https://developer.mozilla.org/">
36
- <text x="10" y="25">MDN Web Docs</text></a>
37
- </svg>`,
38
- );
39
- expect(violations).toStrictEqual([
40
- {
41
- severity: 'error',
42
- line: 2,
43
- col: 14,
44
- message: 'The "xlink:href" attribute is deprecated',
45
- raw: 'xlink:href',
46
- },
47
- ]);
48
- });
@@ -1,35 +0,0 @@
1
- const { mlRuleTest } = require('markuplint');
2
-
3
- const rule = require('../../lib/deprecated-element').default;
4
-
5
- test('normal', async () => {
6
- const { violations } = await mlRuleTest(rule, '<div></div><p><span></span></p>');
7
- expect(violations).toStrictEqual([]);
8
- });
9
-
10
- test('deprecated', async () => {
11
- const { violations } = await mlRuleTest(rule, '<font></font><big><blink></blink></big>');
12
- expect(violations).toStrictEqual([
13
- {
14
- severity: 'error',
15
- message: 'The "font" element is obsolete',
16
- line: 1,
17
- col: 1,
18
- raw: '<font>',
19
- },
20
- {
21
- severity: 'error',
22
- message: 'The "big" element is obsolete',
23
- line: 1,
24
- col: 14,
25
- raw: '<big>',
26
- },
27
- {
28
- severity: 'error',
29
- message: 'The "blink" element is obsolete',
30
- line: 1,
31
- col: 19,
32
- raw: '<blink>',
33
- },
34
- ]);
35
- });
@@ -1,90 +0,0 @@
1
- const { mlRuleTest } = require('markuplint');
2
-
3
- const rule = require('../../lib/disallowed-element').default;
4
-
5
- it('specifies to global rule', async () => {
6
- const { violations } = await mlRuleTest(rule, '<div><hgroup><h1>Heading</h1></hgroup></div>', {
7
- rule: ['hgroup'],
8
- });
9
- expect(violations).toStrictEqual([
10
- {
11
- severity: 'error',
12
- line: 1,
13
- col: 6,
14
- raw: '<hgroup>',
15
- message: 'The "hgroup" element is disallowed',
16
- },
17
- ]);
18
- });
19
-
20
- it('specifies to node rule', async () => {
21
- const { violations } = await mlRuleTest(rule, '<h1><span>Title</span><small>Sub-title</small></h1>', {
22
- nodeRule: [
23
- {
24
- selector: 'h1, h2, h3, h4, h5, h6',
25
- rule: ['small'],
26
- },
27
- ],
28
- });
29
- expect(violations).toStrictEqual([
30
- {
31
- severity: 'error',
32
- line: 1,
33
- col: 23,
34
- raw: '<small>',
35
- message: 'The "small" element is disallowed',
36
- },
37
- ]);
38
- });
39
-
40
- it('Recommend', async () => {
41
- expect(
42
- (
43
- await mlRuleTest(
44
- rule,
45
- '<details><summary><label id="foo">foo</label></summary><input id="foo"/></details>',
46
- {
47
- nodeRule: [
48
- {
49
- selector: 'summary',
50
- rule: ['label'],
51
- },
52
- ],
53
- },
54
- )
55
- ).violations,
56
- ).toStrictEqual([
57
- {
58
- severity: 'error',
59
- line: 1,
60
- col: 19,
61
- raw: '<label id="foo">',
62
- message: 'The "label" element is disallowed',
63
- },
64
- ]);
65
-
66
- expect(
67
- (
68
- await mlRuleTest(
69
- rule,
70
- '<details><summary><label id="foo">foo</label></summary><input id="foo"/></details>',
71
- {
72
- nodeRule: [
73
- {
74
- selector: 'summary',
75
- rule: [':model(interactive)'],
76
- },
77
- ],
78
- },
79
- )
80
- ).violations,
81
- ).toStrictEqual([
82
- {
83
- severity: 'error',
84
- line: 1,
85
- col: 19,
86
- raw: '<label id="foo">',
87
- message: 'The ":model(interactive)" element is disallowed',
88
- },
89
- ]);
90
- });