Format .swcrc as a JSON file (#12320)

* Format `.swcrc` as JSON

* Test `.swcrc` JSON formatting

* Add changelog

* Update snapshots

* Address reviews

* Update `cspell.json`

* Address review
This commit is contained in:
Sosuke Suzuki authored and GitHub committed 2022-02-18 08:39:12 +09:00
1 parent 4c7ba992b7
commit 162097e2d2
5 files changed
+29 -2

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
#### Infer parser for `.swcrc` (#12320 by @sosukesuzuki)
A [`.swcrc`](https://swc.rs/docs/configuration/swcrc) is handled using `json` parser.
+1
View File
@@ -310,6 +310,7 @@
"suchipi", "suchipi",
"supertypes", "supertypes",
"Supprimer", "Supprimer",
"swcrc",
"templating", "templating",
"tempy", "tempy",
"testname", "testname",
+1 -1
View File
@@ -102,7 +102,7 @@ const languages = [
since: "1.5.0", since: "1.5.0",
parsers: ["json"], parsers: ["json"],
vscodeLanguageIds: ["jsonc"], vscodeLanguageIds: ["jsonc"],
filenames: [...data.filenames, ".eslintrc"], filenames: [...data.filenames, ".eslintrc", ".swcrc"],
}) })
), ),
createLanguage(require("linguist-languages/data/JSON5.json"), () => ({ createLanguage(require("linguist-languages/data/JSON5.json"), () => ({
@@ -512,7 +512,8 @@ exports[`CLI --support-info (stdout) 1`] = `
\\"language-configuration.json\\", \\"language-configuration.json\\",
\\"tsconfig.json\\", \\"tsconfig.json\\",
\\"tslint.json\\", \\"tslint.json\\",
\\".eslintrc\\" \\".eslintrc\\",
\\".swcrc\\"
], ],
\\"group\\": \\"JSON\\", \\"group\\": \\"JSON\\",
\\"linguistLanguageId\\": 423, \\"linguistLanguageId\\": 423,
@@ -45,4 +45,26 @@ describe("infers parser from filename", () => {
prettier.format("let foo = ( x = 1 ) => x", { filepath: "x/y/Jakefile" }) prettier.format("let foo = ( x = 1 ) => x", { filepath: "x/y/Jakefile" })
).toBe("let foo = (x = 1) => x;\n"); ).toBe("let foo = (x = 1) => x;\n");
}); });
test("json from .swcrc", () => {
expect(
prettier.format(
`
{
"jsc": {
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
"keepClassNames": false
}
}
`,
{ filepath: "/path/to/.swcrc" }
)
).toBe(`{
"jsc": {
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
"keepClassNames": false
}
}
`);
});
}); });