Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
Frizi committed Jan 6, 2025
1 parent 06eecc1 commit 3799b99
Show file tree
Hide file tree
Showing 30 changed files with 52 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/common/src/services/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ export function findLeastUsedColor(labels: Iterable<Label>) {
}
const min = Math.min(...colorCounts.values())
const [minColor] = [...colorCounts.entries()].find(kv => kv[1] === min) ?? []
return minColor == null ? COLORS[0] : COLOR_STRING_TO_COLOR.get(minColor) ?? COLORS[0]
return minColor == null ? COLORS[0] : (COLOR_STRING_TO_COLOR.get(minColor) ?? COLORS[0])
}

// =================
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/components/JSONSchemaInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default function JSONSchemaInput(props: JSONSchemaInputProps) {
'format' in schema &&
schema.format === 'enso-secret'
const { data: secrets } = useBackendQuery(remoteBackend, 'listSecrets', [], { enabled: isSecret })
const autocompleteItems = isSecret ? secrets?.map((secret) => secret.path) ?? null : null
const autocompleteItems = isSecret ? (secrets?.map((secret) => secret.path) ?? null) : null
const isInvalid = !isAbsent && !getValidator(path)(value)
const validationErrorClassName =
isInvalid && 'border border-danger focus:border-danger focus:outline-danger'
Expand Down Expand Up @@ -190,7 +190,7 @@ export default function JSONSchemaInput(props: JSONSchemaInputProps) {
break
}
case 'object': {
const propertiesObject = 'properties' in schema ? asObject(schema.properties) ?? {} : {}
const propertiesObject = 'properties' in schema ? (asObject(schema.properties) ?? {}) : {}
const requiredProperties =
'required' in schema && Array.isArray(schema.required) ? schema.required : []
const propertyDefinitions = Object.entries(propertiesObject).flatMap(
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/components/Paywall/UpgradeButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function UpgradeButton(props: UpgradeButtonProps) {
size={size}
rounded={rounded}
href={
isEnterprise ? appUtils.getContactSalesURL() : href ?? appUtils.getUpgradeURL(level.name)
isEnterprise ? appUtils.getContactSalesURL() : (href ?? appUtils.getUpgradeURL(level.name))
}
/* This is safe because we are passing all props to the button */
/* eslint-disable-next-line @typescript-eslint/no-explicit-any,no-restricted-syntax */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ export default function KeyboardShortcut(props: KeyboardShortcutProps) {
<Text key={modifier}>{getText(MODIFIER_TO_TEXT_ID[modifier])}</Text>
),
)}
<Text>{shortcut.key === ' ' ? 'Space' : KEY_CHARACTER[shortcut.key] ?? shortcut.key}</Text>
<Text>
{shortcut.key === ' ' ? 'Space' : (KEY_CHARACTER[shortcut.key] ?? shortcut.key)}
</Text>
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/AssetProperties.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ function AssetPropertiesInternal(props: AssetPropertiesInternalProps) {
const updateSecretMutation = useMutation(backendMutationOptions(backend, 'updateSecret'))
const displayedDescription =
editDescriptionMutation.variables?.[0] === item.id ?
editDescriptionMutation.variables[1].description ?? item.description
(editDescriptionMutation.variables[1].description ?? item.description)
: item.description

const editDescriptionForm = Form.useForm({
Expand Down
6 changes: 4 additions & 2 deletions app/gui/src/dashboard/layouts/AssetsTableContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ export default function AssetsTableContextMenu(props: AssetsTableContextMenuProp
} else {
const [firstKey] = selectedKeys
const soleAssetName =
firstKey != null ? nodeMapRef.current.get(firstKey)?.item.title ?? '(unknown)' : '(unknown)'
firstKey != null ?
(nodeMapRef.current.get(firstKey)?.item.title ?? '(unknown)')
: '(unknown)'
setModal(
<ConfirmDeleteModal
defaultOpen
Expand Down Expand Up @@ -179,7 +181,7 @@ export default function AssetsTableContextMenu(props: AssetsTableContextMenuProp
const [firstKey] = selectedKeys
const soleAssetName =
firstKey != null ?
nodeMapRef.current.get(firstKey)?.item.title ?? '(unknown)'
(nodeMapRef.current.get(firstKey)?.item.title ?? '(unknown)')
: '(unknown)'
setModal(
<ConfirmDeleteModal
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/layouts/Settings/FormEntry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function SettingsFormEntry<T extends Record<keyof T, string>>(
const isEditable = data.inputs.some((inputData) =>
typeof inputData.editable === 'boolean' ?
inputData.editable
: inputData.editable?.(context) ?? true,
: (inputData.editable?.(context) ?? true),
)

const form = Form.useForm({
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/layouts/Settings/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ export default function SettingsInput<T extends Record<keyof T, string>>(
} = data
const { getText } = useText()

const isEditable = typeof editable === 'function' ? editable(context) : editable ?? true
const hidden = typeof hiddenRaw === 'function' ? hiddenRaw(context) : hiddenRaw ?? false
const isEditable = typeof editable === 'function' ? editable(context) : (editable ?? true)
const hidden = typeof hiddenRaw === 'function' ? hiddenRaw(context) : (hiddenRaw ?? false)

const Input = INPUT_TYPE_MAP[type]

Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/layouts/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export default function Settings() {
)
}
}, [isQueryBlank, doesEntryMatchQuery, getText, isMatch])
const effectiveTab = tabsToShow.includes(tab) ? tab : tabsToShow[0] ?? SettingsTabType.account
const effectiveTab = tabsToShow.includes(tab) ? tab : (tabsToShow[0] ?? SettingsTabType.account)

const data = React.useMemo<SettingsTabData>(() => {
const tabData = SETTINGS_TAB_DATA[effectiveTab]
Expand Down Expand Up @@ -226,7 +226,7 @@ export default function Settings() {
className="ml-2.5 mr-8 max-w-[min(32rem,_100%)] rounded-full bg-white px-2.5 font-bold"
aria-hidden
>
{data.organizationOnly === true ? organization?.name ?? 'your organization' : user.name}
{data.organizationOnly === true ? (organization?.name ?? 'your organization') : user.name}
</Text>
</Heading>
<div className="sm:ml-[14rem]">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function eventToPartialShortcut(event: KeyboardEvent | ReactKeyboardEvent) {
null
: event.key === ' ' ? 'Space'
: event.key === DELETE_KEY ? 'OsDelete'
: normalizedKeyboardSegmentLookup[event.key.toLowerCase()] ?? event.key
: (normalizedKeyboardSegmentLookup[event.key.toLowerCase()] ?? event.key)
return { key, modifiers }
}

Expand Down
10 changes: 5 additions & 5 deletions app/gui/src/dashboard/pages/authentication/Setup/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const BASE_STEPS: Step[] = [

const isUserCreated = userSession?.type === UserSessionType.full
const defaultName =
session && 'user' in session ? session.user.name : userSession?.email ?? ''
session && 'user' in session ? session.user.name : (userSession?.email ?? '')

return (
<ariaComponents.Form
Expand Down Expand Up @@ -351,7 +351,7 @@ export function Setup() {

const [searchParams] = useSearchParams()

const userPlan = session && 'user' in session ? session.user.plan ?? Plan.free : Plan.free
const userPlan = session && 'user' in session ? (session.user.plan ?? Plan.free) : Plan.free

const steps = BASE_STEPS
const isDebug = searchParams.get('__qd-debg__') === 'true'
Expand Down Expand Up @@ -404,15 +404,15 @@ export function Setup() {
const hideNext =
typeof currentScreen.hideNext === 'function' ?
currentScreen.hideNext(context)
: currentScreen.hideNext ?? false
: (currentScreen.hideNext ?? false)
const canSkip =
typeof currentScreen.canSkip === 'function' ?
currentScreen.canSkip(context)
: currentScreen.canSkip ?? false
: (currentScreen.canSkip ?? false)
const hidePrevious =
typeof currentScreen.hidePrevious === 'function' ?
currentScreen.hidePrevious(context)
: currentScreen.hidePrevious ?? false
: (currentScreen.hidePrevious ?? false)

return (
<Page>
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/utilities/AssetTreeNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class AssetTreeNode<Item extends backendModule.AnyAsset = backend
update.directoryId ?? this.directoryId,
// `null` MUST be special-cases in the following line.
// eslint-disable-next-line eqeqeq
update.children === null ? update.children : update.children ?? this.children,
update.children === null ? update.children : (update.children ?? this.children),
update.depth ?? this.depth,
update.path ?? this.path,
update.initialAssetEvents ?? this.initialAssetEvents,
Expand Down Expand Up @@ -184,7 +184,7 @@ export default class AssetTreeNode<Item extends backendModule.AnyAsset = backend
}
return result?.children?.length === 0 ?
result.with({ children: null })
: result ?? this.asUnion()
: (result ?? this.asUnion())
}

/** Returns all items in the tree, flattened into an array using pre-order traversal. */
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/utilities/Debug.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Debug(props: DebugProps) {
children,
} = props
const childPropsRaw: unknown = children.props
const childProps: object = typeof childPropsRaw === 'object' ? childPropsRaw ?? {} : {}
const childProps: object = typeof childPropsRaw === 'object' ? (childPropsRaw ?? {}) : {}
const propsValues: unknown[] = Object.values(childProps)
const typeRaw: unknown = children.type
const typeName =
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/dashboard/utilities/Navigator2D.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export default class Navigator2D {
const focusTargetNeighbor = neighbor instanceof HTMLElement ? neighbor.focus.bind(null) : null
const focus =
neighbor == null ? null : (
this.elements.get(neighbor)?.focusWhenPressed[direction] ?? focusTargetNeighbor
(this.elements.get(neighbor)?.focusWhenPressed[direction] ?? focusTargetNeighbor)
)
if (focus != null) {
event.preventDefault()
Expand Down Expand Up @@ -388,7 +388,7 @@ export default class Navigator2D {
// eslint-disable-next-line eqeqeq
options.focusWhenPressed?.[direction] === null ?
null
: options.focusWhenPressed?.[direction] ?? options.focusPrimaryChild ?? null,
: (options.focusWhenPressed?.[direction] ?? options.focusPrimaryChild ?? null),
),
dispose,
})
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/utilities/drag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DragPayloadManager<Payload> {
dataTransferItem.type.startsWith(this.mimetype),
)
const id = item?.type.match(this.regex)?.[1] ?? null
return id != null ? this.map.get(id) ?? null : null
return id != null ? (this.map.get(id) ?? null) : null
}

/** Associate data with a {@link React.DragEvent}. */
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/dashboard/utilities/jsonSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ function constantValueOfSchemaHelper(
}
case 'object': {
const propertiesObject =
'properties' in schema ? objectModule.asObject(schema.properties) ?? {} : {}
'properties' in schema ? (objectModule.asObject(schema.properties) ?? {}) : {}
const required = new Set(
'required' in schema && Array.isArray(schema.required) ?
schema.required.map(String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const sourceMask = computed<NodeMask | undefined>(() => {
if (!nodeRect) return
const animProgress =
startsInPort.value ?
(sourceNode.value && graph.nodeHoverAnimations.get(sourceNode.value)) ?? 0
((sourceNode.value && graph.nodeHoverAnimations.get(sourceNode.value)) ?? 0)
: 0
const padding = animProgress * VISIBLE_PORT_MASK_PADDING
if (!maskSource && padding === 0) return
Expand Down
10 changes: 5 additions & 5 deletions app/gui/src/project-view/components/GraphEditor/GraphNode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -472,16 +472,16 @@ const showMenuAt = ref<{ x: number; y: number }>()
:style="nodeStyle"
:class="nodeClass"
:data-node-id="nodeId"
@pointerenter="(nodeHovered = true), updateNodeHover($event)"
@pointerleave="(nodeHovered = false), updateNodeHover(undefined)"
@pointerenter="((nodeHovered = true), updateNodeHover($event))"
@pointerleave="((nodeHovered = false), updateNodeHover(undefined))"
@pointermove="updateNodeHover"
>
<div class="binding" v-text="node.pattern?.code()" />
<button
v-if="!menuVisible && isRecordingOverridden"
class="overrideRecordButton clickable"
data-testid="recordingOverriddenButton"
@click="(isRecordingOverridden = false), setSoleSelected()"
@click="((isRecordingOverridden = false), setSoleSelected())"
>
<SvgIcon name="record" />
</button>
Expand Down Expand Up @@ -527,7 +527,7 @@ const showMenuAt = ref<{ x: number; y: number }>()
:style="contentNodeStyle"
v-on="dragPointer.events"
@click="handleNodeClick"
@contextmenu.stop.prevent="ensureSelected(), (showMenuAt = $event)"
@contextmenu.stop.prevent="(ensureSelected(), (showMenuAt = $event))"
>
<ComponentWidgetTree
:ast="props.node.innerExpr"
Expand Down Expand Up @@ -559,7 +559,7 @@ const showMenuAt = ref<{ x: number; y: number }>()
:nodeId="nodeId"
:forceVisible="nodeHovered"
@newNodeClick="
setSoleSelected(), emit('createNodes', [{ commit: false, content: undefined }])
(setSoleSelected(), emit('createNodes', [{ commit: false, content: undefined }]))
"
@portClick="(...args) => emit('outputPortClick', ...args)"
@portDoubleClick="(...args) => emit('outputPortDoubleClick', ...args)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const textContents = computed(() =>
props.input.value instanceof Ast.TextLiteral ? props.input.value.rawTextContent : '',
)
const placeholder = computed(() =>
WidgetInput.isPlaceholder(props.input) ? inputTextLiteral.value?.rawTextContent ?? '' : '',
WidgetInput.isPlaceholder(props.input) ? (inputTextLiteral.value?.rawTextContent ?? '') : '',
)
const editedContents = ref(textContents.value)
watch(textContents, (value) => (editedContents.value = value))
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/project-view/components/ResizeHandles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ const handler = {
& circle {
pointer-events: all;
r: calc(
var(--resize-handle-radius, 0) + (var(--resize-handle-outside) - var(--resize-handle-inside)) /
2
var(--resize-handle-radius, 0) +
(var(--resize-handle-outside) - var(--resize-handle-inside)) / 2
);
stroke: transparent;
stroke-width: calc(var(--resize-handle-inside) + var(--resize-handle-outside));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ const { AgGridVue } = await import('ag-grid-vue3')
:allowContextMenuWithControlKey="true"
@gridReady="onGridReady"
@firstDataRendered="updateColumnWidths"
@rowDataUpdated="updateColumnWidths($event), emit('rowDataUpdated', $event)"
@rowDataUpdated="(updateColumnWidths($event), emit('rowDataUpdated', $event))"
@columnResized="lockColumnSize"
@cellEditingStarted="emit('cellEditingStarted', $event)"
@cellEditingStopped="emit('cellEditingStopped', $event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ watchEffect(() => {
rawBins.value = rawData.data?.bins ?? undefined
}
const values = Array.isArray(newData) ? newData : newData?.values ?? []
const values = Array.isArray(newData) ? newData : (newData?.values ?? [])
points.value = values.filter((value) => typeof value === 'number' && !Number.isNaN(value))
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ const data = computed<Data>(() => {
Array.isArray(rawData) ?
// eslint-disable-next-line camelcase
rawData.map((y, index) => ({ x: index, y, row_number: index }))
: rawData.data ?? []
: (rawData.data ?? [])
let data: Point[]
const isTimeSeries: boolean =
'x_value_type' in rawData ?
Expand Down Expand Up @@ -526,7 +526,7 @@ watch([boxWidth, boxHeight], () => (shouldAnimate.value = false))
/** Helper function to match a d3 shape from its name. */
function matchShape(d: Point) {
return d.shape != null ? SHAPE_TO_SYMBOL[d.shape] ?? d3.symbolCircle : d3.symbolCircle
return d.shape != null ? (SHAPE_TO_SYMBOL[d.shape] ?? d3.symbolCircle) : d3.symbolCircle
}
watchEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ watchEffect(() => {
...dataHeader,
]
: dataHeader
const rows = data_.data && data_.data.length > 0 ? data_.data[0]?.length ?? 0 : 0
const rows = data_.data && data_.data.length > 0 ? (data_.data[0]?.length ?? 0) : 0
rowData.value = Array.from({ length: rows }, (_, i) => {
const shift = data_.has_index_col ? 1 : 0
return Object.fromEntries(
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/project-view/composables/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export function keyboardBusyExceptIn(el: Opt<Element>) {
}

const hasWindow = typeof window !== 'undefined'
const platform = hasWindow ? window.navigator?.platform ?? '' : ''
const platform = hasWindow ? (window.navigator?.platform ?? '') : ''
export const isMacLike = /(Mac|iPhone|iPod|iPad)/i.test(platform)

/** Check if `mod` key (ctrl or cmd) appropriate for current platform is used */
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/project-view/composables/nodeCreation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export function useNodeCreation(
function placeNode(placement: PlacementStrategy, place: (nodes?: Iterable<Rect>) => Vec2): Vec2 {
return (
placement.type === 'viewport' ? place()
: placement.type === 'mouse' ? tryMouse() ?? place()
: placement.type === 'mouseRelative' ? tryMouseRelative(placement.posOffset) ?? place()
: placement.type === 'mouse' ? (tryMouse() ?? place())
: placement.type === 'mouseRelative' ? (tryMouseRelative(placement.posOffset) ?? place())
: placement.type === 'mouseEvent' ? mouseDictatedPlacement(placement.position)
: placement.type === 'source' ?
place(iter.filterDefined([graphStore.visibleArea(placement.node)]))
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/project-view/stores/graph/graphDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class GraphDb {

/** TODO: Add docs */
getNodeFirstOutputPort(id: NodeId | undefined): AstId | undefined {
return id ? set.first(this.nodeOutputPorts.lookup(id)) ?? this.idFromExternal(id) : undefined
return id ? (set.first(this.nodeOutputPorts.lookup(id)) ?? this.idFromExternal(id)) : undefined
}

/** TODO: Add docs */
Expand Down
4 changes: 2 additions & 2 deletions app/gui/src/project-view/util/callTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ abstract class Argument {
* represented in the AST.
*/
export class ArgumentPlaceholder extends Argument {
public declare index: number
public declare argInfo: SuggestionEntryArgument
declare public index: number
declare public argInfo: SuggestionEntryArgument
/** TODO: Add docs */
constructor(
callId: string,
Expand Down
2 changes: 1 addition & 1 deletion app/gui/src/project-view/util/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const STRING_TO_BOOLEAN: Record<string, boolean> = {
function parseBoolean(value: unknown): boolean | null {
return (
typeof value === 'boolean' ? value
: typeof value === 'string' ? STRING_TO_BOOLEAN[value] ?? null
: typeof value === 'string' ? (STRING_TO_BOOLEAN[value] ?? null)
: null
)
}
Expand Down
2 changes: 1 addition & 1 deletion app/ydoc-shared/src/ast/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2180,7 +2180,7 @@ export class Group extends BaseExpression {
if (open) yield firstChild(open)
const spaced = ((open && expression?.whitespace) ?? '') !== ''
if (expression) yield open ? preferSpacedIf(expression, spaced) : firstChild(expression)
if (close) yield open ?? expression ? preferSpacedIf(close, spaced) : firstChild(close)
if (close) yield (open ?? expression) ? preferSpacedIf(close, spaced) : firstChild(close)
}
}
/** TODO: Add docs */
Expand Down

0 comments on commit 3799b99

Please sign in to comment.