Files
test-repo/tests/format/misc/parser-inference/format.test.js
T
fisker Cheungandautofix-ci[bot] ed5bb0bf62 Refactor tests (#18743)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2026-01-25 10:30:19 +08:00

61 lines
1.3 KiB
JavaScript

import { outdent } from "outdent";
runFormatTest(
{
importMeta: import.meta,
snippets: [
{
name: ".prettierrc in json(empty)",
filename: ".prettierrc",
code: "{}",
},
{
name: ".prettierrc in json",
filename: "path/to/.prettierrc",
code: outdent`
{"printWidth": 100,
"overrides": [
{"files": ".prettierrc",
"options": {"parser": "json"
}},
{"files": "*.js",
"options": {"parser": "babel",
"singleQuote": true,"printWidth": 80,"semi":
false,
"quoteProps": "as-needed"
}}
]}
`,
},
{
name: ".prettierrc in yaml",
filename: ".prettierrc",
code: outdent`
# comment
printWidth: 100
overrides:
- files: '.prettierrc'
options:
parser: "json"
`,
},
{
name: ".prettierrc in yaml (with flowMapping)",
filename: ".prettierrc",
code: outdent`
# comment
printWidth: 100
overrides: {
"files": [".prettierrc", "prettierrc.json"],
"options": { "parser": "json"}
}
`,
},
],
},
[
// don't set parser in options
undefined,
],
);