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
@@ -59,17 +59,11 @@ describe('ExtensionManager.ts', () => {
|
||||
extensionManager.registerExtension = jest.fn();
|
||||
|
||||
// SUT
|
||||
const fakeExtensions = [
|
||||
{ one: '1' },
|
||||
[{ two: '2' }, fakeConfiguration],
|
||||
{ three: '3 ' },
|
||||
];
|
||||
const fakeExtensions = [{ one: '1' }, [{ two: '2' }, fakeConfiguration], { three: '3 ' }];
|
||||
await extensionManager.registerExtensions(fakeExtensions);
|
||||
|
||||
// Assert
|
||||
expect(extensionManager.registerExtension.mock.calls[1][1]).toEqual(
|
||||
fakeConfiguration
|
||||
);
|
||||
expect(extensionManager.registerExtension.mock.calls[1][1]).toEqual(fakeConfiguration);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,15 +98,11 @@ describe('ExtensionManager.ts', () => {
|
||||
const undefinedExtension = undefined;
|
||||
const nullExtension = null;
|
||||
|
||||
await expect(
|
||||
extensionManager.registerExtension(undefinedExtension)
|
||||
).rejects.toThrow(
|
||||
await expect(extensionManager.registerExtension(undefinedExtension)).rejects.toThrow(
|
||||
new Error('Attempting to register a null/undefined extension.')
|
||||
);
|
||||
|
||||
await expect(
|
||||
extensionManager.registerExtension(nullExtension)
|
||||
).rejects.toThrow(
|
||||
await expect(extensionManager.registerExtension(nullExtension)).rejects.toThrow(
|
||||
new Error('Attempting to register a null/undefined extension.')
|
||||
);
|
||||
});
|
||||
@@ -120,9 +110,9 @@ describe('ExtensionManager.ts', () => {
|
||||
it('logs a warning if the extension does not have an id', async () => {
|
||||
const extensionWithoutId = {};
|
||||
|
||||
await expect(
|
||||
extensionManager.registerExtension(extensionWithoutId)
|
||||
).rejects.toThrow(new Error('Extension ID not set'));
|
||||
await expect(extensionManager.registerExtension(extensionWithoutId)).rejects.toThrow(
|
||||
new Error('Extension ID not set')
|
||||
);
|
||||
});
|
||||
|
||||
it('tracks which extensions have been registered', () => {
|
||||
@@ -156,9 +146,7 @@ describe('ExtensionManager.ts', () => {
|
||||
extensionManager.registerExtension(extensionWithBadModule);
|
||||
|
||||
expect(log.warn.mock.calls.length).toBe(1);
|
||||
expect(log.warn.mock.calls[0][0]).toContain(
|
||||
'Null or undefined returned when registering'
|
||||
);
|
||||
expect(log.warn.mock.calls[0][0]).toContain('Null or undefined returned when registering');
|
||||
});
|
||||
|
||||
it('logs an error if an exception is thrown while retrieving a module', async () => {
|
||||
@@ -169,9 +157,7 @@ describe('ExtensionManager.ts', () => {
|
||||
},
|
||||
};
|
||||
|
||||
await expect(
|
||||
extensionManager.registerExtension(extensionWithBadModule)
|
||||
).rejects.toThrow();
|
||||
await expect(extensionManager.registerExtension(extensionWithBadModule)).rejects.toThrow();
|
||||
});
|
||||
|
||||
it('successfully passes dependencies to each module along with extension configuration', () => {
|
||||
|
||||
@@ -145,12 +145,8 @@ export default class ExtensionManager extends PubSubService {
|
||||
}
|
||||
|
||||
public onModeExit(): void {
|
||||
const {
|
||||
registeredExtensionIds,
|
||||
_servicesManager,
|
||||
_commandsManager,
|
||||
_extensionLifeCycleHooks,
|
||||
} = this;
|
||||
const { registeredExtensionIds, _servicesManager, _commandsManager, _extensionLifeCycleHooks } =
|
||||
this;
|
||||
|
||||
registeredExtensionIds.forEach(extensionId => {
|
||||
const onModeExit = _extensionLifeCycleHooks.onModeExit[extensionId];
|
||||
@@ -181,10 +177,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
* @param {Object[]} extensions - Array of extensions
|
||||
*/
|
||||
public registerExtensions = async (
|
||||
extensions: (
|
||||
| ExtensionRegister
|
||||
| [ExtensionRegister, ExtensionConfiguration]
|
||||
)[],
|
||||
extensions: (ExtensionRegister | [ExtensionRegister, ExtensionConfiguration])[],
|
||||
dataSources: unknown[] = []
|
||||
): Promise<void> => {
|
||||
// Todo: we ideally should be able to run registrations in parallel
|
||||
@@ -203,11 +196,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
// for (const extension of extensions)
|
||||
const ohifExtension = extension[0];
|
||||
const configuration = extension[1];
|
||||
await this.registerExtension(
|
||||
ohifExtension,
|
||||
configuration,
|
||||
dataSources
|
||||
);
|
||||
await this.registerExtension(ohifExtension, configuration, dataSources);
|
||||
} else {
|
||||
await this.registerExtension(extension, {}, dataSources);
|
||||
}
|
||||
@@ -260,13 +249,11 @@ export default class ExtensionManager extends PubSubService {
|
||||
}
|
||||
|
||||
if (extension.onModeEnter) {
|
||||
this._extensionLifeCycleHooks.onModeEnter[extensionId] =
|
||||
extension.onModeEnter;
|
||||
this._extensionLifeCycleHooks.onModeEnter[extensionId] = extension.onModeEnter;
|
||||
}
|
||||
|
||||
if (extension.onModeExit) {
|
||||
this._extensionLifeCycleHooks.onModeExit[extensionId] =
|
||||
extension.onModeExit;
|
||||
this._extensionLifeCycleHooks.onModeExit[extensionId] = extension.onModeExit;
|
||||
}
|
||||
|
||||
// Register Modules
|
||||
@@ -284,11 +271,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
this._initCommandsModule(extensionModule);
|
||||
break;
|
||||
case MODULE_TYPES.DATA_SOURCE:
|
||||
this._initDataSourcesModule(
|
||||
extensionModule,
|
||||
extensionId,
|
||||
dataSources
|
||||
);
|
||||
this._initDataSourcesModule(extensionModule, extensionId, dataSources);
|
||||
break;
|
||||
case MODULE_TYPES.HANGING_PROTOCOL:
|
||||
this._initHangingProtocolsModule(extensionModule, extensionId);
|
||||
@@ -425,10 +408,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
* @param dataSourceDef the data source definition to be added
|
||||
* @param activate flag to indicate if the added data source should be set to the active data source
|
||||
*/
|
||||
addDataSource(
|
||||
dataSourceDef: DataSourceDefinition,
|
||||
options = { activate: false }
|
||||
) {
|
||||
addDataSource(dataSourceDef: DataSourceDefinition, options = { activate: false }) {
|
||||
const existingDataSource = this.getDataSources(dataSourceDef.sourceName);
|
||||
if (existingDataSource?.[0]) {
|
||||
// The data source already exists and cannot be added.
|
||||
@@ -448,10 +428,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
* @param dataSourceName the name of the data source to update
|
||||
* @param dataSourceConfiguration the new configuration to update the data source with
|
||||
*/
|
||||
updateDataSourceConfiguration(
|
||||
dataSourceName: string,
|
||||
dataSourceConfiguration: any
|
||||
) {
|
||||
updateDataSourceConfiguration(dataSourceName: string, dataSourceConfiguration: any) {
|
||||
const existingDataSource = this.getDataSources(dataSourceName);
|
||||
if (!existingDataSource?.[0]) {
|
||||
// Cannot update a non existent data source.
|
||||
@@ -465,10 +442,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
|
||||
if (this.activeDataSource === dataSourceName) {
|
||||
// When the active data source is changed/set, fire an event to indicate that its configuration has changed.
|
||||
this._broadcastEvent(
|
||||
ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED,
|
||||
dataSourceDef
|
||||
);
|
||||
this._broadcastEvent(ExtensionManager.EVENTS.ACTIVE_DATA_SOURCE_CHANGED, dataSourceDef);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -502,9 +476,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
dataSources: Array<DataSourceDefinition> = []
|
||||
): void {
|
||||
extensionModule.forEach(element => {
|
||||
this.modulesMap[
|
||||
`${extensionId}.${MODULE_TYPES.DATA_SOURCE}.${element.name}`
|
||||
] = element;
|
||||
this.modulesMap[`${extensionId}.${MODULE_TYPES.DATA_SOURCE}.${element.name}`] = element;
|
||||
});
|
||||
|
||||
extensionModule.forEach(element => {
|
||||
@@ -539,8 +511,7 @@ export default class ExtensionManager extends PubSubService {
|
||||
Object.keys(definitions).forEach(commandName => {
|
||||
const commandDefinition = definitions[commandName];
|
||||
const commandHasContextThatDoesNotExist =
|
||||
commandDefinition.context &&
|
||||
!this._commandsManager.getContext(commandDefinition.context);
|
||||
commandDefinition.context && !this._commandsManager.getContext(commandDefinition.context);
|
||||
|
||||
if (commandHasContextThatDoesNotExist) {
|
||||
this._commandsManager.createContext(commandDefinition.context);
|
||||
|
||||
Reference in new issue
Block a user