Don't default parser to babylon#4528
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.
@lydell Use stdin without --stdin-filepath or prettier.format without { filepath }
There was a problem hiding this comment.
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.
I see. I wanted to come up with a better message, but it's hard.
There was a problem hiding this comment.
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.
For the support info, you need to specify that the default varies across versions; see #4426 (comment)
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.
I have no idea what this means (how it should behave).. we really need to revamp the CLI
|
🎉 |
**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).