@markuplint/types 3.12.0 → 4.0.0-alpha.10

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.
Files changed (101) hide show
  1. package/LICENSE +1 -1
  2. package/lib/check-multi-types.d.ts +2 -5
  3. package/lib/check-multi-types.js +9 -14
  4. package/lib/check.d.ts +1 -1
  5. package/lib/check.js +20 -30
  6. package/lib/css-syntax.d.ts +1 -1
  7. package/lib/css-syntax.js +33 -33
  8. package/lib/debug.js +2 -6
  9. package/lib/defs.d.ts +2 -1
  10. package/lib/defs.js +188 -138
  11. package/lib/enum.d.ts +2 -2
  12. package/lib/enum.js +7 -12
  13. package/lib/get-candidate.d.ts +1 -4
  14. package/lib/get-candidate.js +5 -10
  15. package/lib/index.d.ts +3 -3
  16. package/lib/index.js +3 -6
  17. package/lib/keyword-type.d.ts +2 -2
  18. package/lib/keyword-type.js +20 -25
  19. package/lib/list.d.ts +2 -2
  20. package/lib/list.js +9 -14
  21. package/lib/match-result.d.ts +8 -21
  22. package/lib/match-result.js +6 -13
  23. package/lib/number.d.ts +3 -3
  24. package/lib/number.js +13 -17
  25. package/lib/primitive/index.d.ts +7 -7
  26. package/lib/primitive/index.js +7 -17
  27. package/lib/primitive/is-float.js +2 -6
  28. package/lib/primitive/is-int.js +2 -6
  29. package/lib/primitive/is-non-zero-uint.js +2 -6
  30. package/lib/primitive/is-quantity.d.ts +1 -5
  31. package/lib/primitive/is-quantity.js +9 -13
  32. package/lib/primitive/is-uint.d.ts +3 -6
  33. package/lib/primitive/is-uint.js +4 -8
  34. package/lib/primitive/range.js +3 -7
  35. package/lib/primitive/split-unit.d.ts +2 -2
  36. package/lib/primitive/split-unit.js +4 -8
  37. package/lib/rfc/is-bcp-47.d.ts +1 -1
  38. package/lib/rfc/is-bcp-47.js +3 -7
  39. package/lib/token/index.d.ts +2 -2
  40. package/lib/token/index.js +2 -7
  41. package/lib/token/token-collection.d.ts +58 -70
  42. package/lib/token/token-collection.js +47 -56
  43. package/lib/token/token.d.ts +54 -59
  44. package/lib/token/token.js +14 -20
  45. package/lib/token/types.js +1 -2
  46. package/lib/types.d.ts +58 -82
  47. package/lib/types.js +1 -2
  48. package/lib/types.schema.d.ts +31 -1087
  49. package/lib/types.schema.js +1 -2
  50. package/lib/w3c/check-serialized-permissions-policy.d.ts +1 -1
  51. package/lib/w3c/check-serialized-permissions-policy.js +21 -25
  52. package/lib/whatwg/check-autocomplete.d.ts +1 -1
  53. package/lib/whatwg/check-autocomplete.js +34 -41
  54. package/lib/whatwg/check-datetime/date-string.d.ts +1 -1
  55. package/lib/whatwg/check-datetime/date-string.js +12 -16
  56. package/lib/whatwg/check-datetime/datetime-tokens.d.ts +2 -22
  57. package/lib/whatwg/check-datetime/datetime-tokens.js +58 -64
  58. package/lib/whatwg/check-datetime/duration-string.d.ts +1 -1
  59. package/lib/whatwg/check-datetime/duration-string.js +64 -69
  60. package/lib/whatwg/check-datetime/global-date-and-time-string.d.ts +1 -1
  61. package/lib/whatwg/check-datetime/global-date-and-time-string.js +24 -28
  62. package/lib/whatwg/check-datetime/index.d.ts +1 -1
  63. package/lib/whatwg/check-datetime/index.js +25 -29
  64. package/lib/whatwg/check-datetime/local-date-and-time-string.d.ts +1 -1
  65. package/lib/whatwg/check-datetime/local-date-and-time-string.js +37 -41
  66. package/lib/whatwg/check-datetime/month-string.d.ts +1 -1
  67. package/lib/whatwg/check-datetime/month-string.js +9 -13
  68. package/lib/whatwg/check-datetime/time-string.d.ts +1 -1
  69. package/lib/whatwg/check-datetime/time-string.js +13 -17
  70. package/lib/whatwg/check-datetime/time-zone-offset-string.d.ts +3 -3
  71. package/lib/whatwg/check-datetime/time-zone-offset-string.js +22 -28
  72. package/lib/whatwg/check-datetime/week-string.d.ts +1 -1
  73. package/lib/whatwg/check-datetime/week-string.js +11 -15
  74. package/lib/whatwg/check-datetime/year-string.d.ts +1 -1
  75. package/lib/whatwg/check-datetime/year-string.js +9 -13
  76. package/lib/whatwg/check-datetime/yearless-date-string.d.ts +1 -1
  77. package/lib/whatwg/check-datetime/yearless-date-string.js +11 -15
  78. package/lib/whatwg/check-mime-type.d.ts +5 -5
  79. package/lib/whatwg/check-mime-type.js +11 -17
  80. package/lib/whatwg/is-abs-url.d.ts +1 -1
  81. package/lib/whatwg/is-abs-url.js +8 -12
  82. package/lib/whatwg/is-browser-context-name.d.ts +1 -1
  83. package/lib/whatwg/is-browser-context-name.js +1 -5
  84. package/lib/whatwg/is-custom-element-name.d.ts +10 -5
  85. package/lib/whatwg/is-custom-element-name.js +22 -38
  86. package/lib/whatwg/is-itemprop-name.d.ts +1 -1
  87. package/lib/whatwg/is-itemprop-name.js +1 -5
  88. package/lib/whatwg/is-navigable-target-name.d.ts +1 -1
  89. package/lib/whatwg/is-navigable-target-name.js +1 -5
  90. package/package.json +17 -9
  91. package/test/check.spec.js +0 -89
  92. package/test/css-syntax.spec.js +0 -170
  93. package/test/list.spec.js +0 -133
  94. package/test/primitive/index.spec.js +0 -65
  95. package/test/rfc/is-bcp-47.spec.js +0 -23
  96. package/test/token/token-collection.spec.js +0 -146
  97. package/test/w3c/check-serialized-permissions-policy.spec.js +0 -36
  98. package/test/whatwg/check-autocomplete.spec.js +0 -387
  99. package/test/whatwg/check-datetime/index.spec.js +0 -336
  100. package/test/whatwg/check-mime-type.spec.js +0 -59
  101. package/test/whatwg/is-abs-url.spec.js +0 -8
