chore(prettier): full repo linting and code reformatting once and for all (#3627)
This commit is contained in:
1 parent
01500a2d4c
commit
9045ddaedc
656 files changed
+21737
-20628
No files matched your search
@@ -94,10 +94,7 @@ describe('CommandsManager', () => {
|
||||
|
||||
describe('getCommand()', () => {
|
||||
it('returns undefined if context does not exist', () => {
|
||||
const result = commandsManager.getCommand(
|
||||
'TestCommand',
|
||||
'NonExistentContext'
|
||||
);
|
||||
const result = commandsManager.getCommand('TestCommand', 'NonExistentContext');
|
||||
|
||||
expect(result).toBe(undefined);
|
||||
});
|
||||
@@ -131,9 +128,7 @@ describe('CommandsManager', () => {
|
||||
|
||||
describe('runCommand()', () => {
|
||||
it('Logs a warning if commandName not found in context', () => {
|
||||
const result = commandsManager.runCommand(
|
||||
'CommandThatDoesNotExistInAnyContext'
|
||||
);
|
||||
const result = commandsManager.runCommand('CommandThatDoesNotExistInAnyContext');
|
||||
|
||||
expect(result).toBe(undefined);
|
||||
expect(log.warn.mock.calls[0][0]).toEqual(
|
||||
@@ -149,16 +144,8 @@ describe('CommandsManager', () => {
|
||||
};
|
||||
|
||||
commandsManager.createContext(contextName);
|
||||
commandsManager.registerCommand(
|
||||
contextName,
|
||||
'TestCommand',
|
||||
commandWithNoCommmandFn
|
||||
);
|
||||
const result = commandsManager.runCommand(
|
||||
'TestCommand',
|
||||
null,
|
||||
contextName
|
||||
);
|
||||
commandsManager.registerCommand(contextName, 'TestCommand', commandWithNoCommmandFn);
|
||||
const result = commandsManager.runCommand('TestCommand', null, contextName);
|
||||
|
||||
expect(result).toBe(undefined);
|
||||
expect(log.warn.mock.calls[0][0]).toEqual(
|
||||
@@ -192,9 +179,7 @@ describe('CommandsManager', () => {
|
||||
commandsManager.runCommand('TestCommand', runCommandOptions, 'VIEWER');
|
||||
|
||||
expect(command.commandFn.mock.calls.length).toBe(1);
|
||||
expect(command.commandFn.mock.calls[0][0].test).toEqual(
|
||||
runCommandOptions.test
|
||||
);
|
||||
expect(command.commandFn.mock.calls[0][0].test).toEqual(runCommandOptions.test);
|
||||
});
|
||||
|
||||
it('Returns the result of commandFn', () => {
|
||||
|
||||
@@ -181,30 +181,27 @@ export class CommandsManager {
|
||||
const commands =
|
||||
(Array.isArray(toRun) && toRun) ||
|
||||
((toRun as Command).commandName && [toRun]) ||
|
||||
(Array.isArray((toRun as Commands).commands) &&
|
||||
(toRun as Commands).commands);
|
||||
(Array.isArray((toRun as Commands).commands) && (toRun as Commands).commands);
|
||||
if (!commands) {
|
||||
console.log("Command isn't runnable", toRun);
|
||||
return;
|
||||
}
|
||||
|
||||
let result;
|
||||
(commands as Command[]).forEach(
|
||||
({ commandName, commandOptions, context }) => {
|
||||
if (commandName) {
|
||||
result = this.runCommand(
|
||||
commandName,
|
||||
{
|
||||
...commandOptions,
|
||||
...options,
|
||||
},
|
||||
context
|
||||
);
|
||||
} else {
|
||||
console.warn('No command name supplied in', toRun);
|
||||
}
|
||||
(commands as Command[]).forEach(({ commandName, commandOptions, context }) => {
|
||||
if (commandName) {
|
||||
result = this.runCommand(
|
||||
commandName,
|
||||
{
|
||||
...commandOptions,
|
||||
...options,
|
||||
},
|
||||
context
|
||||
);
|
||||
} else {
|
||||
console.warn('No command name supplied in', toRun);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,7 @@ describe('HotkeysManager', () => {
|
||||
});
|
||||
it('has expected properties', () => {
|
||||
const allProperties = Object.keys(hotkeysManager);
|
||||
const expectedProperties = [
|
||||
'hotkeyDefinitions',
|
||||
'hotkeyDefaults',
|
||||
'isEnabled',
|
||||
];
|
||||
const expectedProperties = ['hotkeyDefinitions', 'hotkeyDefaults', 'isEnabled'];
|
||||
|
||||
const containsAllExpectedProperties = expectedProperties.every(expected =>
|
||||
allProperties.includes(expected)
|
||||
@@ -134,21 +130,16 @@ describe('HotkeysManager', () => {
|
||||
|
||||
hotkeysManager.registerHotkeys(definition);
|
||||
|
||||
const numOfHotkeyDefinitions = Object.keys(
|
||||
hotkeysManager.hotkeyDefinitions
|
||||
).length;
|
||||
const numOfHotkeyDefinitions = Object.keys(hotkeysManager.hotkeyDefinitions).length;
|
||||
|
||||
const commandHash = objectHash({
|
||||
commandName: definition.commandName,
|
||||
commandOptions: definition.commandOptions,
|
||||
});
|
||||
const hotkeyDefinitionForRegisteredCommand =
|
||||
hotkeysManager.hotkeyDefinitions[commandHash];
|
||||
const hotkeyDefinitionForRegisteredCommand = hotkeysManager.hotkeyDefinitions[commandHash];
|
||||
|
||||
expect(numOfHotkeyDefinitions).toBe(1);
|
||||
expect(Object.keys(hotkeysManager.hotkeyDefinitions)[0]).toEqual(
|
||||
commandHash
|
||||
);
|
||||
expect(Object.keys(hotkeysManager.hotkeyDefinitions)[0]).toEqual(commandHash);
|
||||
expect(hotkeyDefinitionForRegisteredCommand).toEqual(definition);
|
||||
});
|
||||
it('calls hotkeys.bind for the group of keys', () => {
|
||||
@@ -182,9 +173,7 @@ describe('HotkeysManager', () => {
|
||||
|
||||
hotkeysManager.restoreDefaultBindings();
|
||||
|
||||
expect(hotkeysManager.setHotkeys.mock.calls[0][0]).toEqual(
|
||||
hotkeysManager.hotkeyDefaults
|
||||
);
|
||||
expect(hotkeysManager.setHotkeys.mock.calls[0][0]).toEqual(hotkeysManager.hotkeyDefaults);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -174,14 +174,7 @@ export class HotkeysManager {
|
||||
* @returns {undefined}
|
||||
*/
|
||||
registerHotkeys(
|
||||
{
|
||||
commandName,
|
||||
commandOptions = {},
|
||||
context,
|
||||
keys,
|
||||
label,
|
||||
isEditable,
|
||||
}: Hotkey = {},
|
||||
{ commandName, commandOptions = {}, context, keys, label, isEditable }: Hotkey = {},
|
||||
extension
|
||||
) {
|
||||
if (!commandName) {
|
||||
@@ -189,9 +182,7 @@ export class HotkeysManager {
|
||||
}
|
||||
|
||||
const commandHash = objectHash({ commandName, commandOptions });
|
||||
const options = Object.keys(commandOptions).length
|
||||
? JSON.stringify(commandOptions)
|
||||
: 'no';
|
||||
const options = Object.keys(commandOptions).length ? JSON.stringify(commandOptions) : 'no';
|
||||
const previouslyRegisteredDefinition = this.hotkeyDefinitions[commandHash];
|
||||
|
||||
if (previouslyRegisteredDefinition) {
|
||||
@@ -255,11 +246,7 @@ export class HotkeysManager {
|
||||
hotkeys.bind(combinedKeys, evt => {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
this._commandsManager.runCommand(
|
||||
commandName,
|
||||
{ evt, ...commandOptions },
|
||||
context
|
||||
);
|
||||
this._commandsManager.runCommand(commandName, { evt, ...commandOptions }, context);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ class ImageSet {
|
||||
)
|
||||
);
|
||||
|
||||
const distanceImagePairs = images.map(function(image: Image) {
|
||||
const distanceImagePairs = images.map(function (image: Image) {
|
||||
const ippVec = new Vector3(..._getImagePositionPatient(image));
|
||||
const positionVector = refIppVec.clone().sub(ippVec);
|
||||
const distance = positionVector.dot(scanAxisNormal);
|
||||
@@ -118,13 +118,13 @@ class ImageSet {
|
||||
};
|
||||
});
|
||||
|
||||
distanceImagePairs.sort(function(a, b) {
|
||||
distanceImagePairs.sort(function (a, b) {
|
||||
return b.distance - a.distance;
|
||||
});
|
||||
|
||||
const sortedImages = distanceImagePairs.map(a => a.image);
|
||||
|
||||
images.sort(function(a, b) {
|
||||
images.sort(function (a, b) {
|
||||
return sortedImages.indexOf(a) - sortedImages.indexOf(b);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -58,12 +58,7 @@ class MetadataProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
const {
|
||||
StudyInstanceUID,
|
||||
SeriesInstanceUID,
|
||||
SOPInstanceUID,
|
||||
frameNumber,
|
||||
} = uids;
|
||||
const { StudyInstanceUID, SeriesInstanceUID, SOPInstanceUID, frameNumber } = uids;
|
||||
|
||||
const instance = DicomMetadataStore.getInstance(
|
||||
StudyInstanceUID,
|
||||
@@ -75,9 +70,7 @@ class MetadataProvider {
|
||||
return;
|
||||
}
|
||||
|
||||
return (
|
||||
(frameNumber && combineFrameInstance(frameNumber, instance)) || instance
|
||||
);
|
||||
return (frameNumber && combineFrameInstance(frameNumber, instance)) || instance;
|
||||
}
|
||||
|
||||
get(query, imageId, options = { fallback: false }) {
|
||||
@@ -107,11 +100,7 @@ class MetadataProvider {
|
||||
return this.get(INSTANCE, imageId);
|
||||
}
|
||||
|
||||
getTagFromInstance(
|
||||
naturalizedTagOrWADOImageLoaderTag,
|
||||
instance,
|
||||
options = { fallback: false }
|
||||
) {
|
||||
getTagFromInstance(naturalizedTagOrWADOImageLoaderTag, instance, options = { fallback: false }) {
|
||||
if (!instance) {
|
||||
return;
|
||||
}
|
||||
@@ -122,10 +111,7 @@ class MetadataProvider {
|
||||
}
|
||||
|
||||
// Maybe its a legacy dicomImageLoader tag then:
|
||||
return this._getCornerstoneDICOMImageLoaderTag(
|
||||
naturalizedTagOrWADOImageLoaderTag,
|
||||
instance
|
||||
);
|
||||
return this._getCornerstoneDICOMImageLoaderTag(naturalizedTagOrWADOImageLoaderTag, instance);
|
||||
}
|
||||
|
||||
_getCornerstoneDICOMImageLoaderTag(wadoImageLoaderTag, instance) {
|
||||
@@ -198,9 +184,7 @@ class MetadataProvider {
|
||||
imageOrientationPatient: toNumber(ImageOrientationPatient),
|
||||
rowCosines: toNumber(rowCosines || [0, 1, 0]),
|
||||
columnCosines: toNumber(columnCosines || [0, 0, -1]),
|
||||
imagePositionPatient: toNumber(
|
||||
instance.ImagePositionPatient || [0, 0, 0]
|
||||
),
|
||||
imagePositionPatient: toNumber(instance.ImagePositionPatient || [0, 0, 0]),
|
||||
sliceThickness: toNumber(instance.SliceThickness),
|
||||
sliceLocation: toNumber(instance.SliceLocation),
|
||||
pixelSpacing: toNumber(PixelSpacing || 1),
|
||||
@@ -254,12 +238,8 @@ class MetadataProvider {
|
||||
if (WindowCenter === undefined || WindowWidth === undefined) {
|
||||
return;
|
||||
}
|
||||
const windowCenter = Array.isArray(WindowCenter)
|
||||
? WindowCenter
|
||||
: [WindowCenter];
|
||||
const windowWidth = Array.isArray(WindowWidth)
|
||||
? WindowWidth
|
||||
: [WindowWidth];
|
||||
const windowCenter = Array.isArray(WindowCenter) ? WindowCenter : [WindowCenter];
|
||||
const windowWidth = Array.isArray(WindowWidth) ? WindowWidth : [WindowWidth];
|
||||
|
||||
metadata = {
|
||||
windowCenter: toNumber(windowCenter),
|
||||
@@ -296,16 +276,11 @@ class MetadataProvider {
|
||||
? RadiopharmaceuticalInformationSequence[0]
|
||||
: RadiopharmaceuticalInformationSequence;
|
||||
|
||||
const {
|
||||
RadiopharmaceuticalStartTime,
|
||||
RadionuclideTotalDose,
|
||||
RadionuclideHalfLife,
|
||||
} = RadiopharmaceuticalInformation;
|
||||
const { RadiopharmaceuticalStartTime, RadionuclideTotalDose, RadionuclideHalfLife } =
|
||||
RadiopharmaceuticalInformation;
|
||||
|
||||
const radiopharmaceuticalInfo = {
|
||||
radiopharmaceuticalStartTime: dicomParser.parseTM(
|
||||
RadiopharmaceuticalStartTime
|
||||
),
|
||||
radiopharmaceuticalStartTime: dicomParser.parseTM(RadiopharmaceuticalStartTime),
|
||||
radionuclideTotalDose: RadionuclideTotalDose,
|
||||
radionuclideHalfLife: RadionuclideHalfLife,
|
||||
};
|
||||
@@ -318,11 +293,7 @@ class MetadataProvider {
|
||||
case WADO_IMAGE_LOADER_TAGS.OVERLAY_PLANE_MODULE:
|
||||
const overlays = [];
|
||||
|
||||
for (
|
||||
let overlayGroup = 0x00;
|
||||
overlayGroup <= 0x1e;
|
||||
overlayGroup += 0x02
|
||||
) {
|
||||
for (let overlayGroup = 0x00; overlayGroup <= 0x1e; overlayGroup += 0x02) {
|
||||
let groupStr = `60${overlayGroup.toString(16)}`;
|
||||
|
||||
if (groupStr.length === 3) {
|
||||
|
||||
Reference in new issue
Block a user