diff --git a/build/progress.js b/build/progress.js index b331400d6..426bd3116 100644 --- a/build/progress.js +++ b/build/progress.js @@ -53,8 +53,13 @@ module.exports = function progress(options = {}) { }, buildEnd() { - process.stdout.clearLine(); - process.stdout.cursorTo(0); + if (process.stdout.isTTY) { + process.stdout.clearLine(); + process.stdout.cursorTo(0); + } + else { + console.log(''); + } } }; }; diff --git a/package.json b/package.json index d6b543639..782f5f040 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,8 @@ "build:lib": "npx tsc -m ES2015 --outDir lib", "watch:bundle": "node build/build.js --watch", "watch:lib": "npx tsc -w -m ES2015 --outDir lib", - "test": "npx jest --config test/ut/jest.config.js" + "test": "npx jest --config test/ut/jest.config.js", + "lint": "npx eslint src/**/*.ts" }, "license": "BSD-3-Clause", "types": "index.d.ts", diff --git a/src/Element.ts b/src/Element.ts index fd5324e38..0f75e67fb 100644 --- a/src/Element.ts +++ b/src/Element.ts @@ -293,6 +293,7 @@ export type ElementCalculateTextPosition = ( let tmpTextPosCalcRes = {} as TextPositionCalculationResult; let tmpBoundingRect = new BoundingRect(0, 0, 0, 0); +// eslint-disable-next-line @typescript-eslint/no-unused-vars interface Element extends Transformable, Eventful<{ [key in ElementEventName]: (e: ElementEvent) => void | boolean diff --git a/src/PainterBase.ts b/src/PainterBase.ts index a65492dab..c4eedeb49 100644 --- a/src/PainterBase.ts +++ b/src/PainterBase.ts @@ -4,10 +4,10 @@ import { GradientObject } from './graphic/Gradient'; import { PatternObject } from './graphic/Pattern'; import { Dictionary } from './core/types'; -interface PainterOption { - width?: number | string // Can be 10 / 10px / auto - height?: number | string -} +// interface PainterOption { +// width?: number | string // Can be 10 / 10px / auto +// height?: number | string +// } export interface PainterBase { diff --git a/src/animation/Animator.ts b/src/animation/Animator.ts index 1fd3a12e9..e65dcc971 100644 --- a/src/animation/Animator.ts +++ b/src/animation/Animator.ts @@ -430,8 +430,8 @@ class Track { for (let i = 0; i < kfsLen; i++) { if (arrDim === 0) { if (this.isValueColor) { - kfs[i].additiveValue - = add1DArray([], kfs[i].value as NumberArray, startValue as NumberArray, -1); + kfs[i].additiveValue = + add1DArray([], kfs[i].value as NumberArray, startValue as NumberArray, -1); } else { kfs[i].additiveValue = kfs[i].value as number - (startValue as number); diff --git a/src/animation/Clip.ts b/src/animation/Clip.ts index 67454f979..caddaf561 100644 --- a/src/animation/Clip.ts +++ b/src/animation/Clip.ts @@ -21,7 +21,7 @@ type ondestroyCallback = () => void type onrestartCallback = () => void export type DeferredEventTypes = 'destroy' | 'restart' -type DeferredEventKeys = 'ondestroy' | 'onrestart' +// type DeferredEventKeys = 'ondestroy' | 'onrestart' export interface ClipProps { life?: number diff --git a/src/config.ts b/src/config.ts index 07c468ae4..7be4a7898 100644 --- a/src/config.ts +++ b/src/config.ts @@ -2,9 +2,11 @@ let dpr = 1; // If in browser environment if (typeof window !== 'undefined') { - dpr = Math.max(window.devicePixelRatio - || (window.screen && (window.screen as any).deviceXDPI / (window.screen as any).logicalXDPI) - || 1, 1); + dpr = Math.max( + window.devicePixelRatio + || (window.screen && (window.screen as any).deviceXDPI / (window.screen as any).logicalXDPI) + || 1, 1 + ); } /** diff --git a/src/core/PathProxy.ts b/src/core/PathProxy.ts index b28e832de..0d520d891 100644 --- a/src/core/PathProxy.ts +++ b/src/core/PathProxy.ts @@ -1059,8 +1059,8 @@ export default class PathProxy { const psi = d[i++]; const anticlockwise = !d[i++]; const r = (rx > ry) ? rx : ry; - const scaleX = (rx > ry) ? 1 : rx / ry; - const scaleY = (rx > ry) ? ry / rx : 1; + // const scaleX = (rx > ry) ? 1 : rx / ry; + // const scaleY = (rx > ry) ? ry / rx : 1; const isEllipse = mathAbs(rx - ry) > 1e-3; let endAngle = startAngle + delta; let breakBuild = false; @@ -1174,6 +1174,7 @@ export interface PathRebuilder { bezierCurveTo(x: number, y: number, x2: number, y2: number, x3: number, y3: number): void quadraticCurveTo(x: number, y: number, x2: number, y2: number): void arc(cx: number, cy: number, r: number, startAngle: number, endAngle: number, anticlockwise: boolean): void + // eslint-disable-next-line max-len ellipse(cx: number, cy: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, anticlockwise: boolean): void rect(x: number, y: number, width: number, height: number): void closePath(): void diff --git a/src/core/arrayDiff.ts b/src/core/arrayDiff.ts index 0a19115ad..4c1186d37 100644 --- a/src/core/arrayDiff.ts +++ b/src/core/arrayDiff.ts @@ -185,6 +185,6 @@ function clonePath(path: DiffPath) { return { newPos: path.newPos, components: path.components.slice(0) }; } -export default function arrayDiff (oldArr: T[], newArr: T[], equal?: EqualFunc): DiffComponent[] { +export default function arrayDiff(oldArr: T[], newArr: T[], equal?: EqualFunc): DiffComponent[] { return diff(oldArr, newArr, equal); } \ No newline at end of file diff --git a/src/core/env.ts b/src/core/env.ts index c47445814..010ef9f0c 100644 --- a/src/core/env.ts +++ b/src/core/env.ts @@ -74,7 +74,7 @@ function detect(ua: string, env: Env) { if (edge) { browser.edge = true; browser.version = edge[1]; - browser.newEdge = +edge[1].split('.')[0] > 18; + browser.newEdge = +edge[1].split('.')[0] > 18; } // It is difficult to detect WeChat in Win Phone precisely, because ua can @@ -108,7 +108,7 @@ function detect(ua: string, env: Env) { // except IE 6-8 and very old firefox 2-3 & opera 10.1 // other browsers all support `transform` - env.transformSupported = env.transform3dSupported + env.transformSupported = env.transform3dSupported // transform 2D is supported in IE9 || (browser.ie && +browser.version >= 9); diff --git a/src/debug/showDebugDirtyRect.ts b/src/debug/showDebugDirtyRect.ts index a307bd154..f0c17831c 100644 --- a/src/debug/showDebugDirtyRect.ts +++ b/src/debug/showDebugDirtyRect.ts @@ -17,7 +17,7 @@ class DebugRect { extend(style, { backgroundColor: 'rgba(0, 0, 255, 0.2)', border: '1px solid #00f' - }) + }); dom.style.cssText = ` position: absolute; opacity: 0; diff --git a/src/graphic/Displayable.ts b/src/graphic/Displayable.ts index 689b46fd8..5293d501f 100644 --- a/src/graphic/Displayable.ts +++ b/src/graphic/Displayable.ts @@ -79,6 +79,7 @@ export type DisplayableState = Pick const PRIMARY_STATES_KEYS = ['z', 'z2', 'invisible'] as const; const PRIMARY_STATES_KEYS_IN_HOVER_LAYER = ['invisible'] as const; +// eslint-disable-next-line @typescript-eslint/no-unused-vars interface Displayable { animate(key?: '', loop?: boolean): Animator animate(key: 'style', loop?: boolean): Animator diff --git a/src/graphic/Path.ts b/src/graphic/Path.ts index 34885002d..9776eface 100644 --- a/src/graphic/Path.ts +++ b/src/graphic/Path.ts @@ -107,6 +107,7 @@ export interface PathProps extends DisplayableProps { type PathKey = keyof PathProps type PathPropertyType = PropType +// eslint-disable-next-line @typescript-eslint/no-unused-vars interface Path { animate(key?: '', loop?: boolean): Animator animate(key: 'style', loop?: boolean): Animator diff --git a/src/graphic/helper/dashStyle.ts b/src/graphic/helper/dashStyle.ts index 1a31efdc9..732ad45c5 100644 --- a/src/graphic/helper/dashStyle.ts +++ b/src/graphic/helper/dashStyle.ts @@ -5,9 +5,9 @@ export function normalizeLineDash(lineType: any, lineWidth?: number): number[] | return null; } lineWidth = lineWidth || 1; - return lineType === 'dashed' + return lineType === 'dashed' ? [4 * lineWidth, 2 * lineWidth] - : lineType === 'dotted' + : lineType === 'dotted' ? [lineWidth] : isNumber(lineType) ? [lineType] : isArray(lineType) ? lineType : null; diff --git a/src/graphic/helper/roundSector.ts b/src/graphic/helper/roundSector.ts index d0dc215bb..ef5a7f466 100644 --- a/src/graphic/helper/roundSector.ts +++ b/src/graphic/helper/roundSector.ts @@ -22,9 +22,9 @@ type CornerTangents = { }; function intersect( - x0: number, y0: number, - x1: number, y1: number, - x2: number, y2: number, + x0: number, y0: number, + x1: number, y1: number, + x2: number, y2: number, x3: number, y3: number ): [number, number] { const x10 = x1 - x0; @@ -41,9 +41,9 @@ function intersect( // Compute perpendicular offset line of length rc. function computeCornerTangents( - x0: number, y0: number, - x1: number, y1: number, - radius: number, cr: number, + x0: number, y0: number, + x1: number, y1: number, + radius: number, cr: number, clockwise: boolean ): CornerTangents { const x01 = x0 - x1; @@ -150,14 +150,14 @@ export function buildPath(ctx: CanvasRenderingContext2D | PathProxy, shape: { // is a circle or annulus else if (arc > PI2 - e) { ctx.moveTo( - x + radius * mathCos(startAngle), + x + radius * mathCos(startAngle), y + radius * mathSin(startAngle) ); ctx.arc(x, y, radius, startAngle, endAngle, !clockwise); if (innerRadius > e) { ctx.moveTo( - x + innerRadius * mathCos(endAngle), + x + innerRadius * mathCos(endAngle), y + innerRadius * mathSin(endAngle) ); ctx.arc(x, y, innerRadius, endAngle, startAngle, clockwise); @@ -219,15 +219,17 @@ export function buildPath(ctx: CanvasRenderingContext2D | PathProxy, shape: { // Have the corners merged? if (cr1 < cr) { + // eslint-disable-next-line max-len ctx.arc(x + ct0.cx, y + ct0.cy, cr1, mathATan2(ct0.y01, ct0.x01), mathATan2(ct1.y01, ct1.x01), !clockwise); } else { - // draw the two corners and the ring - ctx.arc(x + ct0.cx, y + ct0.cy, cr1, mathATan2(ct0.y01, ct0.x01), mathATan2(ct0.y11, ct0.x11), !clockwise); - - ctx.arc(x, y, radius, mathATan2(ct0.cy + ct0.y11, ct0.cx + ct0.x11), mathATan2(ct1.cy + ct1.y11, ct1.cx + ct1.x11), !clockwise); - - ctx.arc(x + ct1.cx, y + ct1.cy, cr1, mathATan2(ct1.y11, ct1.x11), mathATan2(ct1.y01, ct1.x01), !clockwise); + // draw the two corners and the ring + // eslint-disable-next-line max-len + ctx.arc(x + ct0.cx, y + ct0.cy, cr1, mathATan2(ct0.y01, ct0.x01), mathATan2(ct0.y11, ct0.x11), !clockwise); + // eslint-disable-next-line max-len + ctx.arc(x, y, radius, mathATan2(ct0.cy + ct0.y11, ct0.cx + ct0.x11), mathATan2(ct1.cy + ct1.y11, ct1.cx + ct1.x11), !clockwise); + // eslint-disable-next-line max-len + ctx.arc(x + ct1.cx, y + ct1.cy, cr1, mathATan2(ct1.y11, ct1.x11), mathATan2(ct1.y01, ct1.x01), !clockwise); } } // the outer ring is a circular arc @@ -248,15 +250,17 @@ export function buildPath(ctx: CanvasRenderingContext2D | PathProxy, shape: { // Have the corners merged? if (cr0 < icr) { + // eslint-disable-next-line max-len ctx.arc(x + ct0.cx, y + ct0.cy, cr0, mathATan2(ct0.y01, ct0.x01), mathATan2(ct1.y01, ct1.x01), !clockwise); } // draw the two corners and the ring else { - ctx.arc(x + ct0.cx, y + ct0.cy, cr0, mathATan2(ct0.y01, ct0.x01), mathATan2(ct0.y11, ct0.x11), !clockwise); - - ctx.arc(x, y, innerRadius, mathATan2(ct0.cy + ct0.y11, ct0.cx + ct0.x11), mathATan2(ct1.cy + ct1.y11, ct1.cx + ct1.x11), clockwise); - - ctx.arc(x + ct1.cx, y + ct1.cy, cr0, mathATan2(ct1.y11, ct1.x11), mathATan2(ct1.y01, ct1.x01), !clockwise); + // eslint-disable-next-line max-len + ctx.arc(x + ct0.cx, y + ct0.cy, cr0, mathATan2(ct0.y01, ct0.x01), mathATan2(ct0.y11, ct0.x11), !clockwise); + // eslint-disable-next-line max-len + ctx.arc(x, y, innerRadius, mathATan2(ct0.cy + ct0.y11, ct0.cx + ct0.x11), mathATan2(ct1.cy + ct1.y11, ct1.cx + ct1.x11), clockwise); + // eslint-disable-next-line max-len + ctx.arc(x + ct1.cx, y + ct1.cy, cr0, mathATan2(ct1.y11, ct1.x11), mathATan2(ct1.y01, ct1.x01), !clockwise); } } // the inner ring is just a circular arc diff --git a/src/graphic/shape/Sector.ts b/src/graphic/shape/Sector.ts index 0c0f51d13..0b3f6cdfb 100644 --- a/src/graphic/shape/Sector.ts +++ b/src/graphic/shape/Sector.ts @@ -30,7 +30,7 @@ class Sector extends Path { } buildPath(ctx: CanvasRenderingContext2D, shape: SectorShape) { - roundSectorHelper.buildPath(ctx, shape) + roundSectorHelper.buildPath(ctx, shape); } isZeroArea() { diff --git a/src/svg/Painter.ts b/src/svg/Painter.ts index 8cb19150d..811eb64a3 100644 --- a/src/svg/Painter.ts +++ b/src/svg/Painter.ts @@ -444,13 +444,11 @@ class SVGPainter implements PainterBase { dispose() { this.root.innerHTML = ''; - this._svgRoot - = this._backgroundRoot - = this._svgDom - = this._backgroundNode - = this._viewport - = this.storage - = null; + this._svgRoot = + this._backgroundRoot = + this._svgDom = + this._backgroundNode = + this._viewport = this.storage = null; } clear() { diff --git a/src/tool/dividePath.ts b/src/tool/dividePath.ts index a7fc8a38c..6c670a894 100644 --- a/src/tool/dividePath.ts +++ b/src/tool/dividePath.ts @@ -1,7 +1,7 @@ import { fromPoints } from '../core/bbox'; import BoundingRect from '../core/BoundingRect'; import Point from '../core/Point'; -import { each, map } from '../core/util'; +import { map } from '../core/util'; import Path from '../graphic/Path'; import Polygon from '../graphic/shape/Polygon'; import Rect from '../graphic/shape/Rect'; diff --git a/src/tool/morphPath.ts b/src/tool/morphPath.ts index 6c6fd205e..c29d33d59 100644 --- a/src/tool/morphPath.ts +++ b/src/tool/morphPath.ts @@ -2,7 +2,7 @@ import PathProxy from '../core/PathProxy'; import { cubicSubdivide } from '../core/curve'; import Path from '../graphic/Path'; import Element, { ElementAnimateConfig } from '../Element'; -import { defaults, extend, map } from '../core/util'; +import { defaults, map } from '../core/util'; import { lerp } from '../core/vector'; import Group, { GroupLike } from '../graphic/Group'; import { clonePath } from './path'; @@ -558,10 +558,15 @@ function hilbert(x: number, y: number, minX: number, minY: number, maxX: number, let d = 0; let tmp: number; for (let s = (1 << bits) / 2; s > 0; s /= 2) { - let rx = 0, ry = 0; + let rx = 0; + let ry = 0; - if ((x & s) > 0) rx = 1; - if ((y & s) > 0) ry = 1; + if ((x & s) > 0) { + rx = 1; + } + if ((y & s) > 0) { + ry = 1; + } d += s * s * ((3 * rx) ^ ry); @@ -603,7 +608,7 @@ function sortPaths(pathList: Path[]): Path[] { cp, z: hilbert(cp[0], cp[1], xMin, yMin, xMax, yMax), path: pathList[idx] - } + }; }); return items.sort((a, b) => a.z - b.z).map(item => item.path); @@ -645,7 +650,7 @@ function createEmptyReturn() { fromIndividuals: [] as Path[], toIndividuals: [] as Path[], count: 0 - } + }; } /** * Make combine morphing from many paths to one. @@ -756,7 +761,7 @@ export function combineMorph( restoreToPath(); oldDone && oldDone(); } - } + }; // Animate each element individually. for (let i = 0; i < toLen; i++) { // TODO only call during once? @@ -886,4 +891,4 @@ export function separateMorph( }; } -export { split as defaultDividePath } \ No newline at end of file +export { split as defaultDividePath }; diff --git a/src/vml/Painter.ts b/src/vml/Painter.ts index 945c8cbf4..2d55f5726 100644 --- a/src/vml/Painter.ts +++ b/src/vml/Painter.ts @@ -3,9 +3,8 @@ * VML Painter. */ -import {logError} from '../core/util'; +import {logError, each} from '../core/util'; import * as vmlCore from './core'; -import {each} from '../core/util'; function parseInt10(val) { return parseInt(val, 10); diff --git a/src/zrender.ts b/src/zrender.ts index a1d02b6e9..b7de31820 100644 --- a/src/zrender.ts +++ b/src/zrender.ts @@ -15,7 +15,7 @@ import Storage from './Storage'; import {PainterBase} from './PainterBase'; import Animation from './animation/Animation'; import HandlerProxy from './dom/HandlerProxy'; -import Element, {ElementEventCallback, ElementEvent} from './Element'; +import Element, { ElementEventCallback } from './Element'; import { Dictionary, ElementEventName, RenderedEvent, WithThisType } from './core/types'; import { LayerConfig } from './canvas/Layer'; import { GradientObject } from './graphic/Gradient'; @@ -407,6 +407,7 @@ class ZRender { } on(eventName: ElementEventName, eventHandler: ElementEventCallback, context?: Ctx): this + // eslint-disable-next-line max-len on(eventName: string, eventHandler: WithThisType, unknown extends Ctx ? ZRenderType : Ctx>, context?: Ctx): this // eslint-disable-next-line max-len on(eventName: string, eventHandler: (...args: any) => any, context?: Ctx): this {