]>
Commit | Line | Data |
---|---|---|
eb39fafa DC |
1 | /** |
2 | * @fileoverview Tests for no-irregular-whitespace rule. | |
3 | * @author Jonathan Kingston | |
4 | */ | |
5 | ||
6 | "use strict"; | |
7 | ||
8 | //------------------------------------------------------------------------------ | |
9 | // Requirements | |
10 | //------------------------------------------------------------------------------ | |
11 | ||
12 | const rule = require("../../../lib/rules/no-irregular-whitespace"), | |
13 | { RuleTester } = require("../../../lib/rule-tester"); | |
14 | ||
15 | //------------------------------------------------------------------------------ | |
16 | // Tests | |
17 | //------------------------------------------------------------------------------ | |
18 | ||
19 | const ruleTester = new RuleTester(); | |
20 | ||
21 | const expectedErrors = [{ | |
22 | messageId: "noIrregularWhitespace", | |
23 | type: "Program" | |
24 | }]; | |
25 | const expectedCommentErrors = [{ | |
26 | messageId: "noIrregularWhitespace", | |
27 | type: "Program", | |
28 | line: 1, | |
29 | column: 4 | |
30 | }]; | |
31 | ||
32 | ruleTester.run("no-irregular-whitespace", rule, { | |
33 | valid: [ | |
34 | "'\\u000B';", | |
35 | "'\\u000C';", | |
36 | "'\\u0085';", | |
37 | "'\\u00A0';", | |
38 | "'\\u180E';", | |
39 | "'\\ufeff';", | |
40 | "'\\u2000';", | |
41 | "'\\u2001';", | |
42 | "'\\u2002';", | |
43 | "'\\u2003';", | |
44 | "'\\u2004';", | |
45 | "'\\u2005';", | |
46 | "'\\u2006';", | |
47 | "'\\u2007';", | |
48 | "'\\u2008';", | |
49 | "'\\u2009';", | |
50 | "'\\u200A';", | |
51 | "'\\u200B';", | |
52 | "'\\u2028';", | |
53 | "'\\u2029';", | |
54 | "'\\u202F';", | |
55 | "'\\u205f';", | |
56 | "'\\u3000';", | |
57 | "'\u000B';", | |
58 | "'\u000C';", | |
59 | "'\u0085';", | |
60 | "'\u00A0';", | |
61 | "'\u180E';", | |
62 | "'\ufeff';", | |
63 | "'\u2000';", | |
64 | "'\u2001';", | |
65 | "'\u2002';", | |
66 | "'\u2003';", | |
67 | "'\u2004';", | |
68 | "'\u2005';", | |
69 | "'\u2006';", | |
70 | "'\u2007';", | |
71 | "'\u2008';", | |
72 | "'\u2009';", | |
73 | "'\u200A';", | |
74 | "'\u200B';", | |
75 | "'\\\u2028';", // multiline string | |
76 | "'\\\u2029';", // multiline string | |
77 | "'\u202F';", | |
78 | "'\u205f';", | |
79 | "'\u3000';", | |
80 | { code: "// \u000B", options: [{ skipComments: true }] }, | |
81 | { code: "// \u000C", options: [{ skipComments: true }] }, | |
82 | { code: "// \u0085", options: [{ skipComments: true }] }, | |
83 | { code: "// \u00A0", options: [{ skipComments: true }] }, | |
84 | { code: "// \u180E", options: [{ skipComments: true }] }, | |
85 | { code: "// \ufeff", options: [{ skipComments: true }] }, | |
86 | { code: "// \u2000", options: [{ skipComments: true }] }, | |
87 | { code: "// \u2001", options: [{ skipComments: true }] }, | |
88 | { code: "// \u2002", options: [{ skipComments: true }] }, | |
89 | { code: "// \u2003", options: [{ skipComments: true }] }, | |
90 | { code: "// \u2004", options: [{ skipComments: true }] }, | |
91 | { code: "// \u2005", options: [{ skipComments: true }] }, | |
92 | { code: "// \u2006", options: [{ skipComments: true }] }, | |
93 | { code: "// \u2007", options: [{ skipComments: true }] }, | |
94 | { code: "// \u2008", options: [{ skipComments: true }] }, | |
95 | { code: "// \u2009", options: [{ skipComments: true }] }, | |
96 | { code: "// \u200A", options: [{ skipComments: true }] }, | |
97 | { code: "// \u200B", options: [{ skipComments: true }] }, | |
98 | { code: "// \u202F", options: [{ skipComments: true }] }, | |
99 | { code: "// \u205f", options: [{ skipComments: true }] }, | |
100 | { code: "// \u3000", options: [{ skipComments: true }] }, | |
101 | { code: "/* \u000B */", options: [{ skipComments: true }] }, | |
102 | { code: "/* \u000C */", options: [{ skipComments: true }] }, | |
103 | { code: "/* \u0085 */", options: [{ skipComments: true }] }, | |
104 | { code: "/* \u00A0 */", options: [{ skipComments: true }] }, | |
105 | { code: "/* \u180E */", options: [{ skipComments: true }] }, | |
106 | { code: "/* \ufeff */", options: [{ skipComments: true }] }, | |
107 | { code: "/* \u2000 */", options: [{ skipComments: true }] }, | |
108 | { code: "/* \u2001 */", options: [{ skipComments: true }] }, | |
109 | { code: "/* \u2002 */", options: [{ skipComments: true }] }, | |
110 | { code: "/* \u2003 */", options: [{ skipComments: true }] }, | |
111 | { code: "/* \u2004 */", options: [{ skipComments: true }] }, | |
112 | { code: "/* \u2005 */", options: [{ skipComments: true }] }, | |
113 | { code: "/* \u2006 */", options: [{ skipComments: true }] }, | |
114 | { code: "/* \u2007 */", options: [{ skipComments: true }] }, | |
115 | { code: "/* \u2008 */", options: [{ skipComments: true }] }, | |
116 | { code: "/* \u2009 */", options: [{ skipComments: true }] }, | |
117 | { code: "/* \u200A */", options: [{ skipComments: true }] }, | |
118 | { code: "/* \u200B */", options: [{ skipComments: true }] }, | |
119 | { code: "/* \u2028 */", options: [{ skipComments: true }] }, | |
120 | { code: "/* \u2029 */", options: [{ skipComments: true }] }, | |
121 | { code: "/* \u202F */", options: [{ skipComments: true }] }, | |
122 | { code: "/* \u205f */", options: [{ skipComments: true }] }, | |
123 | { code: "/* \u3000 */", options: [{ skipComments: true }] }, | |
124 | { code: "/\u000B/", options: [{ skipRegExps: true }] }, | |
125 | { code: "/\u000C/", options: [{ skipRegExps: true }] }, | |
126 | { code: "/\u0085/", options: [{ skipRegExps: true }] }, | |
127 | { code: "/\u00A0/", options: [{ skipRegExps: true }] }, | |
128 | { code: "/\u180E/", options: [{ skipRegExps: true }] }, | |
129 | { code: "/\ufeff/", options: [{ skipRegExps: true }] }, | |
130 | { code: "/\u2000/", options: [{ skipRegExps: true }] }, | |
131 | { code: "/\u2001/", options: [{ skipRegExps: true }] }, | |
132 | { code: "/\u2002/", options: [{ skipRegExps: true }] }, | |
133 | { code: "/\u2003/", options: [{ skipRegExps: true }] }, | |
134 | { code: "/\u2004/", options: [{ skipRegExps: true }] }, | |
135 | { code: "/\u2005/", options: [{ skipRegExps: true }] }, | |
136 | { code: "/\u2006/", options: [{ skipRegExps: true }] }, | |
137 | { code: "/\u2007/", options: [{ skipRegExps: true }] }, | |
138 | { code: "/\u2008/", options: [{ skipRegExps: true }] }, | |
139 | { code: "/\u2009/", options: [{ skipRegExps: true }] }, | |
140 | { code: "/\u200A/", options: [{ skipRegExps: true }] }, | |
141 | { code: "/\u200B/", options: [{ skipRegExps: true }] }, | |
142 | { code: "/\u202F/", options: [{ skipRegExps: true }] }, | |
143 | { code: "/\u205f/", options: [{ skipRegExps: true }] }, | |
144 | { code: "/\u3000/", options: [{ skipRegExps: true }] }, | |
145 | { code: "`\u000B`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
146 | { code: "`\u000C`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
147 | { code: "`\u0085`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
148 | { code: "`\u00A0`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
149 | { code: "`\u180E`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
150 | { code: "`\ufeff`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
151 | { code: "`\u2000`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
152 | { code: "`\u2001`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
153 | { code: "`\u2002`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
154 | { code: "`\u2003`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
155 | { code: "`\u2004`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
156 | { code: "`\u2005`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
157 | { code: "`\u2006`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
158 | { code: "`\u2007`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
159 | { code: "`\u2008`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
160 | { code: "`\u2009`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
161 | { code: "`\u200A`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
162 | { code: "`\u200B`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
163 | { code: "`\u202F`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
164 | { code: "`\u205f`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
165 | { code: "`\u3000`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
166 | ||
456be15e TL |
167 | { code: "`\u3000${foo}\u3000`", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, |
168 | { code: "const error = ` \u3000 `;", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
169 | { code: "const error = `\n\u3000`;", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
170 | { code: "const error = `\u3000\n`;", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
171 | { code: "const error = `\n\u3000\n`;", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
172 | { code: "const error = `foo\u3000bar\nfoo\u3000bar`;", options: [{ skipTemplates: true }], parserOptions: { ecmaVersion: 6 } }, | |
173 | ||
eb39fafa DC |
174 | // Unicode BOM. |
175 | "\uFEFFconsole.log('hello BOM');" | |
176 | ], | |
177 | ||
178 | invalid: [ | |
179 | { | |
180 | code: "var any \u000B = 'thing';", | |
181 | errors: expectedErrors | |
182 | }, | |
183 | { | |
184 | code: "var any \u000C = 'thing';", | |
185 | errors: expectedErrors | |
186 | }, | |
187 | { | |
188 | code: "var any \u00A0 = 'thing';", | |
189 | errors: expectedErrors | |
190 | }, | |
191 | ||
192 | /* | |
193 | * it was moved out of General_Category=Zs (separator, space) in Unicode 6.3.0, so should not be considered a whitespace character. | |
194 | * https://codeblog.jonskeet.uk/2014/12/01/when-is-an-identifier-not-an-identifier-attack-of-the-mongolian-vowel-separator/ | |
195 | * { | |
196 | * code: "var any \u180E = 'thing';", | |
197 | * errors: expectedErrors | |
198 | * }, | |
199 | */ | |
200 | { | |
201 | code: "var any \ufeff = 'thing';", | |
202 | errors: expectedErrors | |
203 | }, | |
204 | { | |
205 | code: "var any \u2000 = 'thing';", | |
206 | errors: expectedErrors | |
207 | }, | |
208 | { | |
209 | code: "var any \u2001 = 'thing';", | |
210 | errors: expectedErrors | |
211 | }, | |
212 | { | |
213 | code: "var any \u2002 = 'thing';", | |
214 | errors: expectedErrors | |
215 | }, | |
216 | { | |
217 | code: "var any \u2003 = 'thing';", | |
218 | errors: expectedErrors | |
219 | }, | |
220 | { | |
221 | code: "var any \u2004 = 'thing';", | |
222 | errors: expectedErrors | |
223 | }, | |
224 | { | |
225 | code: "var any \u2005 = 'thing';", | |
226 | errors: expectedErrors | |
227 | }, | |
228 | { | |
229 | code: "var any \u2006 = 'thing';", | |
230 | errors: expectedErrors | |
231 | }, | |
232 | { | |
233 | code: "var any \u2007 = 'thing';", | |
234 | errors: expectedErrors | |
235 | }, | |
236 | { | |
237 | code: "var any \u2008 = 'thing';", | |
238 | errors: expectedErrors | |
239 | }, | |
240 | { | |
241 | code: "var any \u2009 = 'thing';", | |
242 | errors: expectedErrors | |
243 | }, | |
244 | { | |
245 | code: "var any \u200A = 'thing';", | |
246 | errors: expectedErrors | |
247 | }, | |
248 | { | |
249 | code: "var any \u2028 = 'thing';", | |
250 | errors: expectedErrors | |
251 | }, | |
252 | { | |
253 | code: "var any \u2029 = 'thing';", | |
254 | errors: expectedErrors | |
255 | }, | |
256 | { | |
257 | code: "var any \u202F = 'thing';", | |
258 | errors: expectedErrors | |
259 | }, | |
260 | { | |
261 | code: "var any \u205f = 'thing';", | |
262 | errors: expectedErrors | |
263 | }, | |
264 | { | |
265 | code: "var any \u3000 = 'thing';", | |
266 | errors: expectedErrors | |
267 | }, | |
268 | { | |
269 | code: "var a = 'b',\u2028c = 'd',\ne = 'f'\u2028", | |
270 | errors: [ | |
271 | { | |
272 | messageId: "noIrregularWhitespace", | |
273 | type: "Program", | |
274 | line: 1, | |
275 | column: 13 | |
276 | }, | |
277 | { | |
278 | messageId: "noIrregularWhitespace", | |
279 | type: "Program", | |
280 | line: 3, | |
281 | column: 8 | |
282 | } | |
283 | ] | |
284 | }, | |
285 | { | |
286 | code: "var any \u3000 = 'thing', other \u3000 = 'thing';\nvar third \u3000 = 'thing';", | |
287 | errors: [ | |
288 | { | |
289 | messageId: "noIrregularWhitespace", | |
290 | type: "Program", | |
291 | line: 1, | |
292 | column: 9 | |
293 | }, | |
294 | { | |
295 | messageId: "noIrregularWhitespace", | |
296 | type: "Program", | |
297 | line: 1, | |
298 | column: 28 | |
299 | }, | |
300 | { | |
301 | messageId: "noIrregularWhitespace", | |
302 | type: "Program", | |
303 | line: 2, | |
304 | column: 11 | |
305 | } | |
306 | ] | |
307 | }, | |
308 | { | |
309 | code: "// \u000B", | |
310 | errors: expectedCommentErrors | |
311 | }, | |
312 | { | |
313 | code: "// \u000C", | |
314 | errors: expectedCommentErrors | |
315 | }, | |
316 | { | |
317 | code: "// \u0085", | |
318 | errors: expectedCommentErrors | |
319 | }, | |
320 | { | |
321 | code: "// \u00A0", | |
322 | errors: expectedCommentErrors | |
323 | }, | |
324 | { | |
325 | code: "// \u180E", | |
326 | errors: expectedCommentErrors | |
327 | }, | |
328 | { | |
329 | code: "// \ufeff", | |
330 | errors: expectedCommentErrors | |
331 | }, | |
332 | { | |
333 | code: "// \u2000", | |
334 | errors: expectedCommentErrors | |
335 | }, | |
336 | { | |
337 | code: "// \u2001", | |
338 | errors: expectedCommentErrors | |
339 | }, | |
340 | { | |
341 | code: "// \u2002", | |
342 | errors: expectedCommentErrors | |
343 | }, | |
344 | { | |
345 | code: "// \u2003", | |
346 | errors: expectedCommentErrors | |
347 | }, | |
348 | { | |
349 | code: "// \u2004", | |
350 | errors: expectedCommentErrors | |
351 | }, | |
352 | { | |
353 | code: "// \u2005", | |
354 | errors: expectedCommentErrors | |
355 | }, | |
356 | { | |
357 | code: "// \u2006", | |
358 | errors: expectedCommentErrors | |
359 | }, | |
360 | { | |
361 | code: "// \u2007", | |
362 | errors: expectedCommentErrors | |
363 | }, | |
364 | { | |
365 | code: "// \u2008", | |
366 | errors: expectedCommentErrors | |
367 | }, | |
368 | { | |
369 | code: "// \u2009", | |
370 | errors: expectedCommentErrors | |
371 | }, | |
372 | { | |
373 | code: "// \u200A", | |
374 | errors: expectedCommentErrors | |
375 | }, | |
376 | { | |
377 | code: "// \u200B", | |
378 | errors: expectedCommentErrors | |
379 | }, | |
380 | { | |
381 | code: "// \u202F", | |
382 | errors: expectedCommentErrors | |
383 | }, | |
384 | { | |
385 | code: "// \u205f", | |
386 | errors: expectedCommentErrors | |
387 | }, | |
388 | { | |
389 | code: "// \u3000", | |
390 | errors: expectedCommentErrors | |
391 | }, | |
392 | { | |
393 | code: "/* \u000B */", | |
394 | errors: expectedCommentErrors | |
395 | }, | |
396 | { | |
397 | code: "/* \u000C */", | |
398 | errors: expectedCommentErrors | |
399 | }, | |
400 | { | |
401 | code: "/* \u0085 */", | |
402 | errors: expectedCommentErrors | |
403 | }, | |
404 | { | |
405 | code: "/* \u00A0 */", | |
406 | errors: expectedCommentErrors | |
407 | }, | |
408 | { | |
409 | code: "/* \u180E */", | |
410 | errors: expectedCommentErrors | |
411 | }, | |
412 | { | |
413 | code: "/* \ufeff */", | |
414 | errors: expectedCommentErrors | |
415 | }, | |
416 | { | |
417 | code: "/* \u2000 */", | |
418 | errors: expectedCommentErrors | |
419 | }, | |
420 | { | |
421 | code: "/* \u2001 */", | |
422 | errors: expectedCommentErrors | |
423 | }, | |
424 | { | |
425 | code: "/* \u2002 */", | |
426 | errors: expectedCommentErrors | |
427 | }, | |
428 | { | |
429 | code: "/* \u2003 */", | |
430 | errors: expectedCommentErrors | |
431 | }, | |
432 | { | |
433 | code: "/* \u2004 */", | |
434 | errors: expectedCommentErrors | |
435 | }, | |
436 | { | |
437 | code: "/* \u2005 */", | |
438 | errors: expectedCommentErrors | |
439 | }, | |
440 | { | |
441 | code: "/* \u2006 */", | |
442 | errors: expectedCommentErrors | |
443 | }, | |
444 | { | |
445 | code: "/* \u2007 */", | |
446 | errors: expectedCommentErrors | |
447 | }, | |
448 | { | |
449 | code: "/* \u2008 */", | |
450 | errors: expectedCommentErrors | |
451 | }, | |
452 | { | |
453 | code: "/* \u2009 */", | |
454 | errors: expectedCommentErrors | |
455 | }, | |
456 | { | |
457 | code: "/* \u200A */", | |
458 | errors: expectedCommentErrors | |
459 | }, | |
460 | { | |
461 | code: "/* \u200B */", | |
462 | errors: expectedCommentErrors | |
463 | }, | |
464 | { | |
465 | code: "/* \u2028 */", | |
466 | errors: expectedCommentErrors | |
467 | }, | |
468 | { | |
469 | code: "/* \u2029 */", | |
470 | errors: expectedCommentErrors | |
471 | }, | |
472 | { | |
473 | code: "/* \u202F */", | |
474 | errors: expectedCommentErrors | |
475 | }, | |
476 | { | |
477 | code: "/* \u205f */", | |
478 | errors: expectedCommentErrors | |
479 | }, | |
480 | { | |
481 | code: "/* \u3000 */", | |
482 | errors: expectedCommentErrors | |
483 | }, | |
484 | { | |
485 | code: "var any = /\u3000/, other = /\u000B/;", | |
486 | errors: [ | |
487 | { | |
488 | messageId: "noIrregularWhitespace", | |
489 | type: "Program", | |
490 | line: 1, | |
491 | column: 12 | |
492 | }, | |
493 | { | |
494 | messageId: "noIrregularWhitespace", | |
495 | type: "Program", | |
496 | line: 1, | |
497 | column: 25 | |
498 | } | |
499 | ] | |
500 | }, | |
501 | { | |
502 | code: "var any = '\u3000', other = '\u000B';", | |
503 | options: [{ skipStrings: false }], | |
504 | errors: [ | |
505 | { | |
506 | messageId: "noIrregularWhitespace", | |
507 | type: "Program", | |
508 | line: 1, | |
509 | column: 12 | |
510 | }, | |
511 | { | |
512 | messageId: "noIrregularWhitespace", | |
513 | type: "Program", | |
514 | line: 1, | |
515 | column: 25 | |
516 | } | |
517 | ] | |
518 | }, | |
519 | { | |
520 | code: "var any = `\u3000`, other = `\u000B`;", | |
521 | options: [{ skipTemplates: false }], | |
522 | parserOptions: { ecmaVersion: 6 }, | |
523 | errors: [ | |
524 | { | |
525 | messageId: "noIrregularWhitespace", | |
526 | type: "Program", | |
527 | line: 1, | |
528 | column: 12 | |
529 | }, | |
530 | { | |
531 | messageId: "noIrregularWhitespace", | |
532 | type: "Program", | |
533 | line: 1, | |
534 | column: 25 | |
535 | } | |
536 | ] | |
537 | }, | |
538 | { | |
539 | code: "`something ${\u3000 10} another thing`", | |
540 | options: [{ skipTemplates: true }], | |
541 | parserOptions: { ecmaVersion: 6 }, | |
542 | errors: [ | |
543 | { | |
544 | messageId: "noIrregularWhitespace", | |
545 | type: "Program", | |
546 | line: 1, | |
547 | column: 14 | |
548 | } | |
549 | ] | |
6f036462 | 550 | }, |
456be15e TL |
551 | { |
552 | code: "`something ${10\u3000} another thing`", | |
553 | options: [{ skipTemplates: true }], | |
554 | parserOptions: { ecmaVersion: 6 }, | |
555 | errors: [ | |
556 | { | |
557 | messageId: "noIrregularWhitespace", | |
558 | type: "Program", | |
559 | line: 1, | |
560 | column: 16 | |
561 | } | |
562 | ] | |
563 | }, | |
564 | { | |
565 | code: "\u3000\n`\u3000template`", | |
566 | options: [{ skipTemplates: true }], | |
567 | parserOptions: { ecmaVersion: 6 }, | |
568 | errors: [ | |
569 | { | |
570 | messageId: "noIrregularWhitespace", | |
571 | type: "Program", | |
572 | line: 1, | |
573 | column: 1 | |
574 | } | |
575 | ] | |
576 | }, | |
577 | { | |
578 | code: "\u3000\n`\u3000multiline\ntemplate`", | |
579 | options: [{ skipTemplates: true }], | |
580 | parserOptions: { ecmaVersion: 6 }, | |
581 | errors: [ | |
582 | { | |
583 | messageId: "noIrregularWhitespace", | |
584 | type: "Program", | |
585 | line: 1, | |
586 | column: 1 | |
587 | } | |
588 | ] | |
589 | }, | |
590 | { | |
591 | code: "\u3000`\u3000template`", | |
592 | options: [{ skipTemplates: true }], | |
593 | parserOptions: { ecmaVersion: 6 }, | |
594 | errors: [ | |
595 | { | |
596 | messageId: "noIrregularWhitespace", | |
597 | type: "Program", | |
598 | line: 1, | |
599 | column: 1 | |
600 | } | |
601 | ] | |
602 | }, | |
603 | { | |
604 | code: "\u3000`\u3000multiline\ntemplate`", | |
605 | options: [{ skipTemplates: true }], | |
606 | parserOptions: { ecmaVersion: 6 }, | |
607 | errors: [ | |
608 | { | |
609 | messageId: "noIrregularWhitespace", | |
610 | type: "Program", | |
611 | line: 1, | |
612 | column: 1 | |
613 | } | |
614 | ] | |
615 | }, | |
616 | { | |
617 | code: "`\u3000template`\u3000", | |
618 | options: [{ skipTemplates: true }], | |
619 | parserOptions: { ecmaVersion: 6 }, | |
620 | errors: [ | |
621 | { | |
622 | messageId: "noIrregularWhitespace", | |
623 | type: "Program", | |
624 | line: 1, | |
625 | column: 12 | |
626 | } | |
627 | ] | |
628 | }, | |
629 | { | |
630 | code: "`\u3000multiline\ntemplate`\u3000", | |
631 | options: [{ skipTemplates: true }], | |
632 | parserOptions: { ecmaVersion: 6 }, | |
633 | errors: [ | |
634 | { | |
635 | messageId: "noIrregularWhitespace", | |
636 | type: "Program", | |
637 | line: 2, | |
638 | column: 10 | |
639 | } | |
640 | ] | |
641 | }, | |
642 | { | |
643 | code: "`\u3000template`\n\u3000", | |
644 | options: [{ skipTemplates: true }], | |
645 | parserOptions: { ecmaVersion: 6 }, | |
646 | errors: [ | |
647 | { | |
648 | messageId: "noIrregularWhitespace", | |
649 | type: "Program", | |
650 | line: 2, | |
651 | column: 1 | |
652 | } | |
653 | ] | |
654 | }, | |
655 | { | |
656 | code: "`\u3000multiline\ntemplate`\n\u3000", | |
657 | options: [{ skipTemplates: true }], | |
658 | parserOptions: { ecmaVersion: 6 }, | |
659 | errors: [ | |
660 | { | |
661 | messageId: "noIrregularWhitespace", | |
662 | type: "Program", | |
663 | line: 3, | |
664 | column: 1 | |
665 | } | |
666 | ] | |
667 | }, | |
6f036462 TL |
668 | |
669 | // full location tests | |
670 | { | |
671 | code: "var foo = \u000B bar;", | |
672 | errors: [ | |
673 | { | |
674 | messageId: "noIrregularWhitespace", | |
675 | type: "Program", | |
676 | line: 1, | |
677 | column: 11, | |
678 | endLine: 1, | |
679 | endColumn: 12 | |
680 | } | |
681 | ] | |
682 | }, | |
683 | { | |
684 | code: "var foo =\u000Bbar;", | |
685 | errors: [ | |
686 | { | |
687 | messageId: "noIrregularWhitespace", | |
688 | type: "Program", | |
689 | line: 1, | |
690 | column: 10, | |
691 | endLine: 1, | |
692 | endColumn: 11 | |
693 | } | |
694 | ] | |
695 | }, | |
696 | { | |
697 | code: "var foo = \u000B\u000B bar;", | |
698 | errors: [ | |
699 | { | |
700 | messageId: "noIrregularWhitespace", | |
701 | type: "Program", | |
702 | line: 1, | |
703 | column: 11, | |
704 | endLine: 1, | |
705 | endColumn: 13 | |
706 | } | |
707 | ] | |
708 | }, | |
709 | { | |
710 | code: "var foo = \u000B\u000C bar;", | |
711 | errors: [ | |
712 | { | |
713 | messageId: "noIrregularWhitespace", | |
714 | type: "Program", | |
715 | line: 1, | |
716 | column: 11, | |
717 | endLine: 1, | |
718 | endColumn: 13 | |
719 | } | |
720 | ] | |
721 | }, | |
722 | { | |
723 | code: "var foo = \u000B \u000B bar;", | |
724 | errors: [ | |
725 | { | |
726 | messageId: "noIrregularWhitespace", | |
727 | type: "Program", | |
728 | line: 1, | |
729 | column: 11, | |
730 | endLine: 1, | |
731 | endColumn: 12 | |
732 | }, | |
733 | { | |
734 | messageId: "noIrregularWhitespace", | |
735 | type: "Program", | |
736 | line: 1, | |
737 | column: 13, | |
738 | endLine: 1, | |
739 | endColumn: 14 | |
740 | } | |
741 | ] | |
742 | }, | |
743 | { | |
744 | code: "var foo = \u000Bbar\u000B;", | |
745 | errors: [ | |
746 | { | |
747 | messageId: "noIrregularWhitespace", | |
748 | type: "Program", | |
749 | line: 1, | |
750 | column: 11, | |
751 | endLine: 1, | |
752 | endColumn: 12 | |
753 | }, | |
754 | { | |
755 | messageId: "noIrregularWhitespace", | |
756 | type: "Program", | |
757 | line: 1, | |
758 | column: 15, | |
759 | endLine: 1, | |
760 | endColumn: 16 | |
761 | } | |
762 | ] | |
763 | }, | |
764 | { | |
765 | code: "\u000B", | |
766 | errors: [ | |
767 | { | |
768 | messageId: "noIrregularWhitespace", | |
769 | type: "Program", | |
770 | line: 1, | |
771 | column: 1, | |
772 | endLine: 1, | |
773 | endColumn: 2 | |
774 | } | |
775 | ] | |
776 | }, | |
777 | { | |
778 | code: "\u00A0\u2002\u2003", | |
779 | errors: [ | |
780 | { | |
781 | messageId: "noIrregularWhitespace", | |
782 | type: "Program", | |
783 | line: 1, | |
784 | column: 1, | |
785 | endLine: 1, | |
786 | endColumn: 4 | |
787 | } | |
788 | ] | |
789 | }, | |
790 | { | |
791 | code: "var foo = \u000B\nbar;", | |
792 | errors: [ | |
793 | { | |
794 | messageId: "noIrregularWhitespace", | |
795 | type: "Program", | |
796 | line: 1, | |
797 | column: 11, | |
798 | endLine: 1, | |
799 | endColumn: 12 | |
800 | } | |
801 | ] | |
802 | }, | |
803 | { | |
804 | code: "var foo =\u000B\n\u000Bbar;", | |
805 | errors: [ | |
806 | { | |
807 | messageId: "noIrregularWhitespace", | |
808 | type: "Program", | |
809 | line: 1, | |
810 | column: 10, | |
811 | endLine: 1, | |
812 | endColumn: 11 | |
813 | }, | |
814 | { | |
815 | messageId: "noIrregularWhitespace", | |
816 | type: "Program", | |
817 | line: 2, | |
818 | column: 1, | |
819 | endLine: 2, | |
820 | endColumn: 2 | |
821 | } | |
822 | ] | |
823 | }, | |
824 | { | |
825 | code: "var foo = \u000C\u000B\n\u000C\u000B\u000Cbar\n;\u000B\u000C\n", | |
826 | errors: [ | |
827 | { | |
828 | messageId: "noIrregularWhitespace", | |
829 | type: "Program", | |
830 | line: 1, | |
831 | column: 11, | |
832 | endLine: 1, | |
833 | endColumn: 13 | |
834 | }, | |
835 | { | |
836 | messageId: "noIrregularWhitespace", | |
837 | type: "Program", | |
838 | line: 2, | |
839 | column: 1, | |
840 | endLine: 2, | |
841 | endColumn: 4 | |
842 | }, | |
843 | { | |
844 | messageId: "noIrregularWhitespace", | |
845 | type: "Program", | |
846 | line: 3, | |
847 | column: 2, | |
848 | endLine: 3, | |
849 | endColumn: 4 | |
850 | } | |
851 | ] | |
852 | }, | |
853 | { | |
854 | code: "var foo = \u2028bar;", | |
855 | errors: [ | |
856 | { | |
857 | messageId: "noIrregularWhitespace", | |
858 | type: "Program", | |
859 | line: 1, | |
860 | column: 11, | |
861 | endLine: 2, | |
862 | endColumn: 1 | |
863 | } | |
864 | ] | |
865 | }, | |
866 | { | |
867 | code: "var foo =\u2029 bar;", | |
868 | errors: [ | |
869 | { | |
870 | messageId: "noIrregularWhitespace", | |
871 | type: "Program", | |
872 | line: 1, | |
873 | column: 10, | |
874 | endLine: 2, | |
875 | endColumn: 1 | |
876 | } | |
877 | ] | |
878 | }, | |
879 | { | |
880 | code: "var foo = bar;\u2028", | |
881 | errors: [ | |
882 | { | |
883 | messageId: "noIrregularWhitespace", | |
884 | type: "Program", | |
885 | line: 1, | |
886 | column: 15, | |
887 | endLine: 2, | |
888 | endColumn: 1 | |
889 | } | |
890 | ] | |
891 | }, | |
892 | { | |
893 | code: "\u2029", | |
894 | errors: [ | |
895 | { | |
896 | messageId: "noIrregularWhitespace", | |
897 | type: "Program", | |
898 | line: 1, | |
899 | column: 1, | |
900 | endLine: 2, | |
901 | endColumn: 1 | |
902 | } | |
903 | ] | |
904 | }, | |
905 | { | |
906 | code: "foo\u2028\u2028", | |
907 | errors: [ | |
908 | { | |
909 | messageId: "noIrregularWhitespace", | |
910 | type: "Program", | |
911 | line: 1, | |
912 | column: 4, | |
913 | endLine: 2, | |
914 | endColumn: 1 | |
915 | }, | |
916 | { | |
917 | messageId: "noIrregularWhitespace", | |
918 | type: "Program", | |
919 | line: 2, | |
920 | column: 1, | |
921 | endLine: 3, | |
922 | endColumn: 1 | |
923 | } | |
924 | ] | |
925 | }, | |
926 | { | |
927 | code: "foo\u2029\u2028", | |
928 | errors: [ | |
929 | { | |
930 | messageId: "noIrregularWhitespace", | |
931 | type: "Program", | |
932 | line: 1, | |
933 | column: 4, | |
934 | endLine: 2, | |
935 | endColumn: 1 | |
936 | }, | |
937 | { | |
938 | messageId: "noIrregularWhitespace", | |
939 | type: "Program", | |
940 | line: 2, | |
941 | column: 1, | |
942 | endLine: 3, | |
943 | endColumn: 1 | |
944 | } | |
945 | ] | |
946 | }, | |
947 | { | |
948 | code: "foo\u2028\n\u2028", | |
949 | errors: [ | |
950 | { | |
951 | messageId: "noIrregularWhitespace", | |
952 | type: "Program", | |
953 | line: 1, | |
954 | column: 4, | |
955 | endLine: 2, | |
956 | endColumn: 1 | |
957 | }, | |
958 | { | |
959 | messageId: "noIrregularWhitespace", | |
960 | type: "Program", | |
961 | line: 3, | |
962 | column: 1, | |
963 | endLine: 4, | |
964 | endColumn: 1 | |
965 | } | |
966 | ] | |
967 | }, | |
968 | { | |
969 | code: "foo\u000B\u2028\u000B", | |
970 | errors: [ | |
971 | { | |
972 | messageId: "noIrregularWhitespace", | |
973 | type: "Program", | |
974 | line: 1, | |
975 | column: 4, | |
976 | endLine: 1, | |
977 | endColumn: 5 | |
978 | }, | |
979 | { | |
980 | messageId: "noIrregularWhitespace", | |
981 | type: "Program", | |
982 | line: 1, | |
983 | column: 5, | |
984 | endLine: 2, | |
985 | endColumn: 1 | |
986 | }, | |
987 | { | |
988 | messageId: "noIrregularWhitespace", | |
989 | type: "Program", | |
990 | line: 2, | |
991 | column: 1, | |
992 | endLine: 2, | |
993 | endColumn: 2 | |
994 | } | |
995 | ] | |
eb39fafa DC |
996 | } |
997 | ] | |
998 | }); |