@@ -445,6 +445,69 @@ ruleTester.run("camelcase", rule, {
445445 ` ,
446446 options : [ { properties : "never" , ignoreDestructuring : true } ] ,
447447 languageOptions : { ecmaVersion : 2022 }
448+ } ,
449+
450+ // Import attribute keys
451+ {
452+ code : "import foo from 'foo.json' with { my_type: 'json' }" ,
453+ options : [ {
454+ properties : "always" ,
455+ ignoreImports : false
456+ } ] ,
457+ languageOptions : { ecmaVersion : 2025 , sourceType : "module" }
458+ } ,
459+ {
460+ code : "export * from 'foo.json' with { my_type: 'json' }" ,
461+ options : [ {
462+ properties : "always" ,
463+ ignoreImports : false
464+ } ] ,
465+ languageOptions : { ecmaVersion : 2025 , sourceType : "module" }
466+ } ,
467+ {
468+ code : "export { default } from 'foo.json' with { my_type: 'json' }" ,
469+ options : [ {
470+ properties : "always" ,
471+ ignoreImports : false
472+ } ] ,
473+ languageOptions : { ecmaVersion : 2025 , sourceType : "module" }
474+ } ,
475+ {
476+ code : "import('foo.json', { my_with: { my_type: 'json' } })" ,
477+ options : [ {
478+ properties : "always" ,
479+ ignoreImports : false
480+ } ] ,
481+ languageOptions : { ecmaVersion : 2025 }
482+ } ,
483+ {
484+ code : "import('foo.json', { 'with': { my_type: 'json' } })" ,
485+ options : [ {
486+ properties : "always" ,
487+ ignoreImports : false
488+ } ] ,
489+ languageOptions : { ecmaVersion : 2025 }
490+ } ,
491+ {
492+ code : "import('foo.json', { my_with: { my_type } })" ,
493+ options : [ {
494+ properties : "always" ,
495+ ignoreImports : false
496+ } ] ,
497+ languageOptions : { ecmaVersion : 2025 }
498+ } ,
499+ {
500+ code : "import('foo.json', { my_with: { my_type } })" ,
501+ options : [ {
502+ properties : "always" ,
503+ ignoreImports : false
504+ } ] ,
505+ languageOptions : {
506+ ecmaVersion : 2025 ,
507+ globals : {
508+ my_type : true // eslint-disable-line camelcase -- for testing
509+ }
510+ }
448511 }
449512 ] ,
450513 invalid : [
@@ -1519,6 +1582,38 @@ ruleTester.run("camelcase", rule, {
15191582 column : 27
15201583 }
15211584 ]
1585+ } ,
1586+
1587+ // Not an import attribute key
1588+ {
1589+ code : "import('foo.json', { my_with: { [my_type]: 'json' } })" ,
1590+ options : [ {
1591+ properties : "always" ,
1592+ ignoreImports : false
1593+ } ] ,
1594+ languageOptions : { ecmaVersion : 2025 } ,
1595+ errors : [
1596+ {
1597+ messageId : "notCamelCase" ,
1598+ data : { name : "my_type" } ,
1599+ type : "Identifier"
1600+ }
1601+ ]
1602+ } ,
1603+ {
1604+ code : "import('foo.json', { my_with: { my_type: my_json } })" ,
1605+ options : [ {
1606+ properties : "always" ,
1607+ ignoreImports : false
1608+ } ] ,
1609+ languageOptions : { ecmaVersion : 2025 } ,
1610+ errors : [
1611+ {
1612+ messageId : "notCamelCase" ,
1613+ data : { name : "my_json" } ,
1614+ type : "Identifier"
1615+ }
1616+ ]
15221617 }
15231618 ]
15241619} ) ;
0 commit comments