File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -157,8 +157,14 @@ type LoadPartialConfigOpts = {
157157} ;
158158
159159export const loadPartialConfig = gensync < [ any ] , PartialConfig | null > (
160- function * ( inputOpts : LoadPartialConfigOpts ) : Handler < PartialConfig | null > {
161- const { showIgnoredFiles, ...opts } = inputOpts ;
160+ function * ( opts ?: LoadPartialConfigOpts ) : Handler < PartialConfig | null > {
161+ let showIgnoredFiles = false ;
162+ // We only extract showIgnoredFiles if opts is an object, so that
163+ // loadPrivatePartialConfig can throw the appropriate error if it's not.
164+ if ( typeof opts === "object" && opts !== null && ! Array . isArray ( opts ) ) {
165+ ( { showIgnoredFiles, ...opts } = opts ) ;
166+ }
167+
162168 const result : ?PrivPartialConfig = yield * loadPrivatePartialConfig ( opts ) ;
163169 if ( ! result ) return null ;
164170
Original file line number Diff line number Diff line change @@ -1330,6 +1330,17 @@ describe("buildConfigChain", function () {
13301330 ] ) ,
13311331 } ) ;
13321332 } ) ;
1333+
1334+ it ( "loadPartialConfig can be called with no arguments" , ( ) => {
1335+ const cwd = process . cwd ( ) ;
1336+
1337+ try {
1338+ process . chdir ( fixture ( "config-files" , "babelrc-extended" ) ) ;
1339+ expect ( ( ) => babel . loadPartialConfig ( ) ) . not . toThrow ( ) ;
1340+ } finally {
1341+ process . chdir ( cwd ) ;
1342+ }
1343+ } ) ;
13331344 } ) ;
13341345
13351346 it ( "should throw when `test` presents but `filename` is not passed" , ( ) => {
You can’t perform that action at this time.
0 commit comments