Resolve rule of fill violation in JSX and add assertion.#16700
Resolve rule of fill violation in JSX and add assertion.#16700sosukesuzuki merged 21 commits intoprettier:mainfrom
Conversation
| const rawJsxWhitespace = options.singleQuote ? "{' '}" : '{" "}'; | ||
| const jsxWhitespace = isMdxBlock | ||
| ? " " | ||
| ? line |
There was a problem hiding this comment.
I'm worrying that it might not be just a careless mistake. I'm not familiar with MDX at all...
src/document/utils/assert-doc.js
Outdated
| }; | ||
|
|
||
| export { assertDoc, assertDocArray }; | ||
| const assertDocFill = |
There was a problem hiding this comment.
assertDocFillParts, since it only accept parts not fill
| hasUnexpectedString = true; | ||
| return; | ||
| case DOC_TYPE_IF_BREAK: | ||
| traverseDoc(doc.breakContents, rec); |
There was a problem hiding this comment.
Is this still needed if we use the last argument in outer traverse ?
There was a problem hiding this comment.
Maybe yes. shouldTraverseConditoinalGroups doesn't affect ifBreak(), where we want to modify the behavior.
prettier/src/document/builders.js
Lines 120 to 132 in 94fa86e
prettier/src/document/utils/traverse-doc.js
Lines 68 to 76 in 1ea2fd0
prettier/src/document/utils/traverse-doc.js
Lines 64 to 66 in 1ea2fd0
Or do I misunderstand?
| throw new Error( | ||
| `Unexpected non-line-break doc at ${i}. Doc type is ${type}.`, | ||
| ); |
There was a problem hiding this comment.
Using InvalidDocError is not straightforward because InvalidDocError considers such documents valid. Error message gets weird and very hard to understand (message: "doc is valid").
I use just Error here.
|
@fisker ping (no hurry) |
|
I'm really sorry for the long delay, I was super busy recently. Change looks good, the only reason I didn't approve is that I'm not sure about using |
| } | ||
|
|
||
| /** | ||
| * returns true iff cleanDoc(doc) === "" |
There was a problem hiding this comment.
| * returns true iff cleanDoc(doc) === "" | |
| * returns true if cleanDoc(doc) === "" |
There was a problem hiding this comment.
It's intentional. I mean "if and only if"
https://en.wikipedia.org/wiki/If_and_only_if
"if and only if" (often shortened as "iff")
Co-authored-by: fisker Cheung <[email protected]>
commit: |
Description
#16582
Checklist
assertDocFill()? -> done(If changing the API or CLI) I’ve documented the changes I’ve made (in thedocs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.✨Try the playground for this PR✨