Lint: Add eslint import plugin (#5955)

## Summary

Adds the linter, turns on the recommended and a few extra rules, fixes
existing violations.

Doesn't prohibit `../../...` imports yet, that'll be it's own PR.

## Changes

- **What**: Consistent and fixable imports
- **Dependencies**: The plugin and parser

## Review Focus

How do you feel about the recommended rules?
What about the extra ones?
[Any
more](https://github.com/un-ts/eslint-plugin-import-x?tab=readme-ov-file#rules)
you'd want to turn on?

┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-5955-Lint-Add-eslint-import-plugin-2856d73d3650819985c0fb9ca3fa94b0)
by [Unito](https://www.unito.io)
This commit is contained in:
Alexander Brown
2025-10-07 20:31:00 -07:00
committed by GitHub
parent 45ebc59033
commit 874ef3ba0c
149 changed files with 1754 additions and 482 deletions

View File

@@ -12,10 +12,13 @@ import { LayoutSource } from '@/renderer/core/layout/types'
import type { DragAndScaleState } from './DragAndScale'
import { LGraphCanvas } from './LGraphCanvas'
import { LGraphGroup } from './LGraphGroup'
import { LGraphNode, type NodeId } from './LGraphNode'
import { LLink, type LinkId } from './LLink'
import { LGraphNode } from './LGraphNode'
import type { NodeId } from './LGraphNode'
import { LLink } from './LLink'
import type { LinkId } from './LLink'
import { MapProxyHandler } from './MapProxyHandler'
import { Reroute, type RerouteId } from './Reroute'
import { Reroute } from './Reroute'
import type { RerouteId } from './Reroute'
import { CustomEventTarget } from './infrastructure/CustomEventTarget'
import type { LGraphEventMap } from './infrastructure/LGraphEventMap'
import type { SubgraphEventMap } from './infrastructure/SubgraphEventMap'

View File

@@ -1,4 +1,5 @@
import { LGraphIcon, type LGraphIconOptions } from './LGraphIcon'
import { LGraphIcon } from './LGraphIcon'
import type { LGraphIconOptions } from './LGraphIcon'
export enum BadgePosition {
TopLeft = 'top-left',

View File

@@ -1,4 +1,5 @@
import { LGraphBadge, type LGraphBadgeOptions } from './LGraphBadge'
import { LGraphBadge } from './LGraphBadge'
import type { LGraphBadgeOptions } from './LGraphBadge'
import { Rectangle } from './infrastructure/Rectangle'
export interface LGraphButtonOptions extends LGraphBadgeOptions {

View File

@@ -1,10 +1,8 @@
import { toString } from 'es-toolkit/compat'
import { PREFIX, SEPARATOR } from '@/constants/groupNodeConstants'
import {
type LinkRenderContext,
LitegraphLinkAdapter
} from '@/renderer/core/canvas/litegraph/litegraphLinkAdapter'
import { LitegraphLinkAdapter } from '@/renderer/core/canvas/litegraph/litegraphLinkAdapter'
import type { LinkRenderContext } from '@/renderer/core/canvas/litegraph/litegraphLinkAdapter'
import { getSlotPosition } from '@/renderer/core/canvas/litegraph/slotCalculations'
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
import { layoutStore } from '@/renderer/core/layout/store/layoutStore'
@@ -12,12 +10,16 @@ import { LayoutSource } from '@/renderer/core/layout/types'
import { CanvasPointer } from './CanvasPointer'
import type { ContextMenu } from './ContextMenu'
import { type AnimationOptions, DragAndScale } from './DragAndScale'
import { DragAndScale } from './DragAndScale'
import type { AnimationOptions } from './DragAndScale'
import type { LGraph } from './LGraph'
import { LGraphGroup } from './LGraphGroup'
import { LGraphNode, type NodeId, type NodeProperty } from './LGraphNode'
import { LLink, type LinkId } from './LLink'
import { Reroute, type RerouteId } from './Reroute'
import { LGraphNode } from './LGraphNode'
import type { NodeId, NodeProperty } from './LGraphNode'
import { LLink } from './LLink'
import type { LinkId } from './LLink'
import { Reroute } from './Reroute'
import type { RerouteId } from './Reroute'
import { LinkConnector } from './canvas/LinkConnector'
import { isOverNodeInput, isOverNodeOutput } from './canvas/measureSlots'
import { strokeShape } from './draw'
@@ -85,8 +87,7 @@ import {
TitleMode
} from './types/globalEnums'
import type { ClipboardItems, SubgraphIO } from './types/serialisation'
import type { NeverNever } from './types/utility'
import type { PickNevers } from './types/utility'
import type { NeverNever, PickNevers } from './types/utility'
import type { IBaseWidget } from './types/widgets'
import { alignNodes, distributeNodes, getBoundaryNodes } from './utils/arrange'
import { findFirstNode, getAllNestedItems } from './utils/collections'

View File

@@ -1,18 +1,20 @@
import { LGraphNodeProperties } from '@/lib/litegraph/src/LGraphNodeProperties'
import {
type SlotPositionContext,
calculateInputSlotPos,
calculateInputSlotPosFromSlot,
calculateOutputSlotPos
} from '@/renderer/core/canvas/litegraph/slotCalculations'
import type { SlotPositionContext } from '@/renderer/core/canvas/litegraph/slotCalculations'
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
import { LayoutSource } from '@/renderer/core/layout/types'
import { type ColorAdjustOptions, adjustColor } from '@/utils/colorUtil'
import { adjustColor } from '@/utils/colorUtil'
import type { ColorAdjustOptions } from '@/utils/colorUtil'
import type { DragAndScale } from './DragAndScale'
import type { LGraph } from './LGraph'
import { BadgePosition, LGraphBadge } from './LGraphBadge'
import { LGraphButton, type LGraphButtonOptions } from './LGraphButton'
import { LGraphButton } from './LGraphButton'
import type { LGraphButtonOptions } from './LGraphButton'
import { LGraphCanvas } from './LGraphCanvas'
import { LLink } from './LLink'
import type { Reroute, RerouteId } from './Reroute'
@@ -42,12 +44,8 @@ import type {
Rect,
Size
} from './interfaces'
import {
type LGraphNodeConstructor,
LiteGraph,
type Subgraph,
type SubgraphNode
} from './litegraph'
import { LiteGraph } from './litegraph'
import type { LGraphNodeConstructor, Subgraph, SubgraphNode } from './litegraph'
import {
createBounds,
isInRect,
@@ -86,7 +84,8 @@ import { distributeSpace } from './utils/spaceDistribution'
import { truncateText } from './utils/textUtils'
import { toClass } from './utils/type'
import { BaseWidget } from './widgets/BaseWidget'
import { type WidgetTypeMap, toConcreteWidget } from './widgets/widgetMap'
import { toConcreteWidget } from './widgets/widgetMap'
import type { WidgetTypeMap } from './widgets/widgetMap'
// #region Types

View File

@@ -3,7 +3,8 @@ import { LayoutSource } from '@/renderer/core/layout/types'
import { LGraphBadge } from './LGraphBadge'
import type { LGraphNode, NodeId } from './LGraphNode'
import { LLink, type LinkId } from './LLink'
import { LLink } from './LLink'
import type { LinkId } from './LLink'
import type {
CanvasColour,
INodeInputSlot,

View File

@@ -8,11 +8,11 @@ import {
import type { CustomEventTarget } from '@/lib/litegraph/src/infrastructure/CustomEventTarget'
import type { LinkConnectorEventMap } from '@/lib/litegraph/src/infrastructure/LinkConnectorEventMap'
import type {
INodeInputSlot,
INodeOutputSlot,
LinkNetwork
LinkNetwork,
Point
} from '@/lib/litegraph/src/interfaces'
import type { INodeInputSlot } from '@/lib/litegraph/src/interfaces'
import type { Point } from '@/lib/litegraph/src/interfaces'
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
import { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'

View File

@@ -9,14 +9,12 @@ import { CustomEventTarget } from '@/lib/litegraph/src/infrastructure/CustomEven
import type { LinkConnectorEventMap } from '@/lib/litegraph/src/infrastructure/LinkConnectorEventMap'
import type {
ConnectingLink,
INodeInputSlot,
INodeOutputSlot,
ItemLocator,
LinkNetwork,
LinkSegment
} from '@/lib/litegraph/src/interfaces'
import type {
INodeInputSlot,
INodeOutputSlot
} from '@/lib/litegraph/src/interfaces'
import { EmptySubgraphInput } from '@/lib/litegraph/src/subgraph/EmptySubgraphInput'
import { EmptySubgraphOutput } from '@/lib/litegraph/src/subgraph/EmptySubgraphOutput'
import { Subgraph } from '@/lib/litegraph/src/subgraph/Subgraph'

View File

@@ -1,8 +1,12 @@
import type { ContextMenu } from './ContextMenu'
import type { LGraphNode } from './LGraphNode'
import { LiteGraphGlobal } from './LiteGraphGlobal'
import type { ConnectingLink, Point } from './interfaces'
import type { IContextMenuOptions, Size } from './interfaces'
import type {
ConnectingLink,
IContextMenuOptions,
Point,
Size
} from './interfaces'
import { loadPolyfills } from './polyfills'
import type { CanvasEventDetail } from './types/events'
import type { RenderShape, TitleMode } from './types/globalEnums'

View File

@@ -8,7 +8,8 @@ import type {
Point
} from '@/lib/litegraph/src/interfaces'
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
import { type IDrawOptions, NodeSlot } from '@/lib/litegraph/src/node/NodeSlot'
import { NodeSlot } from '@/lib/litegraph/src/node/NodeSlot'
import type { IDrawOptions } from '@/lib/litegraph/src/node/NodeSlot'
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
import { isSubgraphInput } from '@/lib/litegraph/src/subgraph/subgraphUtils'

View File

@@ -8,7 +8,8 @@ import type {
Point
} from '@/lib/litegraph/src/interfaces'
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
import { type IDrawOptions, NodeSlot } from '@/lib/litegraph/src/node/NodeSlot'
import { NodeSlot } from '@/lib/litegraph/src/node/NodeSlot'
import type { IDrawOptions } from '@/lib/litegraph/src/node/NodeSlot'
import type { SubgraphInput } from '@/lib/litegraph/src/subgraph/SubgraphInput'
import type { SubgraphOutput } from '@/lib/litegraph/src/subgraph/SubgraphOutput'
import { isSubgraphOutput } from '@/lib/litegraph/src/subgraph/subgraphUtils'

View File

@@ -8,8 +8,10 @@ import type {
IWidgetLocator,
Point
} from '@/lib/litegraph/src/interfaces'
import type { RenderShape } from '@/lib/litegraph/src/types/globalEnums'
import type { LinkDirection } from '@/lib/litegraph/src/types/globalEnums'
import type {
LinkDirection,
RenderShape
} from '@/lib/litegraph/src/types/globalEnums'
/** Base class for all input & output slots. */

View File

@@ -9,12 +9,12 @@ import type {
Point,
Positionable
} from '@/lib/litegraph/src/interfaces'
import {
type CanvasColour,
type CanvasPointer,
type CanvasPointerEvent,
type IContextMenuValue,
LiteGraph
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
import type {
CanvasColour,
CanvasPointer,
CanvasPointerEvent,
IContextMenuValue
} from '@/lib/litegraph/src/litegraph'
import { snapPoint } from '@/lib/litegraph/src/measure'
import { CanvasItem } from '@/lib/litegraph/src/types/globalEnums'

View File

@@ -2,7 +2,8 @@ import type { BaseLGraph, LGraph } from '@/lib/litegraph/src/LGraph'
import type { LGraphButton } from '@/lib/litegraph/src/LGraphButton'
import type { LGraphCanvas } from '@/lib/litegraph/src/LGraphCanvas'
import { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import { LLink, type ResolvedConnection } from '@/lib/litegraph/src/LLink'
import { LLink } from '@/lib/litegraph/src/LLink'
import type { ResolvedConnection } from '@/lib/litegraph/src/LLink'
import { RecursionError } from '@/lib/litegraph/src/infrastructure/RecursionError'
import type {
ISubgraphInput,
@@ -27,11 +28,8 @@ import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
import type { UUID } from '@/lib/litegraph/src/utils/uuid'
import { toConcreteWidget } from '@/lib/litegraph/src/widgets/widgetMap'
import {
type ExecutableLGraphNode,
ExecutableNodeDTO,
type ExecutionId
} from './ExecutableNodeDTO'
import { ExecutableNodeDTO } from './ExecutableNodeDTO'
import type { ExecutableLGraphNode, ExecutionId } from './ExecutableNodeDTO'
import type { SubgraphInput } from './SubgraphInput'
/**

View File

@@ -21,7 +21,8 @@ import type {
Serialisable,
SubgraphIO
} from '@/lib/litegraph/src/types/serialisation'
import { type UUID, createUuidv4 } from '@/lib/litegraph/src/utils/uuid'
import { createUuidv4 } from '@/lib/litegraph/src/utils/uuid'
import type { UUID } from '@/lib/litegraph/src/utils/uuid'
import type { SubgraphInput } from './SubgraphInput'
import type { SubgraphInputNode } from './SubgraphInputNode'

View File

@@ -1,7 +1,8 @@
import type { LGraph } from '@/lib/litegraph/src/LGraph'
import { LGraphGroup } from '@/lib/litegraph/src/LGraphGroup'
import { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import { LLink, type ResolvedConnection } from '@/lib/litegraph/src/LLink'
import { LLink } from '@/lib/litegraph/src/LLink'
import type { ResolvedConnection } from '@/lib/litegraph/src/LLink'
import { Reroute } from '@/lib/litegraph/src/Reroute'
import {
SUBGRAPH_INPUT_ID,

View File

@@ -16,8 +16,8 @@ import type {
Size
} from '../interfaces'
import type { LiteGraph } from '../litegraph'
import type { TWidgetValue } from '../types/widgets'
import type { RenderShape } from './globalEnums'
import type { TWidgetValue } from './widgets'
/**
* An object that implements custom pre-serialization logic via {@link Serialisable.asSerialisable}.

View File

@@ -1,7 +1,8 @@
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import type { IAssetWidget } from '@/lib/litegraph/src/types/widgets'
import { BaseWidget, type DrawWidgetOptions } from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions } from './BaseWidget'
export class AssetWidget
extends BaseWidget<IAssetWidget>

View File

@@ -1,10 +1,7 @@
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Base class for widgets that have increment and decrement buttons.

View File

@@ -1,10 +1,7 @@
import type { IBooleanWidget } from '@/lib/litegraph/src/types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
export class BooleanWidget
extends BaseWidget<IBooleanWidget>

View File

@@ -1,11 +1,8 @@
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import type { IButtonWidget } from '@/lib/litegraph/src/types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
export class ButtonWidget
extends BaseWidget<IButtonWidget>

View File

@@ -1,9 +1,6 @@
import type { IChartWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for displaying charts and data visualizations

View File

@@ -1,9 +1,6 @@
import type { IColorWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for displaying a color picker

View File

@@ -1,7 +1,8 @@
import { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import type { IButtonWidget } from '@/lib/litegraph/src/types/widgets'
import { BaseWidget, type DrawWidgetOptions } from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions } from './BaseWidget'
class DisconnectedWidget extends BaseWidget<IButtonWidget> {
constructor(widget: IButtonWidget) {

View File

@@ -1,9 +1,6 @@
import type { IFileUploadWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for handling file uploads

View File

@@ -1,9 +1,6 @@
import type { IGalleriaWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for displaying image galleries

View File

@@ -1,9 +1,6 @@
import type { IImageCompareWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for comparing two images side by side

View File

@@ -3,11 +3,8 @@ import { clamp } from 'es-toolkit/compat'
import type { IKnobWidget } from '@/lib/litegraph/src/types/widgets'
import { getWidgetStep } from '@/lib/litegraph/src/utils/widget'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
export class KnobWidget extends BaseWidget<IKnobWidget> implements IKnobWidget {
override type = 'knob' as const

View File

@@ -2,7 +2,8 @@ import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import { LiteGraph } from '@/lib/litegraph/src/litegraph'
import type { IBaseWidget } from '@/lib/litegraph/src/types/widgets'
import { BaseWidget, type DrawWidgetOptions } from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions } from './BaseWidget'
/**
* Wraps a legacy POJO custom widget, so that all widgets may be called via the same internal interface.

View File

@@ -1,9 +1,6 @@
import type { IMarkdownWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for displaying markdown formatted text

View File

@@ -1,9 +1,6 @@
import type { IMultiSelectWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for selecting multiple options

View File

@@ -1,9 +1,6 @@
import type { ISelectButtonWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for selecting from a group of buttons

View File

@@ -2,11 +2,8 @@ import { clamp } from 'es-toolkit/compat'
import type { ISliderWidget } from '@/lib/litegraph/src/types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
export class SliderWidget
extends BaseWidget<ISliderWidget>

View File

@@ -1,11 +1,8 @@
import type { LGraphNode } from '@/lib/litegraph/src/LGraphNode'
import type { IStringWidget } from '@/lib/litegraph/src/types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
export class TextWidget
extends BaseWidget<IStringWidget>

View File

@@ -1,9 +1,6 @@
import type { ITextareaWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for multi-line text input

View File

@@ -1,9 +1,6 @@
import type { ITreeSelectWidget } from '../types/widgets'
import {
BaseWidget,
type DrawWidgetOptions,
type WidgetEventOptions
} from './BaseWidget'
import { BaseWidget } from './BaseWidget'
import type { DrawWidgetOptions, WidgetEventOptions } from './BaseWidget'
/**
* Widget for hierarchical tree selection