-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Don't default parser to babylon #4528
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
Conversation
src/main/options.js
Outdated
| if (!rawOptions.parser) { | ||
| const logger = (opts && opts.logger) || console; | ||
| if (!rawOptions.filepath) { | ||
| logger.warn("Skipping file with unknown filepath"); |
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.
What is an unknown filepath?
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.
@lydell Use stdin without --stdin-filepath or prettier.format without { filepath }
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.
At first I decided to throw an error but I figured that could be a little too harsh
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 see. I wanted to come up with a better message, but it's hard.
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.
Really like the updated message, good job!
|
I fetched your branch and played around with it a little, and it seems nice. Minor logging glitch: Question about stdout: Currently the above print LICENSE as-is to stdout. Is it better to not print it to stdout at all? Similar: What should |
src/main/core-options.js
Outdated
| category: CATEGORY_GLOBAL, | ||
| type: "choice", | ||
| default: "babylon", | ||
| default: undefined, |
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.
For the support info, you need to specify that the default varies across versions; see #4426 (comment)
suchipi
left a comment
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.
LGTM, aside from the logging issue @lydell mentioned
Good questions, I'm not sure. I'm comfortable with throwing an error in the latter, but I'm not sure what we should do about |
|
So I tried to improve the logging experience a bit but there are too much cases to cover 😅 This code is pretty complex, I'd appreciate more testing |
|
I think I covered most use cases in |
| }); | ||
| }); | ||
|
|
||
| describe("--write and --list-different with unknown path and no parser", () => { |
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 have no idea what this means (how it should behave).. we really need to revamp the CLI
lydell
left a comment
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.
This is so good! 😍
|
🎉 |
**What kind of change does this PR introduce?** Bugfix **Did you add tests for your changes?** No **If relevant, did you update the documentation?** No **Summary**  Prettier shows warning currently that filePath and parser aren't specified. It would throw errors in future major versions. [#4828](prettier/prettier#4528) This PR cleans the warning shown in the above image. <!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? --> <!-- Try to link to an open issue for more information. --> **Does this PR introduce a breaking change?** No **Other information** No
Closes #2884
This takes a different approach from #4426 to make it more explicit a parser wasn't specified or inferred (returns normalized opts as
nullandformat()bails formatting).