-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Fix rule of fill violations in utils and tests #16656
base: main
Are you sure you want to change the base?
Fix rule of fill violations in utils and tests #16656
Conversation
/* | ||
This is not really `cleanDoc` from `src/document/utils.js` | ||
But if we pass array to it, it will flat array | ||
*/ | ||
const cleanDoc = (parts) => parts.flat(); | ||
expect( | ||
await formatDoc( | ||
// The argument of fill must not be passed to cleanDoc because it's not a doc | ||
fill(cleanDoc(["foo", literalline, "bar"])), // invalid fill | ||
), | ||
).toBe('fill(["foo", literallineWithoutBreakParent, breakParent, "bar"])'); | ||
|
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'm considering this test case doesn't make sense. I'll add some tests if we need alternative tests.
Oops, a test case I recently added might be somewhat fragile. I'll fix it (increase
|
Though we expect "fill" to have odd length, but we didn't throw for violations, we even did wrong things in core, so plugins should already made mistakes, we can't force them to follow the strict rule, at least not a good time. I know I said add assert for "fill", but it should only run in dev mode. For "stripTrailingHardline", instead of remove "hardline" from parts directly, maybe we can replace it with empty string. Do you think it will work? |
Yes, I agree with you, they shuold. However, maybe the comment misses an important point. We don't (won't) expect |
And I found that new logic might be able to get simpler 😅 . I was somewhat confused and it might confused you. I'll see it later. |
I reverted some commits to get this PR to be conservative. |
seiyab/prettier@8565e91 seemsgood, but it should not need call |
Description
#16582
Do we need changelog for change in
stripTrailingHardline()
?Checklist
(If changing the API or CLI) I’ve documented the changes I’ve made (in thedocs/
directory).(If the change is user-facing) I’ve added my changes tochangelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