#8745 - Refactor: Use nullish coalescing operator#9497
Open
bekaChaduneli wants to merge 1 commit intomasterfrom
Open
#8745 - Refactor: Use nullish coalescing operator#9497bekaChaduneli wants to merge 1 commit intomasterfrom
bekaChaduneli wants to merge 1 commit intomasterfrom
Conversation
…efault value handling
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
How the feature works? / How did you fix the issue?
Replaced logical OR (
||) operators with nullish coalescing (??) operators across all packages where the left-hand operand can only benullorundefined, following the@typescript-eslint/prefer-nullish-coalescingrule.Changes made:
ketcher-macromolecules–editorSlice.ts,useIndigoVersionToRedux.ts- Replacedprocess.env.X || ''with??process.env.BUILD_DATE || ''process.env.BUILD_DATE ?? ''ketcher-react–KetcherBuilder.ts- Replaced optional config params fallbacksbuttons || {},customButtons || [],process.env.VERSION || ''buttons ?? {},customButtons ?? [],process.env.VERSION ?? ''ketcher-react–sgroup.ts,select.ts,rotate-controller.ts- Replacededitor.selection() || {}and?.atoms || []patternsthis.editor.selection() || {}this.editor.selection() ?? {}ketcher-react– ContextMenu hooks (useAtomEdit,useBondEdit,useBondTypeChange,useChangeBondDirection,useRGroupAttachmentPointEdit,useRGroupAttachmentPointRemove) - Replaced optional prop fallbacksprops?.bondIds || []props?.bondIds ?? []ketcher-react– Toolbar containers (TopToolbar,BottomToolbar,LeftToolbar,RightToolbar,FloatingTools) - Replaced Redux state fallbacksstate.actionState || {}state.actionState ?? {}ketcher-core–Zoom.ts,BaseRenderer.ts,TransientDrawingView.ts- Replaced optional chained dimension fallbackscanvasWrapperBbox?.width || 0,ZoomTool.instance?.canvas || select(...)canvasWrapperBbox?.width ?? 0,ZoomTool.instance?.canvas ?? select(...)ketcher-core–remoteStructService.ts,SettingsManager.ts,rotate.ts,sgroup.ts,atom.ts,AttachmentPoint.ts- Replaced remaining optional-chain fallback patternsketcher-standalone–standaloneStructService.ts,indigoWorker.ts- Replacedselected || []andoptions || {}ketcher-macromolecules–rnaBuilderSlice.ts,librarySlice.ts,rnaBuilderSlice.helper.ts,manipulateCachedRnaPresets.ts,getMonomerName.ts,supportedFormatProperties.ts- Replaced label/preset/option fallbacksNote:
structConverter.tswas intentionally left unchanged — its||operators are boolean OR conditions in predicate logic (checking numeric0-based flags), where replacing with??would change semantics and introduce bugs.Approach: Only replaced
||with??when:T | null | undefinednull/undefined, not0,false, or""Check list
#1234 – issue name