@@ -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
- });
@@ -1,387 +0,0 @@
1
- const { checkAutoComplete } = require('../../lib/whatwg/check-autocomplete');
2
-
3
- const check = checkAutoComplete();
4
-
5
- test('basic', () => {
6
- expect(check('on').matched).toBe(true);
7
- expect(check('on webauthn').matched).toBe(false);
8
- expect(check('off').matched).toBe(true);
9
- expect(check('off webauthn').matched).toBe(false);
10
- expect(check('name').matched).toBe(true);
11
- expect(check('given-name').matched).toBe(true);
12
- expect(check('given-name webauthn').matched).toBe(true);
13
- expect(check('given-name webauthun').matched).toBe(false);
14
- expect(check('section-').matched).toBe(true);
15
- expect(check('section-foo').matched).toBe(true);
16
- expect(check('section-foo webauthn').matched).toBe(true);
17
- expect(check('section-foo name').matched).toBe(true);
18
- expect(check('section-foo name webauthn').matched).toBe(true);
19
- expect(check('section-foo shipping name').matched).toBe(true);
20
- expect(check('section-foo billing name').matched).toBe(true);
21
- expect(check('section-foo billing home').matched).toBe(true);
22
- expect(check('section-foo billing work').matched).toBe(true);
23
- expect(check('section-foo billing home tel').matched).toBe(true);
24
- expect(check('section-foo billing work email').matched).toBe(true);
25
- expect(check('section-foo billing work email webauthn').matched).toBe(true);
26
- expect(check('shipping name').matched).toBe(true);
27
- expect(check('billing name').matched).toBe(true);
28
- expect(check('billing home').matched).toBe(true);
29
- expect(check('billing work').matched).toBe(true);
30
- expect(check('billing home tel').matched).toBe(true);
31
- expect(check('billing work email').matched).toBe(true);
32
- expect(check('billing work email webauthn').matched).toBe(true);
33
- expect(check('home tel').matched).toBe(true);
34
- expect(check('work email').matched).toBe(true);
35
- expect(check('work email webauthn').matched).toBe(true);
36
- });
37
-
38
- test('unexpected-token', () => {
39
- expect(check('section-foo , name')).toStrictEqual({
40
- matched: false,
41
- raw: ',',
42
- offset: 12,
43
- length: 1,
44
- line: 1,
45
- column: 13,
46
- reason: 'unexpected-token',
47
- expects: [
48
- { type: 'const', value: 'billing' },
49
- { type: 'const', value: 'shipping' },
50
- { type: 'common', value: 'autofill field name' },
51
- ],
52
- candidate: undefined,
53
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
54
- });
55
- });
56
-
57
- test('unexpected-token', () => {
58
- expect(check('xxx')).toStrictEqual({
59
- matched: false,
60
- raw: 'xxx',
61
- offset: 0,
62
- length: 3,
63
- line: 1,
64
- column: 1,
65
- reason: 'unexpected-token',
66
- expects: [
67
- { type: 'common', value: 'autofill named group' },
68
- { type: 'common', value: 'autofill field name' },
69
- ],
70
- candidate: undefined,
71
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
72
- });
73
- });
74
-
75
- test('unexpected-token', () => {
76
- expect(check('section-foo neme')).toStrictEqual({
77
- matched: false,
78
- raw: 'neme',
79
- offset: 12,
80
- length: 4,
81
- line: 1,
82
- column: 13,
83
- reason: 'unexpected-token',
84
- expects: [
85
- { type: 'const', value: 'billing' },
86
- { type: 'const', value: 'shipping' },
87
- { type: 'common', value: 'autofill field name' },
88
- ],
89
- candidate: 'name',
90
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
91
- });
92
- expect(check('section-foo shipping neme')).toStrictEqual({
93
- matched: false,
94
- raw: 'neme',
95
- offset: 21,
96
- length: 4,
97
- line: 1,
98
- column: 22,
99
- reason: 'unexpected-token',
100
- expects: [
101
- { type: 'common', value: 'autofill field name' },
102
- { type: 'const', value: 'home' },
103
- { type: 'const', value: 'work' },
104
- { type: 'const', value: 'mobile' },
105
- { type: 'const', value: 'fax' },
106
- { type: 'const', value: 'pager' },
107
- ],
108
- candidate: 'name',
109
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
110
- });
111
- expect(check('section-foo shipping home name')).toStrictEqual({
112
- matched: false,
113
- raw: 'name',
114
- offset: 26,
115
- length: 4,
116
- line: 1,
117
- column: 27,
118
- reason: 'unexpected-token',
119
- expects: [
120
- { type: 'const', value: 'tel' },
121
- { type: 'const', value: 'tel-country-code' },
122
- { type: 'const', value: 'tel-national' },
123
- { type: 'const', value: 'tel-area-code' },
124
- { type: 'const', value: 'tel-local' },
125
- { type: 'const', value: 'tel-local-prefix' },
126
- { type: 'const', value: 'tel-local-suffix' },
127
- { type: 'const', value: 'tel-extension' },
128
- { type: 'const', value: 'email' },
129
- { type: 'const', value: 'impp' },
130
- ],
131
- candidate: undefined,
132
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
133
- });
134
- expect(check('section-foo shipping home emall')).toStrictEqual({
135
- matched: false,
136
- raw: 'emall',
137
- offset: 26,
138
- length: 5,
139
- line: 1,
140
- column: 27,
141
- reason: 'unexpected-token',
142
- expects: [
143
- { type: 'const', value: 'tel' },
144
- { type: 'const', value: 'tel-country-code' },
145
- { type: 'const', value: 'tel-national' },
146
- { type: 'const', value: 'tel-area-code' },
147
- { type: 'const', value: 'tel-local' },
148
- { type: 'const', value: 'tel-local-prefix' },
149
- { type: 'const', value: 'tel-local-suffix' },
150
- { type: 'const', value: 'tel-extension' },
151
- { type: 'const', value: 'email' },
152
- { type: 'const', value: 'impp' },
153
- ],
154
- candidate: 'email',
155
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-tel',
156
- });
157
- });
158
-
159
- test('duplicated', () => {
160
- expect(check('name name')).toStrictEqual({
161
- matched: false,
162
- raw: 'name',
163
- offset: 5,
164
- length: 4,
165
- line: 1,
166
- column: 6,
167
- partName: 'the content of the list',
168
- reason: 'duplicated',
169
- expects: [{ type: 'format', value: 'autocomplete' }],
170
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete',
171
- });
172
- expect(check('on on')).toStrictEqual({
173
- matched: false,
174
- raw: 'on',
175
- offset: 3,
176
- length: 2,
177
- line: 1,
178
- column: 4,
179
- partName: 'the content of the list',
180
- reason: 'duplicated',
181
- expects: [{ type: 'format', value: 'autocomplete' }],
182
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete',
183
- });
184
- });
185
-
186
- test('extra-token', () => {
187
- expect(check('on off')).toStrictEqual({
188
- matched: false,
189
- raw: 'off',
190
- offset: 3,
191
- length: 3,
192
- line: 1,
193
- column: 4,
194
- reason: 'extra-token',
195
- expects: [{ type: 'format', value: 'autocomplete' }],
196
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
197
- });
198
- expect(check('off on')).toStrictEqual({
199
- matched: false,
200
- raw: 'on',
201
- offset: 4,
202
- length: 2,
203
- line: 1,
204
- column: 5,
205
- reason: 'extra-token',
206
- expects: [{ type: 'format', value: 'autocomplete' }],
207
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
208
- });
209
- expect(check('on name')).toStrictEqual({
210
- matched: false,
211
- raw: 'name',
212
- offset: 3,
213
- length: 4,
214
- line: 1,
215
- column: 4,
216
- reason: 'extra-token',
217
- expects: [{ type: 'format', value: 'autocomplete' }],
218
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofilling-form-controls:-the-autocomplete-attribute:attr-fe-autocomplete-on-2',
219
- });
220
- expect(check('name on')).toStrictEqual({
221
- matched: false,
222
- raw: 'on',
223
- offset: 5,
224
- length: 2,
225
- line: 1,
226
- column: 6,
227
- reason: 'extra-token',
228
- expects: [{ type: 'format', value: 'autocomplete' }],
229
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
230
- });
231
- expect(check('section-foo name on')).toStrictEqual({
232
- matched: false,
233
- raw: 'on',
234
- offset: 17,
235
- length: 2,
236
- line: 1,
237
- column: 18,
238
- reason: 'extra-token',
239
- expects: [{ type: 'format', value: 'autocomplete' }],
240
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
241
- });
242
- expect(check('section-foo billing name on')).toStrictEqual({
243
- matched: false,
244
- raw: 'on',
245
- offset: 25,
246
- length: 2,
247
- line: 1,
248
- column: 26,
249
- reason: 'extra-token',
250
- expects: [{ type: 'format', value: 'autocomplete' }],
251
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
252
- });
253
- expect(check('billing name on')).toStrictEqual({
254
- matched: false,
255
- raw: 'on',
256
- offset: 13,
257
- length: 2,
258
- line: 1,
259
- column: 14,
260
- reason: 'extra-token',
261
- expects: [{ type: 'format', value: 'autocomplete' }],
262
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
263
- });
264
- expect(check('tel on')).toStrictEqual({
265
- matched: false,
266
- raw: 'on',
267
- offset: 4,
268
- length: 2,
269
- line: 1,
270
- column: 5,
271
- reason: 'extra-token',
272
- expects: [{ type: 'format', value: 'autocomplete' }],
273
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
274
- });
275
- expect(check('home tel on')).toStrictEqual({
276
- matched: false,
277
- raw: 'on',
278
- offset: 9,
279
- length: 2,
280
- line: 1,
281
- column: 10,
282
- reason: 'extra-token',
283
- expects: [{ type: 'format', value: 'autocomplete' }],
284
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
285
- });
286
- expect(check('billing home tel on')).toStrictEqual({
287
- matched: false,
288
- raw: 'on',
289
- offset: 17,
290
- length: 2,
291
- line: 1,
292
- column: 18,
293
- reason: 'extra-token',
294
- expects: [{ type: 'format', value: 'autocomplete' }],
295
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
296
- });
297
- expect(check('billing home tel on')).toStrictEqual({
298
- matched: false,
299
- raw: 'on',
300
- offset: 17,
301
- length: 2,
302
- line: 1,
303
- column: 18,
304
- reason: 'extra-token',
305
- expects: [{ type: 'format', value: 'autocomplete' }],
306
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
307
- });
308
- expect(check('section-foo billing home tel on')).toStrictEqual({
309
- matched: false,
310
- raw: 'on',
311
- offset: 29,
312
- length: 2,
313
- line: 1,
314
- column: 30,
315
- reason: 'extra-token',
316
- expects: [{ type: 'format', value: 'autocomplete' }],
317
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
318
- });
319
- expect(check('section-foo home tel on')).toStrictEqual({
320
- matched: false,
321
- raw: 'on',
322
- offset: 21,
323
- length: 2,
324
- line: 1,
325
- column: 22,
326
- reason: 'extra-token',
327
- expects: [{ type: 'format', value: 'autocomplete' }],
328
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
329
- });
330
- expect(check('section-foo tel on')).toStrictEqual({
331
- matched: false,
332
- raw: 'on',
333
- offset: 16,
334
- length: 2,
335
- line: 1,
336
- column: 17,
337
- reason: 'extra-token',
338
- expects: [{ type: 'format', value: 'autocomplete' }],
339
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
340
- });
341
- });
342
-
343
- test('duplicated section', () => {
344
- expect(check('section-foo section-bar')).toStrictEqual({
345
- matched: false,
346
- raw: 'section-bar',
347
- offset: 12,
348
- length: 11,
349
- line: 1,
350
- column: 13,
351
- partName: 'autofill named group',
352
- reason: 'duplicated',
353
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-section',
354
- });
355
- });
356
-
357
- test('duplicated part', () => {
358
- expect(check('shipping billing')).toStrictEqual({
359
- matched: false,
360
- raw: 'billing',
361
- offset: 9,
362
- length: 7,
363
- line: 1,
364
- column: 10,
365
- reason: 'duplicated',
366
- expects: [{ type: 'format', value: 'autocomplete' }],
367
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fe-autocomplete-shipping',
368
- });
369
- });
370
-
371
- test('typo', () => {
372
- expect(check('secsion-foo name')).toStrictEqual({
373
- matched: false,
374
- raw: 'secsion-foo',
375
- offset: 0,
376
- length: 11,
377
- line: 1,
378
- column: 1,
379
- reason: 'unexpected-token',
380
- expects: [
381
- { type: 'common', value: 'autofill named group' },
382
- { type: 'common', value: 'autofill field name' },
383
- ],
384
- candidate: 'section-foo',
385
- ref: 'https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-field',
386
- });
387
- });