@@ -682,6 +682,37 @@ describe("FlatESLint", () => {
682682 ) ;
683683 } ) ;
684684
685+ it ( "should throw if eslint.config.js file is not present" , async ( ) => {
686+ eslint = new FlatESLint ( {
687+ cwd : getFixturePath ( ".." )
688+ } ) ;
689+ await assert . rejects ( ( ) => eslint . lintText ( "var foo = 'bar';" ) , / C o u l d n o t f i n d c o n f i g f i l e / u) ;
690+ } ) ;
691+
692+ it ( "should not throw if eslint.config.js file is not present and overrideConfigFile is `true`" , async ( ) => {
693+ eslint = new FlatESLint ( {
694+ cwd : getFixturePath ( ".." ) ,
695+ overrideConfigFile : true
696+ } ) ;
697+ await eslint . lintText ( "var foo = 'bar';" ) ;
698+ } ) ;
699+
700+ it ( "should not throw if eslint.config.js file is not present and overrideConfigFile is path to a config file" , async ( ) => {
701+ eslint = new FlatESLint ( {
702+ cwd : getFixturePath ( ".." ) ,
703+ overrideConfigFile : "fixtures/configurations/quotes-error.js"
704+ } ) ;
705+ await eslint . lintText ( "var foo = 'bar';" ) ;
706+ } ) ;
707+
708+ it ( "should throw if overrideConfigFile is path to a file that doesn't exist" , async ( ) => {
709+ eslint = new FlatESLint ( {
710+ cwd : getFixturePath ( "" ) ,
711+ overrideConfigFile : "does-not-exist.js"
712+ } ) ;
713+ await assert . rejects ( ( ) => eslint . lintText ( "var foo = 'bar';" ) , { code : "ENOENT" } ) ;
714+ } ) ;
715+
685716 it ( "should throw if non-string value is given to 'code' parameter" , async ( ) => {
686717 eslint = new FlatESLint ( ) ;
687718 await assert . rejects ( ( ) => eslint . lintText ( 100 ) , / ' c o d e ' m u s t b e a s t r i n g / u) ;
@@ -797,6 +828,37 @@ describe("FlatESLint", () => {
797828 assert . strictEqual ( results [ 0 ] . suppressedMessages . length , 0 ) ;
798829 } ) ;
799830
831+ it ( "should throw if eslint.config.js file is not present" , async ( ) => {
832+ eslint = new FlatESLint ( {
833+ cwd : getFixturePath ( ".." )
834+ } ) ;
835+ await assert . rejects ( ( ) => eslint . lintFiles ( "fixtures/undef*.js" ) , / C o u l d n o t f i n d c o n f i g f i l e / u) ;
836+ } ) ;
837+
838+ it ( "should not throw if eslint.config.js file is not present and overrideConfigFile is `true`" , async ( ) => {
839+ eslint = new FlatESLint ( {
840+ cwd : getFixturePath ( ".." ) ,
841+ overrideConfigFile : true
842+ } ) ;
843+ await eslint . lintFiles ( "fixtures/undef*.js" ) ;
844+ } ) ;
845+
846+ it ( "should not throw if eslint.config.js file is not present and overrideConfigFile is path to a config file" , async ( ) => {
847+ eslint = new FlatESLint ( {
848+ cwd : getFixturePath ( ".." ) ,
849+ overrideConfigFile : "fixtures/configurations/quotes-error.js"
850+ } ) ;
851+ await eslint . lintFiles ( "fixtures/undef*.js" ) ;
852+ } ) ;
853+
854+ it ( "should throw if overrideConfigFile is path to a file that doesn't exist" , async ( ) => {
855+ eslint = new FlatESLint ( {
856+ cwd : getFixturePath ( ) ,
857+ overrideConfigFile : "does-not-exist.js"
858+ } ) ;
859+ await assert . rejects ( ( ) => eslint . lintFiles ( "undef*.js" ) , { code : "ENOENT" } ) ;
860+ } ) ;
861+
800862 it ( "should throw an error when given a config file and a valid file and invalid parser" , async ( ) => {
801863 eslint = new FlatESLint ( {
802864 overrideConfig : {
0 commit comments