Skip to content

Commit

Permalink
Allow $schema property in json config files (#14067)
Browse files Browse the repository at this point in the history
* Fix: Error on  property in json config files

* options[] delete moved down
  • Loading branch information
The-x-Theorist committed Dec 29, 2021
1 parent 69ae3b5 commit 2c68d03
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/babel-core/src/config/files/configuration.ts
Expand Up @@ -272,6 +272,8 @@ const readConfigJSON5 = makeStaticFileCache((filepath, content): ConfigFile => {
throw new Error(`${filepath}: Expected config object but found array`);
}

delete options["$schema"];

return {
filepath,
dirname: path.dirname(filepath),
Expand Down
14 changes: 14 additions & 0 deletions packages/babel-core/test/config-chain.js
Expand Up @@ -1343,5 +1343,19 @@ describe("buildConfigChain", function () {
});
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
});

it("should not throw error on $schema property in json config files", () => {
const filename = fixture(
"config-files",
"babel-config-json-$schema-property",
"babel.config.json",
);
expect(() => {
babel.loadPartialConfig({
filename,
cwd: path.dirname(filename),
});
}).not.toThrow();
});
});
});
@@ -0,0 +1,3 @@
{
"$schema": "https://json.schemastore.org/babelrc"
}

0 comments on commit 2c68d03

Please sign in to comment.