Created
November 30, 2023 10:02
-
-
Save nmn/f605e6564a5725201e61e6b3f3aee2ba to your computer and use it in GitHub Desktop.
Prettier Experimental Ternaries - Bad Cases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const exprs = | |
pathUtils.isTemplateLiteral(path) ? path.get('expressions') | |
: pathUtils.isTaggedTemplateExpression(path) ? | |
path.get('quasi').get('expressions') | |
: []; | |
// I would want that formated as: | |
const exprs = | |
pathUtils.isTemplateLiteral(path) ? | |
path.get('expressions') | |
: pathUtils.isTaggedTemplateExpression(path) ? | |
path.get('quasi').get('expressions') | |
: []; | |
// If the ternary is multi-line, the conditions and the "then" cases should all be on separate lines. | |
const key = | |
prop.key.type === 'Identifier' && !prop.computed ? prop.key.name | |
: prop.key.type === 'StringLiteral' ? prop.key.value | |
: null; | |
// I would want that to be formatted as: | |
const key = | |
prop.key.type === 'Identifier' && !prop.computed ? | |
prop.key.name | |
: prop.key.type === 'StringLiteral' ? | |
prop.key.value | |
: null; | |
// If we are emulating if-else, the "then" cases need to be on their own lines. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment