@@ -407,6 +407,35 @@ ruleTester.run("camelcase", rule, {
407
407
code : "class C { snake_case; #snake_case; #snake_case2() {} }" ,
408
408
options : [ { properties : "never" } ] ,
409
409
parserOptions : { ecmaVersion : 2022 }
410
+ } ,
411
+
412
+ // Combinations of `properties` and `ignoreDestructring`
413
+ {
414
+ code : `
415
+ const { some_property } = obj;
416
+
417
+ const bar = { some_property };
418
+
419
+ obj.some_property = 10;
420
+
421
+ const xyz = { some_property: obj.some_property };
422
+
423
+ const foo = ({ some_property }) => {
424
+ console.log(some_property)
425
+ };
426
+ ` ,
427
+ options : [ { properties : "never" , ignoreDestructuring : true } ] ,
428
+ parserOptions : { ecmaVersion : 2022 }
429
+ } ,
430
+
431
+ // https://github.com/eslint/eslint/issues/15572
432
+ {
433
+ code : `
434
+ const { some_property } = obj;
435
+ doSomething({ some_property });
436
+ ` ,
437
+ options : [ { properties : "never" , ignoreDestructuring : true } ] ,
438
+ parserOptions : { ecmaVersion : 2022 }
410
439
}
411
440
] ,
412
441
invalid : [
@@ -1416,6 +1445,78 @@ ruleTester.run("camelcase", rule, {
1416
1445
options : [ { properties : "always" } ] ,
1417
1446
parserOptions : { ecmaVersion : 2022 } ,
1418
1447
errors : [ { messageId : "notCamelCasePrivate" , data : { name : "snake_case" } } ]
1448
+ } ,
1449
+
1450
+ // Combinations of `properties` and `ignoreDestructring`
1451
+ {
1452
+ code : `
1453
+ const { some_property } = obj;
1454
+ doSomething({ some_property });
1455
+ ` ,
1456
+ options : [ { properties : "always" , ignoreDestructuring : true } ] ,
1457
+ parserOptions : { ecmaVersion : 2022 } ,
1458
+ errors : [
1459
+ {
1460
+ messageId : "notCamelCase" ,
1461
+ data : { name : "some_property" } ,
1462
+ line : 3 ,
1463
+ column : 27
1464
+ }
1465
+ ]
1466
+ } ,
1467
+ {
1468
+ code : `
1469
+ const { some_property } = obj;
1470
+ doSomething({ some_property });
1471
+ doSomething({ [some_property]: "bar" });
1472
+ ` ,
1473
+ options : [ { properties : "never" , ignoreDestructuring : true } ] ,
1474
+ parserOptions : { ecmaVersion : 2022 } ,
1475
+ errors : [
1476
+ {
1477
+ messageId : "notCamelCase" ,
1478
+ data : { name : "some_property" } ,
1479
+ line : 4 ,
1480
+ column : 28
1481
+ }
1482
+ ]
1483
+ } ,
1484
+ {
1485
+ code : `
1486
+ const { some_property } = obj;
1487
+
1488
+ const bar = { some_property };
1489
+
1490
+ obj.some_property = 10;
1491
+
1492
+ const xyz = { some_property: obj.some_property };
1493
+
1494
+ const foo = ({ some_property }) => {
1495
+ console.log(some_property)
1496
+ };
1497
+ ` ,
1498
+ options : [ { properties : "always" , ignoreDestructuring : true } ] ,
1499
+ parserOptions : { ecmaVersion : 2022 } ,
1500
+ errors : [
1501
+ {
1502
+ messageId : "notCamelCase" ,
1503
+ data : { name : "some_property" } ,
1504
+ line : 4 ,
1505
+ column : 27
1506
+ } ,
1507
+ {
1508
+ messageId : "notCamelCase" ,
1509
+ data : { name : "some_property" } ,
1510
+ line : 6 ,
1511
+ column : 17
1512
+ } ,
1513
+ {
1514
+ messageId : "notCamelCase" ,
1515
+ data : { name : "some_property" } ,
1516
+ line : 8 ,
1517
+ column : 27
1518
+ }
1519
+ ]
1419
1520
}
1420
1521
]
1421
1522
} ) ;
0 commit comments