Fix JSONC filenames list (#15947)
This commit is contained in:
1 parent
6c6a332171
commit
1cd4d9c160
5 files changed
+40
-13
No files matched your search
@@ -0,0 +1,14 @@
|
||||
#### Fix incorrect parser inference (#15947 by @fisker)
|
||||
|
||||
Files like `.eslintrc.json` were incorrectly formatted as JSONC files.
|
||||
|
||||
<!-- prettier-ignore -->
|
||||
```jsx
|
||||
// Input
|
||||
prettier --file-info .eslintrc.json
|
||||
{ "ignored": false, "inferredParser": "jsonc" }
|
||||
|
||||
// Prettier main
|
||||
prettier --file-info .eslintrc.json
|
||||
{ "ignored": false, "inferredParser": "json" }
|
||||
```
|
||||
@@ -156,6 +156,7 @@
|
||||
"jscodeshift",
|
||||
"jsesc",
|
||||
"jsfmt",
|
||||
"jslintrc",
|
||||
"jsonata",
|
||||
"judgements",
|
||||
"kalmanb",
|
||||
|
||||
@@ -14,10 +14,26 @@ const languages = [
|
||||
parsers: ["json"],
|
||||
vscodeLanguageIds: ["json"],
|
||||
extensions: data.extensions.filter((extension) => extension !== ".jsonl"),
|
||||
filenames: [
|
||||
...data.filenames,
|
||||
".babelrc",
|
||||
".jscsrc",
|
||||
".jshintrc",
|
||||
".jslintrc",
|
||||
".swcrc",
|
||||
],
|
||||
})),
|
||||
createLanguage(linguistLanguages["JSON with Comments"], () => ({
|
||||
parsers: ["jsonc"],
|
||||
vscodeLanguageIds: ["jsonc"],
|
||||
// Too many filenames from `linguist-languages` are not a valid JSONC files.
|
||||
// https://github.com/prettier/prettier/issues/15945#issuecomment-1895371835
|
||||
filenames: [
|
||||
"devcontainer.json",
|
||||
"jsconfig.json",
|
||||
"language-configuration.json",
|
||||
"tsconfig.json",
|
||||
],
|
||||
})),
|
||||
createLanguage(linguistLanguages.JSON5, () => ({
|
||||
parsers: ["json5"],
|
||||
|
||||
@@ -488,7 +488,12 @@ exports[`CLI --support-info (stdout) 1`] = `
|
||||
"Pipfile.lock",
|
||||
"composer.lock",
|
||||
"flake.lock",
|
||||
"mcmod.info"
|
||||
"mcmod.info",
|
||||
".babelrc",
|
||||
".jscsrc",
|
||||
".jshintrc",
|
||||
".jslintrc",
|
||||
".swcrc"
|
||||
],
|
||||
"linguistLanguageId": 174,
|
||||
"name": "JSON",
|
||||
@@ -522,19 +527,10 @@ exports[`CLI --support-info (stdout) 1`] = `
|
||||
".sublime_session"
|
||||
],
|
||||
"filenames": [
|
||||
".babelrc",
|
||||
".devcontainer.json",
|
||||
".eslintrc.json",
|
||||
".jscsrc",
|
||||
".jshintrc",
|
||||
".jslintrc",
|
||||
".swcrc",
|
||||
"api-extractor.json",
|
||||
"devcontainer.json",
|
||||
"jsconfig.json",
|
||||
"language-configuration.json",
|
||||
"tsconfig.json",
|
||||
"tslint.json"
|
||||
"tsconfig.json"
|
||||
],
|
||||
"group": "JSON",
|
||||
"linguistLanguageId": 423,
|
||||
|
||||
@@ -66,8 +66,8 @@ describe("infers parser from filename", () => {
|
||||
{
|
||||
"jsc": {
|
||||
// Requires v1.2.50 or upper and requires target to be es2016 or upper.
|
||||
"keepClassNames": false,
|
||||
},
|
||||
"keepClassNames": false
|
||||
}
|
||||
}
|
||||
` + "\n",
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user