@markuplint/types 3.5.0 → 3.6.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.
- package/lib/check.spec.js +63 -58
- package/lib/css-syntax.spec.js +151 -149
- package/lib/list.spec.js +117 -117
- package/lib/primitive/index.spec.js +52 -52
- package/lib/rfc/is-bcp-47.spec.js +8 -8
- package/lib/token/token-collection.spec.js +155 -134
- package/lib/w3c/check-serialized-permissions-policy.spec.js +30 -28
- package/lib/whatwg/check-autocomplete.spec.js +360 -360
- package/lib/whatwg/check-datetime/index.spec.js +277 -276
- package/lib/whatwg/check-mime-type.spec.js +52 -52
- package/lib/whatwg/is-abs-url.spec.js +5 -5
- package/lib/whatwg/is-itemprop-name.js +1 -1
- package/package.json +8 -10
- package/test/check.spec.js +89 -0
- package/test/css-syntax.spec.js +165 -0
- package/test/list.spec.js +133 -0
- package/test/primitive/index.spec.js +65 -0
- package/test/rfc/is-bcp-47.spec.js +23 -0
- package/test/token/token-collection.spec.js +146 -0
- package/test/w3c/check-serialized-permissions-policy.spec.js +36 -0
- package/test/whatwg/check-autocomplete.spec.js +387 -0
- package/test/whatwg/check-datetime/index.spec.js +336 -0
- package/test/whatwg/check-mime-type.spec.js +59 -0
- package/test/whatwg/is-abs-url.spec.js +8 -0
|
@@ -1,145 +1,166 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
const token_collection_1 = require(
|
|
5
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
const token_collection_1 = require('./token-collection');
|
|
5
|
+
|
|
6
|
+
const _1 = require('.');
|
|
6
7
|
test('parse', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
+
]);
|
|
44
45
|
});
|
|
45
46
|
test('parse comma separator', () => {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
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
|
+
]);
|
|
88
89
|
});
|
|
89
90
|
test('A comma is an ident if the comma is not a separator', () => {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
+
]);
|
|
127
128
|
});
|
|
128
129
|
test('getConsecutiveToken', () => {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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);
|
|
133
144
|
});
|
|
134
145
|
test('fromPatterns', () => {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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
|
+
]);
|
|
145
166
|
});
|
|
@@ -1,34 +1,36 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
// @ts-nocheck
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
const check_serialized_permissions_policy_1 = require(
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
const check_serialized_permissions_policy_1 = require('./check-serialized-permissions-policy');
|
|
5
5
|
const check = (0, check_serialized_permissions_policy_1.checkSerializedPermissionsPolicy)();
|
|
6
6
|
test('checkSerializedPermissionsPolicy', () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
31
|
});
|
|
32
32
|
test('YouTube embed', () => {
|
|
33
|
-
|
|
33
|
+
expect(
|
|
34
|
+
check('accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture').matched,
|
|
35
|
+
).toBe(true);
|
|
34
36
|
});
|