]> git.proxmox.com Git - pve-eslint.git/blob - eslint/tests/lib/rules/quotes.js
import 8.23.1 source
[pve-eslint.git] / eslint / tests / lib / rules / quotes.js
1 /**
2 * @fileoverview Tests for quotes rule.
3 * @author Matt DuVall <http://www.mattduvall.com/>, Michael Paulukonis
4 */
5
6 "use strict";
7
8 //------------------------------------------------------------------------------
9 // Requirements
10 //------------------------------------------------------------------------------
11
12 const rule = require("../../../lib/rules/quotes"),
13 { RuleTester } = require("../../../lib/rule-tester");
14
15 //------------------------------------------------------------------------------
16 // Tests
17 //------------------------------------------------------------------------------
18
19 const ruleTester = new RuleTester();
20
21 ruleTester.run("quotes", rule, {
22 valid: [
23 "var foo = \"bar\";",
24 { code: "var foo = 'bar';", options: ["single"] },
25 { code: "var foo = \"bar\";", options: ["double"] },
26 { code: "var foo = 1;", options: ["single"] },
27 { code: "var foo = 1;", options: ["double"] },
28 { code: "var foo = \"'\";", options: ["single", { avoidEscape: true }] },
29 { code: "var foo = '\"';", options: ["double", { avoidEscape: true }] },
30 { code: "var foo = <>Hello world</>;", options: ["single"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
31 { code: "var foo = <>Hello world</>;", options: ["double"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
32 { code: "var foo = <>Hello world</>;", options: ["double", { avoidEscape: true }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
33 { code: "var foo = <>Hello world</>;", options: ["backtick"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
34 { code: "var foo = <div>Hello world</div>;", options: ["single"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
35 { code: "var foo = <div id=\"foo\"></div>;", options: ["single"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
36 { code: "var foo = <div>Hello world</div>;", options: ["double"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
37 { code: "var foo = <div>Hello world</div>;", options: ["double", { avoidEscape: true }], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
38 { code: "var foo = `bar`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
39 { code: "var foo = `bar 'baz'`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
40 { code: "var foo = `bar \"baz\"`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
41 { code: "var foo = 1;", options: ["backtick"] },
42 { code: "var foo = \"a string containing `backtick` quotes\";", options: ["backtick", { avoidEscape: true }] },
43 { code: "var foo = <div id=\"foo\"></div>;", options: ["backtick"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
44 { code: "var foo = <div>Hello world</div>;", options: ["backtick"], parserOptions: { ecmaVersion: 6, ecmaFeatures: { jsx: true } } },
45 { code: "class C { \"f\"; \"m\"() {} }", options: ["double"], parserOptions: { ecmaVersion: 2022 } },
46 { code: "class C { 'f'; 'm'() {} }", options: ["single"], parserOptions: { ecmaVersion: 2022 } },
47
48 // Backticks are only okay if they have substitutions, contain a line break, or are tagged
49 { code: "var foo = `back\ntick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } },
50 { code: "var foo = `back\rtick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } },
51 { code: "var foo = `back\u2028tick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } },
52 { code: "var foo = `back\u2029tick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } },
53 {
54 code: "var foo = `back\\\\\ntick`;", // 2 backslashes followed by a newline
55 options: ["single"],
56 parserOptions: { ecmaVersion: 6 }
57 },
58 { code: "var foo = `back\\\\\\\\\ntick`;", options: ["single"], parserOptions: { ecmaVersion: 6 } },
59 { code: "var foo = `\n`;", options: ["single"], parserOptions: { ecmaVersion: 6 } },
60 { code: "var foo = `back${x}tick`;", options: ["double"], parserOptions: { ecmaVersion: 6 } },
61 { code: "var foo = tag`backtick`;", options: ["double"], parserOptions: { ecmaVersion: 6 } },
62
63 // Backticks are also okay if allowTemplateLiterals
64 { code: "var foo = `bar 'foo' baz` + 'bar';", options: ["single", { allowTemplateLiterals: true }], parserOptions: { ecmaVersion: 6 } },
65 { code: "var foo = `bar 'foo' baz` + \"bar\";", options: ["double", { allowTemplateLiterals: true }], parserOptions: { ecmaVersion: 6 } },
66 { code: "var foo = `bar 'foo' baz` + `bar`;", options: ["backtick", { allowTemplateLiterals: true }], parserOptions: { ecmaVersion: 6 } },
67
68 // `backtick` should not warn the directive prologues.
69 { code: "\"use strict\"; var foo = `backtick`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
70 { code: "\"use strict\"; 'use strong'; \"use asm\"; var foo = `backtick`;", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
71 { code: "function foo() { \"use strict\"; \"use strong\"; \"use asm\"; var foo = `backtick`; }", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
72 { code: "(function() { 'use strict'; 'use strong'; 'use asm'; var foo = `backtick`; })();", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
73 { code: "(() => { \"use strict\"; \"use strong\"; \"use asm\"; var foo = `backtick`; })();", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
74
75 // `backtick` should not warn import/export sources.
76 { code: "import \"a\"; import 'b';", options: ["backtick"], parserOptions: { ecmaVersion: 6, sourceType: "module" } },
77 { code: "import a from \"a\"; import b from 'b';", options: ["backtick"], parserOptions: { ecmaVersion: 6, sourceType: "module" } },
78 { code: "export * from \"a\"; export * from 'b';", options: ["backtick"], parserOptions: { ecmaVersion: 6, sourceType: "module" } },
79
80 // `backtick` should not warn module export names.
81 { code: "import { \"a\" as b, 'c' as d } from 'mod';", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
82 { code: "let a, c; export { a as \"b\", c as 'd' };", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
83 { code: "export { \"a\", 'b' } from 'mod';", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
84 { code: "export { a as \"b\", c as 'd' } from 'mod';", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
85 { code: "export { \"a\" as b, 'c' as d } from 'mod';", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
86 { code: "export { \"a\" as \"b\", 'c' as 'd' } from 'mod';", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
87 { code: "export * as \"a\" from 'mod';", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
88 { code: "export * as 'a' from 'mod';", options: ["backtick"], parserOptions: { ecmaVersion: 2022, sourceType: "module" } },
89
90 // `backtick` should not warn property/method names (not computed).
91 { code: "var obj = {\"key0\": 0, 'key1': 1};", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
92 { code: "class Foo { 'bar'(){} }", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
93 { code: "class Foo { static ''(){} }", options: ["backtick"], parserOptions: { ecmaVersion: 6 } },
94 { code: "class C { \"double\"; 'single'; }", options: ["backtick"], parserOptions: { ecmaVersion: 2022 } }
95 ],
96 invalid: [
97 {
98 code: "var foo = 'bar';",
99 output: "var foo = \"bar\";",
100 errors: [{
101 messageId: "wrongQuotes",
102 data: { description: "doublequote" },
103 type: "Literal"
104 }]
105 },
106 {
107 code: "var foo = \"bar\";",
108 output: "var foo = 'bar';",
109 options: ["single"],
110 errors: [{
111 messageId: "wrongQuotes",
112 data: { description: "singlequote" },
113 type: "Literal"
114 }]
115 },
116 {
117 code: "var foo = `bar`;",
118 output: "var foo = 'bar';",
119 options: ["single"],
120 parserOptions: {
121 ecmaVersion: 6
122 },
123 errors: [{
124 messageId: "wrongQuotes",
125 data: { description: "singlequote" },
126 type: "TemplateLiteral"
127 }]
128 },
129 {
130 code: "var foo = 'don\\'t';",
131 output: "var foo = \"don't\";",
132 errors: [{
133 messageId: "wrongQuotes",
134 data: { description: "doublequote" },
135 type: "Literal"
136 }]
137 },
138 {
139 code: "var msg = \"Plugin '\" + name + \"' not found\"",
140 output: "var msg = 'Plugin \\'' + name + '\\' not found'",
141 options: ["single"],
142 errors: [
143 {
144 messageId: "wrongQuotes",
145 data: { description: "singlequote" },
146 type: "Literal",
147 column: 11
148 },
149 {
150 messageId: "wrongQuotes",
151 data: { description: "singlequote" },
152 type: "Literal",
153 column: 31
154 }
155 ]
156 },
157 {
158 code: "var foo = 'bar';",
159 output: "var foo = \"bar\";",
160 options: ["double"],
161 errors: [{
162 messageId: "wrongQuotes",
163 data: { description: "doublequote" },
164 type: "Literal"
165 }]
166 },
167 {
168 code: "var foo = `bar`;",
169 output: "var foo = \"bar\";",
170 options: ["double"],
171 parserOptions: {
172 ecmaVersion: 6
173 },
174 errors: [{
175 messageId: "wrongQuotes",
176 data: { description: "doublequote" },
177 type: "TemplateLiteral"
178 }]
179 },
180 {
181 code: "var foo = \"bar\";",
182 output: "var foo = 'bar';",
183 options: ["single", { avoidEscape: true }],
184 errors: [{
185 messageId: "wrongQuotes",
186 data: { description: "singlequote" },
187 type: "Literal"
188 }]
189 },
190 {
191 code: "var foo = 'bar';",
192 output: "var foo = \"bar\";",
193 options: ["double", { avoidEscape: true }],
194 errors: [{
195 messageId: "wrongQuotes",
196 data: { description: "doublequote" },
197 type: "Literal"
198 }]
199 },
200 {
201 code: "var foo = '\\\\';",
202 output: "var foo = \"\\\\\";",
203 options: ["double", { avoidEscape: true }],
204 errors: [{
205 messageId: "wrongQuotes",
206 data: { description: "doublequote" },
207 type: "Literal"
208 }]
209 },
210 {
211 code: "var foo = \"bar\";",
212 output: "var foo = 'bar';",
213 options: ["single", { allowTemplateLiterals: true }],
214 errors: [{
215 messageId: "wrongQuotes",
216 data: { description: "singlequote" },
217 type: "Literal"
218 }]
219 },
220 {
221 code: "var foo = 'bar';",
222 output: "var foo = \"bar\";",
223 options: ["double", { allowTemplateLiterals: true }],
224 errors: [{
225 messageId: "wrongQuotes",
226 data: { description: "doublequote" },
227 type: "Literal"
228 }]
229 },
230 {
231 code: "var foo = 'bar';",
232 output: "var foo = `bar`;",
233 options: ["backtick"],
234 parserOptions: { ecmaVersion: 2015 },
235 errors: [{
236 messageId: "wrongQuotes",
237 data: { description: "backtick" },
238 type: "Literal"
239 }]
240 },
241 {
242 code: "var foo = 'b${x}a$r';",
243 output: "var foo = `b\\${x}a$r`;",
244 options: ["backtick"],
245 parserOptions: { ecmaVersion: 2015 },
246 errors: [{
247 messageId: "wrongQuotes",
248 data: { description: "backtick" },
249 type: "Literal"
250 }]
251 },
252 {
253 code: "var foo = \"bar\";",
254 output: "var foo = `bar`;",
255 options: ["backtick"],
256 parserOptions: { ecmaVersion: 2015 },
257 errors: [{
258 messageId: "wrongQuotes",
259 data: { description: "backtick" },
260 type: "Literal"
261 }]
262 },
263 {
264 code: "var foo = \"bar\";",
265 output: "var foo = `bar`;",
266 options: ["backtick", { avoidEscape: true }],
267 parserOptions: { ecmaVersion: 2015 },
268 errors: [{
269 messageId: "wrongQuotes",
270 data: { description: "backtick" },
271 type: "Literal"
272 }]
273 },
274 {
275 code: "var foo = 'bar';",
276 output: "var foo = `bar`;",
277 options: ["backtick", { avoidEscape: true }],
278 parserOptions: { ecmaVersion: 2015 },
279 errors: [{
280 messageId: "wrongQuotes",
281 data: { description: "backtick" },
282 type: "Literal"
283 }]
284 },
285
286 // "use strict" is *not* a directive prologue in these statements so is subject to the rule
287 {
288 code: "var foo = `backtick`; \"use strict\";",
289 output: "var foo = `backtick`; `use strict`;",
290 options: ["backtick"],
291 parserOptions: { ecmaVersion: 6 },
292 errors: [{
293 messageId: "wrongQuotes",
294 data: { description: "backtick" },
295 type: "Literal"
296 }]
297 },
298 {
299 code: "{ \"use strict\"; var foo = `backtick`; }",
300 output: "{ `use strict`; var foo = `backtick`; }",
301 options: ["backtick"],
302 parserOptions: { ecmaVersion: 6 },
303 errors: [{
304 messageId: "wrongQuotes",
305 data: { description: "backtick" },
306 type: "Literal"
307 }]
308 },
309 {
310 code: "if (1) { \"use strict\"; var foo = `backtick`; }",
311 output: "if (1) { `use strict`; var foo = `backtick`; }",
312 options: ["backtick"],
313 parserOptions: { ecmaVersion: 6 },
314 errors: [{
315 messageId: "wrongQuotes",
316 data: { description: "backtick" },
317 type: "Literal"
318 }]
319 },
320
321 // `backtick` should warn computed property names.
322 {
323 code: "var obj = {[\"key0\"]: 0, ['key1']: 1};",
324 output: "var obj = {[`key0`]: 0, [`key1`]: 1};",
325 options: ["backtick"],
326 parserOptions: { ecmaVersion: 6 },
327 errors: [
328 {
329 messageId: "wrongQuotes",
330 data: { description: "backtick" },
331 type: "Literal"
332 },
333 {
334 messageId: "wrongQuotes",
335 data: { description: "backtick" },
336 type: "Literal"
337 }
338 ]
339 },
340 {
341 code: "class Foo { ['a'](){} static ['b'](){} }",
342 output: "class Foo { [`a`](){} static [`b`](){} }",
343 options: ["backtick"],
344 parserOptions: { ecmaVersion: 6 },
345 errors: [
346 {
347 messageId: "wrongQuotes",
348 data: { description: "backtick" },
349 type: "Literal"
350 },
351 {
352 messageId: "wrongQuotes",
353 data: { description: "backtick" },
354 type: "Literal"
355 }
356 ]
357 },
358
359 // https://github.com/eslint/eslint/issues/7084
360 {
361 code: "<div blah={\"blah\"} />",
362 output: "<div blah={'blah'} />",
363 options: ["single"],
364 parserOptions: { ecmaFeatures: { jsx: true } },
365 errors: [
366 {
367 messageId: "wrongQuotes",
368 data: { description: "singlequote" },
369 type: "Literal"
370 }
371 ]
372 },
373 {
374 code: "<div blah={'blah'} />",
375 output: "<div blah={\"blah\"} />",
376 options: ["double"],
377 parserOptions: { ecmaFeatures: { jsx: true } },
378 errors: [
379 {
380 messageId: "wrongQuotes",
381 data: { description: "doublequote" },
382 type: "Literal"
383 }
384 ]
385 },
386 {
387 code: "<div blah={'blah'} />",
388 output: "<div blah={`blah`} />",
389 options: ["backtick"],
390 parserOptions: { ecmaFeatures: { jsx: true }, ecmaVersion: 2015 },
391 errors: [
392 {
393 messageId: "wrongQuotes",
394 data: { description: "backtick" },
395 type: "Literal"
396 }
397 ]
398 },
399
400 // https://github.com/eslint/eslint/issues/7610
401 {
402 code: "`use strict`;",
403 output: null,
404 parserOptions: { ecmaVersion: 6 },
405 errors: [{
406 messageId: "wrongQuotes",
407 data: { description: "doublequote" },
408 type: "TemplateLiteral"
409 }]
410 },
411 {
412 code: "function foo() { `use strict`; foo(); }",
413 output: null,
414 parserOptions: { ecmaVersion: 6 },
415 errors: [{
416 messageId: "wrongQuotes",
417 data: { description: "doublequote" },
418 type: "TemplateLiteral"
419 }]
420 },
421 {
422 code: "foo = function() { `use strict`; foo(); }",
423 output: null,
424 parserOptions: { ecmaVersion: 6 },
425 errors: [{
426 messageId: "wrongQuotes",
427 data: { description: "doublequote" },
428 type: "TemplateLiteral"
429 }]
430 },
431 {
432 code: "() => { `use strict`; foo(); }",
433 output: null,
434 parserOptions: { ecmaVersion: 6 },
435 errors: [{
436 messageId: "wrongQuotes",
437 data: { description: "doublequote" },
438 type: "TemplateLiteral"
439 }]
440 },
441 {
442 code: "() => { foo(); `use strict`; }",
443 output: "() => { foo(); \"use strict\"; }",
444 parserOptions: { ecmaVersion: 6 },
445 errors: [{
446 messageId: "wrongQuotes",
447 data: { description: "doublequote" },
448 type: "TemplateLiteral"
449 }]
450 },
451 {
452 code: "foo(); `use strict`;",
453 output: "foo(); \"use strict\";",
454 parserOptions: { ecmaVersion: 6 },
455 errors: [{
456 messageId: "wrongQuotes",
457 data: { description: "doublequote" },
458 type: "TemplateLiteral"
459 }]
460 },
461
462 // https://github.com/eslint/eslint/issues/7646
463 {
464 code: "var foo = `foo\\nbar`;",
465 output: "var foo = \"foo\\nbar\";",
466 parserOptions: { ecmaVersion: 6 },
467 errors: [{
468 messageId: "wrongQuotes",
469 data: { description: "doublequote" },
470 type: "TemplateLiteral"
471 }]
472 },
473 {
474 code: "var foo = `foo\\\nbar`;", // 1 backslash followed by a newline
475 output: "var foo = \"foo\\\nbar\";",
476 parserOptions: { ecmaVersion: 6 },
477 errors: [{
478 messageId: "wrongQuotes",
479 data: { description: "doublequote" },
480 type: "TemplateLiteral"
481 }]
482 },
483 {
484 code: "var foo = `foo\\\\\\\nbar`;", // 3 backslashes followed by a newline
485 output: "var foo = \"foo\\\\\\\nbar\";",
486 parserOptions: { ecmaVersion: 6 },
487 errors: [{
488 messageId: "wrongQuotes",
489 data: { description: "doublequote" },
490 type: "TemplateLiteral"
491 }]
492 },
493 {
494 code: "````",
495 output: "\"\"``",
496 parserOptions: { ecmaVersion: 6 },
497 errors: [{
498 messageId: "wrongQuotes",
499 data: { description: "doublequote" },
500 type: "TemplateLiteral",
501 line: 1,
502 column: 1
503 }]
504 },
505
506 // Strings containing octal escape sequences. Don't autofix to backticks.
507 {
508 code: "var foo = \"\\1\"",
509 output: "var foo = '\\1'",
510 options: ["single"],
511 errors: [
512 {
513 messageId: "wrongQuotes",
514 data: { description: "singlequote" },
515 type: "Literal"
516 }
517 ]
518 },
519 {
520 code: "var foo = '\\1'",
521 output: "var foo = \"\\1\"",
522 options: ["double"],
523 errors: [
524 {
525 messageId: "wrongQuotes",
526 data: { description: "doublequote" },
527 type: "Literal"
528 }
529 ]
530 },
531 {
532 code: "var notoctal = '\\0'",
533 output: "var notoctal = `\\0`",
534 options: ["backtick"],
535 parserOptions: { ecmaVersion: 6 },
536 errors: [
537 {
538 messageId: "wrongQuotes",
539 data: { description: "backtick" },
540 type: "Literal"
541 }
542 ]
543 },
544 {
545 code: "var foo = '\\1'",
546 output: null,
547 options: ["backtick"],
548 parserOptions: { ecmaVersion: 6 },
549 errors: [
550 {
551 messageId: "wrongQuotes",
552 data: { description: "backtick" },
553 type: "Literal"
554 }
555 ]
556 },
557 {
558 code: "var foo = \"\\1\"",
559 output: null,
560 options: ["backtick"],
561 parserOptions: { ecmaVersion: 6 },
562 errors: [
563 {
564 messageId: "wrongQuotes",
565 data: { description: "backtick" },
566 type: "Literal"
567 }
568 ]
569 },
570 {
571 code: "var foo = '\\01'",
572 output: null,
573 options: ["backtick"],
574 parserOptions: { ecmaVersion: 6 },
575 errors: [
576 {
577 messageId: "wrongQuotes",
578 data: { description: "backtick" },
579 type: "Literal"
580 }
581 ]
582 },
583 {
584 code: "var foo = '\\0\\1'",
585 output: null,
586 options: ["backtick"],
587 parserOptions: { ecmaVersion: 6 },
588 errors: [
589 {
590 messageId: "wrongQuotes",
591 data: { description: "backtick" },
592 type: "Literal"
593 }
594 ]
595 },
596 {
597 code: "var foo = '\\08'",
598 output: null,
599 options: ["backtick"],
600 parserOptions: { ecmaVersion: 6 },
601 errors: [
602 {
603 messageId: "wrongQuotes",
604 data: { description: "backtick" },
605 type: "Literal"
606 }
607 ]
608 },
609 {
610 code: "var foo = 'prefix \\33'",
611 output: null,
612 options: ["backtick"],
613 parserOptions: { ecmaVersion: 6 },
614 errors: [
615 {
616 messageId: "wrongQuotes",
617 data: { description: "backtick" },
618 type: "Literal"
619 }
620 ]
621 },
622 {
623 code: "var foo = 'prefix \\75 suffix'",
624 output: null,
625 options: ["backtick"],
626 parserOptions: { ecmaVersion: 6 },
627 errors: [
628 {
629 messageId: "wrongQuotes",
630 data: { description: "backtick" },
631 type: "Literal"
632 }
633 ]
634 },
635 {
636 code: "var nonOctalDecimalEscape = '\\8'",
637 output: null,
638 options: ["backtick"],
639 parserOptions: { ecmaVersion: 6 },
640 errors: [
641 {
642 messageId: "wrongQuotes",
643 data: { description: "backtick" },
644 type: "Literal"
645 }
646 ]
647 },
648
649
650 // class members
651 {
652 code: "class C { 'foo'; }",
653 output: "class C { \"foo\"; }",
654 options: ["double"],
655 parserOptions: { ecmaVersion: 2022 },
656 errors: [
657 {
658 messageId: "wrongQuotes",
659 data: { description: "doublequote" },
660 type: "Literal"
661 }
662 ]
663 },
664 {
665 code: "class C { 'foo'() {} }",
666 output: "class C { \"foo\"() {} }",
667 options: ["double"],
668 parserOptions: { ecmaVersion: 2022 },
669 errors: [
670 {
671 messageId: "wrongQuotes",
672 data: { description: "doublequote" },
673 type: "Literal"
674 }
675 ]
676 },
677 {
678 code: "class C { \"foo\"; }",
679 output: "class C { 'foo'; }",
680 options: ["single"],
681 parserOptions: { ecmaVersion: 2022 },
682 errors: [
683 {
684 messageId: "wrongQuotes",
685 data: { description: "singlequote" },
686 type: "Literal"
687 }
688 ]
689 },
690 {
691 code: "class C { \"foo\"() {} }",
692 output: "class C { 'foo'() {} }",
693 options: ["single"],
694 parserOptions: { ecmaVersion: 2022 },
695 errors: [
696 {
697 messageId: "wrongQuotes",
698 data: { description: "singlequote" },
699 type: "Literal"
700 }
701 ]
702 },
703 {
704 code: "class C { [\"foo\"]; }",
705 output: "class C { [`foo`]; }",
706 options: ["backtick"],
707 parserOptions: { ecmaVersion: 2022 },
708 errors: [
709 {
710 messageId: "wrongQuotes",
711 data: { description: "backtick" },
712 type: "Literal"
713 }
714 ]
715 },
716 {
717 code: "class C { foo = \"foo\"; }",
718 output: "class C { foo = `foo`; }",
719 options: ["backtick"],
720 parserOptions: { ecmaVersion: 2022 },
721 errors: [
722 {
723 messageId: "wrongQuotes",
724 data: { description: "backtick" },
725 type: "Literal"
726 }
727 ]
728 }
729 ]
730 });