feat(linting): add eslint

This commit is contained in:
moklick
2022-08-08 13:34:00 +02:00
parent f5c8a89582
commit 7150e0369e
72 changed files with 531 additions and 130 deletions
@@ -1,4 +1,4 @@
import React, { memo, useCallback } from 'react';
import { memo, useCallback } from 'react';
import { useStore } from '../../hooks/useStore';
import { EdgeMarker, ReactFlowState } from '../../types';
@@ -24,6 +24,10 @@ const Marker = ({
}: MarkerProps) => {
const Symbol = useMarkerSymbol(type);
if (!Symbol) {
return null;
}
return (
<marker
className="react-flow__arrowhead"
@@ -1,4 +1,4 @@
import React, { useMemo } from 'react';
import { useMemo } from 'react';
import { MarkerType, EdgeMarker } from '../../types';
type SymbolProps = Omit<EdgeMarker, 'type'>;
@@ -36,14 +36,14 @@ export const MarkerSymbols = {
export function useMarkerSymbol(type: MarkerType) {
const symbol = useMemo(() => {
const symbolExists = MarkerSymbols.hasOwnProperty(type);
const symbolExists = Object.prototype.hasOwnProperty.call(MarkerSymbols, type);
if (!symbolExists) {
// @ts-ignore
if (process.env.NODE_ENV === 'development') {
console.warn(`[React Flow]: Marker type "${type}" doesn't exist. Help: https://reactflow.dev/error#900`);
}
return () => null;
return null;
}
return MarkerSymbols[type];
@@ -1,4 +1,4 @@
import React, { memo, CSSProperties } from 'react';
import { memo, CSSProperties } from 'react';
import shallow from 'zustand/shallow';
import cc from 'classcat';
@@ -114,7 +114,6 @@ const EdgeRenderer = (props: EdgeRendererProps) => {
const targetPosition = targetHandle?.position || Position.Top;
if (!sourceHandle) {
// @ts-ignore
if (process.env.NODE_ENV === 'development') {
console.warn(
`[React Flow]: Couldn't create edge for source handle id: ${edge.sourceHandle}; edge id: ${edge.id}. Help: https://reactflow.dev/error#800`
@@ -124,7 +123,6 @@ const EdgeRenderer = (props: EdgeRendererProps) => {
}
if (!targetHandle) {
// @ts-ignore
if (process.env.NODE_ENV === 'development') {
console.warn(
`[React Flow]: Couldn't create edge for target handle id: ${edge.targetHandle}; edge id: ${edge.id}. Help: https://reactflow.dev/error#800`
@@ -41,7 +41,7 @@ export function createEdgeTypes(edgeTypes: EdgeTypes): EdgeTypesWrapped {
};
}
export function getHandlePosition(position: Position, nodeRect: Rect, handle: any | null = null): XYPosition {
export function getHandlePosition(position: Position, nodeRect: Rect, handle: HandleElement | null = null): XYPosition {
const x = (handle?.x || 0) + nodeRect.x;
const y = (handle?.y || 0) + nodeRect.y;
const width = handle?.width || nodeRect.width;
@@ -97,10 +97,10 @@ interface EdgePositions {
export const getEdgePositions = (
sourceNodeRect: Rect,
sourceHandle: HandleElement | unknown,
sourceHandle: HandleElement,
sourcePosition: Position,
targetNodeRect: Rect,
targetHandle: HandleElement | unknown,
targetHandle: HandleElement,
targetPosition: Position
): EdgePositions => {
const sourceHandlePos = getHandlePosition(sourcePosition, sourceNodeRect, sourceHandle);