lint(curly): consistent use of curly brackets in codebase (#3584)
This commit is contained in:
1 parent
9ae3d9f769
commit
5d435424e2
113 files changed
+1501
-1056
No files matched your search
@@ -11,7 +11,7 @@ const extensionManager = {
|
||||
registeredExtensionIds: [],
|
||||
moduleEntries: {},
|
||||
|
||||
getModuleEntry: function (id) {
|
||||
getModuleEntry: function(id) {
|
||||
return this.moduleEntries[id];
|
||||
},
|
||||
};
|
||||
@@ -20,7 +20,7 @@ const commandsManager = {};
|
||||
|
||||
const ohifOverlayItem = {
|
||||
id: 'ohif.overlayItem',
|
||||
content: function (props) {
|
||||
content: function(props) {
|
||||
return {
|
||||
label: this.label,
|
||||
value: props[this.attribute],
|
||||
|
||||
@@ -12,8 +12,12 @@ const flattenNestedStrings = (
|
||||
strs: NestedStrings | string,
|
||||
ret?: Record<string, string>
|
||||
): Record<string, string> => {
|
||||
if (!ret) ret = {};
|
||||
if (!strs) return ret;
|
||||
if (!ret) {
|
||||
ret = {};
|
||||
}
|
||||
if (!strs) {
|
||||
return ret;
|
||||
}
|
||||
if (Array.isArray(strs)) {
|
||||
for (const val of strs) {
|
||||
flattenNestedStrings(val, ret);
|
||||
@@ -81,7 +85,9 @@ export default class CustomizationService extends PubSubService {
|
||||
this.extensionManager.registeredExtensionIds.forEach(extensionId => {
|
||||
const key = `${extensionId}.customizationModule.default`;
|
||||
const defaultCustomizations = this.findExtensionValue(key);
|
||||
if (!defaultCustomizations) return;
|
||||
if (!defaultCustomizations) {
|
||||
return;
|
||||
}
|
||||
const { value } = defaultCustomizations;
|
||||
this.addReference(value, true);
|
||||
});
|
||||
@@ -172,9 +178,13 @@ export default class CustomizationService extends PubSubService {
|
||||
* type into the new type, allowing default behaviour to be configured.
|
||||
*/
|
||||
public transform(customization: Customization): Customization {
|
||||
if (!customization) return customization;
|
||||
if (!customization) {
|
||||
return customization;
|
||||
}
|
||||
const { customizationType } = customization;
|
||||
if (!customizationType) return customization;
|
||||
if (!customizationType) {
|
||||
return customization;
|
||||
}
|
||||
const parent = this.getCustomization(customizationType);
|
||||
const result = parent
|
||||
? Object.assign(Object.create(parent), customization)
|
||||
@@ -242,7 +252,9 @@ export default class CustomizationService extends PubSubService {
|
||||
* or a customization itself.
|
||||
*/
|
||||
addReference(value?: Obj | string, isGlobal = true, id?: string): void {
|
||||
if (!value) return;
|
||||
if (!value) {
|
||||
return;
|
||||
}
|
||||
if (typeof value === 'string') {
|
||||
const extensionValue = this.findExtensionValue(value);
|
||||
// The child of a reference is only a set of references when an array,
|
||||
@@ -265,7 +277,9 @@ export default class CustomizationService extends PubSubService {
|
||||
* or customization.
|
||||
*/
|
||||
addReferences(references?: Obj | Obj[], isGlobal = true): void {
|
||||
if (!references) return;
|
||||
if (!references) {
|
||||
return;
|
||||
}
|
||||
if (Array.isArray(references)) {
|
||||
references.forEach(item => {
|
||||
this.addReference(item, isGlobal);
|
||||
|
||||
@@ -157,7 +157,9 @@ export default class DisplaySetService extends PubSubService {
|
||||
}
|
||||
|
||||
public deleteDisplaySet(displaySetInstanceUID) {
|
||||
if (!displaySetInstanceUID) return;
|
||||
if (!displaySetInstanceUID) {
|
||||
return;
|
||||
}
|
||||
const { activeDisplaySets, activeDisplaySetsMap } = this;
|
||||
|
||||
const activeDisplaySetsIndex = activeDisplaySets.findIndex(
|
||||
@@ -314,7 +316,9 @@ export default class DisplaySetService extends PubSubService {
|
||||
}
|
||||
// This means that all instances already existed or got added to
|
||||
// existing display sets, and had an invalidated event fired
|
||||
if (!instances.length) return allDisplaySets;
|
||||
if (!instances.length) {
|
||||
return allDisplaySets;
|
||||
}
|
||||
}
|
||||
|
||||
if (!instances.length) {
|
||||
@@ -329,7 +333,9 @@ export default class DisplaySetService extends PubSubService {
|
||||
// creating additional display sets using the sop class handler
|
||||
displaySets = handler.getDisplaySetsFromSeries(instances);
|
||||
|
||||
if (!displaySets || !displaySets.length) continue;
|
||||
if (!displaySets || !displaySets.length) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// applying hp-defined viewport settings to the displaysets
|
||||
displaySets.forEach(ds => {
|
||||
|
||||
@@ -134,7 +134,7 @@ function checkHpsBestMatch(hps) {
|
||||
displaySetOptions: {
|
||||
id: 'displaySetSelector',
|
||||
options: {},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
@@ -192,6 +192,6 @@ describe('HangingProtocolService', () => {
|
||||
it('matches best image match', () => {
|
||||
checkHpsBestMatch(hangingProtocolService);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -86,7 +86,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
metadata.ModalitiesInStudy ??
|
||||
(metadata.series || []).reduce((prev, curr) => {
|
||||
const { Modality } = curr;
|
||||
if (Modality && prev.indexOf(Modality) == -1) prev.push(Modality);
|
||||
if (Modality && prev.indexOf(Modality) == -1) {
|
||||
prev.push(Modality);
|
||||
}
|
||||
return prev;
|
||||
}, []),
|
||||
},
|
||||
@@ -200,7 +202,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
* protocolId, stageIndex, stageId and activeStudyUID
|
||||
*/
|
||||
public getState(): HangingProtocol.HPInfo {
|
||||
if (!this.protocol) return;
|
||||
if (!this.protocol) {
|
||||
return;
|
||||
}
|
||||
return {
|
||||
protocolId: this.protocol.id,
|
||||
stageIndex: this.stageIndex,
|
||||
@@ -257,8 +261,12 @@ export default class HangingProtocolService extends PubSubService {
|
||||
* @returns protocol - the protocol with the given id
|
||||
*/
|
||||
public getProtocolById(protocolId: string): HangingProtocol.Protocol {
|
||||
if (!protocolId) return;
|
||||
if (protocolId === this.protocol?.id) return this.protocol;
|
||||
if (!protocolId) {
|
||||
return;
|
||||
}
|
||||
if (protocolId === this.protocol?.id) {
|
||||
return this.protocol;
|
||||
}
|
||||
const protocol = this.protocols.get(protocolId);
|
||||
if (!protocol) {
|
||||
throw new Error(`No protocol ${protocolId} found`);
|
||||
@@ -697,7 +705,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const { id } = displaySet;
|
||||
const displaySetMatchDetail = displaySetMatchDetails.get(id);
|
||||
|
||||
const { displaySetInstanceUID: oldDisplaySetInstanceUID } = displaySetMatchDetail;
|
||||
const {
|
||||
displaySetInstanceUID: oldDisplaySetInstanceUID,
|
||||
} = displaySetMatchDetail;
|
||||
|
||||
const displaySetInstanceUID =
|
||||
displaySet.id === displaySetSelectorId
|
||||
@@ -730,8 +740,12 @@ export default class HangingProtocolService extends PubSubService {
|
||||
);
|
||||
}
|
||||
|
||||
if (options === null) return options;
|
||||
if (typeof options !== 'object') return options;
|
||||
if (options === null) {
|
||||
return options;
|
||||
}
|
||||
if (typeof options !== 'object') {
|
||||
return options;
|
||||
}
|
||||
|
||||
// If options is an object with a custom attribute, compute a new options object
|
||||
if (options.custom) {
|
||||
@@ -892,7 +906,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
if (stageId) {
|
||||
for (let i = 0; i < stages.length; i++) {
|
||||
const stage = stages[i];
|
||||
if (stage.id === stageId && stage.status !== 'disabled') return i;
|
||||
if (stage.id === stageId && stage.status !== 'disabled') {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -905,7 +921,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
let firstNotDisabled: number;
|
||||
|
||||
for (let i = 0; i < stages.length; i++) {
|
||||
if (stages[i].status === 'enabled') return i;
|
||||
if (stages[i].status === 'enabled') {
|
||||
return i;
|
||||
}
|
||||
if (firstNotDisabled === undefined && stages[i].status !== 'disabled') {
|
||||
firstNotDisabled = i;
|
||||
}
|
||||
@@ -979,7 +997,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
if (stageId !== undefined) {
|
||||
return protocol.stages.findIndex(it => it.id === stageId);
|
||||
}
|
||||
if (stageIndex !== undefined) return stageIndex;
|
||||
if (stageIndex !== undefined) {
|
||||
return stageIndex;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1050,9 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const protocol = this.protocol;
|
||||
const stage = protocol.stages[stageIdx];
|
||||
const defaultViewport = stage.defaultViewport || protocol.defaultViewport;
|
||||
if (!defaultViewport) return;
|
||||
if (!defaultViewport) {
|
||||
return;
|
||||
}
|
||||
|
||||
const useViewport = { ...defaultViewport };
|
||||
return this._matchViewport(useViewport, options);
|
||||
@@ -1152,12 +1174,18 @@ export default class HangingProtocolService extends PubSubService {
|
||||
offset: number,
|
||||
options: HangingProtocol.SetProtocolOptions = {}
|
||||
): HangingProtocol.DisplaySetMatchDetails {
|
||||
if (!matchDetails) return;
|
||||
if (offset === 0) return matchDetails;
|
||||
if (!matchDetails) {
|
||||
return;
|
||||
}
|
||||
if (offset === 0) {
|
||||
return matchDetails;
|
||||
}
|
||||
const { matchingScores = [] } = matchDetails;
|
||||
if (offset === -1) {
|
||||
const { inDisplay } = options;
|
||||
if (!inDisplay) return matchDetails;
|
||||
if (!inDisplay) {
|
||||
return matchDetails;
|
||||
}
|
||||
for (let i = 0; i < matchDetails.matchingScores.length; i++) {
|
||||
if (
|
||||
inDisplay.indexOf(
|
||||
@@ -1184,12 +1212,16 @@ export default class HangingProtocolService extends PubSubService {
|
||||
id: string,
|
||||
displaySetUID: string
|
||||
): void {
|
||||
if (match.displaySetInstanceUID === displaySetUID) return;
|
||||
if (match.displaySetInstanceUID === displaySetUID) {
|
||||
return;
|
||||
}
|
||||
if (!match.matchingScores) {
|
||||
throw new Error('No matchingScores found in ' + match);
|
||||
}
|
||||
for (const subMatch of match.matchingScores) {
|
||||
if (subMatch.displaySetInstanceUID === displaySetUID) return;
|
||||
if (subMatch.displaySetInstanceUID === displaySetUID) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
throw new Error(
|
||||
`Reused viewport details ${id} with ds ${displaySetUID} not valid`
|
||||
@@ -1391,21 +1423,23 @@ export default class HangingProtocolService extends PubSubService {
|
||||
const matchActiveOnly = this.protocol.numberOfPriorsReferenced === -1;
|
||||
this.studies.forEach(study => {
|
||||
// Skip non-active if active only
|
||||
if (matchActiveOnly && this.activeStudy !== study) return;
|
||||
if (matchActiveOnly && this.activeStudy !== study) {
|
||||
return;
|
||||
}
|
||||
|
||||
const studyDisplaySets = this.displaySets.filter(
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID
|
||||
it => it.StudyInstanceUID === study.StudyInstanceUID
|
||||
);
|
||||
|
||||
const studyMatchDetails = this.protocolEngine.findMatch(
|
||||
study,
|
||||
studyMatchingRules,
|
||||
{
|
||||
studies: this.studies,
|
||||
displaySets: studyDisplaySets,
|
||||
allDisplaySets: this.displaySets,
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
}
|
||||
study,
|
||||
studyMatchingRules,
|
||||
{
|
||||
studies: this.studies,
|
||||
displaySets: studyDisplaySets,
|
||||
allDisplaySets: this.displaySets,
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
}
|
||||
);
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
@@ -1414,10 +1448,10 @@ export default class HangingProtocolService extends PubSubService {
|
||||
}
|
||||
|
||||
this.debug(
|
||||
'study',
|
||||
study.StudyInstanceUID,
|
||||
'display sets #',
|
||||
studyDisplaySets.length
|
||||
'study',
|
||||
study.StudyInstanceUID,
|
||||
'display sets #',
|
||||
studyDisplaySets.length
|
||||
);
|
||||
studyDisplaySets.forEach(displaySet => {
|
||||
const {
|
||||
@@ -1426,15 +1460,15 @@ export default class HangingProtocolService extends PubSubService {
|
||||
displaySetInstanceUID,
|
||||
} = displaySet;
|
||||
const seriesMatchDetails = this.protocolEngine.findMatch(
|
||||
displaySet,
|
||||
seriesMatchingRules,
|
||||
// Todo: why we have images here since the matching type does not have it
|
||||
{
|
||||
studies: this.studies,
|
||||
instance: displaySet.images?.[0],
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
displaySets: studyDisplaySets,
|
||||
}
|
||||
displaySet,
|
||||
seriesMatchingRules,
|
||||
// Todo: why we have images here since the matching type does not have it
|
||||
{
|
||||
studies: this.studies,
|
||||
instance: displaySet.images?.[0],
|
||||
displaySetMatchDetails: this.displaySetMatchDetails,
|
||||
displaySets: studyDisplaySets,
|
||||
}
|
||||
);
|
||||
|
||||
// Prevent bestMatch from being updated if the matchDetails' required attribute check has failed
|
||||
|
||||
+9
-3
@@ -13,7 +13,9 @@ const isDisplaySetFromUrl = (displaySet): boolean => {
|
||||
params
|
||||
);
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid', params);
|
||||
if (!initialSeriesInstanceUID && !initialSOPInstanceUID) return false;
|
||||
if (!initialSeriesInstanceUID && !initialSOPInstanceUID) {
|
||||
return false;
|
||||
}
|
||||
const isSeriesMatch =
|
||||
!initialSeriesInstanceUID ||
|
||||
initialSeriesInstanceUID.some(
|
||||
@@ -32,9 +34,13 @@ const isDisplaySetFromUrl = (displaySet): boolean => {
|
||||
*/
|
||||
function sopInstanceLocation(displaySets) {
|
||||
const displaySet = displaySets?.[0];
|
||||
if (!displaySet) return;
|
||||
if (!displaySet) {
|
||||
return;
|
||||
}
|
||||
const initialSOPInstanceUID = getSplitParam('initialsopinstanceuid');
|
||||
if (!initialSOPInstanceUID) return;
|
||||
if (!initialSOPInstanceUID) {
|
||||
return;
|
||||
}
|
||||
|
||||
const index = displaySet.instances.findIndex(instance =>
|
||||
initialSOPInstanceUID.includes(instance.SOPInstanceUID)
|
||||
|
||||
+4
-3
@@ -1,5 +1,6 @@
|
||||
export default (study, extraData) => {
|
||||
const ret = extraData?.displaySets?.filter(ds => ds.numImageFrames>0)?.length;
|
||||
console.log("number of display sets with images", ret);
|
||||
const ret = extraData?.displaySets?.filter(ds => ds.numImageFrames > 0)
|
||||
?.length;
|
||||
console.log('number of display sets with images', ret);
|
||||
return ret;
|
||||
};
|
||||
};
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
export default (study, extraData) => extraData?.displaySets?.map(ds => ds.SeriesDescription);
|
||||
export default (study, extraData) =>
|
||||
extraData?.displaySets?.map(ds => ds.SeriesDescription);
|
||||
@@ -111,10 +111,12 @@ validate.validators.includes = function(value, options, key) {
|
||||
const includedValues = testValue.filter(el => dicomArrayValue.includes(el));
|
||||
if (includedValues.length === 0) {
|
||||
return `${key} must include at least one of the following values: ${testValue.join(
|
||||
', '
|
||||
', '
|
||||
)}`;
|
||||
}
|
||||
} else return `${key} ${testValue} must be an array`;
|
||||
} else {
|
||||
return `${key} ${testValue} must be an array`;
|
||||
}
|
||||
// else if (!value.includes(testValue)) {
|
||||
// return `${key} ${value} must include ${testValue}`;
|
||||
// }
|
||||
@@ -151,7 +153,9 @@ validate.validators.doesNotInclude = function(value, options, key) {
|
||||
if (includedValues.length > 0) {
|
||||
return `${key} must not include the following value: ${includedValues}`;
|
||||
}
|
||||
} else return `${key} ${testValue} must be an array`;
|
||||
} else {
|
||||
return `${key} ${testValue} must be an array`;
|
||||
}
|
||||
};
|
||||
// Ignore case contains.
|
||||
// options testValue MUST be in lower case already, otherwise it won't match
|
||||
@@ -175,31 +179,31 @@ validate.validators.containsI = function(value, options, key) {
|
||||
const testValue = getTestValue(options);
|
||||
if (Array.isArray(value)) {
|
||||
if (
|
||||
value.some(
|
||||
item => !validate.validators.containsI(item.toLowerCase(), options, key)
|
||||
)
|
||||
value.some(
|
||||
item => !validate.validators.containsI(item.toLowerCase(), options, key)
|
||||
)
|
||||
) {
|
||||
return undefined;
|
||||
}
|
||||
return `No item of ${value.join(',')} contains ${JSON.stringify(
|
||||
testValue
|
||||
testValue
|
||||
)}`;
|
||||
}
|
||||
if (Array.isArray(testValue)) {
|
||||
if (
|
||||
testValue.some(
|
||||
subTest =>
|
||||
!validate.validators.containsI(value, subTest.toLowerCase(), key)
|
||||
)
|
||||
testValue.some(
|
||||
subTest =>
|
||||
!validate.validators.containsI(value, subTest.toLowerCase(), key)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
return `${key} must contain at least one of ${testValue.join(',')}`;
|
||||
}
|
||||
if (
|
||||
testValue &&
|
||||
value.indexOf &&
|
||||
value.toLowerCase().indexOf(testValue.toLowerCase()) === -1
|
||||
testValue &&
|
||||
value.indexOf &&
|
||||
value.toLowerCase().indexOf(testValue.toLowerCase()) === -1
|
||||
) {
|
||||
return key + 'must contain any case of' + testValue;
|
||||
}
|
||||
@@ -227,14 +231,14 @@ validate.validators.contains = function(value, options, key) {
|
||||
return undefined;
|
||||
}
|
||||
return `No item of ${value.join(',')} contains ${JSON.stringify(
|
||||
testValue
|
||||
testValue
|
||||
)}`;
|
||||
}
|
||||
if (Array.isArray(testValue)) {
|
||||
if (
|
||||
testValue.some(
|
||||
subTest => !validate.validators.contains(value, subTest, key)
|
||||
)
|
||||
testValue.some(
|
||||
subTest => !validate.validators.contains(value, subTest, key)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -454,11 +458,13 @@ validate.validators.range = function(value, options, key) {
|
||||
if (value === undefined || value < min || value > max) {
|
||||
return `${key} with value ${value} must be between ${min} and ${max}`;
|
||||
}
|
||||
} else return `${key} must be an array of length 2`;
|
||||
} else {
|
||||
return `${key} must be an array of length 2`;
|
||||
}
|
||||
};
|
||||
|
||||
validate.validators.notNull = value =>
|
||||
value === null || value === undefined ? 'Value is null' : undefined;
|
||||
value === null || value === undefined ? 'Value is null' : undefined;
|
||||
const getTestValue = options => {
|
||||
if (Array.isArray(options)) {
|
||||
return options.map(option => option?.value ?? option);
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -40,7 +40,7 @@ export default class StateSyncService extends PubSubService {
|
||||
this.configuration = configuration || {};
|
||||
}
|
||||
|
||||
public init(extensionManager: ExtensionManager): void { }
|
||||
public init(extensionManager: ExtensionManager): void {}
|
||||
|
||||
/** Registers a new sync store called `id`. The state
|
||||
* defines how the state is stored, and any default clearing of the
|
||||
|
||||
@@ -66,7 +66,9 @@ export default class ToolbarService extends PubSubService {
|
||||
* called with {...commandOptions,...options}
|
||||
*/
|
||||
recordInteraction(interaction, options?: Record<string, unknown>) {
|
||||
if (!interaction) return;
|
||||
if (!interaction) {
|
||||
return;
|
||||
}
|
||||
const commandsManager = this._commandsManager;
|
||||
const { groupId, itemId, interactionType, commands } = interaction;
|
||||
|
||||
|
||||
@@ -35,10 +35,16 @@ const addUniqueIndex = (arr, key, viewports, isUpdatingSameViewport) => {
|
||||
};
|
||||
|
||||
const getLutId = (ds): string => {
|
||||
if (!ds || !ds.options) return DEFAULT;
|
||||
if (ds.options.id) return ds.options.id;
|
||||
if (!ds || !ds.options) {
|
||||
return DEFAULT;
|
||||
}
|
||||
if (ds.options.id) {
|
||||
return ds.options.id;
|
||||
}
|
||||
const arr = Object.entries(ds.options).map(([key, val]) => `${key}=${val}`);
|
||||
if (!arr.length) return DEFAULT;
|
||||
if (!arr.length) {
|
||||
return DEFAULT;
|
||||
}
|
||||
return arr.join(JOIN_STR);
|
||||
};
|
||||
|
||||
@@ -93,7 +99,9 @@ export type PresentationIds = {
|
||||
* @returns PresentationIds
|
||||
*/
|
||||
const getPresentationIds = (viewport, viewports): PresentationIds => {
|
||||
if (!viewport) return;
|
||||
if (!viewport) {
|
||||
return;
|
||||
}
|
||||
const {
|
||||
viewportOptions,
|
||||
displaySetInstanceUIDs,
|
||||
@@ -108,7 +116,9 @@ const getPresentationIds = (viewport, viewports): PresentationIds => {
|
||||
const lutPresentationArr = [lutId];
|
||||
|
||||
const positionPresentationArr = [orientation || 'acquisition'];
|
||||
if (id) positionPresentationArr.push(id);
|
||||
if (id) {
|
||||
positionPresentationArr.push(id);
|
||||
}
|
||||
|
||||
for (const uid of displaySetInstanceUIDs) {
|
||||
positionPresentationArr.push(uid);
|
||||
|
||||
Reference in new issue
Block a user