chore: lint files

This commit is contained in:
Braks
2022-05-15 17:02:28 +02:00
parent 4ee7eb909a
commit a90bbb9b5e
10 changed files with 48 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
import { MarkerType, Elements } from '@braks/vue-flow'
import type { Elements } from '@braks/vue-flow'
import { MarkerType } from '@braks/vue-flow'
const markerEnd = MarkerType.Arrow

View File

@@ -1,6 +1,7 @@
<script lang="ts" setup>
import { Component, CSSProperties, DefineComponent } from 'vue'
import { getEdgeCenter, BezierEdge, EdgeText, Position, EdgeProps, EdgeTextProps, GraphNode } from '@braks/vue-flow'
import type { CSSProperties, Component, DefineComponent } from 'vue'
import type { EdgeProps, EdgeTextProps, GraphNode } from '@braks/vue-flow'
import { BezierEdge, EdgeText, Position, getEdgeCenter } from '@braks/vue-flow'
import { createGrid, gridRatio } from './createGrid'
import { drawSmoothLinePath } from './drawSvgPath'
import { generatePath } from './generatePath'
@@ -39,10 +40,6 @@ interface PathFindingEdgeProps extends EdgeProps {
targetHandleId?: string
}
const nodePadding = 10
const graphPadding = 20
const roundCoordinatesTo = gridRatio
const props = withDefaults(defineProps<PathFindingEdgeProps>(), {
selected: false,
sourcePosition: Position.Bottom,
@@ -52,6 +49,10 @@ const props = withDefaults(defineProps<PathFindingEdgeProps>(), {
labelBgStyle: () => ({}),
})
const nodePadding = 10
const graphPadding = 20
const roundCoordinatesTo = gridRatio
const centered = computed(() =>
getEdgeCenter({
...props,
@@ -104,12 +105,14 @@ const path = computed(() => {
})
const attrs: any = useAttrs()
</script>
<script lang="ts">
export default {
name: 'PathFindingEdge',
inheritAttrs: false,
}
</script>
<template>
<BezierEdge v-if="gridPath && gridPath.length <= 2" v-bind="{ ...props, ...attrs }" />
<template v-else>

View File

@@ -1,13 +1,13 @@
import { Grid } from 'pathfinding'
import { Position } from '@braks/vue-flow'
import { guaranteeWalkablePath, getNextPointFromPosition } from './guaranteeWalkablePath'
import type { Position } from '@braks/vue-flow'
import { getNextPointFromPosition, guaranteeWalkablePath } from './guaranteeWalkablePath'
import { graphToGridPoint } from './pointConversion'
import { round } from './utils'
import type { NodeBoundingBox, GraphBoundingBox } from './getBoundingBoxes'
import type { GraphBoundingBox, NodeBoundingBox } from './getBoundingBoxes'
export const gridRatio = 10
export type PointInfo = {
export interface PointInfo {
x: number
y: number
position: Position

View File

@@ -1,7 +1,7 @@
/**
* Draws a SVG path from a list of points, using straight lines.
*/
import { XYPosition } from '@braks/vue-flow'
import type { XYPosition } from '@braks/vue-flow'
const getMidPoint = (Ax: number, Ay: number, Bx: number, By: number) => {
const Zx = (Ax - Bx) / 2 + Bx

View File

@@ -1,6 +1,6 @@
import { AStarFinder, Util, DiagonalMovement, Heuristic } from 'pathfinding'
import type { Grid } from 'pathfinding'
import { XYPosition } from '@braks/vue-flow'
import { AStarFinder, DiagonalMovement, Util } from 'pathfinding'
import type { Grid, Heuristic } from 'pathfinding'
import type { XYPosition } from '@braks/vue-flow'
// https://www.npmjs.com/package/pathfinding#advanced-usage
declare module 'pathfinding' {

View File

@@ -1,7 +1,7 @@
import { XYPosition, GraphNode } from '@braks/vue-flow'
import { roundUp, roundDown } from './utils'
import type { GraphNode, XYPosition } from '@braks/vue-flow'
import { roundDown, roundUp } from './utils'
export type NodeBoundingBox = {
export interface NodeBoundingBox {
id: string
width: number
height: number
@@ -11,7 +11,7 @@ export type NodeBoundingBox = {
bottomRight: XYPosition
}
export type GraphBoundingBox = {
export interface GraphBoundingBox {
width: number
height: number
topLeft: XYPosition

View File

@@ -1,5 +1,5 @@
import type { Grid } from 'pathfinding'
import { Position, XYPosition } from '@braks/vue-flow'
import type { Position, XYPosition } from '@braks/vue-flow'
type Direction = 'top' | 'bottom' | 'left' | 'right'

View File

@@ -1,4 +1,4 @@
import { XYPosition } from '@braks/vue-flow'
import type { XYPosition } from '@braks/vue-flow'
const gridRatio = 10

View File

@@ -1,5 +1,5 @@
declare module '*.vue' {
import { DefineComponent } from 'vue'
import type { DefineComponent } from 'vue'
// eslint-disable-next-line @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>
export default component

View File

@@ -1756,6 +1756,11 @@
resolved "https://registry.yarnpkg.com/@types/parse-json/-/parse-json-4.0.0.tgz#2f8bb441434d163b35fb8ffdccd7138927ffb8c0"
integrity sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==
"@types/pathfinding@^0.0.5":
version "0.0.5"
resolved "https://registry.yarnpkg.com/@types/pathfinding/-/pathfinding-0.0.5.tgz#36ebc95770e3ee0c67a9afc8b5c1dc59472cebdc"
integrity sha512-mmH8rE8zNJ3aNuEBcm9/psBNMb4UdIK7rN9zKiVeuBD2G2cJIeQkluCRBlAWxJ5btdXnq/jVO1cW0bLEW+pakQ==
"@types/prop-types@*":
version "15.7.4"
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.4.tgz#fcf7205c25dff795ee79af1e30da2c9790808f11"
@@ -4969,6 +4974,11 @@ hash-sum@^2.0.0:
resolved "https://registry.yarnpkg.com/hash-sum/-/hash-sum-2.0.0.tgz#81d01bb5de8ea4a214ad5d6ead1b523460b0b45a"
integrity sha512-WdZTbAByD+pHfl/g9QSsBIIwy8IT+EsPiKDs0KNX+zSHhdDLFKdZu0BQHljvO+0QI/BasbMSUa8wYNCZTvhslg==
heap@0.2.5:
version "0.2.5"
resolved "https://registry.yarnpkg.com/heap/-/heap-0.2.5.tgz#713b65590ebcc40fcbeeaf55e851694092b39af1"
integrity sha1-cTtlWQ68xA/L7q9V6FFpQJKzmvE=
hosted-git-info@^2.1.4:
version "2.8.9"
resolved "https://registry.yarnpkg.com/hosted-git-info/-/hosted-git-info-2.8.9.tgz#dffc0bf9a21c02209090f2aa69429e1414daf3f9"
@@ -6719,11 +6729,23 @@ pathe@^0.2.0:
resolved "https://registry.yarnpkg.com/pathe/-/pathe-0.2.0.tgz#30fd7bbe0a0d91f0e60bae621f5d19e9e225c339"
integrity sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==
pathfinding@^0.4.18:
version "0.4.18"
resolved "https://registry.yarnpkg.com/pathfinding/-/pathfinding-0.4.18.tgz#a9990f6fa22b7ef196e5651b049165403a045fe8"
integrity sha1-qZkPb6IrfvGW5WUbBJFlQDoEX+g=
dependencies:
heap "0.2.5"
pend@~1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/pend/-/pend-1.2.0.tgz#7a57eb550a6783f9115331fcf4663d5c8e007a50"
integrity sha1-elfrVQpng/kRUzH89GY9XI4AelA=
perfect-arrows@^0.3.7:
version "0.3.7"
resolved "https://registry.yarnpkg.com/perfect-arrows/-/perfect-arrows-0.3.7.tgz#6932e1c82d26cfe86e7933aed28d45502e5ea131"
integrity sha512-wEN2gerTPVWl3yqoFEF8OeGbg3aRe2sxNUi9rnyYrCsL4JcI6K2tBDezRtqVrYG0BNtsWLdYiiTrYm+X//8yLQ==
performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"