-
-
Notifications
You must be signed in to change notification settings - Fork 2.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
Enforce newlines between operands of ternary expressions if the expression spans multiple lines (multiline-ternary) #1558
Labels
Milestone
Comments
This rule seems to have a bug, which I've filed against ESLint here: eslint/eslint#13782 |
Nevermind, I was misunderstanding the rule. |
3% ecosystem impact.
PRs need to be sent to these packages: |
This was referenced Oct 31, 2020
Sorry for dragging up such an old issue. My team just noticed this since we upgraded to Just wanted to share some unfortunate diffs that this generated: </head>
<body>
<div id="slip">
- ${printerName == null ? '' : `
+ ${printerName == null
+ ? ''
+ : `
<div class="printer-name">
${escapeHtml(printerName)}
</div>
`}
- ${!isCopy ? '' : `
+ ${!isCopy
+ ? ''
+ : `
<div class="copy-header">
<div class="copy-title">KOPIA</div>
<div class="copy-date">${escapeHtml(formatDateTime(now, 'yyyy-MM-dd HH:mm:ss', timeZone))}</div> _created_at: requestTime,
_id: id,
_updated_at: requestTime,
- employee: employee == null || employeeGroups == null ? null : {
- _created_at: employee._created_at,
- _id: employee._id,
- _updated_at: employee._updated_at,
- name: employee.name,
- groups: employeeGroups
- },
+ employee: employee == null || employeeGroups == null
+ ? null
+ : {
+ _created_at: employee._created_at,
+ _id: employee._id,
+ _updated_at: employee._updated_at,
+ name: employee.name,
+ groups: employeeGroups
+ },
orderIntentId,
paymentMethodId: paymentMethod._id, const html = await renderSlipFromOrder(restaurant, orders, printerQueue ?? null, isCopy ?? false, dataloader)
- return html == null ? null : {
- html,
- needsPrinting: null,
- printerQueueId: printerQueue?._id ?? null,
- restaurantId: restaurant._id
- }
+ return html == null
+ ? null
+ : {
+ html,
+ needsPrinting: null,
+ printerQueueId: printerQueue?._id ?? null,
+ restaurantId: restaurant._id
+ }
}
}
} - ${servingLocation?.tableName == null || servingLocation.tableName === '' ? '' : `
+ ${servingLocation?.tableName == null || servingLocation.tableName === ''
+ ? ''
+ : `
<div class="footer-text">Utlämnas till: ${escapeHtml(servingLocation.tableName)}</div>
`} {
$set: {
- alternativeItems: patch.alternativeItems == null ? undefined : ({
- alternativeItems: patch.alternativeItems?.map(item => ({
- countableUsage: item.countableUsage ?? undefined,
- isDefault: item.isDefault ?? false,
- name: item.name,
- productId: item.addonProductId ?? undefined
- }))
- }),
+ alternativeItems: patch.alternativeItems == null
+ ? undefined
+ : ({
+ alternativeItems: patch.alternativeItems?.map(item => ({
+ countableUsage: item.countableUsage ?? undefined,
+ isDefault: item.isDefault ?? false,
+ name: item.name,
+ productId: item.addonProductId ?? undefined
+ }))
+ }),
forceChoice: patch.forceChoice ?? undefined,
isCountable: patch.isCountable ?? undefined,
maxChoices: patch.maxChoices ?? undefined, |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
https://eslint.org/docs/rules/multiline-ternary
Desired config:
JavaScript allows operands of ternary expressions to be separated by newlines, which can improve the readability of your program.
For example:
The above can be rewritten as the following to improve readability and more clearly delineate the operands:
Rule Details
This rule enforces or disallows newlines between operands of a ternary expression.
Note: The location of the operators is not enforced by this rule. Please see the operator-linebreak rule if you are interested in enforcing the location of the operators themselves.
always-multiline
Examples of incorrect code for this rule with the
"always-multiline"
option:Examples of correct code for this rule with the
"always-multiline"
option:The text was updated successfully, but these errors were encountered: