@markuplint/types 3.8.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.
- package/lib/check-multi-types.d.ts +2 -2
- package/lib/check-multi-types.js +9 -14
- package/lib/check.d.ts +1 -1
- package/lib/check.js +20 -30
- package/lib/css-syntax.d.ts +1 -1
- package/lib/css-syntax.js +18 -23
- package/lib/debug.js +2 -6
- package/lib/defs.d.ts +1 -1
- package/lib/defs.js +82 -85
- package/lib/enum.d.ts +2 -2
- package/lib/enum.js +6 -11
- package/lib/get-candidate.js +3 -8
- package/lib/index.d.ts +3 -3
- package/lib/index.js +3 -6
- package/lib/keyword-type.d.ts +2 -2
- package/lib/keyword-type.js +17 -22
- package/lib/list.d.ts +2 -2
- package/lib/list.js +9 -14
- package/lib/match-result.d.ts +1 -1
- package/lib/match-result.js +6 -13
- package/lib/number.d.ts +2 -2
- package/lib/number.js +11 -15
- package/lib/primitive/index.d.ts +7 -7
- package/lib/primitive/index.js +7 -17
- package/lib/primitive/is-float.js +1 -5
- package/lib/primitive/is-int.js +1 -5
- package/lib/primitive/is-non-zero-uint.js +1 -5
- package/lib/primitive/is-quantity.js +9 -13
- package/lib/primitive/is-uint.js +1 -5
- package/lib/primitive/range.js +1 -5
- package/lib/primitive/split-unit.js +3 -7
- package/lib/rfc/is-bcp-47.d.ts +1 -1
- package/lib/rfc/is-bcp-47.js +3 -7
- package/lib/token/index.d.ts +2 -2
- package/lib/token/index.js +2 -7
- package/lib/token/token-collection.d.ts +4 -5
- package/lib/token/token-collection.js +35 -43
- package/lib/token/token.d.ts +2 -2
- package/lib/token/token.js +6 -13
- package/lib/token/types.js +1 -2
- package/lib/types.d.ts +2 -2
- package/lib/types.js +1 -2
- package/lib/types.schema.js +1 -2
- package/lib/w3c/check-serialized-permissions-policy.d.ts +1 -1
- package/lib/w3c/check-serialized-permissions-policy.js +16 -20
- package/lib/whatwg/check-autocomplete.d.ts +1 -1
- package/lib/whatwg/check-autocomplete.js +24 -28
- package/lib/whatwg/check-datetime/date-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/date-string.js +9 -13
- package/lib/whatwg/check-datetime/datetime-tokens.d.ts +1 -1
- package/lib/whatwg/check-datetime/datetime-tokens.js +40 -46
- package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/duration-string.js +38 -44
- package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/global-date-and-time-string.js +17 -21
- package/lib/whatwg/check-datetime/index.d.ts +1 -1
- package/lib/whatwg/check-datetime/index.js +25 -29
- package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/local-date-and-time-string.js +20 -25
- package/lib/whatwg/check-datetime/month-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/month-string.js +9 -13
- package/lib/whatwg/check-datetime/time-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/time-string.js +9 -13
- package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +3 -3
- package/lib/whatwg/check-datetime/time-zone-offset-string.js +16 -22
- package/lib/whatwg/check-datetime/week-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/week-string.js +9 -13
- package/lib/whatwg/check-datetime/year-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/year-string.js +9 -13
- package/lib/whatwg/check-datetime/yearless-date-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/yearless-date-string.js +9 -13
- package/lib/whatwg/check-mime-type.d.ts +1 -1
- package/lib/whatwg/check-mime-type.js +11 -17
- package/lib/whatwg/is-abs-url.d.ts +1 -1
- package/lib/whatwg/is-abs-url.js +1 -5
- package/lib/whatwg/is-browser-context-name.d.ts +1 -1
- package/lib/whatwg/is-browser-context-name.js +1 -5
- package/lib/whatwg/is-custom-element-name.d.ts +1 -1
- package/lib/whatwg/is-custom-element-name.js +1 -5
- package/lib/whatwg/is-itemprop-name.d.ts +1 -1
- package/lib/whatwg/is-itemprop-name.js +1 -5
- package/package.json +13 -8
- package/test/check.spec.js +0 -89
- package/test/css-syntax.spec.js +0 -170
- package/test/list.spec.js +0 -133
- package/test/primitive/index.spec.js +0 -65
- package/test/rfc/is-bcp-47.spec.js +0 -23
- package/test/token/token-collection.spec.js +0 -146
- package/test/w3c/check-serialized-permissions-policy.spec.js +0 -36
- package/test/whatwg/check-autocomplete.spec.js +0 -387
- package/test/whatwg/check-datetime/index.spec.js +0 -336
- package/test/whatwg/check-mime-type.spec.js +0 -59
- package/test/whatwg/is-abs-url.spec.js +0 -8
package/test/check.spec.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
const { check } = require('../lib/check');
|
|
2
|
-
|
|
3
|
-
test('Any', () => {
|
|
4
|
-
expect(check('', 'Any').matched).toBe(true);
|
|
5
|
-
expect(check(' ', 'Any').matched).toBe(true);
|
|
6
|
-
expect(check('a', 'Any').matched).toBe(true);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
test('NoEmptyAny', () => {
|
|
10
|
-
expect(check('', 'NoEmptyAny').matched).toBe(false);
|
|
11
|
-
expect(check(' ', 'NoEmptyAny').matched).toBe(true);
|
|
12
|
-
expect(check('a', 'NoEmptyAny').matched).toBe(true);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
test('OneLineAny', () => {
|
|
16
|
-
expect(check('', 'OneLineAny').matched).toBe(true);
|
|
17
|
-
expect(check(' ', 'OneLineAny').matched).toBe(true);
|
|
18
|
-
expect(check('a', 'OneLineAny').matched).toBe(true);
|
|
19
|
-
expect(check('a ', 'OneLineAny').matched).toBe(true);
|
|
20
|
-
expect(check('a b', 'OneLineAny').matched).toBe(true);
|
|
21
|
-
expect(check('a\n', 'OneLineAny').matched).toBe(false);
|
|
22
|
-
expect(check('a\nb', 'OneLineAny').matched).toBe(false);
|
|
23
|
-
expect(check('a\r\nb', 'OneLineAny').matched).toBe(false);
|
|
24
|
-
expect(check('a\rb', 'OneLineAny').matched).toBe(false);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
test('Pattern', () => {
|
|
28
|
-
expect(check('.*', 'Pattern').matched).toBe(true);
|
|
29
|
-
expect(check('[a-z]+', 'Pattern').matched).toBe(true);
|
|
30
|
-
expect(check(']//[()?!+*', 'Pattern').matched).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
test('BCP47', () => {
|
|
34
|
-
expect(check('en', 'BCP47').matched).toBe(true);
|
|
35
|
-
expect(check('en-US', 'BCP47').matched).toBe(true);
|
|
36
|
-
expect(check('ja', 'BCP47').matched).toBe(true);
|
|
37
|
-
expect(check(' ja ', 'BCP47').matched).toBe(false);
|
|
38
|
-
expect(check('', 'BCP47').matched).toBe(false);
|
|
39
|
-
expect(check('zh/cn', 'BCP47').matched).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('Srcset', () => {
|
|
43
|
-
expect(check('a/bb/ccc/dddd', 'Srcset').matched).toBe(true);
|
|
44
|
-
expect(check('a/bb/ccc/dddd 200w', 'Srcset').matched).toBe(true);
|
|
45
|
-
expect(check('a/bb/ccc/dddd 200w, b/cc/ddd/eeee 1.5x', 'Srcset').matched).toBe(true);
|
|
46
|
-
expect(check('a/bb/ccc/dddd 200w, b/cc/ddd/eeee 1.5a', 'Srcset').matched).toBe(false);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('IconSize', () => {
|
|
50
|
-
expect(check('any', 'IconSize').matched).toBe(true);
|
|
51
|
-
expect(check('Any', 'IconSize').matched).toBe(true);
|
|
52
|
-
expect(check('10x10', 'IconSize').matched).toBe(true);
|
|
53
|
-
expect(check('1x1', 'IconSize').matched).toBe(true);
|
|
54
|
-
expect(check('1x0', 'IconSize').matched).toBe(false);
|
|
55
|
-
expect(check('0x1', 'IconSize').matched).toBe(false);
|
|
56
|
-
expect(check('0x0', 'IconSize').matched).toBe(false);
|
|
57
|
-
expect(check('', 'IconSize').matched).toBe(false);
|
|
58
|
-
expect(check(' ', 'IconSize').matched).toBe(false);
|
|
59
|
-
expect(check('1', 'IconSize').matched).toBe(false);
|
|
60
|
-
expect(check('1x', 'IconSize').matched).toBe(false);
|
|
61
|
-
expect(check('x1', 'IconSize').matched).toBe(false);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
test('Number', () => {
|
|
65
|
-
expect(check('10', { type: 'integer', gt: 0 }).matched).toBe(true);
|
|
66
|
-
expect(check('0', { type: 'integer', gt: 0 }).matched).toBe(false);
|
|
67
|
-
expect(check('0', { type: 'integer', gte: 0 }).matched).toBe(true);
|
|
68
|
-
expect(check('9', { type: 'integer', lt: 10 }).matched).toBe(true);
|
|
69
|
-
expect(check('10', { type: 'integer', lt: 10 }).matched).toBe(false);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
test('Non-exist types', () => {
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
expect(check('abc', 'String').matched).toBe(true);
|
|
75
|
-
// @ts-ignore
|
|
76
|
-
expect(check('abc', 'FooBar').matched).toBe(true);
|
|
77
|
-
// @ts-ignore
|
|
78
|
-
expect(check('abc', ' ').matched).toBe(true);
|
|
79
|
-
// @ts-ignore
|
|
80
|
-
expect(check('abc', '\n').matched).toBe(true);
|
|
81
|
-
// @ts-ignore
|
|
82
|
-
expect(check('abc', '').matched).toBe(true);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
test('ItemProp', () => {
|
|
86
|
-
expect(check('itemListElement', 'ItemProp').matched).toBe(true);
|
|
87
|
-
expect(check('item', 'ItemProp').matched).toBe(true);
|
|
88
|
-
expect(check('position', 'ItemProp').matched).toBe(true);
|
|
89
|
-
});
|
package/test/css-syntax.spec.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
const { cssSyntaxMatch } = require('../lib/css-syntax');
|
|
2
|
-
|
|
3
|
-
test('CSS Standard', () => {
|
|
4
|
-
expect(cssSyntaxMatch('10px', '<length>').matched).toBe(true);
|
|
5
|
-
expect(cssSyntaxMatch('one-pixel', '<length>').matched).toBe(false);
|
|
6
|
-
expect(cssSyntaxMatch('(prefers-color-scheme: dark)', '<media-query-list>').matched).toBe(true);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
test('Extends', () => {
|
|
10
|
-
const sourceSizeList = {
|
|
11
|
-
ref: 'https://html.spec.whatwg.org/multipage/images.html#sizes-attributes',
|
|
12
|
-
syntax: {
|
|
13
|
-
apply: '<source-size-list>',
|
|
14
|
-
def: {
|
|
15
|
-
'source-size-list': '[ <source-size># , ]? <source-size-value>',
|
|
16
|
-
'source-size': '<media-condition> <source-size-value> | auto',
|
|
17
|
-
'source-size-value': '<length> | auto',
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
expect(cssSyntaxMatch('50vw', sourceSizeList).matched).toBe(true);
|
|
22
|
-
expect(cssSyntaxMatch('(max-width: 600px) 200px, 50vw', sourceSizeList).matched).toBe(true);
|
|
23
|
-
expect(cssSyntaxMatch('print 300vw', sourceSizeList).matched).toBe(false);
|
|
24
|
-
expect(cssSyntaxMatch('(max-width: 600px) 200px', sourceSizeList).matched).toBe(false);
|
|
25
|
-
expect(cssSyntaxMatch('100vw', sourceSizeList).matched).toBe(true);
|
|
26
|
-
expect(cssSyntaxMatch('auto', sourceSizeList).matched).toBe(true);
|
|
27
|
-
expect(cssSyntaxMatch('auto, auto', sourceSizeList).matched).toBe(true);
|
|
28
|
-
expect(cssSyntaxMatch('auto, 100vw', sourceSizeList).matched).toBe(true);
|
|
29
|
-
expect(cssSyntaxMatch('auto, 100%', sourceSizeList).matched).toBe(false);
|
|
30
|
-
expect(
|
|
31
|
-
cssSyntaxMatch('(max-width: 600px) 200px', {
|
|
32
|
-
...sourceSizeList,
|
|
33
|
-
syntax: {
|
|
34
|
-
...sourceSizeList.syntax,
|
|
35
|
-
apply: '<source-size>',
|
|
36
|
-
},
|
|
37
|
-
}).matched,
|
|
38
|
-
).toBe(true);
|
|
39
|
-
|
|
40
|
-
const keyTimes = {
|
|
41
|
-
ref: 'https://svgwg.org/specs/animations/#KeyTimesAttribute',
|
|
42
|
-
syntax: {
|
|
43
|
-
apply: '<key-times>',
|
|
44
|
-
def: {
|
|
45
|
-
'key-times': '<number> [; <number>]* [;]?',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
};
|
|
49
|
-
expect(cssSyntaxMatch('20; 20; 30', keyTimes).matched).toBe(true);
|
|
50
|
-
expect(cssSyntaxMatch('20; 20; 30;', keyTimes).matched).toBe(true);
|
|
51
|
-
expect(cssSyntaxMatch('20; 20; abc;', keyTimes).matched).toBe(false);
|
|
52
|
-
expect(cssSyntaxMatch('20; 20; ;', keyTimes).matched).toBe(false);
|
|
53
|
-
|
|
54
|
-
const SVGViewBox = {
|
|
55
|
-
ref: 'https://svgwg.org/svg2-draft/coords.html#ViewBoxAttribute',
|
|
56
|
-
syntax: {
|
|
57
|
-
apply: '<view-box>',
|
|
58
|
-
def: {
|
|
59
|
-
'view-box': '<min-x> [,]? <min-y> [,]? <width> [,]? <height>',
|
|
60
|
-
'min-x': '<number>',
|
|
61
|
-
'min-y': '<number>',
|
|
62
|
-
width: '<number>',
|
|
63
|
-
height: '<number>',
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
expect(cssSyntaxMatch('0 0 30 10', SVGViewBox).matched).toBe(true);
|
|
68
|
-
expect(cssSyntaxMatch('0 0, 30, 10', SVGViewBox).matched).toBe(true);
|
|
69
|
-
expect(cssSyntaxMatch('0 0, 30', SVGViewBox).matched).toBe(false);
|
|
70
|
-
|
|
71
|
-
const percentageList = {
|
|
72
|
-
ref: 'https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#percentage',
|
|
73
|
-
syntax: {
|
|
74
|
-
apply: '<percentage-list>',
|
|
75
|
-
def: {
|
|
76
|
-
'percentage-list': '[ <number> [,]? ]* <number>',
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
expect(cssSyntaxMatch('0 0 30 10', percentageList).matched).toBe(true);
|
|
81
|
-
expect(cssSyntaxMatch('0, 0, 30 10', percentageList).matched).toBe(true);
|
|
82
|
-
expect(cssSyntaxMatch('0', percentageList).matched).toBe(true);
|
|
83
|
-
expect(cssSyntaxMatch('', percentageList).matched).toBe(false);
|
|
84
|
-
|
|
85
|
-
const custom = {
|
|
86
|
-
ref: 'n/a',
|
|
87
|
-
syntax: {
|
|
88
|
-
apply: '<custom>',
|
|
89
|
-
def: {
|
|
90
|
-
custom: '0 | 1 | .',
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
};
|
|
94
|
-
expect(cssSyntaxMatch('0', custom).matched).toBe(true);
|
|
95
|
-
expect(cssSyntaxMatch('1', custom).matched).toBe(true);
|
|
96
|
-
expect(cssSyntaxMatch('.', custom).matched).toBe(true);
|
|
97
|
-
expect(cssSyntaxMatch('2', custom).matched).toBe(false);
|
|
98
|
-
expect(cssSyntaxMatch(':', custom).matched).toBe(false);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
test('custom-type-checking', () => {
|
|
102
|
-
const custom = {
|
|
103
|
-
ref: 'n/a',
|
|
104
|
-
caseSensitive: true,
|
|
105
|
-
syntax: {
|
|
106
|
-
apply: '<custom>',
|
|
107
|
-
def: {
|
|
108
|
-
custom: '<custom-type>',
|
|
109
|
-
'custom-type': token => {
|
|
110
|
-
if (!token) {
|
|
111
|
-
return 0;
|
|
112
|
-
}
|
|
113
|
-
return token.value === '1' ? 1 : 0;
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
};
|
|
118
|
-
expect(cssSyntaxMatch('1', custom).matched).toBe(true);
|
|
119
|
-
expect(cssSyntaxMatch('0', custom).matched).toBe(false);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
test('case-sensitive', () => {
|
|
123
|
-
const custom = {
|
|
124
|
-
ref: 'n/a',
|
|
125
|
-
caseSensitive: true,
|
|
126
|
-
syntax: {
|
|
127
|
-
apply: '<custom>',
|
|
128
|
-
def: {
|
|
129
|
-
custom: 'CaSeS [a | B | aBc]',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
};
|
|
133
|
-
expect(cssSyntaxMatch('CaSeS a', custom).matched).toBe(true);
|
|
134
|
-
expect(cssSyntaxMatch('CaSeS B', custom).matched).toBe(true);
|
|
135
|
-
expect(cssSyntaxMatch('CaSeS aBc', custom).matched).toBe(true);
|
|
136
|
-
expect(cssSyntaxMatch('CaSeS A', custom)).toStrictEqual({
|
|
137
|
-
column: 7,
|
|
138
|
-
line: 1,
|
|
139
|
-
matched: false,
|
|
140
|
-
length: 1,
|
|
141
|
-
offset: 6,
|
|
142
|
-
partName: 'value',
|
|
143
|
-
raw: 'A',
|
|
144
|
-
reason: 'syntax-error',
|
|
145
|
-
ref: 'n/a',
|
|
146
|
-
expects: [
|
|
147
|
-
{
|
|
148
|
-
type: 'syntax',
|
|
149
|
-
value: '<custom>',
|
|
150
|
-
},
|
|
151
|
-
],
|
|
152
|
-
});
|
|
153
|
-
expect(cssSyntaxMatch('CaSeS abc', custom)).toStrictEqual({
|
|
154
|
-
column: 7,
|
|
155
|
-
line: 1,
|
|
156
|
-
matched: false,
|
|
157
|
-
length: 3,
|
|
158
|
-
offset: 6,
|
|
159
|
-
partName: 'value',
|
|
160
|
-
raw: 'abc',
|
|
161
|
-
reason: 'syntax-error',
|
|
162
|
-
ref: 'n/a',
|
|
163
|
-
expects: [
|
|
164
|
-
{
|
|
165
|
-
type: 'syntax',
|
|
166
|
-
value: '<custom>',
|
|
167
|
-
},
|
|
168
|
-
],
|
|
169
|
-
});
|
|
170
|
-
});
|
package/test/list.spec.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
const { checkList } = require('../lib/list');
|
|
2
|
-
|
|
3
|
-
test('Zero space', () => {
|
|
4
|
-
const type = { token: 'Zero', separator: 'space' };
|
|
5
|
-
expect(checkList('0', type).matched).toBe(true);
|
|
6
|
-
expect(checkList(' 0 ', type).matched).toBe(true);
|
|
7
|
-
expect(checkList(' 0 0', type).matched).toBe(true);
|
|
8
|
-
expect(checkList(' 0 0 ', type).matched).toBe(true);
|
|
9
|
-
expect(checkList('0 0 0 ', type).matched).toBe(true);
|
|
10
|
-
expect(checkList('0 0 0 0', type).matched).toBe(true);
|
|
11
|
-
expect(checkList('0 0 0 0', type).matched).toBe(true);
|
|
12
|
-
expect(checkList('1', type).matched).toBe(false);
|
|
13
|
-
expect(checkList(' 1 ', type).matched).toBe(false);
|
|
14
|
-
expect(checkList(' 1 0', type).matched).toBe(false);
|
|
15
|
-
expect(checkList(' 1 0 ', type).matched).toBe(false);
|
|
16
|
-
expect(checkList('0 1 0 ', type).matched).toBe(false);
|
|
17
|
-
expect(checkList('0 1 0 0', type).matched).toBe(false);
|
|
18
|
-
expect(checkList('0 1 0 0', type).matched).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('Zero comma', () => {
|
|
22
|
-
const type = { token: 'Zero', separator: 'comma' };
|
|
23
|
-
expect(checkList('0', type).matched).toBe(true);
|
|
24
|
-
expect(checkList(' 0 ', type).matched).toBe(true);
|
|
25
|
-
expect(checkList(' 0 0', type).matched).toBe(false);
|
|
26
|
-
expect(checkList(' 0,0', type).matched).toBe(true);
|
|
27
|
-
expect(checkList(' 0,,0 ', type).matched).toBe(false);
|
|
28
|
-
expect(checkList('0 0 0 ', type).matched).toBe(false);
|
|
29
|
-
expect(checkList(' 0,0,0,0 ', type).matched).toBe(true);
|
|
30
|
-
expect(checkList('0, 0, 0 , 0', type).matched).toBe(true);
|
|
31
|
-
expect(checkList('0,0,0,0,', type).matched).toBe(false);
|
|
32
|
-
expect(checkList(',0,0,0,0', type).matched).toBe(false);
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
test('Zero comma (disallowToSurroundBySpaces)', () => {
|
|
36
|
-
const type = { token: 'Zero', separator: 'comma', disallowToSurroundBySpaces: true };
|
|
37
|
-
expect(checkList('0', type).matched).toBe(true);
|
|
38
|
-
expect(checkList(' 0 ', type).matched).toBe(false);
|
|
39
|
-
expect(checkList(' 0 0', type).matched).toBe(false);
|
|
40
|
-
expect(checkList(' 0,0', type).matched).toBe(false);
|
|
41
|
-
expect(checkList(' 0,,0 ', type).matched).toBe(false);
|
|
42
|
-
expect(checkList('0 0 0 ', type).matched).toBe(false);
|
|
43
|
-
expect(checkList(' 0,0,0,0 ', type).matched).toBe(false);
|
|
44
|
-
expect(checkList('0, 0, 0 , 0', type).matched).toBe(false);
|
|
45
|
-
expect(checkList('0,0,0,0', type).matched).toBe(true);
|
|
46
|
-
expect(checkList('0,0,0,0,', type).matched).toBe(false);
|
|
47
|
-
expect(checkList(',0,0,0,0', type).matched).toBe(false);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test('Location of the token', () => {
|
|
51
|
-
const type = { token: 'Accept', separator: 'comma' };
|
|
52
|
-
expect(checkList('x/y;a=b', type)).toStrictEqual({
|
|
53
|
-
candidate: 'x/y',
|
|
54
|
-
column: 4,
|
|
55
|
-
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
56
|
-
length: 4,
|
|
57
|
-
line: 1,
|
|
58
|
-
matched: false,
|
|
59
|
-
offset: 3,
|
|
60
|
-
raw: ';a=b',
|
|
61
|
-
reason: 'extra-token',
|
|
62
|
-
partName: 'the content of the list',
|
|
63
|
-
ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
|
|
64
|
-
});
|
|
65
|
-
expect(checkList('x/y,x/y;a=b', type)).toStrictEqual({
|
|
66
|
-
candidate: 'x/y',
|
|
67
|
-
column: 8,
|
|
68
|
-
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
69
|
-
length: 4,
|
|
70
|
-
line: 1,
|
|
71
|
-
matched: false,
|
|
72
|
-
offset: 7,
|
|
73
|
-
raw: ';a=b',
|
|
74
|
-
reason: 'extra-token',
|
|
75
|
-
partName: 'the content of the list',
|
|
76
|
-
ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
|
|
77
|
-
});
|
|
78
|
-
expect(checkList('x/y\n,\nx/y;a=b', type)).toStrictEqual({
|
|
79
|
-
candidate: 'x/y',
|
|
80
|
-
column: 4,
|
|
81
|
-
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
82
|
-
length: 4,
|
|
83
|
-
line: 3,
|
|
84
|
-
matched: false,
|
|
85
|
-
offset: 9,
|
|
86
|
-
raw: ';a=b',
|
|
87
|
-
reason: 'extra-token',
|
|
88
|
-
partName: 'the content of the list',
|
|
89
|
-
ref: 'https://html.spec.whatwg.org/multipage/input.html#attr-input-accept',
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
test('Expected comma', () => {
|
|
94
|
-
const type = { token: 'Accept', separator: 'comma' };
|
|
95
|
-
expect(checkList('x/y,', type)).toStrictEqual({
|
|
96
|
-
column: 4,
|
|
97
|
-
expects: undefined,
|
|
98
|
-
length: 1,
|
|
99
|
-
line: 1,
|
|
100
|
-
matched: false,
|
|
101
|
-
offset: 3,
|
|
102
|
-
raw: ',',
|
|
103
|
-
reason: 'extra-token',
|
|
104
|
-
ref: null,
|
|
105
|
-
});
|
|
106
|
-
expect(checkList('x/y,,x/y', type)).toStrictEqual({
|
|
107
|
-
column: 5,
|
|
108
|
-
expects: undefined,
|
|
109
|
-
length: 1,
|
|
110
|
-
line: 1,
|
|
111
|
-
matched: false,
|
|
112
|
-
offset: 4,
|
|
113
|
-
raw: ',',
|
|
114
|
-
reason: 'unexpected-comma',
|
|
115
|
-
ref: null,
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
test('Missing comma', () => {
|
|
120
|
-
const type = { token: 'Accept', separator: 'comma' };
|
|
121
|
-
expect(checkList('a/b,x/y a/z', type)).toStrictEqual({
|
|
122
|
-
column: 9,
|
|
123
|
-
candidate: ',a/z',
|
|
124
|
-
expects: undefined,
|
|
125
|
-
length: 3,
|
|
126
|
-
line: 1,
|
|
127
|
-
matched: false,
|
|
128
|
-
offset: 8,
|
|
129
|
-
raw: 'a/z',
|
|
130
|
-
reason: 'missing-comma',
|
|
131
|
-
ref: null,
|
|
132
|
-
});
|
|
133
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
const { isInt, isUint, isFloat, isNonZeroUint, isQuantity } = require('../../lib/primitive');
|
|
2
|
-
|
|
3
|
-
test('int', () => {
|
|
4
|
-
expect(isInt('0')).toBe(true);
|
|
5
|
-
expect(isInt('1')).toBe(true);
|
|
6
|
-
expect(isInt('-0')).toBe(true);
|
|
7
|
-
expect(isInt('-1')).toBe(true);
|
|
8
|
-
expect(isInt('10')).toBe(true);
|
|
9
|
-
expect(isInt('100')).toBe(true);
|
|
10
|
-
expect(isInt('1.00')).toBe(false);
|
|
11
|
-
expect(isInt('.001')).toBe(false);
|
|
12
|
-
expect(isInt(' 1 ')).toBe(false);
|
|
13
|
-
expect(isInt('- 1')).toBe(false);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
test('uint', () => {
|
|
17
|
-
expect(isUint('0')).toBe(true);
|
|
18
|
-
expect(isUint('1')).toBe(true);
|
|
19
|
-
expect(isUint('10')).toBe(true);
|
|
20
|
-
expect(isUint('100')).toBe(true);
|
|
21
|
-
expect(isUint('-0')).toBe(false);
|
|
22
|
-
expect(isUint('-1')).toBe(false);
|
|
23
|
-
expect(isUint('1.00')).toBe(false);
|
|
24
|
-
expect(isUint('.001')).toBe(false);
|
|
25
|
-
expect(isUint(' 1 ')).toBe(false);
|
|
26
|
-
expect(isUint('- 1')).toBe(false);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
test('float', () => {
|
|
30
|
-
expect(isFloat('0')).toBe(true);
|
|
31
|
-
expect(isFloat('1')).toBe(true);
|
|
32
|
-
expect(isFloat('10')).toBe(true);
|
|
33
|
-
expect(isFloat('100')).toBe(true);
|
|
34
|
-
expect(isFloat('-0')).toBe(true);
|
|
35
|
-
expect(isFloat('-1')).toBe(true);
|
|
36
|
-
expect(isFloat('1.00')).toBe(true);
|
|
37
|
-
expect(isFloat('.001')).toBe(true);
|
|
38
|
-
expect(isFloat(' 1 ')).toBe(false);
|
|
39
|
-
expect(isFloat('- 1')).toBe(false);
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
test('nonZeroUint', () => {
|
|
43
|
-
expect(isNonZeroUint('0')).toBe(false);
|
|
44
|
-
expect(isNonZeroUint('1')).toBe(true);
|
|
45
|
-
expect(isNonZeroUint('10')).toBe(true);
|
|
46
|
-
expect(isNonZeroUint('100')).toBe(true);
|
|
47
|
-
expect(isNonZeroUint('-0')).toBe(false);
|
|
48
|
-
expect(isNonZeroUint('-1')).toBe(false);
|
|
49
|
-
expect(isNonZeroUint('1.00')).toBe(false);
|
|
50
|
-
expect(isNonZeroUint('.001')).toBe(false);
|
|
51
|
-
expect(isNonZeroUint(' 1 ')).toBe(false);
|
|
52
|
-
expect(isNonZeroUint('- 1')).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
test('quantity', () => {
|
|
56
|
-
expect(isQuantity('0px', ['px', 'em'])).toBe(true);
|
|
57
|
-
expect(isQuantity('.5px', ['px', 'em'])).toBe(true);
|
|
58
|
-
expect(isQuantity('1.5em', ['px', 'em'])).toBe(true);
|
|
59
|
-
expect(isQuantity('1.5cm', ['px', 'em'])).toBe(false);
|
|
60
|
-
expect(isQuantity('1.5px', ['px', 'em'], 'int')).toBe(false);
|
|
61
|
-
expect(isQuantity('-5px', ['px', 'em'], 'int')).toBe(true);
|
|
62
|
-
expect(isQuantity('-5px', ['px', 'em'], 'uint')).toBe(false);
|
|
63
|
-
expect(isQuantity('1.12e+21px', ['px', 'em'], 'float')).toBe(true);
|
|
64
|
-
expect(isQuantity('1.12e+21px', ['px', 'em'], 'int')).toBe(false);
|
|
65
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const { isBCP47 } = require('../../lib/rfc/is-bcp-47');
|
|
2
|
-
|
|
3
|
-
const is = isBCP47();
|
|
4
|
-
|
|
5
|
-
test('en-us', () => {
|
|
6
|
-
expect(is('en-us')).toBe(true);
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
test('ja-JP', () => {
|
|
10
|
-
expect(is('ja-JP')).toBe(true);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
test('Empty', () => {
|
|
14
|
-
expect(is('')).toBe(false);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('Invalid', () => {
|
|
18
|
-
expect(is(':::')).toBe(false);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
test('Surrounded by spaces', () => {
|
|
22
|
-
expect(is(' en ')).toBe(false);
|
|
23
|
-
});
|
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
const { Token } = require('../../lib/token/token');
|
|
2
|
-
const { TokenCollection } = require('../../lib/token/token-collection');
|
|
3
|
-
|
|
4
|
-
test('parse', () => {
|
|
5
|
-
expect(new TokenCollection(' a b c ').toJSON()).toStrictEqual([
|
|
6
|
-
{
|
|
7
|
-
offset: 0,
|
|
8
|
-
type: 13,
|
|
9
|
-
value: ' ',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
offset: 1,
|
|
13
|
-
type: 1,
|
|
14
|
-
value: 'a',
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
offset: 2,
|
|
18
|
-
type: 13,
|
|
19
|
-
value: ' ',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
offset: 4,
|
|
23
|
-
type: 1,
|
|
24
|
-
value: 'b',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
offset: 5,
|
|
28
|
-
type: 13,
|
|
29
|
-
value: ' ',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
offset: 8,
|
|
33
|
-
type: 1,
|
|
34
|
-
value: 'c',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
offset: 9,
|
|
38
|
-
type: 13,
|
|
39
|
-
value: ' ',
|
|
40
|
-
},
|
|
41
|
-
]);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
test('parse comma separator', () => {
|
|
45
|
-
expect(new TokenCollection('a,, ,b,cde', { separator: 'comma' }).toJSON()).toStrictEqual([
|
|
46
|
-
{
|
|
47
|
-
offset: 0,
|
|
48
|
-
type: 1,
|
|
49
|
-
value: 'a',
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
offset: 1,
|
|
53
|
-
type: 18,
|
|
54
|
-
value: ',',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
offset: 2,
|
|
58
|
-
type: 18,
|
|
59
|
-
value: ',',
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
offset: 3,
|
|
63
|
-
type: 13,
|
|
64
|
-
value: ' ',
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
offset: 4,
|
|
68
|
-
type: 18,
|
|
69
|
-
value: ',',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
offset: 5,
|
|
73
|
-
type: 1,
|
|
74
|
-
value: 'b',
|
|
75
|
-
},
|
|
76
|
-
{
|
|
77
|
-
offset: 6,
|
|
78
|
-
type: 18,
|
|
79
|
-
value: ',',
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
offset: 7,
|
|
83
|
-
type: 1,
|
|
84
|
-
value: 'cde',
|
|
85
|
-
},
|
|
86
|
-
]);
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
test('A comma is an ident if the comma is not a separator', () => {
|
|
90
|
-
expect(new TokenCollection('a ,cde , f').toJSON()).toStrictEqual([
|
|
91
|
-
{
|
|
92
|
-
offset: 0,
|
|
93
|
-
type: 1,
|
|
94
|
-
value: 'a',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
offset: 1,
|
|
98
|
-
type: 13,
|
|
99
|
-
value: ' ',
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
offset: 2,
|
|
103
|
-
type: 1,
|
|
104
|
-
value: ',cde',
|
|
105
|
-
},
|
|
106
|
-
{
|
|
107
|
-
offset: 6,
|
|
108
|
-
type: 13,
|
|
109
|
-
value: ' ',
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
offset: 7,
|
|
113
|
-
type: 1,
|
|
114
|
-
value: ',',
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
offset: 8,
|
|
118
|
-
type: 13,
|
|
119
|
-
value: ' ',
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
offset: 9,
|
|
123
|
-
type: 1,
|
|
124
|
-
value: 'f',
|
|
125
|
-
},
|
|
126
|
-
]);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
test('getConsecutiveToken', () => {
|
|
130
|
-
expect(new TokenCollection('a,b,c', { separator: 'comma' }).getConsecutiveToken(Token.Comma)).toBeFalsy();
|
|
131
|
-
expect(new TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(Token.Comma)).toBeTruthy();
|
|
132
|
-
expect(new TokenCollection('a,,b', { separator: 'comma' }).getConsecutiveToken(Token.Comma)?.offset).toBe(2);
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
test('fromPatterns', () => {
|
|
136
|
-
const patterns = [/\+|-/, /[0-9]{2}/, /:?/, /[0-9]{2}/];
|
|
137
|
-
expect(TokenCollection.fromPatterns('+00:00', patterns).map(t => t.value)).toStrictEqual(['+', '00', ':', '00']);
|
|
138
|
-
expect(TokenCollection.fromPatterns('+0000', patterns).map(t => t.value)).toStrictEqual(['+', '00', '', '00']);
|
|
139
|
-
expect(TokenCollection.fromPatterns('+00/00', patterns).map(t => t.value)).toStrictEqual([
|
|
140
|
-
'+',
|
|
141
|
-
'00',
|
|
142
|
-
'',
|
|
143
|
-
'',
|
|
144
|
-
'/00',
|
|
145
|
-
]);
|
|
146
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
const { checkSerializedPermissionsPolicy } = require('../../lib/w3c/check-serialized-permissions-policy');
|
|
2
|
-
|
|
3
|
-
const check = checkSerializedPermissionsPolicy();
|
|
4
|
-
|
|
5
|
-
test('checkSerializedPermissionsPolicy', () => {
|
|
6
|
-
expect(check('').reason).toBe('empty-token');
|
|
7
|
-
expect(check(' ').reason).toBe('unexpected-token');
|
|
8
|
-
// expect(check('a').reason).toBe('missing-token');
|
|
9
|
-
expect(check('a').matched).toBe(true); // Current supported
|
|
10
|
-
expect(check('a:').reason).toBe('unexpected-token');
|
|
11
|
-
// expect(check('a ').reason).toBe('missing-token'); // Current supported
|
|
12
|
-
expect(check('a ').matched).toBe(true);
|
|
13
|
-
expect(check('a a').reason).toBe('unexpected-token');
|
|
14
|
-
expect(check('a *').matched).toBe(true);
|
|
15
|
-
expect(check('a *a').reason).toBe('unexpected-token');
|
|
16
|
-
expect(check('a none').reason).toBe('missing-token');
|
|
17
|
-
expect(check("a 'none'").matched).toBe(true);
|
|
18
|
-
expect(check('a https://markuplint.dev').matched).toBe(true);
|
|
19
|
-
expect(check('a https://markuplint.dev/path/to').reason).toBe('extra-token');
|
|
20
|
-
expect(check('a https://マルチバイト.abc.xyz').reason).toBe('must-be-serialized');
|
|
21
|
-
expect(check('a * https://markuplint.dev').matched).toBe(true);
|
|
22
|
-
expect(check("a * https://markuplint.dev 'none'").matched).toBe(true);
|
|
23
|
-
// expect(check("a * https://markuplint.dev 'none';b").reason).toBe('missing-token');
|
|
24
|
-
expect(check("a * https://markuplint.dev 'none';b").matched).toBe(true); // Current supported
|
|
25
|
-
// expect(check("a * https://markuplint.dev 'none';b ").reason).toBe('missing-token');
|
|
26
|
-
expect(check("a * https://markuplint.dev 'none';b ").matched).toBe(true); // Current supported
|
|
27
|
-
expect(check("a * https://markuplint.dev 'none';b *").matched).toBe(true);
|
|
28
|
-
expect(check("a * https://markuplint.dev 'none';b *;c 'none'").matched).toBe(true);
|
|
29
|
-
expect(check("a * https://markuplint.dev 'none'; b *; c 'none'").matched).toBe(true);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
test('YouTube embed', () => {
|
|
33
|
-
expect(
|
|
34
|
-
check('accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture').matched,
|
|
35
|
-
).toBe(true);
|
|
36
|
-
});
|