Merge pull request #379 from mathuo/373-fix-sonar-issues

chore: fix sonar issues
This commit is contained in:
mathuo 2023-10-22 19:59:33 +01:00 committed by GitHub
commit 8aa0d0192e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 32 additions and 28 deletions

View File

@ -15,7 +15,10 @@ import { PanelTransfer } from '../dnd/dataTransfer';
import { IDisposable } from '../lifecycle'; import { IDisposable } from '../lifecycle';
import { Position } from '../dnd/droptarget'; import { Position } from '../dnd/droptarget';
import { IDockviewPanel } from './dockviewPanel'; import { IDockviewPanel } from './dockviewPanel';
import { FrameworkFactory } from '../panel/componentFactory'; import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';
import { DockviewGroupPanelApi } from '../api/dockviewGroupPanelApi'; import { DockviewGroupPanelApi } from '../api/dockviewGroupPanelApi';
export interface IHeaderActionsRenderer extends IDisposable { export interface IHeaderActionsRenderer extends IDisposable {
@ -40,14 +43,10 @@ export interface TabContextMenuEvent {
export interface DockviewRenderFunctions { export interface DockviewRenderFunctions {
tabComponents?: { tabComponents?: {
[componentName: string]: { [componentName: string]: ComponentConstructor<ITabRenderer>;
new (id: string, component: string): ITabRenderer;
};
}; };
components?: { components?: {
[componentName: string]: { [componentName: string]: ComponentConstructor<IContentRenderer>;
new (id: string, component: string): IContentRenderer;
};
}; };
frameworkTabComponents?: { frameworkTabComponents?: {
[componentName: string]: any; [componentName: string]: any;

View File

@ -1,15 +1,16 @@
import { GridviewPanel } from './gridviewPanel'; import { GridviewPanel } from './gridviewPanel';
import { ISplitviewStyles, Orientation } from '../splitview/splitview'; import { ISplitviewStyles, Orientation } from '../splitview/splitview';
import { FrameworkFactory } from '../panel/componentFactory'; import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';
export interface GridviewComponentOptions { export interface GridviewComponentOptions {
disableAutoResizing?: boolean; disableAutoResizing?: boolean;
proportionalLayout: boolean; proportionalLayout: boolean;
orientation: Orientation; orientation: Orientation;
components?: { components?: {
[componentName: string]: { [componentName: string]: ComponentConstructor<GridviewPanel>;
new (id: string, componentName: string): GridviewPanel;
};
}; };
frameworkComponents?: { frameworkComponents?: {
[componentName: string]: any; [componentName: string]: any;

View File

@ -2,11 +2,15 @@ export interface FrameworkFactory<T> {
createComponent: (id: string, componentId: string, component: any) => T; createComponent: (id: string, componentId: string, component: any) => T;
} }
export type ComponentConstructor<T> = {
new (id: string, component: string): T;
};
export function createComponent<T>( export function createComponent<T>(
id: string, id: string,
componentName?: string, componentName?: string,
components: { components: {
[componentName: string]: { new (id: string, component: string): T }; [componentName: string]: ComponentConstructor<T>;
} = {}, } = {},
frameworkComponents: { frameworkComponents: {
[componentName: string]: any; [componentName: string]: any;

View File

@ -1,21 +1,20 @@
import { FrameworkFactory } from '../panel/componentFactory'; import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';
import { PaneviewDndOverlayEvent } from './paneviewComponent'; import { PaneviewDndOverlayEvent } from './paneviewComponent';
import { IPaneBodyPart, IPaneHeaderPart, PaneviewPanel } from './paneviewPanel'; import { IPaneBodyPart, IPaneHeaderPart, PaneviewPanel } from './paneviewPanel';
export interface PaneviewComponentOptions { export interface PaneviewComponentOptions {
disableAutoResizing?: boolean; disableAutoResizing?: boolean;
components?: { components?: {
[componentName: string]: { [componentName: string]: ComponentConstructor<PaneviewPanel>;
new (id: string, componentName: string): PaneviewPanel;
};
}; };
frameworkComponents?: { frameworkComponents?: {
[componentName: string]: any; [componentName: string]: any;
}; };
headerComponents?: { headerComponents?: {
[componentName: string]: { [componentName: string]: ComponentConstructor<PaneviewPanel>;
new (id: string, componentName: string): PaneviewPanel;
};
}; };
headerframeworkComponents?: { headerframeworkComponents?: {
[componentName: string]: any; [componentName: string]: any;

View File

@ -19,7 +19,7 @@ export class Paneview extends CompositeDisposable implements IDisposable {
private splitview: Splitview; private splitview: Splitview;
private paneItems: PaneItem[] = []; private paneItems: PaneItem[] = [];
private _orientation: Orientation; private _orientation: Orientation;
private animationTimer: any | undefined; private animationTimer: any;
private skipAnimation = false; private skipAnimation = false;
private readonly _onDidChange = new Emitter<void>(); private readonly _onDidChange = new Emitter<void>();

View File

@ -87,7 +87,7 @@ export abstract class PaneviewPanel
private bodyPart?: IPaneHeaderPart; private bodyPart?: IPaneHeaderPart;
private headerPart?: IPaneBodyPart; private headerPart?: IPaneBodyPart;
private expandedSize = 0; private expandedSize = 0;
private animationTimer: any | undefined; private animationTimer: any;
private _orientation: Orientation; private _orientation: Orientation;
private _headerVisible: boolean; private _headerVisible: boolean;

View File

@ -2,7 +2,10 @@ import { IPanel, PanelInitParameters } from '../panel/types';
import { IView, SplitViewOptions, LayoutPriority } from './splitview'; import { IView, SplitViewOptions, LayoutPriority } from './splitview';
import { SplitviewPanel } from './splitviewPanel'; import { SplitviewPanel } from './splitviewPanel';
import { SplitviewComponent } from './splitviewComponent'; import { SplitviewComponent } from './splitviewComponent';
import { FrameworkFactory } from '../panel/componentFactory'; import {
ComponentConstructor,
FrameworkFactory,
} from '../panel/componentFactory';
export interface PanelViewInitParameters extends PanelInitParameters { export interface PanelViewInitParameters extends PanelInitParameters {
minimumSize?: number; minimumSize?: number;
@ -19,9 +22,7 @@ export interface ISerializableView extends IView, IPanel {
export interface SplitviewComponentOptions extends SplitViewOptions { export interface SplitviewComponentOptions extends SplitViewOptions {
disableAutoResizing?: boolean; disableAutoResizing?: boolean;
components?: { components?: {
[componentName: string]: { [componentName: string]: ComponentConstructor<SplitviewPanel>;
new (id: string, componentName: string): SplitviewPanel;
};
}; };
frameworkComponents?: { frameworkComponents?: {
[componentName: string]: any; [componentName: string]: any;

View File

@ -274,7 +274,7 @@ export class SplitviewComponent
view.orientation = this.splitview.orientation; view.orientation = this.splitview.orientation;
view.init({ view.init({
params: options.params || {}, params: options.params ?? {},
minimumSize: options.minimumSize, minimumSize: options.minimumSize,
maximumSize: options.maximumSize, maximumSize: options.maximumSize,
snap: options.snap, snap: options.snap,

View File

@ -194,7 +194,7 @@ export const usePortalsLifecycle: PortalLifecycleHook = () => {
// it does the job... // it does the job...
export function isReactElement( export function isReactElement(
element: any | React.ReactElement element: unknown
): element is React.ReactElement { ): element is React.ReactElement {
return element?.type; return !!(element as React.ReactElement)?.type;
} }