@markuplint/types 3.0.0-dev.25 → 3.0.0-dev.300
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/README.md +63 -61
- package/lib/check-multi-types.d.ts +2 -2
- package/lib/check-multi-types.js +9 -13
- package/lib/check.d.ts +7 -6
- package/lib/check.js +20 -30
- package/lib/css-syntax.d.ts +1 -1
- package/lib/css-syntax.js +60 -63
- package/lib/debug.js +2 -6
- package/lib/defs.d.ts +1 -1
- package/lib/defs.js +163 -91
- package/lib/enum.d.ts +4 -3
- package/lib/enum.js +7 -12
- package/lib/get-candidate.d.ts +1 -1
- 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 -21
- package/lib/list.d.ts +4 -3
- package/lib/list.js +9 -13
- package/lib/match-result.d.ts +4 -4
- package/lib/match-result.js +6 -12
- package/lib/number.d.ts +3 -3
- 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.d.ts +1 -1
- package/lib/primitive/is-quantity.js +9 -13
- package/lib/primitive/is-uint.d.ts +1 -1
- 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 +13 -13
- package/lib/token/token-collection.js +55 -50
- package/lib/token/token.d.ts +11 -10
- package/lib/token/token.js +16 -24
- package/lib/token/types.d.ts +3 -0
- package/lib/types.d.ts +47 -46
- package/lib/types.js +1 -2
- package/lib/types.schema.d.ts +2 -2
- package/lib/types.schema.js +1 -3
- 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 +28 -32
- 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 +43 -46
- package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
- package/lib/whatwg/check-datetime/duration-string.js +48 -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 +25 -26
- 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 -21
- 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 +12 -18
- 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 +3 -1
- package/lib/whatwg/is-browser-context-name.js +3 -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 +2 -6
- package/lib/whatwg/is-navigable-target-name.d.ts +11 -0
- package/lib/whatwg/is-navigable-target-name.js +20 -0
- package/package.json +19 -14
- package/types.schema.json +314 -311
- package/gen/specific-schema.json +0 -98
- package/gen/types.ts +0 -66
- package/lib/check.spec.js +0 -76
- package/lib/css-syntax.spec.d.ts +0 -1
- package/lib/css-syntax.spec.js +0 -157
- package/lib/list.spec.d.ts +0 -1
- package/lib/list.spec.js +0 -129
- package/lib/primitive/index.spec.d.ts +0 -1
- package/lib/primitive/index.spec.js +0 -62
- package/lib/rfc/is-bcp-47.spec.d.ts +0 -1
- package/lib/rfc/is-bcp-47.spec.js +0 -19
- package/lib/token/token-collection.spec.d.ts +0 -1
- package/lib/token/token-collection.spec.js +0 -144
- package/lib/w3c/check-serialized-permissions-policy.spec.d.ts +0 -1
- package/lib/w3c/check-serialized-permissions-policy.spec.js +0 -34
- package/lib/whatwg/check-autocomplete.spec.d.ts +0 -1
- package/lib/whatwg/check-autocomplete.spec.js +0 -379
- package/lib/whatwg/check-datetime/index.spec.d.ts +0 -1
- package/lib/whatwg/check-datetime/index.spec.js +0 -318
- package/lib/whatwg/check-mime-type.spec.d.ts +0 -1
- package/lib/whatwg/check-mime-type.spec.js +0 -58
- package/lib/whatwg/is-abs-url.spec.d.ts +0 -1
- package/lib/whatwg/is-abs-url.spec.js +0 -8
- package/patches/css-tree+2.3.1.patch +0 -23
- package/src/check-multi-types.ts +0 -35
- package/src/check.spec.ts +0 -83
- package/src/check.ts +0 -48
- package/src/css-syntax.spec.ts +0 -167
- package/src/css-syntax.ts +0 -188
- package/src/debug.ts +0 -3
- package/src/defs.ts +0 -811
- package/src/enum.ts +0 -25
- package/src/get-candidate.ts +0 -24
- package/src/index.ts +0 -3
- package/src/keyword-type.ts +0 -64
- package/src/list.spec.ts +0 -133
- package/src/list.ts +0 -34
- package/src/match-result.ts +0 -49
- package/src/number.ts +0 -46
- package/src/primitive/index.spec.ts +0 -65
- package/src/primitive/index.ts +0 -7
- package/src/primitive/is-float.ts +0 -8
- package/src/primitive/is-int.ts +0 -8
- package/src/primitive/is-non-zero-uint.ts +0 -8
- package/src/primitive/is-quantity.ts +0 -38
- package/src/primitive/is-uint.ts +0 -15
- package/src/primitive/range.ts +0 -14
- package/src/primitive/split-unit.ts +0 -20
- package/src/rfc/is-bcp-47.spec.ts +0 -23
- package/src/rfc/is-bcp-47.ts +0 -13
- package/src/token/index.ts +0 -2
- package/src/token/token-collection.spec.ts +0 -147
- package/src/token/token-collection.ts +0 -444
- package/src/token/token.ts +0 -144
- package/src/types.schema.ts +0 -1113
- package/src/types.ts +0 -118
- package/src/w3c/check-serialized-permissions-policy.spec.ts +0 -38
- package/src/w3c/check-serialized-permissions-policy.ts +0 -303
- package/src/whatwg/check-autocomplete.spec.ts +0 -387
- package/src/whatwg/check-autocomplete.ts +0 -380
- package/src/whatwg/check-datetime/date-string.ts +0 -44
- package/src/whatwg/check-datetime/datetime-tokens.ts +0 -600
- package/src/whatwg/check-datetime/duration-string.ts +0 -399
- package/src/whatwg/check-datetime/global-date-and-time-string.ts +0 -96
- package/src/whatwg/check-datetime/index.spec.ts +0 -333
- package/src/whatwg/check-datetime/index.ts +0 -36
- package/src/whatwg/check-datetime/local-date-and-time-string.ts +0 -163
- package/src/whatwg/check-datetime/month-string.ts +0 -31
- package/src/whatwg/check-datetime/time-string.ts +0 -49
- package/src/whatwg/check-datetime/time-zone-offset-string.ts +0 -93
- package/src/whatwg/check-datetime/week-string.ts +0 -41
- package/src/whatwg/check-datetime/year-string.ts +0 -26
- package/src/whatwg/check-datetime/yearless-date-string.ts +0 -38
- package/src/whatwg/check-mime-type.spec.ts +0 -59
- package/src/whatwg/check-mime-type.ts +0 -46
- package/src/whatwg/is-abs-url.spec.ts +0 -8
- package/src/whatwg/is-abs-url.ts +0 -31
- package/src/whatwg/is-browser-context-name.ts +0 -16
- package/src/whatwg/is-custom-element-name.ts +0 -76
- package/src/whatwg/is-itemprop-name.ts +0 -17
- package/tsconfig.test.json +0 -3
- package/tsconfig.tsbuildinfo +0 -1
- /package/lib/{check.spec.d.ts → token/types.js} +0 -0
|
@@ -1,318 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// @ts-nocheck
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const date_string_1 = require("./date-string");
|
|
5
|
-
const datetime_tokens_1 = require("./datetime-tokens");
|
|
6
|
-
const duration_string_1 = require("./duration-string");
|
|
7
|
-
const global_date_and_time_string_1 = require("./global-date-and-time-string");
|
|
8
|
-
const local_date_and_time_string_1 = require("./local-date-and-time-string");
|
|
9
|
-
const month_string_1 = require("./month-string");
|
|
10
|
-
const time_string_1 = require("./time-string");
|
|
11
|
-
const time_zone_offset_string_1 = require("./time-zone-offset-string");
|
|
12
|
-
const week_string_1 = require("./week-string");
|
|
13
|
-
const year_string_1 = require("./year-string");
|
|
14
|
-
const yearless_date_string_1 = require("./yearless-date-string");
|
|
15
|
-
const _1 = require(".");
|
|
16
|
-
const isMonth = (0, month_string_1.checkMonthString)();
|
|
17
|
-
const isDate = (0, date_string_1.checkDateString)();
|
|
18
|
-
const isYearlessDate = (0, yearless_date_string_1.checkYearlessDateString)();
|
|
19
|
-
const isTimeString = (0, time_string_1.checkTimeString)();
|
|
20
|
-
const isLocalDateAndTime = (0, local_date_and_time_string_1.checkLocalDateAndTimeString)();
|
|
21
|
-
const isNormalizedLocalDateAndTime = (0, local_date_and_time_string_1.checkNormalizedLocalDateAndTimeString)();
|
|
22
|
-
const isTimeZoneOffset = (0, time_zone_offset_string_1.checkTimeZoneOffsetString)();
|
|
23
|
-
const isGlobalDateAndTime = (0, global_date_and_time_string_1.checkGlobalDateAndTimeString)();
|
|
24
|
-
const isWeek = (0, week_string_1.checkWeekString)();
|
|
25
|
-
const isYear = (0, year_string_1.checkYearString)();
|
|
26
|
-
const isDurationISO8601Like = (0, duration_string_1.checkDurationISO8601LikeString)();
|
|
27
|
-
const isDurationComponentList = (0, duration_string_1.checkDurationComponentListString)();
|
|
28
|
-
const isDateTime = (0, _1.checkDateTime)();
|
|
29
|
-
test('max-week', () => {
|
|
30
|
-
expect((0, datetime_tokens_1.getMaxWeekNum)(1976)).toBe(53);
|
|
31
|
-
expect((0, datetime_tokens_1.getMaxWeekNum)(1977)).toBe(52);
|
|
32
|
-
expect((0, datetime_tokens_1.getMaxWeekNum)(1978)).toBe(52);
|
|
33
|
-
expect((0, datetime_tokens_1.getMaxWeekNum)(1979)).toBe(52);
|
|
34
|
-
expect((0, datetime_tokens_1.getMaxWeekNum)(1981)).toBe(53);
|
|
35
|
-
});
|
|
36
|
-
test('month-string', () => {
|
|
37
|
-
expect(isMonth('').reason).toBe('empty-token');
|
|
38
|
-
expect(isMonth(' ').reason).toBe('unexpected-token');
|
|
39
|
-
expect(isMonth('a').reason).toBe('unexpected-token');
|
|
40
|
-
expect(isMonth('0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 4 });
|
|
41
|
-
expect(isMonth('0000').reason).toStrictEqual({ type: 'out-of-range', gt: 0 });
|
|
42
|
-
expect(isMonth('0001').reason).toBe('missing-token');
|
|
43
|
-
expect(isMonth('0001:').reason).toBe('unexpected-token');
|
|
44
|
-
expect(isMonth('0001-').reason).toBe('missing-token');
|
|
45
|
-
expect(isMonth('0001-a').reason).toBe('unexpected-token');
|
|
46
|
-
expect(isMonth('0001-0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
47
|
-
expect(isMonth('0001-001').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
48
|
-
expect(isMonth('0001-00').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 12 });
|
|
49
|
-
expect(isMonth('0001-13').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 12 });
|
|
50
|
-
expect(isMonth('0001-01').matched).toBe(true);
|
|
51
|
-
expect(isMonth('0001-12').matched).toBe(true);
|
|
52
|
-
expect(isMonth('10001-01').matched).toBe(true);
|
|
53
|
-
expect(isMonth('0001-01-').reason).toBe('extra-token');
|
|
54
|
-
});
|
|
55
|
-
test('date-string', () => {
|
|
56
|
-
expect(isDate('').reason).toBe('empty-token');
|
|
57
|
-
expect(isDate(' ').reason).toBe('unexpected-token');
|
|
58
|
-
expect(isDate('a').reason).toBe('unexpected-token');
|
|
59
|
-
expect(isDate('0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 4 });
|
|
60
|
-
expect(isDate('0000').reason).toStrictEqual({ type: 'out-of-range', gt: 0 });
|
|
61
|
-
expect(isDate('2000').reason).toBe('missing-token');
|
|
62
|
-
expect(isDate('2000:').reason).toBe('unexpected-token');
|
|
63
|
-
expect(isDate('2000-').reason).toBe('missing-token');
|
|
64
|
-
expect(isDate('2000-a').reason).toBe('unexpected-token');
|
|
65
|
-
expect(isDate('2000-0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
66
|
-
expect(isDate('2000-00').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 12 });
|
|
67
|
-
expect(isDate('2000-01').reason).toBe('missing-token');
|
|
68
|
-
expect(isDate('2000-01:').reason).toBe('unexpected-token');
|
|
69
|
-
expect(isDate('2000-01-').reason).toBe('missing-token');
|
|
70
|
-
expect(isDate('2000-01-a').reason).toBe('unexpected-token');
|
|
71
|
-
expect(isDate('2000-01-0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
72
|
-
expect(isDate('2000-01-001').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
73
|
-
expect(isDate('2000-01-00').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 31 });
|
|
74
|
-
expect(isDate('2000-01-01').matched).toBe(true);
|
|
75
|
-
expect(isDate('2000-01-31').matched).toBe(true);
|
|
76
|
-
expect(isDate('2000-01-32').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 31 });
|
|
77
|
-
expect(isDate('2000-02-28').matched).toBe(true);
|
|
78
|
-
expect(isDate('2000-02-29').matched).toBe(true);
|
|
79
|
-
expect(isDate('2000-02-30').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 29 });
|
|
80
|
-
expect(isDate('2001-02-28').matched).toBe(true);
|
|
81
|
-
expect(isDate('2001-02-29').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 28 });
|
|
82
|
-
});
|
|
83
|
-
test('yearless-date-string', () => {
|
|
84
|
-
expect(isYearlessDate('').reason).toBe('empty-token');
|
|
85
|
-
expect(isYearlessDate(' ').reason).toBe('unexpected-token');
|
|
86
|
-
expect(isYearlessDate('a').reason).toBe('unexpected-token');
|
|
87
|
-
expect(isYearlessDate('0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
88
|
-
expect(isYearlessDate('00').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 12 });
|
|
89
|
-
expect(isYearlessDate('01').reason).toBe('missing-token');
|
|
90
|
-
expect(isYearlessDate('01:').reason).toBe('unexpected-token');
|
|
91
|
-
expect(isYearlessDate('01-').reason).toBe('missing-token');
|
|
92
|
-
expect(isYearlessDate('01-a').reason).toBe('unexpected-token');
|
|
93
|
-
expect(isYearlessDate('01-0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
94
|
-
expect(isYearlessDate('01-00').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 31 });
|
|
95
|
-
expect(isYearlessDate('01-01').matched).toBe(true);
|
|
96
|
-
expect(isYearlessDate('01-31').matched).toBe(true);
|
|
97
|
-
expect(isYearlessDate('01-32').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 31 });
|
|
98
|
-
expect(isYearlessDate('02-28').matched).toBe(true);
|
|
99
|
-
expect(isYearlessDate('02-29').matched).toBe(true);
|
|
100
|
-
expect(isYearlessDate('02-30').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 29 });
|
|
101
|
-
});
|
|
102
|
-
test('time-string', () => {
|
|
103
|
-
expect(isTimeString('').reason).toBe('empty-token');
|
|
104
|
-
expect(isTimeString(' ').reason).toBe('unexpected-token');
|
|
105
|
-
expect(isTimeString('a').reason).toBe('unexpected-token');
|
|
106
|
-
expect(isTimeString('0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
107
|
-
expect(isTimeString('000').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
108
|
-
expect(isTimeString('24').reason).toStrictEqual({ type: 'out-of-range', gte: 0, lte: 23 });
|
|
109
|
-
expect(isTimeString('00').reason).toBe('missing-token');
|
|
110
|
-
expect(isTimeString('00-').reason).toBe('unexpected-token');
|
|
111
|
-
expect(isTimeString('00:').reason).toBe('missing-token');
|
|
112
|
-
expect(isTimeString('00:a').reason).toBe('unexpected-token');
|
|
113
|
-
expect(isTimeString('00:0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
114
|
-
expect(isTimeString('00:000').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
115
|
-
expect(isTimeString('00:00').matched).toBe(true);
|
|
116
|
-
expect(isTimeString('00:59').matched).toBe(true);
|
|
117
|
-
expect(isTimeString('00:60').reason).toStrictEqual({ type: 'out-of-range', gte: 0, lte: 59 });
|
|
118
|
-
expect(isTimeString('00:00-').reason).toBe('unexpected-token');
|
|
119
|
-
expect(isTimeString('00:00:').reason).toBe('missing-token');
|
|
120
|
-
expect(isTimeString('00:00:a').reason).toBe('unexpected-token');
|
|
121
|
-
expect(isTimeString('00:00:0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
122
|
-
expect(isTimeString('00:00:000').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
123
|
-
expect(isTimeString('00:00:00').matched).toBe(true);
|
|
124
|
-
expect(isTimeString('00:00:59').matched).toBe(true);
|
|
125
|
-
expect(isTimeString('00:00:60').reason).toStrictEqual({ type: 'out-of-range', gte: 0, lte: 59 });
|
|
126
|
-
expect(isTimeString('00:00:00:').reason).toBe('unexpected-token');
|
|
127
|
-
expect(isTimeString('00:00:00.').reason).toBe('missing-token');
|
|
128
|
-
expect(isTimeString('00:00:00.a').reason).toBe('unexpected-token');
|
|
129
|
-
expect(isTimeString('00:00:00.0').matched).toBe(true);
|
|
130
|
-
expect(isTimeString('00:00:00.9').matched).toBe(true);
|
|
131
|
-
expect(isTimeString('00:00:00.00').matched).toBe(true);
|
|
132
|
-
expect(isTimeString('00:00:00.99').matched).toBe(true);
|
|
133
|
-
expect(isTimeString('00:00:00.000').matched).toBe(true);
|
|
134
|
-
expect(isTimeString('00:00:00.999').matched).toBe(true);
|
|
135
|
-
expect(isTimeString('00:00:00.0000').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 1, lte: 3 });
|
|
136
|
-
expect(isTimeString('00:00:00.1000').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 1, lte: 3 });
|
|
137
|
-
});
|
|
138
|
-
test('local-date-and-time-string', () => {
|
|
139
|
-
expect(isLocalDateAndTime('').reason).toBe('empty-token');
|
|
140
|
-
expect(isLocalDateAndTime(' ').reason).toBe('unexpected-token');
|
|
141
|
-
expect(isLocalDateAndTime('2020-12-31').reason).toBe('missing-token');
|
|
142
|
-
expect(isLocalDateAndTime('2020-12-31:').reason).toBe('unexpected-token');
|
|
143
|
-
expect(isLocalDateAndTime('2020-12-31T').reason).toBe('missing-token');
|
|
144
|
-
expect(isLocalDateAndTime('2020-12-31 ').reason).toBe('missing-token');
|
|
145
|
-
expect(isLocalDateAndTime('2020-12-31 ').reason).toBe('unexpected-token');
|
|
146
|
-
expect(isLocalDateAndTime('2020-12-31T00:00:00.000').matched).toBe(true);
|
|
147
|
-
});
|
|
148
|
-
test('normalized-local-date-and-time-string', () => {
|
|
149
|
-
expect(isNormalizedLocalDateAndTime('').reason).toBe('empty-token');
|
|
150
|
-
expect(isNormalizedLocalDateAndTime(' ').reason).toBe('unexpected-token');
|
|
151
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31').reason).toBe('missing-token');
|
|
152
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31:').reason).toBe('unexpected-token');
|
|
153
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T').reason).toBe('missing-token');
|
|
154
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31 ').reason).toBe('unexpected-token');
|
|
155
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T00:00').matched).toBe(true);
|
|
156
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T00:00:00').reason).toBe('extra-token');
|
|
157
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T00:00:01').matched).toBe(true);
|
|
158
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T00:00:00.0').reason).toBe('extra-token');
|
|
159
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T00:00:00.00').reason).toBe('extra-token');
|
|
160
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T00:00:00.000').reason).toBe('extra-token');
|
|
161
|
-
expect(isNormalizedLocalDateAndTime('2020-12-31T00:00:00.001').matched).toBe(true);
|
|
162
|
-
});
|
|
163
|
-
test('time-zone-offset', () => {
|
|
164
|
-
expect(isTimeZoneOffset('').reason).toBe('empty-token');
|
|
165
|
-
expect(isTimeZoneOffset(' ').reason).toBe('unexpected-token');
|
|
166
|
-
expect(isTimeZoneOffset('a').reason).toBe('unexpected-token');
|
|
167
|
-
expect(isTimeZoneOffset('z').reason).toBe('unexpected-token');
|
|
168
|
-
expect(isTimeZoneOffset('Z').matched).toBe(true);
|
|
169
|
-
expect(isTimeZoneOffset('Z:').reason).toBe('extra-token');
|
|
170
|
-
expect(isTimeZoneOffset('ZZ').reason).toBe('extra-token');
|
|
171
|
-
expect(isTimeZoneOffset('+').reason).toBe('missing-token');
|
|
172
|
-
expect(isTimeZoneOffset('-').reason).toBe('missing-token');
|
|
173
|
-
expect(isTimeZoneOffset('+-').reason).toBe('unexpected-token');
|
|
174
|
-
expect(isTimeZoneOffset('+00').reason).toBe('missing-token');
|
|
175
|
-
expect(isTimeZoneOffset('+00:').reason).toBe('missing-token');
|
|
176
|
-
expect(isTimeZoneOffset('+00:00').matched).toBe(true);
|
|
177
|
-
expect(isTimeZoneOffset('+24:00').matched).toBe(false);
|
|
178
|
-
expect(isTimeZoneOffset('+00:60').matched).toBe(false);
|
|
179
|
-
expect(isTimeZoneOffset('+000:00').matched).toBe(false);
|
|
180
|
-
expect(isTimeZoneOffset('+00:000').matched).toBe(false);
|
|
181
|
-
expect(isTimeZoneOffset('+00:00:').reason).toBe('extra-token');
|
|
182
|
-
expect(isTimeZoneOffset('+0000').matched).toBe(true);
|
|
183
|
-
expect(isTimeZoneOffset('+2400').matched).toBe(false);
|
|
184
|
-
expect(isTimeZoneOffset('+0060').matched).toBe(false);
|
|
185
|
-
expect(isTimeZoneOffset('+00000').matched).toBe(false);
|
|
186
|
-
expect(isTimeZoneOffset('+0000:').reason).toBe('extra-token');
|
|
187
|
-
});
|
|
188
|
-
test('global-date-and-time-string', () => {
|
|
189
|
-
expect(isGlobalDateAndTime('2000-01-01').reason).toBe('missing-token');
|
|
190
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00').reason).toBe('missing-token');
|
|
191
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00').reason).toBe('missing-token');
|
|
192
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00+').reason).toBe('missing-token');
|
|
193
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00Z').matched).toBe(true);
|
|
194
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00+00').reason).toBe('missing-token');
|
|
195
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00+0000').matched).toBe(true);
|
|
196
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00+00:00').matched).toBe(true);
|
|
197
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00-2359').matched).toBe(true);
|
|
198
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00-23:59').matched).toBe(true);
|
|
199
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00:00+0000').matched).toBe(true);
|
|
200
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00:00.000+0000').matched).toBe(true);
|
|
201
|
-
expect(isGlobalDateAndTime('2000-01-01T00:00:00.000+0000a').reason).toBe('extra-token');
|
|
202
|
-
});
|
|
203
|
-
test('week-string', () => {
|
|
204
|
-
expect(isWeek('').reason).toBe('empty-token');
|
|
205
|
-
expect(isWeek(' ').reason).toBe('unexpected-token');
|
|
206
|
-
expect(isWeek('a').reason).toBe('unexpected-token');
|
|
207
|
-
expect(isWeek('2000').reason).toBe('missing-token');
|
|
208
|
-
expect(isWeek('2000-').reason).toBe('missing-token');
|
|
209
|
-
expect(isWeek('2000-a').reason).toBe('unexpected-token');
|
|
210
|
-
expect(isWeek('2000-W').reason).toBe('missing-token');
|
|
211
|
-
expect(isWeek('2000-Wa').reason).toBe('unexpected-token');
|
|
212
|
-
expect(isWeek('2000-W0').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 2, lte: 2 });
|
|
213
|
-
expect(isWeek('2000-W00').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 52 });
|
|
214
|
-
expect(isWeek('2000-W53').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 52 });
|
|
215
|
-
expect(isWeek('2000-W01').matched).toBe(true);
|
|
216
|
-
expect(isWeek('2000-W52').matched).toBe(true);
|
|
217
|
-
expect(isWeek('2004-W00').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 53 });
|
|
218
|
-
expect(isWeek('2004-W54').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 53 });
|
|
219
|
-
expect(isWeek('2004-W01').matched).toBe(true);
|
|
220
|
-
expect(isWeek('2004-W53').matched).toBe(true);
|
|
221
|
-
expect(isWeek('2000-W01a').reason).toBe('extra-token');
|
|
222
|
-
});
|
|
223
|
-
test('year-string', () => {
|
|
224
|
-
expect(isYear('').reason).toBe('empty-token');
|
|
225
|
-
expect(isYear(' ').reason).toBe('unexpected-token');
|
|
226
|
-
expect(isYear('a').reason).toBe('unexpected-token');
|
|
227
|
-
expect(isYear('200').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 4 });
|
|
228
|
-
expect(isYear('2000').matched).toBe(true);
|
|
229
|
-
expect(isYear('20000').matched).toBe(true);
|
|
230
|
-
});
|
|
231
|
-
test('duration-string (IS08601 like)', () => {
|
|
232
|
-
expect(isDurationISO8601Like('').reason).toBe('empty-token');
|
|
233
|
-
expect(isDurationISO8601Like(' ').reason).toBe('unexpected-token');
|
|
234
|
-
expect(isDurationISO8601Like('a').reason).toBe('unexpected-token');
|
|
235
|
-
expect(isDurationISO8601Like('P').reason).toBe('missing-token');
|
|
236
|
-
expect(isDurationISO8601Like('P0').reason).toBe('missing-token');
|
|
237
|
-
expect(isDurationISO8601Like('P0D').reason).toBe('missing-token');
|
|
238
|
-
expect(isDurationISO8601Like('P0H').reason).toBe('unexpected-token');
|
|
239
|
-
expect(isDurationISO8601Like('P0Dt').reason).toBe('unexpected-token');
|
|
240
|
-
expect(isDurationISO8601Like('P0DT').reason).toBe('missing-token');
|
|
241
|
-
expect(isDurationISO8601Like('P0DT0').reason).toBe('missing-token');
|
|
242
|
-
expect(isDurationISO8601Like('P0DT0H').matched).toBe(true);
|
|
243
|
-
expect(isDurationISO8601Like('P0DT0H0').reason).toBe('missing-token');
|
|
244
|
-
expect(isDurationISO8601Like('P0DT0H0M').matched).toBe(true);
|
|
245
|
-
expect(isDurationISO8601Like('P0DT0H0M0').reason).toBe('missing-token');
|
|
246
|
-
expect(isDurationISO8601Like('P0DT0H0M0S').matched).toBe(true);
|
|
247
|
-
expect(isDurationISO8601Like('P0DT0H0M0.').reason).toBe('missing-token');
|
|
248
|
-
expect(isDurationISO8601Like('P0DT0H0M0M').reason).toBe('unexpected-token');
|
|
249
|
-
expect(isDurationISO8601Like('P0DT0H0M0.0').reason).toBe('missing-token');
|
|
250
|
-
expect(isDurationISO8601Like('P0DT0H0M0.0M').reason).toBe('unexpected-token');
|
|
251
|
-
expect(isDurationISO8601Like('P0DT0H0M0.000').reason).toBe('missing-token');
|
|
252
|
-
expect(isDurationISO8601Like('P0DT0H0M0.0000').reason).toStrictEqual({
|
|
253
|
-
gte: 1,
|
|
254
|
-
lte: 3,
|
|
255
|
-
type: 'out-of-range-length-digit',
|
|
256
|
-
});
|
|
257
|
-
expect(isDurationISO8601Like('P0DT0H0M0.000S').matched).toBe(true);
|
|
258
|
-
expect(isDurationISO8601Like('P0DT0H0M0.000S0').reason).toBe('extra-token');
|
|
259
|
-
expect(isDurationISO8601Like('P0DT0H0M0.000S0H').reason).toBe('extra-token');
|
|
260
|
-
expect(isDurationISO8601Like('P0DT0M').matched).toBe(true);
|
|
261
|
-
expect(isDurationISO8601Like('P0DT0S').matched).toBe(true);
|
|
262
|
-
expect(isDurationISO8601Like('P0DT0.0S').matched).toBe(true);
|
|
263
|
-
expect(isDurationISO8601Like('P0DT0M0S').matched).toBe(true);
|
|
264
|
-
expect(isDurationISO8601Like('P0DT0H0S').matched).toBe(true);
|
|
265
|
-
expect(isDurationISO8601Like('P0DT0H0.0S').matched).toBe(true);
|
|
266
|
-
expect(isDurationISO8601Like('P0DT0M0H').reason).toBe('unexpected-token');
|
|
267
|
-
expect(isDurationISO8601Like('P0DT0S0M').reason).toBe('extra-token');
|
|
268
|
-
expect(isDurationISO8601Like('P0DT0.0S0M').reason).toBe('extra-token');
|
|
269
|
-
expect(isDurationISO8601Like('PT4H18M3S').matched).toBe(true);
|
|
270
|
-
});
|
|
271
|
-
test('duration-string (duration component list)', () => {
|
|
272
|
-
expect(isDurationComponentList('').reason).toBe('empty-token');
|
|
273
|
-
expect(isDurationComponentList(' ').reason).toBe('missing-token');
|
|
274
|
-
expect(isDurationComponentList(' a').reason).toBe('unexpected-token');
|
|
275
|
-
expect(isDurationComponentList(' 0').reason).toBe('missing-token');
|
|
276
|
-
expect(isDurationComponentList(' 0a').reason).toBe('unexpected-token');
|
|
277
|
-
expect(isDurationComponentList(' 0w').matched).toBe(true);
|
|
278
|
-
expect(isDurationComponentList(' 0ww').reason).toBe('unexpected-token');
|
|
279
|
-
expect(isDurationComponentList('0w').matched).toBe(true);
|
|
280
|
-
expect(isDurationComponentList('0w ').matched).toBe(true);
|
|
281
|
-
expect(isDurationComponentList('0w 0').reason).toBe('missing-token');
|
|
282
|
-
expect(isDurationComponentList('0w 0w').reason).toBe('duplicated');
|
|
283
|
-
expect(isDurationComponentList('0w 0d').matched).toBe(true);
|
|
284
|
-
expect(isDurationComponentList('0w 0d').matched).toBe(true);
|
|
285
|
-
expect(isDurationComponentList(' 0w 0d').matched).toBe(true);
|
|
286
|
-
expect(isDurationComponentList(' 0w 0d ').matched).toBe(true);
|
|
287
|
-
expect(isDurationComponentList('0w 0d ').matched).toBe(true);
|
|
288
|
-
expect(isDurationComponentList('\n0w\n0d\n').matched).toBe(true);
|
|
289
|
-
expect(isDurationComponentList('0w 0.').reason).toBe('missing-token');
|
|
290
|
-
expect(isDurationComponentList('0w 0.0').reason).toBe('missing-token');
|
|
291
|
-
expect(isDurationComponentList('0w 0.0s').matched).toBe(true);
|
|
292
|
-
expect(isDurationComponentList('0w 0.0d').reason).toBe('unexpected-token');
|
|
293
|
-
expect(isDurationComponentList('0s 0.').reason).toBe('unexpected-token');
|
|
294
|
-
expect(isDurationComponentList('0s 0.0').reason).toBe('unexpected-token');
|
|
295
|
-
expect(isDurationComponentList('0s 0.0s').reason).toBe('unexpected-token');
|
|
296
|
-
expect(isDurationComponentList('0w 0.00s').matched).toBe(true);
|
|
297
|
-
expect(isDurationComponentList('0w 0.000s').matched).toBe(true);
|
|
298
|
-
expect(isDurationComponentList('0w 0.0000s').reason).toStrictEqual({
|
|
299
|
-
gte: 1,
|
|
300
|
-
lte: 3,
|
|
301
|
-
type: 'out-of-range-length-digit',
|
|
302
|
-
});
|
|
303
|
-
expect(isDurationComponentList('0s 0.000s').reason).toBe('unexpected-token');
|
|
304
|
-
expect(isDurationComponentList('0.000s 0s').reason).toBe('duplicated');
|
|
305
|
-
expect(isDurationComponentList('0w0d0h0m0.000s').matched).toBe(true);
|
|
306
|
-
expect(isDurationComponentList('0w 0d 0h 0m 0.000s').matched).toBe(true);
|
|
307
|
-
expect(isDurationComponentList('0w 0d0h 0m0.000s').matched).toBe(true);
|
|
308
|
-
expect(isDurationComponentList(' 2w 3d6m 3.4s 93xxxxxxx').reason).toBe('unexpected-token');
|
|
309
|
-
});
|
|
310
|
-
test('date-time', () => {
|
|
311
|
-
expect(isDateTime('200-1-1').reason).toStrictEqual({ type: 'out-of-range-length-digit', gte: 4 });
|
|
312
|
-
expect(isDateTime('2001-02-29').reason).toStrictEqual({ type: 'out-of-range', gte: 1, lte: 28 });
|
|
313
|
-
expect(isDateTime('2001-02-28T').reason).toBe('missing-token');
|
|
314
|
-
expect(isDateTime('2001-02-28T00').reason).toBe('missing-token');
|
|
315
|
-
expect(isDateTime('2001-02-28T00:0').reason).toStrictEqual({ gte: 2, lte: 2, type: 'out-of-range-length-digit' });
|
|
316
|
-
expect(isDateTime('2000-01-01T00:00:00.000+0000a').reason).toBe('extra-token');
|
|
317
|
-
expect(isDateTime('P0DT0M0H').reason).toBe('unexpected-token');
|
|
318
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const check_mime_type_1 = require("./check-mime-type");
|
|
4
|
-
const check = (0, check_mime_type_1.checkMIMEType)();
|
|
5
|
-
const checkNoParam = (0, check_mime_type_1.checkMIMEType)({ withoutParameters: true });
|
|
6
|
-
test('valid', () => {
|
|
7
|
-
expect(check('x/y').matched).toBe(true);
|
|
8
|
-
expect(check('x/y;a=b;c=D;E="F"').matched).toBe(true);
|
|
9
|
-
});
|
|
10
|
-
test('excrescence-token', () => {
|
|
11
|
-
expect(check('xy;')).toStrictEqual({
|
|
12
|
-
column: 1,
|
|
13
|
-
expects: [{ type: 'format', value: 'MIME Type' }],
|
|
14
|
-
length: 3,
|
|
15
|
-
line: 1,
|
|
16
|
-
matched: false,
|
|
17
|
-
offset: 0,
|
|
18
|
-
raw: 'xy;',
|
|
19
|
-
reason: 'syntax-error',
|
|
20
|
-
ref: null,
|
|
21
|
-
});
|
|
22
|
-
expect(check('x/y;')).toStrictEqual({
|
|
23
|
-
candidate: 'x/y',
|
|
24
|
-
column: 4,
|
|
25
|
-
expects: [{ type: 'format', value: 'MIME Type' }],
|
|
26
|
-
length: 1,
|
|
27
|
-
line: 1,
|
|
28
|
-
matched: false,
|
|
29
|
-
offset: 3,
|
|
30
|
-
raw: ';',
|
|
31
|
-
reason: 'extra-token',
|
|
32
|
-
ref: null,
|
|
33
|
-
});
|
|
34
|
-
expect(checkNoParam('x/y;')).toStrictEqual({
|
|
35
|
-
candidate: 'x/y',
|
|
36
|
-
column: 4,
|
|
37
|
-
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
38
|
-
length: 1,
|
|
39
|
-
line: 1,
|
|
40
|
-
matched: false,
|
|
41
|
-
offset: 3,
|
|
42
|
-
raw: ';',
|
|
43
|
-
reason: 'extra-token',
|
|
44
|
-
ref: null,
|
|
45
|
-
});
|
|
46
|
-
expect(checkNoParam('x/y;a=b;c=D;E="F"')).toStrictEqual({
|
|
47
|
-
candidate: 'x/y',
|
|
48
|
-
column: 4,
|
|
49
|
-
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
50
|
-
length: 14,
|
|
51
|
-
line: 1,
|
|
52
|
-
matched: false,
|
|
53
|
-
offset: 3,
|
|
54
|
-
raw: ';a=b;c=D;E="F"',
|
|
55
|
-
reason: 'extra-token',
|
|
56
|
-
ref: null,
|
|
57
|
-
});
|
|
58
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const is_abs_url_1 = require("./is-abs-url");
|
|
4
|
-
const is = (0, is_abs_url_1.isAbsURL)();
|
|
5
|
-
test('valid', () => {
|
|
6
|
-
expect(is('https://markuplint.dev')).toBe(true);
|
|
7
|
-
expect(is('markuplint.dev')).toBe(false);
|
|
8
|
-
});
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
diff --git a/node_modules/css-tree/package.json b/node_modules/css-tree/package.json
|
|
2
|
-
index 934e699..6be2f82 100644
|
|
3
|
-
--- a/node_modules/css-tree/package.json
|
|
4
|
-
+++ b/node_modules/css-tree/package.json
|
|
5
|
-
@@ -70,6 +70,18 @@
|
|
6
|
-
"./utils": {
|
|
7
|
-
"import": "./lib/utils/index.js",
|
|
8
|
-
"require": "./cjs/utils/index.cjs"
|
|
9
|
-
+ },
|
|
10
|
-
+ "./lexer/error": {
|
|
11
|
-
+ "import": "./lib/lexer/error.js",
|
|
12
|
-
+ "require": "./cjs/lexer/error.cjs"
|
|
13
|
-
+ },
|
|
14
|
-
+ "./lexer/match": {
|
|
15
|
-
+ "import": "./lib/lexer/match.js",
|
|
16
|
-
+ "require": "./cjs/lexer/match.cjs"
|
|
17
|
-
+ },
|
|
18
|
-
+ "./lexer/prepare-tokens": {
|
|
19
|
-
+ "import": "./lib/lexer/prepare-tokens.js",
|
|
20
|
-
+ "require": "./cjs/lexer/prepare-tokens.cjs"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"browser": {
|
package/src/check-multi-types.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import type { CustomSyntaxCheck, UnmatchedResult } from './types';
|
|
2
|
-
|
|
3
|
-
import { log } from './debug';
|
|
4
|
-
import { matched } from './match-result';
|
|
5
|
-
|
|
6
|
-
export function checkMultiTypes(value: string, checks: CustomSyntaxCheck[]) {
|
|
7
|
-
let unmatched: UnmatchedResult | undefined;
|
|
8
|
-
|
|
9
|
-
for (const check of checks) {
|
|
10
|
-
const res = check(value);
|
|
11
|
-
if (res.matched) {
|
|
12
|
-
return res;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// @ts-ignore
|
|
16
|
-
res._fn = check.name;
|
|
17
|
-
|
|
18
|
-
// @ts-ignore
|
|
19
|
-
log('%s(%d) vs %s(%d)', unmatched?._fn, unmatched?.passCount, res._fn, res.passCount);
|
|
20
|
-
const passedA = unmatched?.passCount || 0;
|
|
21
|
-
const passedB = res.passCount || 0;
|
|
22
|
-
const offsetA = unmatched?.offset || 0;
|
|
23
|
-
const offsetB = res.offset;
|
|
24
|
-
|
|
25
|
-
if (passedA < passedB || (passedA === passedB && offsetA <= offsetB)) {
|
|
26
|
-
unmatched = res;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const result = unmatched || matched();
|
|
31
|
-
|
|
32
|
-
log('%d checks result: %O', checks.length, result);
|
|
33
|
-
|
|
34
|
-
return result;
|
|
35
|
-
}
|
package/src/check.spec.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { check } from './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
|
-
});
|
package/src/check.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { Type, Result, List, CustomSyntax, CustomCssSyntax, Enum, KeywordDefinedType, Number } from './types';
|
|
2
|
-
|
|
3
|
-
import { log } from './debug';
|
|
4
|
-
import { checkEnum } from './enum';
|
|
5
|
-
import { checkKeywordType } from './keyword-type';
|
|
6
|
-
import { checkList } from './list';
|
|
7
|
-
import { checkNumber } from './number';
|
|
8
|
-
|
|
9
|
-
export function check(value: string, type: Type, ref?: string, cache = true): Result {
|
|
10
|
-
if (isKeyword(type)) {
|
|
11
|
-
log('Check keyword: %s', type);
|
|
12
|
-
return checkKeywordType(value, type, cache);
|
|
13
|
-
}
|
|
14
|
-
if (isList(type)) {
|
|
15
|
-
log('Check list: %O', type);
|
|
16
|
-
return checkList(value, type, ref, cache);
|
|
17
|
-
}
|
|
18
|
-
if (isEnum(type)) {
|
|
19
|
-
log('Check enum: %O', type);
|
|
20
|
-
return checkEnum(value, type, ref);
|
|
21
|
-
}
|
|
22
|
-
log('Check number: %O', type);
|
|
23
|
-
return checkNumber(value, type, ref);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function isKeyword(type: Type): type is KeywordDefinedType {
|
|
27
|
-
return typeof type === 'string';
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function isList(type: Type): type is List {
|
|
31
|
-
return typeof type !== 'string' && 'token' in type;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function isEnum(type: Type): type is Enum {
|
|
35
|
-
return typeof type !== 'string' && 'enum' in type;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function isNumber(type: Type): type is Number {
|
|
39
|
-
return typeof type !== 'string' && 'enum' in type;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function isCSSSyntax(type: CustomSyntax | CustomCssSyntax): type is CustomCssSyntax {
|
|
43
|
-
return typeof type === 'string' || 'syntax' in type;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export function isCustomSyntax(type: CustomSyntax | CustomCssSyntax): type is CustomSyntax {
|
|
47
|
-
return !isCSSSyntax(type);
|
|
48
|
-
}
|