Allow $schema property in json config files (#14067)
* Fix: Error on property in json config files * options[] delete moved down
This commit is contained in:
parent
69ae3b5a25
commit
2c68d03bf2
@ -272,6 +272,8 @@ const readConfigJSON5 = makeStaticFileCache((filepath, content): ConfigFile => {
|
|||||||
throw new Error(`${filepath}: Expected config object but found array`);
|
throw new Error(`${filepath}: Expected config object but found array`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete options["$schema"];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
filepath,
|
filepath,
|
||||||
dirname: path.dirname(filepath),
|
dirname: path.dirname(filepath),
|
||||||
|
|||||||
@ -1343,5 +1343,19 @@ describe("buildConfigChain", function () {
|
|||||||
});
|
});
|
||||||
}).toThrow(/Preset \/\* your preset \*\/ requires a filename/);
|
}).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"
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user