@@ -788,7 +788,69 @@ describe("defineConfig()", () => {
788788 "no-debugger" : "error" ,
789789 } ,
790790 } ) ;
791- } , / P l u g i n c o n f i g " t e s t \/ c o n f i g 1 " i s a n e s l i n t r c c o n f i g a n d c a n n o t b e u s e d i n t h i s c o n t e x t \. / u) ;
791+ } , / P l u g i n c o n f i g " c o n f i g 1 " i n p l u g i n " t e s t " i s a n e s l i n t r c c o n f i g a n d c a n n o t b e u s e d i n t h i s c o n t e x t \. / u) ;
792+ } ) ;
793+
794+ it ( "should use flat config when base config is legacy" , ( ) => {
795+ const testPlugin = {
796+ configs : {
797+ recommended : {
798+ env : { browser : true } , // legacy config
799+ rules : { "no-console" : "error" } ,
800+ } ,
801+ "flat/recommended" : {
802+ rules : { "no-console" : "error" } ,
803+ } ,
804+ } ,
805+ } ;
806+
807+ const config = defineConfig ( {
808+ plugins : {
809+ test : testPlugin ,
810+ } ,
811+ extends : [ "test/recommended" ] ,
812+ rules : {
813+ "no-debugger" : "error" ,
814+ } ,
815+ } ) ;
816+
817+ assert . deepStrictEqual ( config , [
818+ {
819+ name : "UserConfig[0] > test/recommended" ,
820+ rules : { "no-console" : "error" } ,
821+ } ,
822+ {
823+ plugins : { test : testPlugin } ,
824+ rules : { "no-debugger" : "error" } ,
825+ } ,
826+ ] ) ;
827+ } ) ;
828+
829+ it ( "should throw error when both base and flat configs are legacy" , ( ) => {
830+ const testPlugin = {
831+ configs : {
832+ recommended : {
833+ env : { browser : true } ,
834+ rules : { "no-console" : "error" } ,
835+ } ,
836+ "flat/recommended" : {
837+ env : { browser : true } ,
838+ rules : { "no-console" : "error" } ,
839+ } ,
840+ } ,
841+ } ;
842+
843+ assert . throws ( ( ) => {
844+ defineConfig ( {
845+ plugins : {
846+ test : testPlugin ,
847+ } ,
848+ extends : [ "test/recommended" ] ,
849+ rules : {
850+ "no-debugger" : "error" ,
851+ } ,
852+ } ) ;
853+ } , / P l u g i n c o n f i g " r e c o m m e n d e d " i n p l u g i n " t e s t " i s a n e s l i n t r c c o n f i g a n d c a n n o t b e u s e d i n t h i s c o n t e x t \. / u) ;
792854 } ) ;
793855 } ) ;
794856
0 commit comments