Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow $schema property in json config files #14067

Merged
merged 2 commits into from Dec 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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"
}