@@ -191,9 +191,9 @@ async function assertMergedResult(values, result) {
191191async function assertInvalidConfig ( values , message ) {
192192 const configs = createFlatConfigArray ( values ) ;
193193
194- await configs . normalize ( ) ;
195194
196195 assert . throws ( ( ) => {
196+ configs . normalizeSync ( ) ;
197197 configs . getConfig ( "foo.js" ) ;
198198 } , message ) ;
199199}
@@ -719,14 +719,162 @@ describe("FlatConfigArray", () => {
719719 describe ( "Config array elements" , ( ) => {
720720 it ( "should error on 'eslint:recommended' string config" , async ( ) => {
721721
722- await assertInvalidConfig ( [ "eslint:recommended" ] , "All arguments must be objects ." ) ;
722+ await assertInvalidConfig ( [ "eslint:recommended" ] , "Config (unnamed): Unexpected non-object config at original index 0 ." ) ;
723723 } ) ;
724724
725725 it ( "should error on 'eslint:all' string config" , async ( ) => {
726726
727- await assertInvalidConfig ( [ "eslint:all" ] , "All arguments must be objects." ) ;
727+ await assertInvalidConfig ( [ "eslint:all" ] , "Config (unnamed): Unexpected non-object config at original index 0." ) ;
728+ } ) ;
729+
730+
731+ it ( "should throw an error when undefined original config is normalized" , ( ) => {
732+
733+ const configs = new FlatConfigArray ( [ void 0 ] ) ;
734+
735+ assert . throws ( ( ) => {
736+ configs . normalizeSync ( ) ;
737+ } , "Config (unnamed): Unexpected undefined config at original index 0." ) ;
738+
739+ } ) ;
740+
741+ it ( "should throw an error when undefined original config is normalized asynchronously" , async ( ) => {
742+
743+ const configs = new FlatConfigArray ( [ void 0 ] ) ;
744+
745+ try {
746+ await configs . normalize ( ) ;
747+ assert . fail ( "Error not thrown" ) ;
748+ } catch ( error ) {
749+ assert . strictEqual ( error . message , "Config (unnamed): Unexpected undefined config at original index 0." ) ;
750+ }
751+
752+ } ) ;
753+
754+ it ( "should throw an error when null original config is normalized" , ( ) => {
755+
756+ const configs = new FlatConfigArray ( [ null ] ) ;
757+
758+ assert . throws ( ( ) => {
759+ configs . normalizeSync ( ) ;
760+ } , "Config (unnamed): Unexpected null config at original index 0." ) ;
761+
762+ } ) ;
763+
764+ it ( "should throw an error when null original config is normalized asynchronously" , async ( ) => {
765+
766+ const configs = new FlatConfigArray ( [ null ] ) ;
767+
768+ try {
769+ await configs . normalize ( ) ;
770+ assert . fail ( "Error not thrown" ) ;
771+ } catch ( error ) {
772+ assert . strictEqual ( error . message , "Config (unnamed): Unexpected null config at original index 0." ) ;
773+ }
774+
775+ } ) ;
776+
777+ it ( "should throw an error when undefined base config is normalized" , ( ) => {
778+
779+ const configs = new FlatConfigArray ( [ ] , { baseConfig : [ void 0 ] } ) ;
780+
781+ assert . throws ( ( ) => {
782+ configs . normalizeSync ( ) ;
783+ } , "Config (unnamed): Unexpected undefined config at base index 0." ) ;
784+
785+ } ) ;
786+
787+ it ( "should throw an error when undefined base config is normalized asynchronously" , async ( ) => {
788+
789+ const configs = new FlatConfigArray ( [ ] , { baseConfig : [ void 0 ] } ) ;
790+
791+ try {
792+ await configs . normalize ( ) ;
793+ assert . fail ( "Error not thrown" ) ;
794+ } catch ( error ) {
795+ assert . strictEqual ( error . message , "Config (unnamed): Unexpected undefined config at base index 0." ) ;
796+ }
797+
798+ } ) ;
799+
800+ it ( "should throw an error when null base config is normalized" , ( ) => {
801+
802+ const configs = new FlatConfigArray ( [ ] , { baseConfig : [ null ] } ) ;
803+
804+ assert . throws ( ( ) => {
805+ configs . normalizeSync ( ) ;
806+ } , "Config (unnamed): Unexpected null config at base index 0." ) ;
807+
808+ } ) ;
809+
810+ it ( "should throw an error when null base config is normalized asynchronously" , async ( ) => {
811+
812+ const configs = new FlatConfigArray ( [ ] , { baseConfig : [ null ] } ) ;
813+
814+ try {
815+ await configs . normalize ( ) ;
816+ assert . fail ( "Error not thrown" ) ;
817+ } catch ( error ) {
818+ assert . strictEqual ( error . message , "Config (unnamed): Unexpected null config at base index 0." ) ;
819+ }
820+
728821 } ) ;
729822
823+ it ( "should throw an error when undefined user-defined config is normalized" , ( ) => {
824+
825+ const configs = new FlatConfigArray ( [ ] ) ;
826+
827+ configs . push ( void 0 ) ;
828+
829+ assert . throws ( ( ) => {
830+ configs . normalizeSync ( ) ;
831+ } , "Config (unnamed): Unexpected undefined config at user-defined index 0." ) ;
832+
833+ } ) ;
834+
835+ it ( "should throw an error when undefined user-defined config is normalized asynchronously" , async ( ) => {
836+
837+ const configs = new FlatConfigArray ( [ ] ) ;
838+
839+ configs . push ( void 0 ) ;
840+
841+ try {
842+ await configs . normalize ( ) ;
843+ assert . fail ( "Error not thrown" ) ;
844+ } catch ( error ) {
845+ assert . strictEqual ( error . message , "Config (unnamed): Unexpected undefined config at user-defined index 0." ) ;
846+ }
847+
848+ } ) ;
849+
850+ it ( "should throw an error when null user-defined config is normalized" , ( ) => {
851+
852+ const configs = new FlatConfigArray ( [ ] ) ;
853+
854+ configs . push ( null ) ;
855+
856+ assert . throws ( ( ) => {
857+ configs . normalizeSync ( ) ;
858+ } , "Config (unnamed): Unexpected null config at user-defined index 0." ) ;
859+
860+ } ) ;
861+
862+ it ( "should throw an error when null user-defined config is normalized asynchronously" , async ( ) => {
863+
864+ const configs = new FlatConfigArray ( [ ] ) ;
865+
866+ configs . push ( null ) ;
867+
868+ try {
869+ await configs . normalize ( ) ;
870+ assert . fail ( "Error not thrown" ) ;
871+ } catch ( error ) {
872+ assert . strictEqual ( error . message , "Config (unnamed): Unexpected null config at user-defined index 0." ) ;
873+ }
874+
875+ } ) ;
876+
877+
730878 } ) ;
731879
732880 describe ( "Config Properties" , ( ) => {
0 commit comments