]> git.proxmox.com Git - pve-eslint.git/blame - eslint/tests/lib/rules/no-shadow.js
import 8.3.0 source
[pve-eslint.git] / eslint / tests / lib / rules / no-shadow.js
CommitLineData
eb39fafa
DC
1/**
2 * @fileoverview Tests for no-shadow rule.
3 * @author Ilya Volodin
4 */
5
6"use strict";
7
8//------------------------------------------------------------------------------
9// Requirements
10//------------------------------------------------------------------------------
11
12const rule = require("../../../lib/rules/no-shadow"),
13 { RuleTester } = require("../../../lib/rule-tester");
14
15//------------------------------------------------------------------------------
16// Tests
17//------------------------------------------------------------------------------
18
19const ruleTester = new RuleTester();
20
21ruleTester.run("no-shadow", rule, {
22 valid: [
23 "var a=3; function b(x) { a++; return x + a; }; setTimeout(function() { b(a); }, 0);",
24 "(function() { var doSomething = function doSomething() {}; doSomething() }())",
25 "var arguments;\nfunction bar() { }",
26 { code: "var a=3; var b = (x) => { a++; return x + a; }; setTimeout(() => { b(a); }, 0);", parserOptions: { ecmaVersion: 6 } },
27 { code: "class A {}", parserOptions: { ecmaVersion: 6 } },
28 { code: "class A { constructor() { var a; } }", parserOptions: { ecmaVersion: 6 } },
29 { code: "(function() { var A = class A {}; })()", parserOptions: { ecmaVersion: 6 } },
30 { code: "{ var a; } var a;", parserOptions: { ecmaVersion: 6 } }, // this case reports `no-redeclare`, not shadowing.
31 { code: "{ let a; } let a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
32 { code: "{ let a; } var a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
33 { code: "{ let a; } function a() {}", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
34 { code: "{ const a = 0; } const a = 1;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
35 { code: "{ const a = 0; } var a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
36 { code: "{ const a = 0; } function a() {}", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
37 { code: "function foo() { let a; } let a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
38 { code: "function foo() { let a; } var a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
39 { code: "function foo() { let a; } function a() {}", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
40 { code: "function foo() { var a; } let a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
41 { code: "function foo() { var a; } var a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
42 { code: "function foo() { var a; } function a() {}", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
43 { code: "function foo(a) { } let a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
44 { code: "function foo(a) { } var a;", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
45 { code: "function foo(a) { } function a() {}", options: [{ hoist: "never" }], parserOptions: { ecmaVersion: 6 } },
46 { code: "{ let a; } let a;", parserOptions: { ecmaVersion: 6 } },
47 { code: "{ let a; } var a;", parserOptions: { ecmaVersion: 6 } },
48 { code: "{ const a = 0; } const a = 1;", parserOptions: { ecmaVersion: 6 } },
49 { code: "{ const a = 0; } var a;", parserOptions: { ecmaVersion: 6 } },
50 { code: "function foo() { let a; } let a;", parserOptions: { ecmaVersion: 6 } },
51 { code: "function foo() { let a; } var a;", parserOptions: { ecmaVersion: 6 } },
52 { code: "function foo() { var a; } let a;", parserOptions: { ecmaVersion: 6 } },
53 { code: "function foo() { var a; } var a;", parserOptions: { ecmaVersion: 6 } },
54 { code: "function foo(a) { } let a;", parserOptions: { ecmaVersion: 6 } },
55 { code: "function foo(a) { } var a;", parserOptions: { ecmaVersion: 6 } },
56 "function foo() { var Object = 0; }",
57 { code: "function foo() { var top = 0; }", env: { browser: true } },
58 { code: "var Object = 0;", options: [{ builtinGlobals: true }] },
59 { code: "var top = 0;", options: [{ builtinGlobals: true }], env: { browser: true } },
609c276f
TL
60 { code: "function foo(cb) { (function (cb) { cb(42); })(cb); }", options: [{ allow: ["cb"] }] },
61 { code: "class C { foo; foo() { let foo; } }", parserOptions: { ecmaVersion: 2022 } },
62 { code: "class C { static { var x; } static { var x; } }", parserOptions: { ecmaVersion: 2022 } },
63 { code: "class C { static { let x; } static { let x; } }", parserOptions: { ecmaVersion: 2022 } },
64 { code: "class C { static { var x; { var x; /* redeclaration */ } } }", parserOptions: { ecmaVersion: 2022 } },
65 { code: "class C { static { { var x; } { var x; /* redeclaration */ } } }", parserOptions: { ecmaVersion: 2022 } },
66 { code: "class C { static { { let x; } { let x; } } }", parserOptions: { ecmaVersion: 2022 } }
eb39fafa
DC
67 ],
68 invalid: [
69 {
70 code: "function a(x) { var b = function c() { var x = 'foo'; }; }",
71 errors: [{
72 messageId: "noShadow",
5422a9cc
TL
73 data: {
74 name: "x",
75 shadowedLine: 1,
76 shadowedColumn: 12
77 },
eb39fafa
DC
78 type: "Identifier",
79 line: 1,
80 column: 44
81 }]
82 },
83 {
84 code: "var a = (x) => { var b = () => { var x = 'foo'; }; }",
85 parserOptions: { ecmaVersion: 6 },
86 errors: [{
87 messageId: "noShadow",
5422a9cc
TL
88 data: {
89 name: "x",
90 shadowedLine: 1,
91 shadowedColumn: 10
92 },
eb39fafa
DC
93 type: "Identifier",
94 line: 1,
95 column: 38
96 }]
97 },
98 {
99 code: "function a(x) { var b = function () { var x = 'foo'; }; }",
100 errors: [{
101 messageId: "noShadow",
5422a9cc
TL
102 data: {
103 name: "x",
104 shadowedLine: 1,
105 shadowedColumn: 12
106 },
eb39fafa
DC
107 type: "Identifier",
108 line: 1,
109 column: 43
110 }]
111 },
112 {
113 code: "var x = 1; function a(x) { return ++x; }",
114 errors: [{
115 messageId: "noShadow",
5422a9cc
TL
116 data: {
117 name: "x",
118 shadowedLine: 1,
119 shadowedColumn: 5
120 },
eb39fafa
DC
121 type: "Identifier",
122 line: 1,
123 column: 23
124 }]
125 },
126 {
127 code: "var a=3; function b() { var a=10; }",
128 errors: [{
129 messageId: "noShadow",
5422a9cc
TL
130 data: {
131 name: "a",
132 shadowedLine: 1,
133 shadowedColumn: 5
134 },
eb39fafa
DC
135 type: "Identifier"
136 }]
137 },
138 {
139 code: "var a=3; function b() { var a=10; }; setTimeout(function() { b(); }, 0);",
140 errors: [{
141 messageId: "noShadow",
5422a9cc
TL
142 data: {
143 name: "a",
144 shadowedLine: 1,
145 shadowedColumn: 5
146 },
eb39fafa
DC
147 type: "Identifier"
148 }]
149 },
150 {
151 code: "var a=3; function b() { var a=10; var b=0; }; setTimeout(function() { b(); }, 0);",
152 errors: [
153 {
154 messageId: "noShadow",
5422a9cc
TL
155 data: {
156 name: "a",
157 shadowedLine: 1,
158 shadowedColumn: 5
159 },
eb39fafa
DC
160 type: "Identifier"
161 }, {
162 messageId: "noShadow",
5422a9cc
TL
163 data: {
164 name: "b",
165 shadowedLine: 1,
166 shadowedColumn: 19
167 },
eb39fafa
DC
168 type: "Identifier"
169 }
170 ]
171 },
172 {
173 code: "var x = 1; { let x = 2; }",
174 parserOptions: { ecmaVersion: 6 },
175 errors: [{
176 messageId: "noShadow",
5422a9cc
TL
177 data: {
178 name: "x",
179 shadowedLine: 1,
180 shadowedColumn: 5
181 },
eb39fafa
DC
182 type: "Identifier"
183 }]
184 },
185 {
186 code: "let x = 1; { const x = 2; }",
187 parserOptions: { ecmaVersion: 6 },
188 errors: [{
189 messageId: "noShadow",
5422a9cc
TL
190 data: {
191 name: "x",
192 shadowedLine: 1,
193 shadowedColumn: 5
194 },
eb39fafa
DC
195 type: "Identifier"
196 }]
197 },
198 {
199 code: "{ let a; } function a() {}",
200 parserOptions: { ecmaVersion: 6 },
201 errors: [{
202 messageId: "noShadow",
5422a9cc
TL
203 data: {
204 name: "a",
205 shadowedLine: 1,
206 shadowedColumn: 21
207 },
eb39fafa
DC
208 type: "Identifier"
209 }]
210 },
211 {
212 code: "{ const a = 0; } function a() {}",
213 parserOptions: { ecmaVersion: 6 },
214 errors: [{
215 messageId: "noShadow",
5422a9cc
TL
216 data: {
217 name: "a",
218 shadowedLine: 1,
219 shadowedColumn: 27
220 },
eb39fafa
DC
221 type: "Identifier"
222 }]
223 },
224 {
225 code: "function foo() { let a; } function a() {}",
226 parserOptions: { ecmaVersion: 6 },
227 errors: [{
228 messageId: "noShadow",
5422a9cc
TL
229 data: {
230 name: "a",
231 shadowedLine: 1,
232 shadowedColumn: 36
233 },
eb39fafa
DC
234 type: "Identifier"
235 }]
236 },
237 {
238 code: "function foo() { var a; } function a() {}",
239 parserOptions: { ecmaVersion: 6 },
240 errors: [{
241 messageId: "noShadow",
5422a9cc
TL
242 data: {
243 name: "a",
244 shadowedLine: 1,
245 shadowedColumn: 36
246 },
eb39fafa
DC
247 type: "Identifier"
248 }]
249 },
250 {
251 code: "function foo(a) { } function a() {}",
252 parserOptions: { ecmaVersion: 6 },
253 errors: [{
254 messageId: "noShadow",
5422a9cc
TL
255 data: {
256 name: "a",
257 shadowedLine: 1,
258 shadowedColumn: 30
259 },
eb39fafa
DC
260 type: "Identifier"
261 }]
262 },
263 {
264 code: "{ let a; } let a;",
265 options: [{ hoist: "all" }],
266 parserOptions: { ecmaVersion: 6 },
267 errors: [{
268 messageId: "noShadow",
5422a9cc
TL
269 data: {
270 name: "a",
271 shadowedLine: 1,
272 shadowedColumn: 16
273 },
eb39fafa
DC
274 type: "Identifier"
275 }]
276 },
277 {
278 code: "{ let a; } var a;",
279 options: [{ hoist: "all" }],
280 parserOptions: { ecmaVersion: 6 },
281 errors: [{
282 messageId: "noShadow",
5422a9cc
TL
283 data: {
284 name: "a",
285 shadowedLine: 1,
286 shadowedColumn: 16
287 },
eb39fafa
DC
288 type: "Identifier"
289 }]
290 },
291 {
292 code: "{ let a; } function a() {}",
293 options: [{ hoist: "all" }],
294 parserOptions: { ecmaVersion: 6 },
295 errors: [{
296 messageId: "noShadow",
5422a9cc
TL
297 data: {
298 name: "a",
299 shadowedLine: 1,
300 shadowedColumn: 21
301 },
eb39fafa
DC
302 type: "Identifier"
303 }]
304 },
305 {
306 code: "{ const a = 0; } const a = 1;",
307 options: [{ hoist: "all" }],
308 parserOptions: { ecmaVersion: 6 },
309 errors: [{
310 messageId: "noShadow",
5422a9cc
TL
311 data: {
312 name: "a",
313 shadowedLine: 1,
314 shadowedColumn: 24
315 },
eb39fafa
DC
316 type: "Identifier"
317 }]
318 },
319 {
320 code: "{ const a = 0; } var a;",
321 options: [{ hoist: "all" }],
322 parserOptions: { ecmaVersion: 6 },
323 errors: [{
324 messageId: "noShadow",
5422a9cc
TL
325 data: {
326 name: "a",
327 shadowedLine: 1,
328 shadowedColumn: 22
329 },
eb39fafa
DC
330 type: "Identifier"
331 }]
332 },
333 {
334 code: "{ const a = 0; } function a() {}",
335 options: [{ hoist: "all" }],
336 parserOptions: { ecmaVersion: 6 },
337 errors: [{
338 messageId: "noShadow",
5422a9cc
TL
339 data: {
340 name: "a",
341 shadowedLine: 1,
342 shadowedColumn: 27
343 },
eb39fafa
DC
344 type: "Identifier"
345 }]
346 },
347 {
348 code: "function foo() { let a; } let a;",
349 options: [{ hoist: "all" }],
350 parserOptions: { ecmaVersion: 6 },
351 errors: [{
352 messageId: "noShadow",
5422a9cc
TL
353 data: {
354 name: "a",
355 shadowedLine: 1,
356 shadowedColumn: 31
357 },
eb39fafa
DC
358 type: "Identifier"
359 }]
360 },
361 {
362 code: "function foo() { let a; } var a;",
363 options: [{ hoist: "all" }],
364 parserOptions: { ecmaVersion: 6 },
365 errors: [{
366 messageId: "noShadow",
5422a9cc
TL
367 data: {
368 name: "a",
369 shadowedLine: 1,
370 shadowedColumn: 31
371 },
eb39fafa
DC
372 type: "Identifier"
373 }]
374 },
375 {
376 code: "function foo() { let a; } function a() {}",
377 options: [{ hoist: "all" }],
378 parserOptions: { ecmaVersion: 6 },
379 errors: [{
380 messageId: "noShadow",
5422a9cc
TL
381 data: {
382 name: "a",
383 shadowedLine: 1,
384 shadowedColumn: 36
385 },
eb39fafa
DC
386 type: "Identifier"
387 }]
388 },
389 {
390 code: "function foo() { var a; } let a;",
391 options: [{ hoist: "all" }],
392 parserOptions: { ecmaVersion: 6 },
393 errors: [{
394 messageId: "noShadow",
5422a9cc
TL
395 data: {
396 name: "a",
397 shadowedLine: 1,
398 shadowedColumn: 31
399 },
eb39fafa
DC
400 type: "Identifier"
401 }]
402 },
403 {
404 code: "function foo() { var a; } var a;",
405 options: [{ hoist: "all" }],
406 parserOptions: { ecmaVersion: 6 },
407 errors: [{
408 messageId: "noShadow",
5422a9cc
TL
409 data: {
410 name: "a",
411 shadowedLine: 1,
412 shadowedColumn: 31
413 },
eb39fafa
DC
414 type: "Identifier"
415 }]
416 },
417 {
418 code: "function foo() { var a; } function a() {}",
419 options: [{ hoist: "all" }],
420 parserOptions: { ecmaVersion: 6 },
421 errors: [{
422 messageId: "noShadow",
5422a9cc
TL
423 data: {
424 name: "a",
425 shadowedLine: 1,
426 shadowedColumn: 36
427 },
eb39fafa
DC
428 type: "Identifier"
429 }]
430 },
431 {
432 code: "function foo(a) { } let a;",
433 options: [{ hoist: "all" }],
434 parserOptions: { ecmaVersion: 6 },
435 errors: [{
436 messageId: "noShadow",
5422a9cc
TL
437 data: {
438 name: "a",
439 shadowedLine: 1,
440 shadowedColumn: 25
441 },
eb39fafa
DC
442 type: "Identifier"
443 }]
444 },
445 {
446 code: "function foo(a) { } var a;",
447 options: [{ hoist: "all" }],
448 parserOptions: { ecmaVersion: 6 },
449 errors: [{
450 messageId: "noShadow",
5422a9cc
TL
451 data: {
452 name: "a",
453 shadowedLine: 1,
454 shadowedColumn: 25
455 },
eb39fafa
DC
456 type: "Identifier"
457 }]
458 },
459 {
460 code: "function foo(a) { } function a() {}",
461 options: [{ hoist: "all" }],
462 parserOptions: { ecmaVersion: 6 },
463 errors: [{
464 messageId: "noShadow",
5422a9cc
TL
465 data: {
466 name: "a",
467 shadowedLine: 1,
468 shadowedColumn: 30
469 },
eb39fafa
DC
470 type: "Identifier"
471 }]
472 },
473 {
474 code: "(function a() { function a(){} })()",
475 errors: [{
476 messageId: "noShadow",
5422a9cc
TL
477 data: {
478 name: "a",
479 shadowedLine: 1,
480 shadowedColumn: 11
481 },
eb39fafa
DC
482 type: "Identifier"
483 }]
484 },
485 {
486 code: "(function a() { class a{} })()",
487 parserOptions: { ecmaVersion: 6 },
488 errors: [{
489 messageId: "noShadow",
5422a9cc
TL
490 data: {
491 name: "a",
492 shadowedLine: 1,
493 shadowedColumn: 11
494 },
eb39fafa
DC
495 type: "Identifier"
496 }]
497 },
498 {
499 code: "(function a() { (function a(){}); })()",
500 errors: [{
501 messageId: "noShadow",
5422a9cc
TL
502 data: {
503 name: "a",
504 shadowedLine: 1,
505 shadowedColumn: 11
506 },
eb39fafa
DC
507 type: "Identifier"
508 }]
509 },
510 {
511 code: "(function a() { (class a{}); })()",
512 parserOptions: { ecmaVersion: 6 },
513 errors: [{
514 messageId: "noShadow",
5422a9cc
TL
515 data: {
516 name: "a",
517 shadowedLine: 1,
518 shadowedColumn: 11
519 },
eb39fafa
DC
520 type: "Identifier"
521 }]
522 },
523 {
524 code: "(function() { var a = function(a) {}; })()",
525 errors: [{
526 messageId: "noShadow",
5422a9cc
TL
527 data: {
528 name: "a",
529 shadowedLine: 1,
530 shadowedColumn: 19
531 },
eb39fafa
DC
532 type: "Identifier"
533 }]
534 },
535 {
536 code: "(function() { var a = function() { function a() {} }; })()",
537 errors: [{
538 messageId: "noShadow",
5422a9cc
TL
539 data: {
540 name: "a",
541 shadowedLine: 1,
542 shadowedColumn: 19
543 },
eb39fafa
DC
544 type: "Identifier"
545 }]
546 },
547 {
548 code: "(function() { var a = function() { class a{} }; })()",
549 parserOptions: { ecmaVersion: 6 },
550 errors: [{
551 messageId: "noShadow",
5422a9cc
TL
552 data: {
553 name: "a",
554 shadowedLine: 1,
555 shadowedColumn: 19
556 },
eb39fafa
DC
557 type: "Identifier"
558 }]
559 },
560 {
561 code: "(function() { var a = function() { (function a() {}); }; })()",
562 errors: [{
563 messageId: "noShadow",
5422a9cc
TL
564 data: {
565 name: "a",
566 shadowedLine: 1,
567 shadowedColumn: 19
568 },
eb39fafa
DC
569 type: "Identifier"
570 }]
571 },
572 {
573 code: "(function() { var a = function() { (class a{}); }; })()",
574 parserOptions: { ecmaVersion: 6 },
575 errors: [{
576 messageId: "noShadow",
5422a9cc
TL
577 data: {
578 name: "a",
579 shadowedLine: 1,
580 shadowedColumn: 19
581 },
eb39fafa
DC
582 type: "Identifier"
583 }]
584 },
585 {
586 code: "(function() { var a = class { constructor() { class a {} } }; })()",
587 parserOptions: { ecmaVersion: 6 },
588 errors: [{
589 messageId: "noShadow",
5422a9cc
TL
590 data: {
591 name: "a",
592 shadowedLine: 1,
593 shadowedColumn: 19
594 },
eb39fafa
DC
595 type: "Identifier"
596 }]
597 },
598 {
599 code: "class A { constructor() { var A; } }",
600 parserOptions: { ecmaVersion: 6 },
601 errors: [{
602 messageId: "noShadow",
5422a9cc
TL
603 data: {
604 name: "A",
605 shadowedLine: 1,
606 shadowedColumn: 7
607 },
eb39fafa
DC
608 type: "Identifier"
609 }]
610 },
611 {
612 code: "(function a() { function a(){ function a(){} } })()",
613 errors: [
614 {
615 messageId: "noShadow",
5422a9cc
TL
616 data: {
617 name: "a",
618 shadowedLine: 1,
619 shadowedColumn: 11
620 },
eb39fafa
DC
621 type: "Identifier",
622 line: 1,
623 column: 26
624 },
625 {
626 messageId: "noShadow",
5422a9cc
TL
627 data: {
628 name: "a",
629 shadowedLine: 1,
630 shadowedColumn: 26
631 },
eb39fafa
DC
632 type: "Identifier",
633 line: 1,
634 column: 40
635 }
636 ]
637 },
638 {
639 code: "function foo() { var Object = 0; }",
640 options: [{ builtinGlobals: true }],
641 errors: [{
5422a9cc
TL
642 messageId: "noShadowGlobal",
643 data: {
644 name: "Object"
645 },
eb39fafa
DC
646 type: "Identifier"
647 }]
648 },
649 {
650 code: "function foo() { var top = 0; }",
651 options: [{ builtinGlobals: true }],
652 env: { browser: true },
653 errors: [{
5422a9cc
TL
654 messageId: "noShadowGlobal",
655 data: {
656 name: "top"
657 },
eb39fafa
DC
658 type: "Identifier"
659 }]
660 },
661 {
662 code: "var Object = 0;",
663 options: [{ builtinGlobals: true }],
664 parserOptions: { ecmaVersion: 6, sourceType: "module" },
665 errors: [{
5422a9cc
TL
666 messageId: "noShadowGlobal",
667 data: {
668 name: "Object"
669 },
eb39fafa
DC
670 type: "Identifier"
671 }]
672 },
673 {
674 code: "var top = 0;",
675 options: [{ builtinGlobals: true }],
676 parserOptions: { ecmaVersion: 6, sourceType: "module" },
677 env: { browser: true },
678 errors: [{
5422a9cc
TL
679 messageId: "noShadowGlobal",
680 data: {
681 name: "top"
682 },
eb39fafa
DC
683 type: "Identifier"
684 }]
685 },
686 {
687 code: "var Object = 0;",
688 options: [{ builtinGlobals: true }],
689 parserOptions: { ecmaFeatures: { globalReturn: true } },
690 errors: [{
5422a9cc
TL
691 messageId: "noShadowGlobal",
692 data: {
693 name: "Object"
694 },
eb39fafa
DC
695 type: "Identifier"
696 }]
697 },
698 {
699 code: "var top = 0;",
700 options: [{ builtinGlobals: true }],
701 parserOptions: { ecmaFeatures: { globalReturn: true } },
702 env: { browser: true },
703 errors: [{
5422a9cc
TL
704 messageId: "noShadowGlobal",
705 data: {
706 name: "top"
707 },
eb39fafa
DC
708 type: "Identifier"
709 }]
710 },
711 {
712 code: "function foo(cb) { (function (cb) { cb(42); })(cb); }",
713 errors: [{
714 messageId: "noShadow",
5422a9cc
TL
715 data: {
716 name: "cb",
717 shadowedLine: 1,
718 shadowedColumn: 14
719 },
eb39fafa
DC
720 type: "Identifier",
721 line: 1,
722 column: 31
723 }]
609c276f
TL
724 },
725 {
726 code: "class C { static { let a; { let a; } } }",
727 parserOptions: { ecmaVersion: 2022 },
728 errors: [{
729 messageId: "noShadow",
730 data: {
731 name: "a",
732 shadowedLine: 1,
733 shadowedColumn: 24
734 },
735 type: "Identifier",
736 line: 1,
737 column: 33
738 }]
739 },
740 {
741 code: "class C { static { var C; } }",
742 parserOptions: { ecmaVersion: 2022 },
743 errors: [{
744 messageId: "noShadow",
745 data: {
746 name: "C",
747 shadowedLine: 1,
748 shadowedColumn: 7
749 },
750 type: "Identifier",
751 line: 1,
752 column: 24
753 }]
754 },
755 {
756 code: "class C { static { let C; } }",
757 parserOptions: { ecmaVersion: 2022 },
758 errors: [{
759 messageId: "noShadow",
760 data: {
761 name: "C",
762 shadowedLine: 1,
763 shadowedColumn: 7
764 },
765 type: "Identifier",
766 line: 1,
767 column: 24
768 }]
769 },
770 {
771 code: "var a; class C { static { var a; } }",
772 parserOptions: { ecmaVersion: 2022 },
773 errors: [{
774 messageId: "noShadow",
775 data: {
776 name: "a",
777 shadowedLine: 1,
778 shadowedColumn: 5
779 },
780 type: "Identifier",
781 line: 1,
782 column: 31
783 }]
784 },
785 {
786 code: "class C { static { var a; } } var a;",
787 options: [{ hoist: "all" }],
788 parserOptions: { ecmaVersion: 2022 },
789 errors: [{
790 messageId: "noShadow",
791 data: {
792 name: "a",
793 shadowedLine: 1,
794 shadowedColumn: 35
795 },
796 type: "Identifier",
797 line: 1,
798 column: 24
799 }]
800 },
801 {
802 code: "class C { static { let a; } } let a;",
803 options: [{ hoist: "all" }],
804 parserOptions: { ecmaVersion: 2022 },
805 errors: [{
806 messageId: "noShadow",
807 data: {
808 name: "a",
809 shadowedLine: 1,
810 shadowedColumn: 35
811 },
812 type: "Identifier",
813 line: 1,
814 column: 24
815 }]
816 },
817 {
818 code: "class C { static { var a; } } let a;",
819 options: [{ hoist: "all" }],
820 parserOptions: { ecmaVersion: 2022 },
821 errors: [{
822 messageId: "noShadow",
823 data: {
824 name: "a",
825 shadowedLine: 1,
826 shadowedColumn: 35
827 },
828 type: "Identifier",
829 line: 1,
830 column: 24
831 }]
832 },
833 {
834 code: "class C { static { var a; class D { static { var a; } } } }",
835 parserOptions: { ecmaVersion: 2022 },
836 errors: [{
837 messageId: "noShadow",
838 data: {
839 name: "a",
840 shadowedLine: 1,
841 shadowedColumn: 24
842 },
843 type: "Identifier",
844 line: 1,
845 column: 50
846 }]
847 },
848 {
849 code: "class C { static { let a; class D { static { let a; } } } }",
850 parserOptions: { ecmaVersion: 2022 },
851 errors: [{
852 messageId: "noShadow",
853 data: {
854 name: "a",
855 shadowedLine: 1,
856 shadowedColumn: 24
857 },
858 type: "Identifier",
859 line: 1,
860 column: 50
861 }]
eb39fafa
DC
862 }
863 ]
864});