-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add curly braces when attribute shorthand is used but not allowed #119
Conversation
@jesseskinner just fyi - I don't know enough to review the PRs in this repo. I just noticed that one issue and thought I'd point it out |
@benmccann No problem! Thanks for catching that. |
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 I'd find it more readable if you instead had a completely separate branch for the attribute shorthand case, i.e.
if (isAttributeShorthand) {
if (options.svelteAllowShorthand) {
return concat([line, '{', node.name, '}']);
}
else {
return concat([line, node.name, '="{', node.name, '}"']);
}
} else { ... }
But your solution works fine too, so LGTM
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.
Thanks for this! Could you resolve the merge conflicts and apply the refactoring suggestion from @ehrencrona which makes it more readable? I'm happy to merge this in then.
@dummdidumm Done & done. The refactoring broke an old test, and that revealed that svelteStrictMode came into play here too, so I added the extra test case. With |
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.
Thanks, all looking good! I refactored the other branch to make that one more readable, too, and added some more tests.
Closes #110
I also added the ability for custom options in formatting tests, which was needed to reproduce this bug.