lint: fix lint

This commit is contained in:
Yanyan-Wang 2021-05-19 12:04:28 +08:00 committed by Yanyan Wang
parent 1370d65e37
commit 559220b698
11 changed files with 58 additions and 58 deletions

View File

@ -22,6 +22,7 @@ module.exports = {
'guard-for-in': 0,
'no-restricted-globals': 0,
'max-classes-per-file': 0,
"@typescript-eslint/no-this-alias": 0,
// 后面需要去掉
'no-restricted-syntax': 0,
'prefer-spread': 0,

View File

@ -18,15 +18,15 @@ export default {
};
},
setAllItemStates(e: IG6GraphEvent) {
const self = this;
const item: INode = e.item as INode;
const graph = this.graph;
this.item = item;
if (!this.shouldUpdate(e.item, { event: e, action: 'activate' })) {
const graph = self.graph;
self.item = item;
if (!self.shouldUpdate(e.item, { event: e, action: 'activate' })) {
return;
}
const self = this;
const activeState = this.activeState;
const inactiveState = this.inactiveState;
const activeState = self.activeState;
const inactiveState = self.inactiveState;
const nodes = graph.getNodes();
const edges = graph.getEdges();
const nodeLength = nodes.length;

View File

@ -174,7 +174,7 @@ export default {
this.updateViewport(e);
}
e.type = 'dragend';
//graph.emit('canvas:dragend', e);
// graph.emit('canvas:dragend', e);
this.endDrag();
},
endDrag() {

View File

@ -252,10 +252,10 @@ export default {
* @param evt
*/
onDropNode(evt: IG6GraphEvent) {
if (!this.targets || this.targets.length === 0) return;
const self = this;
if (!self.targets || self.targets.length === 0) return;
const item = evt.item as INode;
this.updatePositions(evt);
self.updatePositions(evt);
const graph: IGraph = self.graph;
const comboId = item.getModel().comboId as string;
@ -265,7 +265,7 @@ export default {
if (self.comboActiveState) {
graph.setItemState(combo, self.comboActiveState, false);
}
this.targets.map((node: INode) => {
self.targets.map((node: INode) => {
const nodeModel = node.getModel();
if (comboId !== nodeModel.comboId) {
graph.updateComboTree(node, comboId);
@ -273,7 +273,7 @@ export default {
});
graph.updateCombo(combo as ICombo);
} else {
this.targets.map((node: INode) => {
self.targets.map((node: INode) => {
const model = node.getModel();
if (model.comboId) {
graph.updateComboTree(node);
@ -283,7 +283,7 @@ export default {
// 将节点拖动到另外个节点上面emit 事件抛出当前操作的节点及目标节点
graph.emit('dragnodeend', {
items: this.targets,
items: self.targets,
targetItem: item,
});
},

View File

@ -1,8 +1,4 @@
import { G6Event, IG6GraphEvent } from '@antv/g6-core';
import { mat3 } from '@antv/matrix-util';
import { clone } from '@antv/util';
const DELTA = 0.05;
import { G6Event } from '@antv/g6-core';
export default {
firstScale: null,
@ -37,8 +33,8 @@ export default {
};
},
onPinch(evt) {
evt.preventDefault || evt.preventDefault();
evt.originalEvent.preventDefault || evt.originalEvent.preventDefault();
if (evt.preventDefault) evt.preventDefault();
if (evt.originalEvent.preventDefault) evt.originalEvent.preventDefault();
const pointers = evt.originalEvent.pointers;
if (pointers.length < 2) return;

View File

@ -1,8 +1,8 @@
import { addEventListener } from '@antv/dom-util';
import { ICanvas, IGroup, IShape } from '@antv/g-base';
import { each, isNil, wrapBehavior } from '@antv/util';
import { each, wrapBehavior } from '@antv/util';
import { AbstractEvent, IG6GraphEvent, Matrix, Item, Util } from '@antv/g6-core';
import Graph from '../graph';
const { cloneEvent, isViewportChanged } = Util;
type Fun = () => void;

View File

@ -138,7 +138,7 @@ export default class LayoutController extends AbstractLayout {
private execLayoutMethod(layoutCfg, order): Promise<void> {
return new Promise((reslove, reject) => {
const { graph } = this;
let layoutType = layoutCfg.type;
const layoutType = layoutCfg.type;
// 每个布局方法都需要注册
layoutCfg.onLayoutEnd = () => {

View File

@ -261,7 +261,7 @@ export default class Graph extends AbstractGraph implements IGraph {
context.globalCompositeOperation = compositeOperation;
}
}
callback && callback(dataURL);
if (callback) callback(dataURL);
}, 16);
}

View File

@ -16,6 +16,23 @@ import Util from './util';
import './element';
import './behavior';
const G6 = {
version: Global.version,
Graph,
Util,
Layout,
registerLayout,
Global,
registerBehavior,
registerCombo,
registerEdge,
registerNode,
Algorithm,
Arrow,
Marker,
Shape
};
function registerExtenderWrapper<T1, T2>(
registerExtender: (registerName: T1, registerFunction: T2, global: Object) => Object,
): (registerName: T1, registerFunction: T2) => Object {
@ -26,23 +43,8 @@ function registerExtenderWrapper<T1, T2>(
const registerGraph = registerExtenderWrapper(oRegisterGraph);
const G6 = {
version: Global.version,
Graph,
Util,
Layout,
registerLayout,
registerGraph,
Global,
registerBehavior,
registerCombo,
registerEdge,
registerNode,
Algorithm,
Arrow,
Marker,
Shape,
};
(G6 as any).registerGraph = registerGraph;
export * from '@antv/g6-core';
export * from './types';

View File

@ -9,13 +9,13 @@ export interface IGraph extends IAbstractGraph {
/**
* dataUrl
*/
toDataURL(): string;
toDataURL: () => string;
/**
*
* @param {String} name
*/
downloadImage(name?: string, type?: DataUrlType, backgroundColor?: string): void;
downloadImage: (name?: string, type?: DataUrlType, backgroundColor?: string) => void;
/**
*
@ -23,11 +23,11 @@ export interface IGraph extends IAbstractGraph {
* @param {String} type "image/png" | "image/jpeg" | "image/webp" | "image/bmp"
* @param {Object} imageConfig padding
*/
downloadFullImage(
downloadFullImage: (
name?: string,
type?: DataUrlType,
imageConfig?: { backgroundColor?: string; padding?: number | number[] },
): void;
) => void;
/**
* dataUrl
@ -35,37 +35,37 @@ export interface IGraph extends IAbstractGraph {
* @param {String} type "image/png" | "image/jpeg" | "image/webp" | "image/bmp"
* @param {Object} imageConfig padding
*/
toFullDataURL(
toFullDataURL: (
callback: (res: string) => any,
type?: DataUrlType,
imageConfig?: { backgroundColor?: string; padding?: number | number[] },
): void;
) => void;
/**
*
* @param {object} plugin
*/
addPlugin(plugin: PluginBase): void;
addPlugin: (plugin: PluginBase) => void;
/**
*
* @param {object} plugin
*/
removePlugin(plugin: PluginBase): void;
removePlugin: (plugin: PluginBase) => void;
/**
*
* @param {string} imgURL url地址
* @param {WaterMarkerConfig} config
*/
setImageWaterMarker(imgURL: string, config: WaterMarkerConfig);
setImageWaterMarker: (imgURL: string, config: WaterMarkerConfig) => void;
/**
*
* @param {string[]} texts
* @param {WaterMarkerConfig} config
*/
setTextWaterMarker(texts: string[], config?: WaterMarkerConfig);
setTextWaterMarker: (texts: string[], config?: WaterMarkerConfig) => void;
}
export interface ITreeGraph extends IGraph {
@ -74,20 +74,20 @@ export interface ITreeGraph extends IGraph {
* @param {TreeGraphData} data
* @param {string | Item} parent id
*/
addChild(data: TreeGraphData, parent: string | Item): void;
addChild: (data: TreeGraphData, parent: string | Item) => void;
/**
*
* @param {TreeGraphData} data
* @param {string} parent id
*/
updateChild(data: TreeGraphData, parent?: string): void;
updateChild: (data: TreeGraphData, parent?: string) => void;
/**
*
* @param {string} id id
*/
removeChild(id: string): void;
removeChild: (id: string) => void;
/**
* id获取对应的源数据
@ -95,14 +95,14 @@ export interface ITreeGraph extends IGraph {
* @param {TreeGraphData | undefined} parent
* @return {TreeGraphData}
*/
findDataById(id: string, parent?: TreeGraphData | undefined): TreeGraphData | null;
findDataById: (id: string, parent?: TreeGraphData | undefined) => TreeGraphData | null;
/**
*
* @param {TreeGraphData} data
* @param {function} onFrame
*/
layoutAnimate(
layoutAnimate: (
data: TreeGraphData,
onFrame?: (
item: Item,
@ -110,18 +110,18 @@ export interface ITreeGraph extends IGraph {
originAttrs?: ShapeStyle,
data?: TreeGraphData,
) => unknown,
): void;
) => void;
/**
*
*/
stopLayoutAnimate(): void;
stopLayoutAnimate: () => void;
/**
*
* @return {boolean}
*/
isLayoutAnimating(): boolean;
isLayoutAnimating: () => boolean;
}
export class G6GraphEvent extends GraphEvent implements IG6GraphEvent {

View File

@ -1,6 +1,7 @@
import * as ColorUtil from './color';
import * as LayoutUtil from './layout';
import { Util } from '@antv/g6-core';
const G6Util: any = { ...Util, ...ColorUtil, ...LayoutUtil };
export default G6Util;