Skip to content

Commit 1b40666

Browse files
committed
style: lint code
1 parent b67da04 commit 1b40666

26 files changed

+587
-664
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
dist
22
src/__tests__
3+
**/*.d.ts

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ module.exports = {
44
amd: true,
55
node: true,
66
},
7+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
8+
plugins: ['@typescript-eslint'],
79
parser: '@typescript-eslint/parser',
810
parserOptions: {
911
sourceType: 'module',
1012
},
11-
extends: ['eslint:recommended', 'plugin:prettier/recommended'],
1213
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
"@babel/runtime": "^7.15.4",
3939
"@commitlint/cli": "^17.4.3",
4040
"@commitlint/config-conventional": "^17.4.3",
41-
"@typescript-eslint/parser": "^5.0.0",
41+
"@typescript-eslint/eslint-plugin": "^5.52.0",
42+
"@typescript-eslint/parser": "^5.52.0",
4243
"babel-loader": "^8.0.6",
4344
"better-docs": "^2.3.2",
4445
"canvg": "^3.0.6",

src/customLink.ts

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import {
2-
LinkDragMoveHelper,
3-
generateUUID,
4-
getArrowPoints,
5-
calcP1,
6-
calcP4,
7-
} from './utils/index'
1+
import { LinkDragMoveHelper, generateUUID, getArrowPoints, calcP1, calcP4 } from './utils/index'
82
import { createSvgGroup } from './utils/svg'
93

104
// TODO Link label
11-
export const createLink = function(from, to, isInitPaint, obj) {
5+
export const createLink = function (from, to, isInitPaint, obj) {
126
const map = this.map.getBoundingClientRect()
137
if (!from || !to) {
148
return // not expand
@@ -115,10 +109,12 @@ export const createLink = function(from, to, isInitPaint, obj) {
115109
this.currentLink = newSvgGroup
116110
}
117111
this.linkSvgGroup.appendChild(newSvgGroup)
118-
if (!isInitPaint) { this.showLinkController(p2x, p2y, p3x, p3y, newLinkObj, fromData, toData) }
112+
if (!isInitPaint) {
113+
this.showLinkController(p2x, p2y, p3x, p3y, newLinkObj, fromData, toData)
114+
}
119115
}
120116

121-
export const removeLink = function(linkSvg) {
117+
export const removeLink = function (linkSvg) {
122118
let link
123119
if (linkSvg) {
124120
link = linkSvg
@@ -134,7 +130,7 @@ export const removeLink = function(linkSvg) {
134130
link.remove()
135131
link = null
136132
}
137-
export const selectLink = function(targetElement) {
133+
export const selectLink = function (targetElement) {
138134
this.currentLink = targetElement
139135
const obj = targetElement.linkObj
140136
const from = obj.from
@@ -168,20 +164,12 @@ export const selectLink = function(targetElement) {
168164

169165
this.showLinkController(p2x, p2y, p3x, p3y, obj, fromData, toData)
170166
}
171-
export const hideLinkController = function() {
167+
export const hideLinkController = function () {
172168
this.linkController.style.display = 'none'
173169
this.P2.style.display = 'none'
174170
this.P3.style.display = 'none'
175171
}
176-
export const showLinkController = function(
177-
p2x,
178-
p2y,
179-
p3x,
180-
p3y,
181-
linkObj,
182-
fromData,
183-
toData
184-
) {
172+
export const showLinkController = function (p2x, p2y, p3x, p3y, linkObj, fromData, toData) {
185173
this.linkController.style.display = 'initial'
186174
this.P2.style.display = 'initial'
187175
this.P3.style.display = 'initial'
@@ -227,10 +215,7 @@ export const showLinkController = function(
227215

228216
this.P2.style.top = p2y + 'px'
229217
this.P2.style.left = p2x + 'px'
230-
this.currentLink.children[0].setAttribute(
231-
'd',
232-
`M ${p1x} ${p1y} C ${p2x} ${p2y} ${p3x} ${p3y} ${p4x} ${p4y}`
233-
)
218+
this.currentLink.children[0].setAttribute('d', `M ${p1x} ${p1y} C ${p2x} ${p2y} ${p3x} ${p3y} ${p4x} ${p4y}`)
234219
this.line1.setAttribute('x1', p1x)
235220
this.line1.setAttribute('y1', p1y)
236221
this.line1.setAttribute('x2', p2x)
@@ -250,14 +235,8 @@ export const showLinkController = function(
250235

251236
this.P3.style.top = p3y + 'px'
252237
this.P3.style.left = p3x + 'px'
253-
this.currentLink.children[0].setAttribute(
254-
'd',
255-
`M ${p1x} ${p1y} C ${p2x} ${p2y} ${p3x} ${p3y} ${p4x} ${p4y}`
256-
)
257-
this.currentLink.children[1].setAttribute(
258-
'd',
259-
`M ${arrowPoint.x1} ${arrowPoint.y1} L ${p4x} ${p4y} L ${arrowPoint.x2} ${arrowPoint.y2}`
260-
)
238+
this.currentLink.children[0].setAttribute('d', `M ${p1x} ${p1y} C ${p2x} ${p2y} ${p3x} ${p3y} ${p4x} ${p4y}`)
239+
this.currentLink.children[1].setAttribute('d', `M ${arrowPoint.x1} ${arrowPoint.y1} L ${p4x} ${p4y} L ${arrowPoint.x2} ${arrowPoint.y2}`)
261240
this.line2.setAttribute('x1', p3x)
262241
this.line2.setAttribute('y1', p3y)
263242
this.line2.setAttribute('x2', p4x)

src/exampleData/1.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export default {
99
topic: 'logo',
1010
id: '56dae51a90d350a8',
1111
direction: 0,
12-
expanded: true, children: [
12+
expanded: true,
13+
children: [
1314
{
1415
topic: 'mind-elixir',
1516
image: {
@@ -185,8 +186,7 @@ export default {
185186
expanded: true,
186187
children: [
187188
{
188-
topic:
189-
'Drag a node to another node\nand the former one will become a child node of latter one',
189+
topic: 'Drag a node to another node\nand the former one will become a child node of latter one',
190190
id: 'bd1f07c598e729dc',
191191
},
192192
],

src/exampleData/2.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ export default {
6565
{
6666
topic: 'grp',
6767
id: '3390930112ea7367',
68-
tags: [
69-
'what add node actually do is to append grp tag to children',
70-
],
68+
tags: ['what add node actually do is to append grp tag to children'],
7169
},
7270
{ topic: 'grp...', id: '3390940a8c8380a6' },
7371
],

src/global.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
declare interface Element {
2-
setAttribute(name: string, value: boolean): void;
3-
setAttribute(name: string, value: number): void;
2+
setAttribute(name: string, value: boolean): void
3+
setAttribute(name: string, value: number): void
44
}

src/iconfont/iconfont.js

Lines changed: 59 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)