@markuplint/types 1.0.0-dev.20211213.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +117 -0
- package/extends.json +12 -0
- package/gen/specific-schema.json +98 -0
- package/gen/types.ts +66 -0
- package/lib/check-multi-types.d.ts +2 -0
- package/lib/check-multi-types.js +29 -0
- package/lib/check.d.ts +8 -0
- package/lib/check.js +49 -0
- package/lib/check.spec.d.ts +1 -0
- package/lib/check.spec.js +57 -0
- package/lib/css-syntax.d.ts +2 -0
- package/lib/css-syntax.js +141 -0
- package/lib/css-syntax.spec.d.ts +1 -0
- package/lib/css-syntax.spec.js +157 -0
- package/lib/debug.d.ts +2 -0
- package/lib/debug.js +6 -0
- package/lib/defs.d.ts +3 -0
- package/lib/defs.js +752 -0
- package/lib/enum.d.ts +3 -0
- package/lib/enum.js +26 -0
- package/lib/get-candicate.d.ts +3 -0
- package/lib/get-candicate.js +26 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.js +6 -0
- package/lib/keyword-type.d.ts +3 -0
- package/lib/keyword-type.js +46 -0
- package/lib/list.d.ts +3 -0
- package/lib/list.js +29 -0
- package/lib/list.spec.d.ts +1 -0
- package/lib/list.spec.js +129 -0
- package/lib/match-result.d.ts +9 -0
- package/lib/match-result.js +33 -0
- package/lib/number.d.ts +3 -0
- package/lib/number.js +41 -0
- package/lib/primitive/index.d.ts +7 -0
- package/lib/primitive/index.js +17 -0
- package/lib/primitive/index.spec.d.ts +1 -0
- package/lib/primitive/index.spec.js +62 -0
- package/lib/primitive/is-float.d.ts +6 -0
- package/lib/primitive/is-float.js +12 -0
- package/lib/primitive/is-int.d.ts +6 -0
- package/lib/primitive/is-int.js +12 -0
- package/lib/primitive/is-non-zero-uint.d.ts +6 -0
- package/lib/primitive/is-non-zero-uint.js +12 -0
- package/lib/primitive/is-quantity.d.ts +7 -0
- package/lib/primitive/is-quantity.js +41 -0
- package/lib/primitive/is-uint.d.ts +8 -0
- package/lib/primitive/is-uint.js +19 -0
- package/lib/primitive/range.d.ts +8 -0
- package/lib/primitive/range.js +18 -0
- package/lib/primitive/split-unit.d.ts +9 -0
- package/lib/primitive/split-unit.js +24 -0
- package/lib/rfc/is-bcp-47.d.ts +5 -0
- package/lib/rfc/is-bcp-47.js +14 -0
- package/lib/rfc/is-bcp-47.spec.d.ts +1 -0
- package/lib/rfc/is-bcp-47.spec.js +19 -0
- package/lib/token/index.d.ts +2 -0
- package/lib/token/index.js +7 -0
- package/lib/token/token-collection.d.ts +62 -0
- package/lib/token/token-collection.js +383 -0
- package/lib/token/token-collection.spec.d.ts +1 -0
- package/lib/token/token-collection.spec.js +144 -0
- package/lib/token/token.d.ts +55 -0
- package/lib/token/token.js +128 -0
- package/lib/types.d.ts +78 -0
- package/lib/types.js +2 -0
- package/lib/types.schema.d.ts +54 -0
- package/lib/types.schema.js +8 -0
- package/lib/w3c/check-serialized-permissions-policy.d.ts +15 -0
- package/lib/w3c/check-serialized-permissions-policy.js +251 -0
- package/lib/w3c/check-serialized-permissions-policy.spec.d.ts +1 -0
- package/lib/w3c/check-serialized-permissions-policy.spec.js +26 -0
- package/lib/whatwg/check-autocomplete.d.ts +5 -0
- package/lib/whatwg/check-autocomplete.js +282 -0
- package/lib/whatwg/check-autocomplete.spec.d.ts +1 -0
- package/lib/whatwg/check-autocomplete.spec.js +370 -0
- package/lib/whatwg/check-datetime/date-string.d.ts +5 -0
- package/lib/whatwg/check-datetime/date-string.js +31 -0
- package/lib/whatwg/check-datetime/datetime-tokens.d.ts +3 -0
- package/lib/whatwg/check-datetime/datetime-tokens.js +509 -0
- package/lib/whatwg/check-datetime/duration-string.d.ts +6 -0
- package/lib/whatwg/check-datetime/duration-string.js +322 -0
- package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +5 -0
- package/lib/whatwg/check-datetime/global-date-and-time-string.js +66 -0
- package/lib/whatwg/check-datetime/index.d.ts +5 -0
- package/lib/whatwg/check-datetime/index.js +35 -0
- package/lib/whatwg/check-datetime/index.spec.d.ts +1 -0
- package/lib/whatwg/check-datetime/index.spec.js +318 -0
- package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +9 -0
- package/lib/whatwg/check-datetime/local-date-and-time-string.js +116 -0
- package/lib/whatwg/check-datetime/month-string.d.ts +5 -0
- package/lib/whatwg/check-datetime/month-string.js +20 -0
- package/lib/whatwg/check-datetime/time-string.d.ts +5 -0
- package/lib/whatwg/check-datetime/time-string.js +35 -0
- package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +7 -0
- package/lib/whatwg/check-datetime/time-zone-offset-string.js +75 -0
- package/lib/whatwg/check-datetime/week-string.d.ts +5 -0
- package/lib/whatwg/check-datetime/week-string.js +29 -0
- package/lib/whatwg/check-datetime/year-string.d.ts +5 -0
- package/lib/whatwg/check-datetime/year-string.js +20 -0
- package/lib/whatwg/check-datetime/yearless-date-string.d.ts +5 -0
- package/lib/whatwg/check-datetime/yearless-date-string.js +27 -0
- package/lib/whatwg/check-mime-type.d.ts +11 -0
- package/lib/whatwg/check-mime-type.js +42 -0
- package/lib/whatwg/check-mime-type.spec.d.ts +1 -0
- package/lib/whatwg/check-mime-type.spec.js +58 -0
- package/lib/whatwg/is-abs-url.d.ts +15 -0
- package/lib/whatwg/is-abs-url.js +34 -0
- package/lib/whatwg/is-abs-url.spec.d.ts +1 -0
- package/lib/whatwg/is-abs-url.spec.js +8 -0
- package/lib/whatwg/is-browser-context-name.d.ts +11 -0
- package/lib/whatwg/is-browser-context-name.js +18 -0
- package/lib/whatwg/is-custom-element-name.d.ts +22 -0
- package/lib/whatwg/is-custom-element-name.js +77 -0
- package/lib/whatwg/is-itemprop-name.d.ts +12 -0
- package/lib/whatwg/is-itemprop-name.js +19 -0
- package/package.json +33 -0
- package/src/check-multi-types.ts +35 -0
- package/src/check.spec.ts +62 -0
- package/src/check.ts +48 -0
- package/src/css-syntax.spec.ts +167 -0
- package/src/css-syntax.ts +177 -0
- package/src/debug.ts +3 -0
- package/src/defs.ts +810 -0
- package/src/enum.ts +25 -0
- package/src/get-candicate.ts +24 -0
- package/src/index.ts +3 -0
- package/src/keyword-type.ts +52 -0
- package/src/list.spec.ts +133 -0
- package/src/list.ts +34 -0
- package/src/match-result.ts +49 -0
- package/src/number.ts +46 -0
- package/src/primitive/index.spec.ts +65 -0
- package/src/primitive/index.ts +7 -0
- package/src/primitive/is-float.ts +8 -0
- package/src/primitive/is-int.ts +8 -0
- package/src/primitive/is-non-zero-uint.ts +8 -0
- package/src/primitive/is-quantity.ts +38 -0
- package/src/primitive/is-uint.ts +15 -0
- package/src/primitive/range.ts +14 -0
- package/src/primitive/split-unit.ts +20 -0
- package/src/rfc/is-bcp-47.spec.ts +23 -0
- package/src/rfc/is-bcp-47.ts +13 -0
- package/src/token/index.ts +2 -0
- package/src/token/token-collection.spec.ts +147 -0
- package/src/token/token-collection.ts +444 -0
- package/src/token/token.ts +144 -0
- package/src/types.schema.ts +1059 -0
- package/src/types.ts +118 -0
- package/src/w3c/check-serialized-permissions-policy.spec.ts +27 -0
- package/src/w3c/check-serialized-permissions-policy.ts +287 -0
- package/src/whatwg/check-autocomplete.spec.ts +378 -0
- package/src/whatwg/check-autocomplete.ts +324 -0
- package/src/whatwg/check-datetime/date-string.ts +44 -0
- package/src/whatwg/check-datetime/datetime-tokens.ts +600 -0
- package/src/whatwg/check-datetime/duration-string.ts +399 -0
- package/src/whatwg/check-datetime/global-date-and-time-string.ts +96 -0
- package/src/whatwg/check-datetime/index.spec.ts +333 -0
- package/src/whatwg/check-datetime/index.ts +36 -0
- package/src/whatwg/check-datetime/local-date-and-time-string.ts +163 -0
- package/src/whatwg/check-datetime/month-string.ts +31 -0
- package/src/whatwg/check-datetime/time-string.ts +49 -0
- package/src/whatwg/check-datetime/time-zone-offset-string.ts +93 -0
- package/src/whatwg/check-datetime/week-string.ts +41 -0
- package/src/whatwg/check-datetime/year-string.ts +26 -0
- package/src/whatwg/check-datetime/yearless-date-string.ts +38 -0
- package/src/whatwg/check-mime-type.spec.ts +59 -0
- package/src/whatwg/check-mime-type.ts +46 -0
- package/src/whatwg/is-abs-url.spec.ts +8 -0
- package/src/whatwg/is-abs-url.ts +31 -0
- package/src/whatwg/is-browser-context-name.ts +16 -0
- package/src/whatwg/is-custom-element-name.ts +76 -0
- package/src/whatwg/is-itemprop-name.ts +17 -0
- package/tsconfig.test.json +3 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/types.schema.json +1092 -0
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const check_autocomplete_1 = require("./check-autocomplete");
|
|
4
|
+
const check = (0, check_autocomplete_1.checkAutoComplete)();
|
|
5
|
+
test('valid', () => {
|
|
6
|
+
expect(check('on').matched).toBe(true);
|
|
7
|
+
expect(check('off').matched).toBe(true);
|
|
8
|
+
expect(check('name').matched).toBe(true);
|
|
9
|
+
expect(check('given-name').matched).toBe(true);
|
|
10
|
+
expect(check('section-').matched).toBe(true);
|
|
11
|
+
expect(check('section-foo').matched).toBe(true);
|
|
12
|
+
expect(check('section-foo name').matched).toBe(true);
|
|
13
|
+
expect(check('section-foo shipping name').matched).toBe(true);
|
|
14
|
+
expect(check('section-foo billing name').matched).toBe(true);
|
|
15
|
+
expect(check('section-foo billing home').matched).toBe(true);
|
|
16
|
+
expect(check('section-foo billing work').matched).toBe(true);
|
|
17
|
+
expect(check('section-foo billing home tel').matched).toBe(true);
|
|
18
|
+
expect(check('section-foo billing work email').matched).toBe(true);
|
|
19
|
+
expect(check('shipping name').matched).toBe(true);
|
|
20
|
+
expect(check('billing name').matched).toBe(true);
|
|
21
|
+
expect(check('billing home').matched).toBe(true);
|
|
22
|
+
expect(check('billing work').matched).toBe(true);
|
|
23
|
+
expect(check('billing home tel').matched).toBe(true);
|
|
24
|
+
expect(check('billing work email').matched).toBe(true);
|
|
25
|
+
expect(check('home tel').matched).toBe(true);
|
|
26
|
+
expect(check('work email').matched).toBe(true);
|
|
27
|
+
});
|
|
28
|
+
test('unexpected-token', () => {
|
|
29
|
+
expect(check('section-foo , name')).toStrictEqual({
|
|
30
|
+
matched: false,
|
|
31
|
+
raw: ',',
|
|
32
|
+
offset: 12,
|
|
33
|
+
length: 1,
|
|
34
|
+
line: 1,
|
|
35
|
+
column: 13,
|
|
36
|
+
reason: 'unexpected-token',
|
|
37
|
+
expects: [
|
|
38
|
+
{ type: 'const', value: 'billing' },
|
|
39
|
+
{ type: 'const', value: 'shipping' },
|
|
40
|
+
{ type: 'common', value: 'autofill field name' },
|
|
41
|
+
],
|
|
42
|
+
candicate: undefined,
|
|
43
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
test('unexpected-token', () => {
|
|
47
|
+
expect(check('xxx')).toStrictEqual({
|
|
48
|
+
matched: false,
|
|
49
|
+
raw: 'xxx',
|
|
50
|
+
offset: 0,
|
|
51
|
+
length: 3,
|
|
52
|
+
line: 1,
|
|
53
|
+
column: 1,
|
|
54
|
+
reason: 'unexpected-token',
|
|
55
|
+
expects: [
|
|
56
|
+
{ type: 'common', value: 'autofill named group' },
|
|
57
|
+
{ type: 'common', value: 'autofill field name' },
|
|
58
|
+
],
|
|
59
|
+
candicate: undefined,
|
|
60
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
test('unexpected-token', () => {
|
|
64
|
+
expect(check('section-foo neme')).toStrictEqual({
|
|
65
|
+
matched: false,
|
|
66
|
+
raw: 'neme',
|
|
67
|
+
offset: 12,
|
|
68
|
+
length: 4,
|
|
69
|
+
line: 1,
|
|
70
|
+
column: 13,
|
|
71
|
+
reason: 'unexpected-token',
|
|
72
|
+
expects: [
|
|
73
|
+
{ type: 'const', value: 'billing' },
|
|
74
|
+
{ type: 'const', value: 'shipping' },
|
|
75
|
+
{ type: 'common', value: 'autofill field name' },
|
|
76
|
+
],
|
|
77
|
+
candicate: 'name',
|
|
78
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
79
|
+
});
|
|
80
|
+
expect(check('section-foo shipping neme')).toStrictEqual({
|
|
81
|
+
matched: false,
|
|
82
|
+
raw: 'neme',
|
|
83
|
+
offset: 21,
|
|
84
|
+
length: 4,
|
|
85
|
+
line: 1,
|
|
86
|
+
column: 22,
|
|
87
|
+
reason: 'unexpected-token',
|
|
88
|
+
expects: [
|
|
89
|
+
{ type: 'common', value: 'autofill field name' },
|
|
90
|
+
{ type: 'const', value: 'home' },
|
|
91
|
+
{ type: 'const', value: 'work' },
|
|
92
|
+
{ type: 'const', value: 'mobile' },
|
|
93
|
+
{ type: 'const', value: 'fax' },
|
|
94
|
+
{ type: 'const', value: 'pager' },
|
|
95
|
+
],
|
|
96
|
+
candicate: 'name',
|
|
97
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
98
|
+
});
|
|
99
|
+
expect(check('section-foo shipping home neme')).toStrictEqual({
|
|
100
|
+
matched: false,
|
|
101
|
+
raw: 'neme',
|
|
102
|
+
offset: 26,
|
|
103
|
+
length: 4,
|
|
104
|
+
line: 1,
|
|
105
|
+
column: 27,
|
|
106
|
+
reason: 'unexpected-token',
|
|
107
|
+
expects: [
|
|
108
|
+
{ type: 'const', value: 'tel' },
|
|
109
|
+
{ type: 'const', value: 'tel-country-code' },
|
|
110
|
+
{ type: 'const', value: 'tel-national' },
|
|
111
|
+
{ type: 'const', value: 'tel-area-code' },
|
|
112
|
+
{ type: 'const', value: 'tel-local' },
|
|
113
|
+
{ type: 'const', value: 'tel-local-prefix' },
|
|
114
|
+
{ type: 'const', value: 'tel-local-suffix' },
|
|
115
|
+
{ type: 'const', value: 'tel-extension' },
|
|
116
|
+
{ type: 'const', value: 'email' },
|
|
117
|
+
{ type: 'const', value: 'impp' },
|
|
118
|
+
],
|
|
119
|
+
candicate: undefined,
|
|
120
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
|
|
121
|
+
});
|
|
122
|
+
expect(check('section-foo shipping home emall')).toStrictEqual({
|
|
123
|
+
matched: false,
|
|
124
|
+
raw: 'emall',
|
|
125
|
+
offset: 26,
|
|
126
|
+
length: 5,
|
|
127
|
+
line: 1,
|
|
128
|
+
column: 27,
|
|
129
|
+
reason: 'unexpected-token',
|
|
130
|
+
expects: [
|
|
131
|
+
{ type: 'const', value: 'tel' },
|
|
132
|
+
{ type: 'const', value: 'tel-country-code' },
|
|
133
|
+
{ type: 'const', value: 'tel-national' },
|
|
134
|
+
{ type: 'const', value: 'tel-area-code' },
|
|
135
|
+
{ type: 'const', value: 'tel-local' },
|
|
136
|
+
{ type: 'const', value: 'tel-local-prefix' },
|
|
137
|
+
{ type: 'const', value: 'tel-local-suffix' },
|
|
138
|
+
{ type: 'const', value: 'tel-extension' },
|
|
139
|
+
{ type: 'const', value: 'email' },
|
|
140
|
+
{ type: 'const', value: 'impp' },
|
|
141
|
+
],
|
|
142
|
+
candicate: 'email',
|
|
143
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
test('duplicated', () => {
|
|
147
|
+
expect(check('name name')).toStrictEqual({
|
|
148
|
+
matched: false,
|
|
149
|
+
raw: 'name',
|
|
150
|
+
offset: 5,
|
|
151
|
+
length: 4,
|
|
152
|
+
line: 1,
|
|
153
|
+
column: 6,
|
|
154
|
+
partName: 'the content of the list',
|
|
155
|
+
reason: 'duplicated',
|
|
156
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
157
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete',
|
|
158
|
+
});
|
|
159
|
+
expect(check('on on')).toStrictEqual({
|
|
160
|
+
matched: false,
|
|
161
|
+
raw: 'on',
|
|
162
|
+
offset: 3,
|
|
163
|
+
length: 2,
|
|
164
|
+
line: 1,
|
|
165
|
+
column: 4,
|
|
166
|
+
partName: 'the content of the list',
|
|
167
|
+
reason: 'duplicated',
|
|
168
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
169
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete',
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
test('extra-token', () => {
|
|
173
|
+
expect(check('on off')).toStrictEqual({
|
|
174
|
+
matched: false,
|
|
175
|
+
raw: 'off',
|
|
176
|
+
offset: 3,
|
|
177
|
+
length: 3,
|
|
178
|
+
line: 1,
|
|
179
|
+
column: 4,
|
|
180
|
+
reason: 'extra-token',
|
|
181
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
182
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
|
|
183
|
+
});
|
|
184
|
+
expect(check('off on')).toStrictEqual({
|
|
185
|
+
matched: false,
|
|
186
|
+
raw: 'on',
|
|
187
|
+
offset: 4,
|
|
188
|
+
length: 2,
|
|
189
|
+
line: 1,
|
|
190
|
+
column: 5,
|
|
191
|
+
reason: 'extra-token',
|
|
192
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
193
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
|
|
194
|
+
});
|
|
195
|
+
expect(check('on name')).toStrictEqual({
|
|
196
|
+
matched: false,
|
|
197
|
+
raw: 'name',
|
|
198
|
+
offset: 3,
|
|
199
|
+
length: 4,
|
|
200
|
+
line: 1,
|
|
201
|
+
column: 4,
|
|
202
|
+
reason: 'extra-token',
|
|
203
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
204
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
|
|
205
|
+
});
|
|
206
|
+
expect(check('name on')).toStrictEqual({
|
|
207
|
+
matched: false,
|
|
208
|
+
raw: 'on',
|
|
209
|
+
offset: 5,
|
|
210
|
+
length: 2,
|
|
211
|
+
line: 1,
|
|
212
|
+
column: 6,
|
|
213
|
+
reason: 'extra-token',
|
|
214
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
215
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
216
|
+
});
|
|
217
|
+
expect(check('section-foo name on')).toStrictEqual({
|
|
218
|
+
matched: false,
|
|
219
|
+
raw: 'on',
|
|
220
|
+
offset: 17,
|
|
221
|
+
length: 2,
|
|
222
|
+
line: 1,
|
|
223
|
+
column: 18,
|
|
224
|
+
reason: 'extra-token',
|
|
225
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
226
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
227
|
+
});
|
|
228
|
+
expect(check('section-foo billing name on')).toStrictEqual({
|
|
229
|
+
matched: false,
|
|
230
|
+
raw: 'on',
|
|
231
|
+
offset: 25,
|
|
232
|
+
length: 2,
|
|
233
|
+
line: 1,
|
|
234
|
+
column: 26,
|
|
235
|
+
reason: 'extra-token',
|
|
236
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
237
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
238
|
+
});
|
|
239
|
+
expect(check('billing name on')).toStrictEqual({
|
|
240
|
+
matched: false,
|
|
241
|
+
raw: 'on',
|
|
242
|
+
offset: 13,
|
|
243
|
+
length: 2,
|
|
244
|
+
line: 1,
|
|
245
|
+
column: 14,
|
|
246
|
+
reason: 'extra-token',
|
|
247
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
248
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
249
|
+
});
|
|
250
|
+
expect(check('tel on')).toStrictEqual({
|
|
251
|
+
matched: false,
|
|
252
|
+
raw: 'on',
|
|
253
|
+
offset: 4,
|
|
254
|
+
length: 2,
|
|
255
|
+
line: 1,
|
|
256
|
+
column: 5,
|
|
257
|
+
reason: 'extra-token',
|
|
258
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
259
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
260
|
+
});
|
|
261
|
+
expect(check('home tel on')).toStrictEqual({
|
|
262
|
+
matched: false,
|
|
263
|
+
raw: 'on',
|
|
264
|
+
offset: 9,
|
|
265
|
+
length: 2,
|
|
266
|
+
line: 1,
|
|
267
|
+
column: 10,
|
|
268
|
+
reason: 'extra-token',
|
|
269
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
270
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
271
|
+
});
|
|
272
|
+
expect(check('billing home tel on')).toStrictEqual({
|
|
273
|
+
matched: false,
|
|
274
|
+
raw: 'on',
|
|
275
|
+
offset: 17,
|
|
276
|
+
length: 2,
|
|
277
|
+
line: 1,
|
|
278
|
+
column: 18,
|
|
279
|
+
reason: 'extra-token',
|
|
280
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
281
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
282
|
+
});
|
|
283
|
+
expect(check('billing home tel on')).toStrictEqual({
|
|
284
|
+
matched: false,
|
|
285
|
+
raw: 'on',
|
|
286
|
+
offset: 17,
|
|
287
|
+
length: 2,
|
|
288
|
+
line: 1,
|
|
289
|
+
column: 18,
|
|
290
|
+
reason: 'extra-token',
|
|
291
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
292
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
293
|
+
});
|
|
294
|
+
expect(check('section-foo billing home tel on')).toStrictEqual({
|
|
295
|
+
matched: false,
|
|
296
|
+
raw: 'on',
|
|
297
|
+
offset: 29,
|
|
298
|
+
length: 2,
|
|
299
|
+
line: 1,
|
|
300
|
+
column: 30,
|
|
301
|
+
reason: 'extra-token',
|
|
302
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
303
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
304
|
+
});
|
|
305
|
+
expect(check('section-foo home tel on')).toStrictEqual({
|
|
306
|
+
matched: false,
|
|
307
|
+
raw: 'on',
|
|
308
|
+
offset: 21,
|
|
309
|
+
length: 2,
|
|
310
|
+
line: 1,
|
|
311
|
+
column: 22,
|
|
312
|
+
reason: 'extra-token',
|
|
313
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
314
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
315
|
+
});
|
|
316
|
+
expect(check('section-foo tel on')).toStrictEqual({
|
|
317
|
+
matched: false,
|
|
318
|
+
raw: 'on',
|
|
319
|
+
offset: 16,
|
|
320
|
+
length: 2,
|
|
321
|
+
line: 1,
|
|
322
|
+
column: 17,
|
|
323
|
+
reason: 'extra-token',
|
|
324
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
325
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
test('duplicated section', () => {
|
|
329
|
+
expect(check('section-foo section-bar')).toStrictEqual({
|
|
330
|
+
matched: false,
|
|
331
|
+
raw: 'section-bar',
|
|
332
|
+
offset: 12,
|
|
333
|
+
length: 11,
|
|
334
|
+
line: 1,
|
|
335
|
+
column: 13,
|
|
336
|
+
partName: 'autofill named group',
|
|
337
|
+
reason: 'duplicated',
|
|
338
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-section',
|
|
339
|
+
});
|
|
340
|
+
});
|
|
341
|
+
test('duplicated part', () => {
|
|
342
|
+
expect(check('shipping billing')).toStrictEqual({
|
|
343
|
+
matched: false,
|
|
344
|
+
raw: 'billing',
|
|
345
|
+
offset: 9,
|
|
346
|
+
length: 7,
|
|
347
|
+
line: 1,
|
|
348
|
+
column: 10,
|
|
349
|
+
reason: 'duplicated',
|
|
350
|
+
expects: [{ type: 'format', value: 'autocomplete' }],
|
|
351
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-shipping',
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
test('typo', () => {
|
|
355
|
+
expect(check('secsion-foo name')).toStrictEqual({
|
|
356
|
+
matched: false,
|
|
357
|
+
raw: 'secsion-foo',
|
|
358
|
+
offset: 0,
|
|
359
|
+
length: 11,
|
|
360
|
+
line: 1,
|
|
361
|
+
column: 1,
|
|
362
|
+
reason: 'unexpected-token',
|
|
363
|
+
expects: [
|
|
364
|
+
{ type: 'common', value: 'autofill named group' },
|
|
365
|
+
{ type: 'common', value: 'autofill field name' },
|
|
366
|
+
],
|
|
367
|
+
candicate: 'section-foo',
|
|
368
|
+
ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
|
|
369
|
+
});
|
|
370
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkDateString = void 0;
|
|
4
|
+
const debug_1 = require("../../debug");
|
|
5
|
+
const token_1 = require("../../token");
|
|
6
|
+
const datetime_tokens_1 = require("./datetime-tokens");
|
|
7
|
+
/**
|
|
8
|
+
* @see https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#dates
|
|
9
|
+
*/
|
|
10
|
+
const checkDateString = () => function checkDateString(value) {
|
|
11
|
+
(0, debug_1.log)('CHECK: date-string');
|
|
12
|
+
const tokens = token_1.TokenCollection.fromPatterns(value, [
|
|
13
|
+
// YYYY
|
|
14
|
+
/[^-]*/,
|
|
15
|
+
// -
|
|
16
|
+
/[^0-9]?/,
|
|
17
|
+
// MM
|
|
18
|
+
/[^-]*/,
|
|
19
|
+
// -
|
|
20
|
+
/[^0-9]/,
|
|
21
|
+
// DD
|
|
22
|
+
/.[0-9]*/,
|
|
23
|
+
]);
|
|
24
|
+
(0, debug_1.log)('Date: "%s" => %O', tokens.value, tokens);
|
|
25
|
+
const res = tokens.eachCheck(datetime_tokens_1.datetimeTokenCheck.year, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.month, datetime_tokens_1.datetimeTokenCheck.hyphen, datetime_tokens_1.datetimeTokenCheck.date, datetime_tokens_1.datetimeTokenCheck.extra);
|
|
26
|
+
if (!res.matched) {
|
|
27
|
+
(0, debug_1.log)('Failed: %O', res);
|
|
28
|
+
}
|
|
29
|
+
return res;
|
|
30
|
+
};
|
|
31
|
+
exports.checkDateString = checkDateString;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { TokenEachCheck } from '../../token/token-collection';
|
|
2
|
+
export declare const datetimeTokenCheck: Record<'year' | 'month' | 'date' | 'hour' | 'minute' | 'second' | 'secondFractionalPart' | 'week' | 'hyphen' | 'coron' | 'extra' | 'coronOrEnd' | 'decimalPointOrEnd' | 'localDateTimeSeparator' | 'normalizedlocalDateTimeSeparator' | 'plusOrMinusSign' | 'weekSign', TokenEachCheck> & Record<'_year' | '_month', number | null>;
|
|
3
|
+
export declare function getMaxWeekNum(year: number): number;
|