Skip to content

Commit

Permalink
chore: fix sonar issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mathuo committed Oct 22, 2023
1 parent 882c135 commit 331e190
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 28 deletions.
13 changes: 6 additions & 7 deletions packages/dockview-core/src/dockview/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ import { PanelTransfer } from '../dnd/dataTransfer';
import { IDisposable } from '../lifecycle';
import { Position } from '../dnd/droptarget';
import { IDockviewPanel } from './dockviewPanel';
import { FrameworkFactory } from '../panel/componentFactory';
import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';
import { DockviewGroupPanelApi } from '../api/dockviewGroupPanelApi';

export interface IHeaderActionsRenderer extends IDisposable {
Expand All @@ -40,14 +43,10 @@ export interface TabContextMenuEvent {

export interface DockviewRenderFunctions {
tabComponents?: {
[componentName: string]: {
new (id: string, component: string): ITabRenderer;
};
[componentName: string]: ComponentConstructor<ITabRenderer>;
};
components?: {
[componentName: string]: {
new (id: string, component: string): IContentRenderer;
};
[componentName: string]: ComponentConstructor<IContentRenderer>;
};
frameworkTabComponents?: {
[componentName: string]: any;
Expand Down
9 changes: 5 additions & 4 deletions packages/dockview-core/src/gridview/options.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { GridviewPanel } from './gridviewPanel';
import { ISplitviewStyles, Orientation } from '../splitview/splitview';
import { FrameworkFactory } from '../panel/componentFactory';
import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';

export interface GridviewComponentOptions {
proportionalLayout: boolean;
orientation: Orientation;
components?: {
[componentName: string]: {
new (id: string, componentName: string): GridviewPanel;
};
[componentName: string]: ComponentConstructor<GridviewPanel>;
};
frameworkComponents?: {
[componentName: string]: any;
Expand Down
6 changes: 5 additions & 1 deletion packages/dockview-core/src/panel/componentFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ export interface FrameworkFactory<T> {
createComponent: (id: string, componentId: string, component: any) => T;
}

export type ComponentConstructor<T> = {
new (id: string, component: string): T;
};

export function createComponent<T>(
id: string,
componentName?: string,
components: {
[componentName: string]: { new (id: string, component: string): T };
[componentName: string]: ComponentConstructor<T>;
} = {},
frameworkComponents: {
[componentName: string]: any;
Expand Down
13 changes: 6 additions & 7 deletions packages/dockview-core/src/paneview/options.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import { FrameworkFactory } from '../panel/componentFactory';
import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';
import { PaneviewDndOverlayEvent } from './paneviewComponent';
import { IPaneBodyPart, IPaneHeaderPart, PaneviewPanel } from './paneviewPanel';

export interface PaneviewComponentOptions {
components?: {
[componentName: string]: {
new (id: string, componentName: string): PaneviewPanel;
};
[componentName: string]: ComponentConstructor<PaneviewPanel>;
};
frameworkComponents?: {
[componentName: string]: any;
};
headerComponents?: {
[componentName: string]: {
new (id: string, componentName: string): PaneviewPanel;
};
[componentName: string]: ComponentConstructor<PaneviewPanel>;
};
headerframeworkComponents?: {
[componentName: string]: any;
Expand Down
2 changes: 1 addition & 1 deletion packages/dockview-core/src/paneview/paneview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class Paneview extends CompositeDisposable implements IDisposable {
private splitview: Splitview;
private paneItems: PaneItem[] = [];
private _orientation: Orientation;
private animationTimer: any | undefined;
private animationTimer: any;
private skipAnimation = false;

private readonly _onDidChange = new Emitter<void>();
Expand Down
2 changes: 1 addition & 1 deletion packages/dockview-core/src/paneview/paneviewPanel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export abstract class PaneviewPanel
private bodyPart?: IPaneHeaderPart;
private headerPart?: IPaneBodyPart;
private expandedSize = 0;
private animationTimer: any | undefined;
private animationTimer: any;
private _orientation: Orientation;

private _headerVisible: boolean;
Expand Down
9 changes: 5 additions & 4 deletions packages/dockview-core/src/splitview/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { IPanel, PanelInitParameters } from '../panel/types';
import { IView, SplitViewOptions, LayoutPriority } from './splitview';
import { SplitviewPanel } from './splitviewPanel';
import { SplitviewComponent } from './splitviewComponent';
import { FrameworkFactory } from '../panel/componentFactory';
import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';

export interface PanelViewInitParameters extends PanelInitParameters {
minimumSize?: number;
Expand All @@ -18,9 +21,7 @@ export interface ISerializableView extends IView, IPanel {

export interface SplitviewComponentOptions extends SplitViewOptions {
components?: {
[componentName: string]: {
new (id: string, componentName: string): SplitviewPanel;
};
[componentName: string]: ComponentConstructor<SplitviewPanel>;
};
frameworkComponents?: {
[componentName: string]: any;
Expand Down
2 changes: 1 addition & 1 deletion packages/dockview-core/src/splitview/splitviewComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ export class SplitviewComponent
view.orientation = this.splitview.orientation;

view.init({
params: options.params || {},
params: options.params ?? {},
minimumSize: options.minimumSize,
maximumSize: options.maximumSize,
snap: options.snap,
Expand Down
4 changes: 2 additions & 2 deletions packages/dockview/src/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const usePortalsLifecycle: PortalLifecycleHook = () => {

// it does the job...
export function isReactElement(
element: any | React.ReactElement
element: unknown
): element is React.ReactElement {
return element?.type;
return !!(element as React.ReactElement)?.type;
}

0 comments on commit 331e190

Please sign in to comment.