Stop inferring the parser to be json for .jsonl files (#9371)

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
This commit is contained in:
fisker CheungandGeorgii Dolzhykov authored and GitHub committed 2020-10-13 09:17:33 +08:00
1 parent 73e3976c34
commit 07f6d49ef3
8 files changed
+48 -2

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
#### Stop inferring the parser to be `json` for `.jsonl` files (#9371 by @fisker)
<!-- prettier-ignore -->
```console
// Prettier stable
$ prettier --check .
Checking formatting...
[error] bad.jsonl: SyntaxError: Unexpected token (2:1)
[error] 1 | '{"type": "t/f", "head": "England", "relation": "invaded", "tail": "United States"}'
[error] > 2 | '{"type": "t/f", "head": "England", "relation": "attacked", "tail": "Baltimore"}'
[error] | ^
[error] 3 |
All matched files use Prettier code style!
// Prettier master
$ prettier --check .
Checking formatting...
All matched files use Prettier code style!
```
+4 -1
View File
@@ -2,6 +2,7 @@
"version": "0.1",
"words": [
"ACMR",
"Alexa",
"algolia",
"Amjad",
"Andrey",
@@ -75,6 +76,7 @@
"declarators",
"dedent",
"defun",
"Deloise",
"deltice",
"deopt",
"dependabot",
@@ -179,8 +181,9 @@
"josephfrazier",
"jsesc",
"jsfmt",
"judgements",
"jsonl",
"JSXs",
"judgements",
"kalmanb",
"Karimov",
"Kassens",
+1
View File
@@ -71,6 +71,7 @@ const languages = [
parsers: ["json"],
vscodeLanguageIds: ["json"],
filenames: [...data.filenames, ".prettierrc"],
extensions: data.extensions.filter((extension) => extension !== ".jsonl"),
})),
createLanguage(
require("linguist-languages/data/JSON with Comments.json"),
@@ -128,6 +128,11 @@ Array [
]
`;
exports[`Known/Unknown (stdout) 1`] = `
"known.js
"
`;
exports[`stdin no path and no parser --check logs error but exits with 0 (stderr) 1`] = `
"[error] No parser and no file path given, couldn't infer a parser.
"
@@ -435,7 +435,6 @@ exports[`CLI --support-info (stdout) 1`] = `
\\".har\\",
\\".ice\\",
\\".JSON-tmLanguage\\",
\\".jsonl\\",
\\".mcmeta\\",
\\".tfstate\\",
\\".tfstate.backup\\",
@@ -194,3 +194,16 @@ describe("API with no path and no parser", () => {
expect(global.console.warn.mock.calls[0]).toMatchSnapshot();
});
});
describe("Known/Unknown", () => {
runPrettier("cli/infer-parser/known-unknown", [
"--end-of-line",
"lf",
"--list-different",
".",
]).test({
status: 1,
stderr: "",
write: [],
});
});
@@ -0,0 +1,2 @@
hello( 'world'
)
@@ -0,0 +1,4 @@
{"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]}
{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]}
{"name": "May", "wins": []}
{"name": "Deloise", "wins": [["three of a kind", "5♣"]]}