-
-
Notifications
You must be signed in to change notification settings - Fork 10
test: port over line-after-filepath-with-errors test
#35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| foo (+-) bar |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| foo (+-) bar |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| function foo() {} |
59 changes: 59 additions & 0 deletions
59
test/__tests__/__snapshots__/line-after-filepath-with-errors.js.snap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
|
||
| exports[`Line breaking after filepath with errors (stderr) 1`] = ` | ||
| "[error] invalid-1.js: SyntaxError: Unexpected token (1:8) | ||
| [error] > 1 | foo (+-) bar | ||
| [error] | ^ | ||
| [error] 2 | | ||
| [error] invalid-2.js: SyntaxError: Unexpected token (1:8) | ||
| [error] > 1 | foo (+-) bar | ||
| [error] | ^ | ||
| [error] 2 | | ||
| [error] invalid-2.unknown: UndefinedParserError: No parser could be inferred for file "$CWD/invalid-2.unknown"." | ||
| `; | ||
|
|
||
| exports[`Line breaking after filepath with errors (stderr) 2`] = ` | ||
| "invalid-1.js | ||
| invalid-2.js | ||
| invalid-2.unknown" | ||
| `; | ||
|
|
||
| exports[`Line breaking after filepath with errors (stderr) 3`] = ` | ||
| "[error] invalid-1.js: SyntaxError: Unexpected token (1:8) | ||
| [error] > 1 | foo (+-) bar | ||
| [error] | ^ | ||
| [error] 2 | | ||
| [error] invalid-2.js: SyntaxError: Unexpected token (1:8) | ||
| [error] > 1 | foo (+-) bar | ||
| [error] | ^ | ||
| [error] 2 | | ||
| [error] invalid-2.unknown: UndefinedParserError: No parser could be inferred for file "$CWD/invalid-2.unknown"." | ||
| `; | ||
|
|
||
| exports[`Line breaking after filepath with errors (stderr) 4`] = ` | ||
| "[error] invalid-1.js: SyntaxError: Unexpected token (1:8) | ||
| [error] > 1 | foo (+-) bar | ||
| [error] | ^ | ||
| [error] 2 | | ||
| [error] invalid-2.js: SyntaxError: Unexpected token (1:8) | ||
| [error] > 1 | foo (+-) bar | ||
| [error] | ^ | ||
| [error] 2 | | ||
| [error] invalid-2.unknown: UndefinedParserError: No parser could be inferred for file "$CWD/invalid-2.unknown"." | ||
| `; | ||
|
|
||
| exports[`Line breaking after filepath with errors (stdout) 1`] = `"function foo() {}"`; | ||
|
|
||
| exports[`Line breaking after filepath with errors (stdout) 2`] = `""`; | ||
|
|
||
| exports[`Line breaking after filepath with errors (stdout) 3`] = `"Checking formatting..."`; | ||
|
|
||
| exports[`Line breaking after filepath with errors (stdout) 4`] = `""`; | ||
|
|
||
| exports[`Line breaking after filepath with errors (write) 1`] = `[]`; | ||
|
|
||
| exports[`Line breaking after filepath with errors (write) 2`] = `[]`; | ||
|
|
||
| exports[`Line breaking after filepath with errors (write) 3`] = `[]`; | ||
|
|
||
| exports[`Line breaking after filepath with errors (write) 4`] = `[]`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { runCli } from "../utils"; | ||
|
|
||
| describe("Line breaking after filepath with errors", () => { | ||
| runCli("syntax-errors", ["./*.{js,unknown}"]).test({ | ||
| status: 1, | ||
| }); | ||
| // TODO (43081j): this test throws errors in prettier. here it doesn't, and | ||
| // lists each invalid file path in the output (stderr). we should decide | ||
| // if to align with prettier | ||
| runCli("syntax-errors", ["--list-different", "./*.{js,unknown}"]).test({ | ||
| status: 1, | ||
| }); | ||
| runCli("syntax-errors", ["--check", "./*.{js,unknown}"]).test({ | ||
| status: 1, | ||
| }); | ||
| runCli("syntax-errors", ["--write", "./*.{js,unknown}"]).test({ | ||
| status: 1, | ||
| }); | ||
| }); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see this
TODOand the one abovethis has been raised in another PR too. basically this block:
prettier-cli/src/index.ts
Lines 181 to 185 in 5d5a6ca
means that with no args, errors are not raised and are ignored
this means running with
list: trueorcheck: truebehaves differently than with no args (i.e. bothfalse)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should first add the fourth mode of operation as mentioned in #30, then I need to look at what the difference is exactly, because if prettier just throws it seems better to output a comprehensible error, while still erroring, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "forth mode", "dump" is implemented now, maybe we can reference that here if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the two tests fail in prettier because the files matching the glob are invalid I think (syntax errors)
so in this test (
--list-different) and the argless one, we do error in prettier but not in prettier CLIthe fourth mode doesn't seem relevant now that I think about it. in general if a glob matches invalid files, it seems we skip them? but I don't remember what past-james was doing here, so I'm just going off the TODOs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if aligning with the old CLI in this aspect isn't a huge pain in the ass we should just do that 🤔 That seems the only blocker for this PR, right?