Merge pull request #3055 from azz/$schema

Delete $schema from resolved config
master
Stephen Scott 2017-10-18 15:08:36 -06:00 committed by GitHub
commit 11624eec20
4 changed files with 31 additions and 1 deletions

View File

@ -9,7 +9,13 @@ const getExplorerMemoized = mem(opts =>
cosmiconfig("prettier", {
sync: opts.sync,
cache: opts.cache,
rcExtensions: true
rcExtensions: true,
transform: result => {
if (result && result.config) {
delete result.config.$schema;
}
return result;
}
})
);

View File

@ -109,3 +109,23 @@ test("API resolveConfig.sync overrides work with absolute paths", () => {
tabWidth: 6
});
});
test("API resolveConfig removes $schema option", () => {
const file = path.resolve(
path.join(__dirname, "../cli/config/$schema/index.js")
);
return prettier.resolveConfig(file).then(result => {
expect(result).toEqual({
tabWidth: 42
});
});
});
test("API resolveConfig.sync removes $schema option", () => {
const file = path.resolve(
path.join(__dirname, "../cli/config/$schema/index.js")
);
expect(prettier.resolveConfig.sync(file)).toEqual({
tabWidth: 42
});
});

View File

@ -0,0 +1,4 @@
{
"$schema": "http://json.schemastore.org/prettierrc",
"tabWidth": 42
}