@markuplint/types 2.2.0 → 3.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/README.md +1 -1
- package/gen/specific-schema.json +6 -6
- package/lib/check-multi-types.d.ts +1 -1
- package/lib/css-syntax.spec.js +1 -1
- package/lib/defs.js +4 -4
- package/lib/get-candidate.d.ts +3 -0
- package/lib/{get-candicate.js → get-candidate.js} +8 -8
- package/lib/list.spec.js +4 -4
- package/lib/match-result.d.ts +1 -1
- package/lib/number.js +4 -4
- package/lib/primitive/is-uint.d.ts +1 -1
- package/lib/primitive/is-uint.js +4 -4
- package/lib/token/token-collection.d.ts +21 -21
- package/lib/token/token-collection.js +101 -101
- package/lib/token/token-collection.spec.js +2 -2
- package/lib/token/token.d.ts +22 -22
- package/lib/token/token.js +36 -36
- package/lib/types.d.ts +2 -2
- package/lib/types.schema.d.ts +3 -0
- package/lib/whatwg/check-autocomplete.js +23 -23
- package/lib/whatwg/check-autocomplete.spec.js +9 -9
- package/lib/whatwg/check-datetime/datetime-tokens.d.ts +1 -1
- package/lib/whatwg/check-datetime/datetime-tokens.js +16 -16
- package/lib/whatwg/check-datetime/global-date-and-time-string.js +3 -3
- package/lib/whatwg/check-datetime/local-date-and-time-string.js +2 -2
- package/lib/whatwg/check-datetime/time-string.js +1 -1
- package/lib/whatwg/check-datetime/time-zone-offset-string.js +4 -4
- package/lib/whatwg/check-mime-type.js +1 -1
- package/lib/whatwg/check-mime-type.spec.js +3 -3
- package/package.json +4 -4
- package/src/css-syntax.spec.ts +1 -1
- package/src/defs.ts +4 -4
- package/src/{get-candicate.ts → get-candidate.ts} +6 -6
- package/src/list.spec.ts +4 -4
- package/src/number.ts +4 -4
- package/src/primitive/is-uint.ts +4 -4
- package/src/token/token-collection.spec.ts +2 -2
- package/src/token/token-collection.ts +113 -113
- package/src/token/token.ts +58 -58
- package/src/types.schema.ts +3 -0
- package/src/types.ts +2 -2
- package/src/whatwg/check-autocomplete.spec.ts +9 -9
- package/src/whatwg/check-autocomplete.ts +23 -23
- package/src/whatwg/check-datetime/datetime-tokens.ts +18 -18
- package/src/whatwg/check-datetime/global-date-and-time-string.ts +3 -3
- package/src/whatwg/check-datetime/local-date-and-time-string.ts +4 -4
- package/src/whatwg/check-datetime/time-string.ts +2 -2
- package/src/whatwg/check-datetime/time-zone-offset-string.ts +4 -4
- package/src/whatwg/check-mime-type.spec.ts +3 -3
- package/src/whatwg/check-mime-type.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/types.schema.json +3 -1
- package/lib/get-candicate.d.ts +0 -3
package/src/types.ts
CHANGED
|
@@ -20,7 +20,7 @@ export type UnmatchedResultOptions = {
|
|
|
20
20
|
partName?: string;
|
|
21
21
|
expects?: Expect[];
|
|
22
22
|
extra?: Expect;
|
|
23
|
-
|
|
23
|
+
candidate?: string;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export type UnmatchedResultReason =
|
|
@@ -64,7 +64,7 @@ export type MatchedResult = {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export type Expect = {
|
|
67
|
-
type: 'const' | 'format' | 'syntax' | '
|
|
67
|
+
type: 'const' | 'format' | 'syntax' | 'regexp' | 'common';
|
|
68
68
|
value: string;
|
|
69
69
|
};
|
|
70
70
|
|
|
@@ -49,7 +49,7 @@ test('unexpected-token', () => {
|
|
|
49
49
|
{ type: 'const', value: 'shipping' },
|
|
50
50
|
{ type: 'common', value: 'autofill field name' },
|
|
51
51
|
],
|
|
52
|
-
|
|
52
|
+
candidate: undefined,
|
|
53
53
|
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
54
54
|
});
|
|
55
55
|
});
|
|
@@ -67,7 +67,7 @@ test('unexpected-token', () => {
|
|
|
67
67
|
{ type: 'common', value: 'autofill named group' },
|
|
68
68
|
{ type: 'common', value: 'autofill field name' },
|
|
69
69
|
],
|
|
70
|
-
|
|
70
|
+
candidate: undefined,
|
|
71
71
|
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
72
72
|
});
|
|
73
73
|
});
|
|
@@ -86,7 +86,7 @@ test('unexpected-token', () => {
|
|
|
86
86
|
{ type: 'const', value: 'shipping' },
|
|
87
87
|
{ type: 'common', value: 'autofill field name' },
|
|
88
88
|
],
|
|
89
|
-
|
|
89
|
+
candidate: 'name',
|
|
90
90
|
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
91
91
|
});
|
|
92
92
|
expect(check('section-foo shipping neme')).toStrictEqual({
|
|
@@ -105,12 +105,12 @@ test('unexpected-token', () => {
|
|
|
105
105
|
{ type: 'const', value: 'fax' },
|
|
106
106
|
{ type: 'const', value: 'pager' },
|
|
107
107
|
],
|
|
108
|
-
|
|
108
|
+
candidate: 'name',
|
|
109
109
|
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
110
110
|
});
|
|
111
|
-
expect(check('section-foo shipping home
|
|
111
|
+
expect(check('section-foo shipping home name')).toStrictEqual({
|
|
112
112
|
matched: false,
|
|
113
|
-
raw: '
|
|
113
|
+
raw: 'name',
|
|
114
114
|
offset: 26,
|
|
115
115
|
length: 4,
|
|
116
116
|
line: 1,
|
|
@@ -128,7 +128,7 @@ test('unexpected-token', () => {
|
|
|
128
128
|
{ type: 'const', value: 'email' },
|
|
129
129
|
{ type: 'const', value: 'impp' },
|
|
130
130
|
],
|
|
131
|
-
|
|
131
|
+
candidate: undefined,
|
|
132
132
|
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
|
|
133
133
|
});
|
|
134
134
|
expect(check('section-foo shipping home emall')).toStrictEqual({
|
|
@@ -151,7 +151,7 @@ test('unexpected-token', () => {
|
|
|
151
151
|
{ type: 'const', value: 'email' },
|
|
152
152
|
{ type: 'const', value: 'impp' },
|
|
153
153
|
],
|
|
154
|
-
|
|
154
|
+
candidate: 'email',
|
|
155
155
|
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
|
|
156
156
|
});
|
|
157
157
|
});
|
|
@@ -381,7 +381,7 @@ test('typo', () => {
|
|
|
381
381
|
{ type: 'common', value: 'autofill named group' },
|
|
382
382
|
{ type: 'common', value: 'autofill field name' },
|
|
383
383
|
],
|
|
384
|
-
|
|
384
|
+
candidate: 'section-foo',
|
|
385
385
|
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
386
386
|
});
|
|
387
387
|
});
|
|
@@ -2,7 +2,7 @@ import type { Expect } from '..';
|
|
|
2
2
|
import type { CustomSyntaxChecker } from '../types';
|
|
3
3
|
|
|
4
4
|
import { log } from '../debug';
|
|
5
|
-
import {
|
|
5
|
+
import { getCandidate } from '../get-candidate';
|
|
6
6
|
import { matched } from '../match-result';
|
|
7
7
|
import { TokenCollection } from '../token';
|
|
8
8
|
|
|
@@ -94,7 +94,7 @@ const contactableFieldNames = [
|
|
|
94
94
|
*/
|
|
95
95
|
const webauthnFieldNames = ['webauthn'];
|
|
96
96
|
|
|
97
|
-
const
|
|
97
|
+
const URL_AUTOCOMPLETE = 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete';
|
|
98
98
|
const URL_ON_OFF =
|
|
99
99
|
'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2';
|
|
100
100
|
const URL_NAMED_GROUP =
|
|
@@ -128,15 +128,15 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
128
128
|
value: 'autocomplete',
|
|
129
129
|
},
|
|
130
130
|
],
|
|
131
|
-
ref:
|
|
131
|
+
ref: URL_AUTOCOMPLETE,
|
|
132
132
|
});
|
|
133
133
|
if (!listingChecked.matched) {
|
|
134
134
|
acLog('Unmatch: %s', listingChecked.reason);
|
|
135
135
|
return listingChecked;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
const
|
|
139
|
-
const headAndTail1 =
|
|
138
|
+
const identTokens = tokens.getIdentTokens();
|
|
139
|
+
const headAndTail1 = identTokens.headAndTail();
|
|
140
140
|
let { head, tail } = headAndTail1;
|
|
141
141
|
if (!head) {
|
|
142
142
|
// Never
|
|
@@ -231,7 +231,7 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
231
231
|
}
|
|
232
232
|
|
|
233
233
|
if (!contactableFiledToken.match(contactableFieldNames, true)) {
|
|
234
|
-
const
|
|
234
|
+
const candidate = getCandidate(contactableFiledToken.value, contactableFieldNames);
|
|
235
235
|
acLog('[Unmatched ("%s")] Unexpected token: "%s"', value, contactableFiledToken.value);
|
|
236
236
|
return contactableFiledToken.unmatched({
|
|
237
237
|
reason: 'unexpected-token',
|
|
@@ -239,7 +239,7 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
239
239
|
type: 'const' as const,
|
|
240
240
|
value: token,
|
|
241
241
|
})),
|
|
242
|
-
|
|
242
|
+
candidate,
|
|
243
243
|
ref: URL_CONTACTABLE_FIELD,
|
|
244
244
|
});
|
|
245
245
|
}
|
|
@@ -249,14 +249,14 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
249
249
|
return matched();
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
const
|
|
252
|
+
const candidate = getCandidate(tail[1].value, webauthnFieldNames);
|
|
253
253
|
|
|
254
|
-
if (
|
|
254
|
+
if (candidate) {
|
|
255
255
|
acLog(
|
|
256
256
|
'[Unmatched ("%s")] Unnecessarily token: "%s", Do you mean "%s"? ',
|
|
257
257
|
value,
|
|
258
258
|
tail[1].value,
|
|
259
|
-
|
|
259
|
+
candidate,
|
|
260
260
|
);
|
|
261
261
|
} else {
|
|
262
262
|
acLog('[Unmatched ("%s")] Unnecessarily token: "%s"', value, tail[1].value);
|
|
@@ -283,14 +283,14 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
283
283
|
return matched();
|
|
284
284
|
}
|
|
285
285
|
|
|
286
|
-
const
|
|
286
|
+
const candidate = getCandidate(tail[0].value, webauthnFieldNames);
|
|
287
287
|
|
|
288
|
-
if (
|
|
288
|
+
if (candidate) {
|
|
289
289
|
acLog(
|
|
290
290
|
'[Unmatched ("%s")] Unnecessarily token: "%s", Do you mean "%s"? ',
|
|
291
291
|
value,
|
|
292
292
|
tail[0].value,
|
|
293
|
-
|
|
293
|
+
candidate,
|
|
294
294
|
);
|
|
295
295
|
} else {
|
|
296
296
|
acLog('[Unmatched ("%s")] Unnecessarily token: "%s"', value, tail[0].value);
|
|
@@ -321,7 +321,7 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
321
321
|
value: 'autofill field name',
|
|
322
322
|
},
|
|
323
323
|
];
|
|
324
|
-
let
|
|
324
|
+
let candidate: string | undefined;
|
|
325
325
|
|
|
326
326
|
if (!hasNamedGroup) {
|
|
327
327
|
expects.unshift({
|
|
@@ -331,9 +331,9 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
331
331
|
|
|
332
332
|
// Potentially typo a named group
|
|
333
333
|
const [prefix, namedGroupStr] = head.value.split('-');
|
|
334
|
-
const
|
|
335
|
-
if (
|
|
336
|
-
|
|
334
|
+
const candidatePrefix = getCandidate(prefix, 'section');
|
|
335
|
+
if (candidatePrefix) {
|
|
336
|
+
candidate = `${candidatePrefix}-${namedGroupStr || ''}`;
|
|
337
337
|
}
|
|
338
338
|
} else if (!hasPartOfAddress) {
|
|
339
339
|
expects.unshift(
|
|
@@ -346,7 +346,7 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
346
346
|
})),
|
|
347
347
|
);
|
|
348
348
|
|
|
349
|
-
|
|
349
|
+
candidate = getCandidate(
|
|
350
350
|
head.value,
|
|
351
351
|
partOfAddress,
|
|
352
352
|
autofillFieldNames,
|
|
@@ -361,20 +361,20 @@ export const checkAutoComplete: CustomSyntaxChecker = () => value => {
|
|
|
361
361
|
})),
|
|
362
362
|
);
|
|
363
363
|
|
|
364
|
-
|
|
364
|
+
candidate = getCandidate(head.value, autofillFieldNames, contactingTokens, contactableFieldNames);
|
|
365
365
|
}
|
|
366
366
|
|
|
367
|
-
|
|
367
|
+
candidate = candidate || getCandidate(head.value, autofillFieldNames);
|
|
368
368
|
|
|
369
|
-
if (
|
|
370
|
-
acLog('[Unmatched ("%s")] Unexpected token: "%s", Do you mean "%s"? ', value, head.value,
|
|
369
|
+
if (candidate) {
|
|
370
|
+
acLog('[Unmatched ("%s")] Unexpected token: "%s", Do you mean "%s"? ', value, head.value, candidate);
|
|
371
371
|
} else {
|
|
372
372
|
acLog('[Unmatched ("%s")] Unexpected token: "%s"', value, head.value);
|
|
373
373
|
}
|
|
374
374
|
return head.unmatched({
|
|
375
375
|
reason: 'unexpected-token',
|
|
376
376
|
expects,
|
|
377
|
-
|
|
377
|
+
candidate,
|
|
378
378
|
ref: URL_AUTOFILL_FIELD,
|
|
379
379
|
});
|
|
380
380
|
};
|
|
@@ -13,9 +13,9 @@ export const datetimeTokenCheck: Record<
|
|
|
13
13
|
| 'secondFractionalPart'
|
|
14
14
|
| 'week'
|
|
15
15
|
| 'hyphen'
|
|
16
|
-
| '
|
|
16
|
+
| 'colon'
|
|
17
17
|
| 'extra'
|
|
18
|
-
| '
|
|
18
|
+
| 'colonOrEnd'
|
|
19
19
|
| 'decimalPointOrEnd'
|
|
20
20
|
| 'localDateTimeSeparator'
|
|
21
21
|
| 'normalizedlocalDateTimeSeparator'
|
|
@@ -391,19 +391,19 @@ export const datetimeTokenCheck: Record<
|
|
|
391
391
|
/**
|
|
392
392
|
* > A U+003A COLON character (:)
|
|
393
393
|
*/
|
|
394
|
-
|
|
395
|
-
log('Parsing Datetime
|
|
394
|
+
colon(colon) {
|
|
395
|
+
log('Parsing Datetime colon: "%s"', colon?.value);
|
|
396
396
|
|
|
397
|
-
if (!
|
|
397
|
+
if (!colon || !colon.value) {
|
|
398
398
|
return unmatched('', 'missing-token', {
|
|
399
|
-
expects: [{ type: 'common', value: '
|
|
399
|
+
expects: [{ type: 'common', value: 'colon' }],
|
|
400
400
|
partName: 'time',
|
|
401
401
|
});
|
|
402
402
|
}
|
|
403
|
-
if (!
|
|
404
|
-
return
|
|
403
|
+
if (!colon.match(':')) {
|
|
404
|
+
return colon.unmatched({
|
|
405
405
|
reason: 'unexpected-token',
|
|
406
|
-
expects: [{ type: 'common', value: '
|
|
406
|
+
expects: [{ type: 'common', value: 'colon' }],
|
|
407
407
|
partName: 'time',
|
|
408
408
|
});
|
|
409
409
|
}
|
|
@@ -414,15 +414,15 @@ export const datetimeTokenCheck: Record<
|
|
|
414
414
|
* or
|
|
415
415
|
* End of token
|
|
416
416
|
*/
|
|
417
|
-
|
|
418
|
-
if (!
|
|
417
|
+
colonOrEnd(colon) {
|
|
418
|
+
if (!colon || !colon.value) {
|
|
419
419
|
return matched();
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
if (!
|
|
423
|
-
return
|
|
422
|
+
if (!colon.match(':')) {
|
|
423
|
+
return colon.unmatched({
|
|
424
424
|
reason: 'unexpected-token',
|
|
425
|
-
expects: [{ type: 'common', value: '
|
|
425
|
+
expects: [{ type: 'common', value: 'colon' }],
|
|
426
426
|
partName: 'time',
|
|
427
427
|
});
|
|
428
428
|
}
|
|
@@ -498,8 +498,8 @@ export const datetimeTokenCheck: Record<
|
|
|
498
498
|
* > a U+002D HYPHEN-MINUS character (-),
|
|
499
499
|
* > representing the sign of the time-zone offset
|
|
500
500
|
*/
|
|
501
|
-
plusOrMinusSign(
|
|
502
|
-
if (!
|
|
501
|
+
plusOrMinusSign(colon) {
|
|
502
|
+
if (!colon) {
|
|
503
503
|
return unmatched('', 'missing-token', {
|
|
504
504
|
expects: [
|
|
505
505
|
{ type: 'const', value: '+' },
|
|
@@ -508,8 +508,8 @@ export const datetimeTokenCheck: Record<
|
|
|
508
508
|
partName: 'time-zone',
|
|
509
509
|
});
|
|
510
510
|
}
|
|
511
|
-
if (!
|
|
512
|
-
return
|
|
511
|
+
if (!colon.match(['+', '-'])) {
|
|
512
|
+
return colon.unmatched({
|
|
513
513
|
reason: 'unexpected-token',
|
|
514
514
|
expects: [
|
|
515
515
|
{ type: 'const', value: '+' },
|
|
@@ -49,7 +49,7 @@ export const checkGlobalDateAndTimeString: CustomSyntaxChecker = () =>
|
|
|
49
49
|
datetimeTokenCheck.date,
|
|
50
50
|
datetimeTokenCheck.localDateTimeSeparator,
|
|
51
51
|
datetimeTokenCheck.hour,
|
|
52
|
-
datetimeTokenCheck.
|
|
52
|
+
datetimeTokenCheck.colon,
|
|
53
53
|
datetimeTokenCheck.minute,
|
|
54
54
|
second => {
|
|
55
55
|
if (!second || !second.value) {
|
|
@@ -58,10 +58,10 @@ export const checkGlobalDateAndTimeString: CustomSyntaxChecker = () =>
|
|
|
58
58
|
|
|
59
59
|
const secondTokens = TokenCollection.fromPatterns(second, [/:?/, /[0-9]*/, /\.?/, /[0-9]*/]);
|
|
60
60
|
|
|
61
|
-
log('
|
|
61
|
+
log('Second Part: "%s" => %O', secondTokens.value, secondTokens);
|
|
62
62
|
|
|
63
63
|
const res = secondTokens.eachCheck(
|
|
64
|
-
datetimeTokenCheck.
|
|
64
|
+
datetimeTokenCheck.colon,
|
|
65
65
|
datetimeTokenCheck.second,
|
|
66
66
|
datetimeTokenCheck.decimalPointOrEnd,
|
|
67
67
|
datetimeTokenCheck.secondFractionalPart,
|
|
@@ -51,9 +51,9 @@ export const checkLocalDateAndTimeString: CustomSyntaxChecker = () =>
|
|
|
51
51
|
datetimeTokenCheck.date,
|
|
52
52
|
datetimeTokenCheck.localDateTimeSeparator,
|
|
53
53
|
datetimeTokenCheck.hour,
|
|
54
|
-
datetimeTokenCheck.
|
|
54
|
+
datetimeTokenCheck.colon,
|
|
55
55
|
datetimeTokenCheck.minute,
|
|
56
|
-
datetimeTokenCheck.
|
|
56
|
+
datetimeTokenCheck.colonOrEnd,
|
|
57
57
|
datetimeTokenCheck.second,
|
|
58
58
|
datetimeTokenCheck.decimalPointOrEnd,
|
|
59
59
|
datetimeTokenCheck.secondFractionalPart,
|
|
@@ -113,9 +113,9 @@ export const checkNormalizedLocalDateAndTimeString: CustomSyntaxChecker = () =>
|
|
|
113
113
|
datetimeTokenCheck.date,
|
|
114
114
|
datetimeTokenCheck.normalizedlocalDateTimeSeparator,
|
|
115
115
|
datetimeTokenCheck.hour,
|
|
116
|
-
datetimeTokenCheck.
|
|
116
|
+
datetimeTokenCheck.colon,
|
|
117
117
|
datetimeTokenCheck.minute,
|
|
118
|
-
datetimeTokenCheck.
|
|
118
|
+
datetimeTokenCheck.colonOrEnd,
|
|
119
119
|
datetimeTokenCheck.second,
|
|
120
120
|
datetimeTokenCheck.decimalPointOrEnd,
|
|
121
121
|
datetimeTokenCheck.secondFractionalPart,
|
|
@@ -33,9 +33,9 @@ export const checkTimeString: CustomSyntaxChecker = () =>
|
|
|
33
33
|
|
|
34
34
|
const res = tokens.eachCheck(
|
|
35
35
|
datetimeTokenCheck.hour,
|
|
36
|
-
datetimeTokenCheck.
|
|
36
|
+
datetimeTokenCheck.colon,
|
|
37
37
|
datetimeTokenCheck.minute,
|
|
38
|
-
datetimeTokenCheck.
|
|
38
|
+
datetimeTokenCheck.colonOrEnd,
|
|
39
39
|
datetimeTokenCheck.second,
|
|
40
40
|
datetimeTokenCheck.decimalPointOrEnd,
|
|
41
41
|
datetimeTokenCheck.secondFractionalPart,
|
|
@@ -68,13 +68,13 @@ export function parseTimeZone(zone: string | Token) {
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
datetimeTokenCheck.hour,
|
|
71
|
-
|
|
72
|
-
if (!
|
|
71
|
+
colon => {
|
|
72
|
+
if (!colon || !colon.value) {
|
|
73
73
|
return;
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
if (!
|
|
77
|
-
return
|
|
76
|
+
if (!colon.match(':')) {
|
|
77
|
+
return colon.unmatched({
|
|
78
78
|
reason: 'unexpected-token',
|
|
79
79
|
expects: [{ type: 'const', value: ':' }],
|
|
80
80
|
partName: 'time-zone',
|
|
@@ -21,7 +21,7 @@ test('excrescence-token', () => {
|
|
|
21
21
|
ref: null,
|
|
22
22
|
});
|
|
23
23
|
expect(check('x/y;')).toStrictEqual({
|
|
24
|
-
|
|
24
|
+
candidate: 'x/y',
|
|
25
25
|
column: 4,
|
|
26
26
|
expects: [{ type: 'format', value: 'MIME Type' }],
|
|
27
27
|
length: 1,
|
|
@@ -33,7 +33,7 @@ test('excrescence-token', () => {
|
|
|
33
33
|
ref: null,
|
|
34
34
|
});
|
|
35
35
|
expect(checkNoParam('x/y;')).toStrictEqual({
|
|
36
|
-
|
|
36
|
+
candidate: 'x/y',
|
|
37
37
|
column: 4,
|
|
38
38
|
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
39
39
|
length: 1,
|
|
@@ -45,7 +45,7 @@ test('excrescence-token', () => {
|
|
|
45
45
|
ref: null,
|
|
46
46
|
});
|
|
47
47
|
expect(checkNoParam('x/y;a=b;c=D;E="F"')).toStrictEqual({
|
|
48
|
-
|
|
48
|
+
candidate: 'x/y',
|
|
49
49
|
column: 4,
|
|
50
50
|
expects: [{ type: 'format', value: 'MIME Type with no parameters' }],
|
|
51
51
|
length: 14,
|
|
@@ -39,7 +39,7 @@ export const checkMIMEType: CustomSyntaxChecker<{
|
|
|
39
39
|
return new Token(extraToken, mimeType.essence.length, value).unmatched({
|
|
40
40
|
reason: 'extra-token',
|
|
41
41
|
expects: expects(withoutParameters),
|
|
42
|
-
|
|
42
|
+
candidate: mimeType.essence,
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
return unmatched(value, 'syntax-error', { expects: expects(withoutParameters) });
|