Skip to content
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

Don't allow use of the nullish coalescing operator in templates #2025

Merged
merged 5 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
mollykreis marked this conversation as resolved.
Show resolved Hide resolved
"type": "patch",
"comment": "Don't allow use of the nullish coalescing operator in templates",
"packageName": "@ni/nimble-components",
"email": "[email protected]",
"dependentChangeType": "patch"
}
11 changes: 11 additions & 0 deletions packages/eslint-config-nimble/typescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ module.exports = {
'@typescript-eslint/indent': 'off'
}
},
{
files: ['template.ts'],
rules: {
// Using '??' in templates does not get flagged correctly by FAST as being a volatile binding.
// See https://github.com/ni/nimble/issues/1843 for more information.
'no-restricted-syntax': [
'error',
{ selector: "LogicalExpression[operator='??']" }
mollykreis marked this conversation as resolved.
Show resolved Hide resolved
]
}
},
{
// Instead of enums, this repo uses const objects and type unions which should live in types.ts
files: ['types.ts'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const template = html<RichTextEditor>`
${ref('mentionListbox')}
@mention-selected=${(x, c) => x.onMentionSelect(c.event as CustomEvent<MentionDetail>)}
>
${repeat(x => Array.from(x.activeMappingConfigs?.values() ?? []), html<MappingConfig>`
${repeat(x => Array.from(x.activeMappingConfigs ? x.activeMappingConfigs.values() : []), html<MappingConfig>`
<${listOptionTag} value="${x => x.mentionHref}">${x => x.displayName}</${listOptionTag}>
`, { recycle: false })}
</${richTextMentionListboxTag}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export const template = html<TableCell>`
@toggle="${(x, c) => x.onActionMenuToggle(c.event as CustomEvent<MenuButtonToggleEventDetail>)}"
@click="${(_, c) => c.event.stopPropagation()}"
class="action-menu"
title="${x => x.actionMenuLabel ?? tableCellActionMenuLabel.getValueFor(x)}"
title="${x => (x.actionMenuLabel ? x.actionMenuLabel : tableCellActionMenuLabel.getValueFor(x))}"
mollykreis marked this conversation as resolved.
Show resolved Hide resolved
>
<${iconThreeDotsLineTag} slot="start"></${iconThreeDotsLineTag}>
${x => x.actionMenuLabel ?? tableCellActionMenuLabel.getValueFor(x)}
${x => (x.actionMenuLabel ? x.actionMenuLabel : tableCellActionMenuLabel.getValueFor(x))}
<slot name="cellActionMenu" slot="menu"></slot>
</${menuButtonTag}>
`)}
Expand Down
4 changes: 2 additions & 2 deletions packages/nimble-components/src/table/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const template = html<Table>`
--ni-private-table-header-container-margin-right: ${x => x.virtualizer.headerContainerMarginRight}px;
--ni-private-table-scroll-height: ${x => x.virtualizer.scrollHeight}px;
--ni-private-table-row-container-top: ${x => x.virtualizer.rowContainerYOffset}px;
--ni-private-table-row-grid-columns: ${x => x.rowGridColumns ?? ''};
--ni-private-table-row-grid-columns: ${x => (x.rowGridColumns ? x.rowGridColumns : '')};
--ni-private-table-cursor-override: ${x => (x.layoutManager.isColumnBeingSized ? 'col-resize' : 'default')};
--ni-private-table-scrollable-min-width: ${x => x.tableScrollableMinWidth}px;
--ni-private-glass-overlay-pointer-events: ${x => (x.layoutManager.isColumnBeingSized ? 'none' : 'default')};
Expand All @@ -60,7 +60,7 @@ export const template = html<Table>`
<span class="checkbox-container">
<${checkboxTag}
${ref('selectionCheckbox')}
class="${x => `selection-checkbox ${x.selectionMode ?? ''}`}"
class="${x => `selection-checkbox ${x.selectionMode ? x.selectionMode : ''}`}"
@change="${(x, c) => x.onAllRowsSelectionChange(c.event as CustomEvent)}"
title="${x => tableSelectAllLabel.getValueFor(x)}"
aria-label="${x => tableSelectAllLabel.getValueFor(x)}"
Expand Down
Loading