@markuplint/types 3.7.0 → 3.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,166 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const token_collection_1 = require('./token-collection');
5
-
6
- const _1 = require('.');
7
- test('parse', () => {
8
- expect(new token_collection_1.TokenCollection(' a b c ').toJSON()).toStrictEqual([
9
- {
10
- offset: 0,
11
- type: 13,
12
- value: ' ',
13
- },
14
- {
15
- offset: 1,
16
- type: 1,
17
- value: 'a',
18
- },
19
- {
20
- offset: 2,
21
- type: 13,
22
- value: ' ',
23
- },
24
- {
25
- offset: 4,
26
- type: 1,
27
- value: 'b',
28
- },
29
- {
30
- offset: 5,
31
- type: 13,
32
- value: ' ',
33
- },
34
- {
35
- offset: 8,
36
- type: 1,
37
- value: 'c',
38
- },
39
- {
40
- offset: 9,
41
- type: 13,
42
- value: ' ',
43
- },
44
- ]);
45
- });
46
- test('parse comma separator', () => {
47
- expect(new token_collection_1.TokenCollection('a,, ,b,cde', { separator: 'comma' }).toJSON()).toStrictEqual([
48
- {
49
- offset: 0,
50
- type: 1,
51
- value: 'a',
52
- },
53
- {
54
- offset: 1,
55
- type: 18,
56
- value: ',',
57
- },
58
- {
59
- offset: 2,
60
- type: 18,
61
- value: ',',
62
- },
63
- {
64
- offset: 3,
65
- type: 13,
66
- value: ' ',
67
- },
68
- {
69
- offset: 4,
70
- type: 18,
71
- value: ',',
72
- },
73
- {
74
- offset: 5,
75
- type: 1,
76
- value: 'b',
77
- },
78
- {
79
- offset: 6,
80
- type: 18,
81
- value: ',',
82
- },
83
- {
84
- offset: 7,
85
- type: 1,
86
- value: 'cde',
87
- },
88
- ]);
89
- });
90
- test('A comma is an ident if the comma is not a separator', () => {
91
- expect(new token_collection_1.TokenCollection('a ,cde , f').toJSON()).toStrictEqual([
92
- {
93
- offset: 0,
94
- type: 1,
95
- value: 'a',
96
- },
97
- {
98
- offset: 1,
99
- type: 13,
100
- value: ' ',
101
- },
102
- {
103
- offset: 2,
104
- type: 1,
105
- value: ',cde',
106
- },
107
- {
108
- offset: 6,
109
- type: 13,
110
- value: ' ',
111
- },
112
- {
113
- offset: 7,
114
- type: 1,
115
- value: ',',
116
- },
117
- {
118
- offset: 8,
119
- type: 13,
120
- value: ' ',
121
- },
122
- {
123
- offset: 9,
124
- type: 1,
125
- value: 'f',
126
- },
127
- ]);
128
- });
129
- test('getConsecutiveToken', () => {
130
- let _a;
131
- expect(
132
- new token_collection_1.TokenCollection('a,b,c', { separator: 'comma' }).getConsecutiveToken(_1.Token.Comma),
133
- ).toBeFalsy();
134
- expect(
135
- new token_collection_1.TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(_1.Token.Comma),
136
- ).toBeTruthy();
137
- expect(
138
- (_a = new token_collection_1.TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(
139
- _1.Token.Comma,
140
- )) === null || _a === void 0
141
- ? void 0
142
- : _a.offset,
143
- ).toBe(2);
144
- });
145
- test('fromPatterns', () => {
146
- const patterns = [/\+|-/, /[0-9]{2}/, /:?/, /[0-9]{2}/];
147
- expect(token_collection_1.TokenCollection.fromPatterns('+00:00', patterns).map(t => t.value)).toStrictEqual([
148
- '+',
149
- '00',
150
- ':',
151
- '00',
152
- ]);
153
- expect(token_collection_1.TokenCollection.fromPatterns('+0000', patterns).map(t => t.value)).toStrictEqual([
154
- '+',
155
- '00',
156
- '',
157
- '00',
158
- ]);
159
- expect(token_collection_1.TokenCollection.fromPatterns('+00/00', patterns).map(t => t.value)).toStrictEqual([
160
- '+',
161
- '00',
162
- '',
163
- '',
164
- '/00',
165
- ]);
166
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,36 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const check_serialized_permissions_policy_1 = require('./check-serialized-permissions-policy');
5
- const check = (0, check_serialized_permissions_policy_1.checkSerializedPermissionsPolicy)();
6
- test('checkSerializedPermissionsPolicy', () => {
7
- expect(check('').reason).toBe('empty-token');
8
- expect(check(' ').reason).toBe('unexpected-token');
9
- // expect(check('a').reason).toBe('missing-token');
10
- expect(check('a').matched).toBe(true); // Current supported
11
- expect(check('a:').reason).toBe('unexpected-token');
12
- // expect(check('a ').reason).toBe('missing-token'); // Current supported
13
- expect(check('a ').matched).toBe(true);
14
- expect(check('a a').reason).toBe('unexpected-token');
15
- expect(check('a *').matched).toBe(true);
16
- expect(check('a *a').reason).toBe('unexpected-token');
17
- expect(check('a none').reason).toBe('missing-token');
18
- expect(check("a 'none'").matched).toBe(true);
19
- expect(check('a https://markuplint.dev').matched).toBe(true);
20
- expect(check('a https://markuplint.dev/path/to').reason).toBe('extra-token');
21
- expect(check('a https://マルチバイト.abc.xyz').reason).toBe('must-be-serialized');
22
- expect(check('a * https://markuplint.dev').matched).toBe(true);
23
- expect(check("a * https://markuplint.dev 'none'").matched).toBe(true);
24
- // expect(check("a * https://markuplint.dev 'none';b").reason).toBe('missing-token');
25
- expect(check("a * https://markuplint.dev 'none';b").matched).toBe(true); // Current supported
26
- // expect(check("a * https://markuplint.dev 'none';b ").reason).toBe('missing-token');
27
- expect(check("a * https://markuplint.dev 'none';b ").matched).toBe(true); // Current supported
28
- expect(check("a * https://markuplint.dev 'none';b *").matched).toBe(true);
29
- expect(check("a * https://markuplint.dev 'none';b *;c 'none'").matched).toBe(true);
30
- expect(check("a * https://markuplint.dev 'none'; b *; c 'none'").matched).toBe(true);
31
- });
32
- test('YouTube embed', () => {
33
- expect(
34
- check('accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture').matched,
35
- ).toBe(true);
36
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,380 +0,0 @@
1
- 'use strict';
2
- // @ts-nocheck
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
- const check_autocomplete_1 = require('./check-autocomplete');
5
- const check = (0, check_autocomplete_1.checkAutoComplete)();
6
- test('basic', () => {
7
- expect(check('on').matched).toBe(true);
8
- expect(check('on webauthn').matched).toBe(false);
9
- expect(check('off').matched).toBe(true);
10
- expect(check('off webauthn').matched).toBe(false);
11
- expect(check('name').matched).toBe(true);
12
- expect(check('given-name').matched).toBe(true);
13
- expect(check('given-name webauthn').matched).toBe(true);
14
- expect(check('given-name webauthun').matched).toBe(false);
15
- expect(check('section-').matched).toBe(true);
16
- expect(check('section-foo').matched).toBe(true);
17
- expect(check('section-foo webauthn').matched).toBe(true);
18
- expect(check('section-foo name').matched).toBe(true);
19
- expect(check('section-foo name webauthn').matched).toBe(true);
20
- expect(check('section-foo shipping name').matched).toBe(true);
21
- expect(check('section-foo billing name').matched).toBe(true);
22
- expect(check('section-foo billing home').matched).toBe(true);
23
- expect(check('section-foo billing work').matched).toBe(true);
24
- expect(check('section-foo billing home tel').matched).toBe(true);
25
- expect(check('section-foo billing work email').matched).toBe(true);
26
- expect(check('section-foo billing work email webauthn').matched).toBe(true);
27
- expect(check('shipping name').matched).toBe(true);
28
- expect(check('billing name').matched).toBe(true);
29
- expect(check('billing home').matched).toBe(true);
30
- expect(check('billing work').matched).toBe(true);
31
- expect(check('billing home tel').matched).toBe(true);
32
- expect(check('billing work email').matched).toBe(true);
33
- expect(check('billing work email webauthn').matched).toBe(true);
34
- expect(check('home tel').matched).toBe(true);
35
- expect(check('work email').matched).toBe(true);
36
- expect(check('work email webauthn').matched).toBe(true);
37
- });
38
- test('unexpected-token', () => {
39
- expect(check('section-foo , name')).toStrictEqual({
40
- matched: false,
41
- raw: ',',
42
- offset: 12,
43
- length: 1,
44
- line: 1,
45
- column: 13,
46
- reason: 'unexpected-token',
47
- expects: [
48
- { type: 'const', value: 'billing' },
49
- { type: 'const', value: 'shipping' },
50
- { type: 'common', value: 'autofill field name' },
51
- ],
52
- candidate: undefined,
53
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
54
- });
55
- });
56
- test('unexpected-token', () => {
57
- expect(check('xxx')).toStrictEqual({
58
- matched: false,
59
- raw: 'xxx',
60
- offset: 0,
61
- length: 3,
62
- line: 1,
63
- column: 1,
64
- reason: 'unexpected-token',
65
- expects: [
66
- { type: 'common', value: 'autofill named group' },
67
- { type: 'common', value: 'autofill field name' },
68
- ],
69
- candidate: undefined,
70
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
71
- });
72
- });
73
- test('unexpected-token', () => {
74
- expect(check('section-foo neme')).toStrictEqual({
75
- matched: false,
76
- raw: 'neme',
77
- offset: 12,
78
- length: 4,
79
- line: 1,
80
- column: 13,
81
- reason: 'unexpected-token',
82
- expects: [
83
- { type: 'const', value: 'billing' },
84
- { type: 'const', value: 'shipping' },
85
- { type: 'common', value: 'autofill field name' },
86
- ],
87
- candidate: 'name',
88
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
89
- });
90
- expect(check('section-foo shipping neme')).toStrictEqual({
91
- matched: false,
92
- raw: 'neme',
93
- offset: 21,
94
- length: 4,
95
- line: 1,
96
- column: 22,
97
- reason: 'unexpected-token',
98
- expects: [
99
- { type: 'common', value: 'autofill field name' },
100
- { type: 'const', value: 'home' },
101
- { type: 'const', value: 'work' },
102
- { type: 'const', value: 'mobile' },
103
- { type: 'const', value: 'fax' },
104
- { type: 'const', value: 'pager' },
105
- ],
106
- candidate: 'name',
107
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
108
- });
109
- expect(check('section-foo shipping home name')).toStrictEqual({
110
- matched: false,
111
- raw: 'name',
112
- offset: 26,
113
- length: 4,
114
- line: 1,
115
- column: 27,
116
- reason: 'unexpected-token',
117
- expects: [
118
- { type: 'const', value: 'tel' },
119
- { type: 'const', value: 'tel-country-code' },
120
- { type: 'const', value: 'tel-national' },
121
- { type: 'const', value: 'tel-area-code' },
122
- { type: 'const', value: 'tel-local' },
123
- { type: 'const', value: 'tel-local-prefix' },
124
- { type: 'const', value: 'tel-local-suffix' },
125
- { type: 'const', value: 'tel-extension' },
126
- { type: 'const', value: 'email' },
127
- { type: 'const', value: 'impp' },
128
- ],
129
- candidate: undefined,
130
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
131
- });
132
- expect(check('section-foo shipping home emall')).toStrictEqual({
133
- matched: false,
134
- raw: 'emall',
135
- offset: 26,
136
- length: 5,
137
- line: 1,
138
- column: 27,
139
- reason: 'unexpected-token',
140
- expects: [
141
- { type: 'const', value: 'tel' },
142
- { type: 'const', value: 'tel-country-code' },
143
- { type: 'const', value: 'tel-national' },
144
- { type: 'const', value: 'tel-area-code' },
145
- { type: 'const', value: 'tel-local' },
146
- { type: 'const', value: 'tel-local-prefix' },
147
- { type: 'const', value: 'tel-local-suffix' },
148
- { type: 'const', value: 'tel-extension' },
149
- { type: 'const', value: 'email' },
150
- { type: 'const', value: 'impp' },
151
- ],
152
- candidate: 'email',
153
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
154
- });
155
- });
156
- test('duplicated', () => {
157
- expect(check('name name')).toStrictEqual({
158
- matched: false,
159
- raw: 'name',
160
- offset: 5,
161
- length: 4,
162
- line: 1,
163
- column: 6,
164
- partName: 'the content of the list',
165
- reason: 'duplicated',
166
- expects: [{ type: 'format', value: 'autocomplete' }],
167
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete',
168
- });
169
- expect(check('on on')).toStrictEqual({
170
- matched: false,
171
- raw: 'on',
172
- offset: 3,
173
- length: 2,
174
- line: 1,
175
- column: 4,
176
- partName: 'the content of the list',
177
- reason: 'duplicated',
178
- expects: [{ type: 'format', value: 'autocomplete' }],
179
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete',
180
- });
181
- });
182
- test('extra-token', () => {
183
- expect(check('on off')).toStrictEqual({
184
- matched: false,
185
- raw: 'off',
186
- offset: 3,
187
- length: 3,
188
- line: 1,
189
- column: 4,
190
- reason: 'extra-token',
191
- expects: [{ type: 'format', value: 'autocomplete' }],
192
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
193
- });
194
- expect(check('off on')).toStrictEqual({
195
- matched: false,
196
- raw: 'on',
197
- offset: 4,
198
- length: 2,
199
- line: 1,
200
- column: 5,
201
- reason: 'extra-token',
202
- expects: [{ type: 'format', value: 'autocomplete' }],
203
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
204
- });
205
- expect(check('on name')).toStrictEqual({
206
- matched: false,
207
- raw: 'name',
208
- offset: 3,
209
- length: 4,
210
- line: 1,
211
- column: 4,
212
- reason: 'extra-token',
213
- expects: [{ type: 'format', value: 'autocomplete' }],
214
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
215
- });
216
- expect(check('name on')).toStrictEqual({
217
- matched: false,
218
- raw: 'on',
219
- offset: 5,
220
- length: 2,
221
- line: 1,
222
- column: 6,
223
- reason: 'extra-token',
224
- expects: [{ type: 'format', value: 'autocomplete' }],
225
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
226
- });
227
- expect(check('section-foo name on')).toStrictEqual({
228
- matched: false,
229
- raw: 'on',
230
- offset: 17,
231
- length: 2,
232
- line: 1,
233
- column: 18,
234
- reason: 'extra-token',
235
- expects: [{ type: 'format', value: 'autocomplete' }],
236
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
237
- });
238
- expect(check('section-foo billing name on')).toStrictEqual({
239
- matched: false,
240
- raw: 'on',
241
- offset: 25,
242
- length: 2,
243
- line: 1,
244
- column: 26,
245
- reason: 'extra-token',
246
- expects: [{ type: 'format', value: 'autocomplete' }],
247
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
248
- });
249
- expect(check('billing name on')).toStrictEqual({
250
- matched: false,
251
- raw: 'on',
252
- offset: 13,
253
- length: 2,
254
- line: 1,
255
- column: 14,
256
- reason: 'extra-token',
257
- expects: [{ type: 'format', value: 'autocomplete' }],
258
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
259
- });
260
- expect(check('tel on')).toStrictEqual({
261
- matched: false,
262
- raw: 'on',
263
- offset: 4,
264
- length: 2,
265
- line: 1,
266
- column: 5,
267
- reason: 'extra-token',
268
- expects: [{ type: 'format', value: 'autocomplete' }],
269
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
270
- });
271
- expect(check('home tel on')).toStrictEqual({
272
- matched: false,
273
- raw: 'on',
274
- offset: 9,
275
- length: 2,
276
- line: 1,
277
- column: 10,
278
- reason: 'extra-token',
279
- expects: [{ type: 'format', value: 'autocomplete' }],
280
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
281
- });
282
- expect(check('billing home tel on')).toStrictEqual({
283
- matched: false,
284
- raw: 'on',
285
- offset: 17,
286
- length: 2,
287
- line: 1,
288
- column: 18,
289
- reason: 'extra-token',
290
- expects: [{ type: 'format', value: 'autocomplete' }],
291
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
292
- });
293
- expect(check('billing home tel on')).toStrictEqual({
294
- matched: false,
295
- raw: 'on',
296
- offset: 17,
297
- length: 2,
298
- line: 1,
299
- column: 18,
300
- reason: 'extra-token',
301
- expects: [{ type: 'format', value: 'autocomplete' }],
302
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
303
- });
304
- expect(check('section-foo billing home tel on')).toStrictEqual({
305
- matched: false,
306
- raw: 'on',
307
- offset: 29,
308
- length: 2,
309
- line: 1,
310
- column: 30,
311
- reason: 'extra-token',
312
- expects: [{ type: 'format', value: 'autocomplete' }],
313
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
314
- });
315
- expect(check('section-foo home tel on')).toStrictEqual({
316
- matched: false,
317
- raw: 'on',
318
- offset: 21,
319
- length: 2,
320
- line: 1,
321
- column: 22,
322
- reason: 'extra-token',
323
- expects: [{ type: 'format', value: 'autocomplete' }],
324
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
325
- });
326
- expect(check('section-foo tel on')).toStrictEqual({
327
- matched: false,
328
- raw: 'on',
329
- offset: 16,
330
- length: 2,
331
- line: 1,
332
- column: 17,
333
- reason: 'extra-token',
334
- expects: [{ type: 'format', value: 'autocomplete' }],
335
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
336
- });
337
- });
338
- test('duplicated section', () => {
339
- expect(check('section-foo section-bar')).toStrictEqual({
340
- matched: false,
341
- raw: 'section-bar',
342
- offset: 12,
343
- length: 11,
344
- line: 1,
345
- column: 13,
346
- partName: 'autofill named group',
347
- reason: 'duplicated',
348
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-section',
349
- });
350
- });
351
- test('duplicated part', () => {
352
- expect(check('shipping billing')).toStrictEqual({
353
- matched: false,
354
- raw: 'billing',
355
- offset: 9,
356
- length: 7,
357
- line: 1,
358
- column: 10,
359
- reason: 'duplicated',
360
- expects: [{ type: 'format', value: 'autocomplete' }],
361
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-shipping',
362
- });
363
- });
364
- test('typo', () => {
365
- expect(check('secsion-foo name')).toStrictEqual({
366
- matched: false,
367
- raw: 'secsion-foo',
368
- offset: 0,
369
- length: 11,
370
- line: 1,
371
- column: 1,
372
- reason: 'unexpected-token',
373
- expects: [
374
- { type: 'common', value: 'autofill named group' },
375
- { type: 'common', value: 'autofill field name' },
376
- ],
377
- candidate: 'section-foo',
378
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
379
- });
380
- });
@@ -1 +0,0 @@
1
- export {};