[Lint] Lint unused imports (#493)

This commit is contained in:
Chenlei Hu
2025-02-08 21:20:39 -05:00
committed by GitHub
parent 12f8d33b78
commit de74d8a08c
8 changed files with 38 additions and 15 deletions

View File

@@ -2,6 +2,7 @@ import globals from "globals"
import eslint from "@eslint/js" import eslint from "@eslint/js"
import tseslint from "typescript-eslint" import tseslint from "typescript-eslint"
import stylistic from "@stylistic/eslint-plugin" import stylistic from "@stylistic/eslint-plugin"
import unusedImports from "eslint-plugin-unused-imports"
export default tseslint.config( export default tseslint.config(
{ files: ["**/*.{js,mjs,ts,mts}"] }, { files: ["**/*.{js,mjs,ts,mts}"] },
@@ -161,4 +162,15 @@ export default tseslint.config(
}, },
files: ["test/**/*.ts"], files: ["test/**/*.ts"],
}, },
{
plugins: {
"unused-imports": unusedImports,
},
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "off",
"@typescript-eslint/prefer-as-const": "off",
"unused-imports/no-unused-imports": "error",
},
},
) )

17
package-lock.json generated
View File

@@ -14,6 +14,7 @@
"@types/eslint__js": "^8.42.3", "@types/eslint__js": "^8.42.3",
"@types/node": "^22.1.0", "@types/node": "^22.1.0",
"eslint": "^9.14.0", "eslint": "^9.14.0",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^15.12.0", "globals": "^15.12.0",
"husky": "^9.1.7", "husky": "^9.1.7",
"jsdom": "^25.0.1", "jsdom": "^25.0.1",
@@ -2696,6 +2697,22 @@
} }
} }
}, },
"node_modules/eslint-plugin-unused-imports": {
"version": "4.1.4",
"resolved": "https://registry.npmjs.org/eslint-plugin-unused-imports/-/eslint-plugin-unused-imports-4.1.4.tgz",
"integrity": "sha512-YptD6IzQjDardkl0POxnnRBhU1OEePMV0nd6siHaRBbd+lyh6NAhFEobiznKU7kTsSsDeSD62Pe7kAM1b7dAZQ==",
"dev": true,
"license": "MIT",
"peerDependencies": {
"@typescript-eslint/eslint-plugin": "^8.0.0-0 || ^7.0.0 || ^6.0.0 || ^5.0.0",
"eslint": "^9.0.0 || ^8.0.0"
},
"peerDependenciesMeta": {
"@typescript-eslint/eslint-plugin": {
"optional": true
}
}
},
"node_modules/eslint-scope": { "node_modules/eslint-scope": {
"version": "8.2.0", "version": "8.2.0",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz",

View File

@@ -26,7 +26,9 @@
"preview": "vite preview", "preview": "vite preview",
"watch": "vite build --watch", "watch": "vite build --watch",
"release": "node scripts/release.js", "release": "node scripts/release.js",
"test": "vitest" "test": "vitest",
"lint": "eslint src",
"lint:fix": "eslint src --fix"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -47,6 +49,7 @@
"@types/eslint__js": "^8.42.3", "@types/eslint__js": "^8.42.3",
"@types/node": "^22.1.0", "@types/node": "^22.1.0",
"eslint": "^9.14.0", "eslint": "^9.14.0",
"eslint-plugin-unused-imports": "^4.1.4",
"globals": "^15.12.0", "globals": "^15.12.0",
"husky": "^9.1.7", "husky": "^9.1.7",
"jsdom": "^25.0.1", "jsdom": "^25.0.1",

View File

@@ -1,6 +1,5 @@
// @ts-strict-ignore // @ts-strict-ignore
import type { CanvasPointerEvent } from "./types/events" import type { CanvasPointerEvent } from "./types/events"
import type { LGraphCanvas } from "./LGraphCanvas"
import { dist2 } from "./measure" import { dist2 } from "./measure"
/** /**

View File

@@ -22,7 +22,7 @@ import type {
ReadOnlyPoint, ReadOnlyPoint,
ReadOnlyRect, ReadOnlyRect,
} from "./interfaces" } from "./interfaces"
import type { IBaseWidget, IWidget, TWidgetValue } from "./types/widgets" import type { IWidget } from "./types/widgets"
import { LGraphNode, type NodeId } from "./LGraphNode" import { LGraphNode, type NodeId } from "./LGraphNode"
import type { import type {
CanvasDragEvent, CanvasDragEvent,
@@ -59,21 +59,14 @@ import {
} from "./measure" } from "./measure"
import { LabelPosition, strokeShape } from "./draw" import { LabelPosition, strokeShape } from "./draw"
import { DragAndScale } from "./DragAndScale" import { DragAndScale } from "./DragAndScale"
import { LinkReleaseContextExtended, LiteGraph, clamp } from "./litegraph" import { LinkReleaseContextExtended, LiteGraph } from "./litegraph"
import { stringOrEmpty, stringOrNull } from "./strings" import { stringOrEmpty, stringOrNull } from "./strings"
import { alignNodes, distributeNodes, getBoundaryNodes } from "./utils/arrange" import { alignNodes, distributeNodes, getBoundaryNodes } from "./utils/arrange"
import { Reroute, type RerouteId } from "./Reroute" import { Reroute, type RerouteId } from "./Reroute"
import { getAllNestedItems, findFirstNode } from "./utils/collections" import { getAllNestedItems, findFirstNode } from "./utils/collections"
import { CanvasPointer } from "./CanvasPointer" import { CanvasPointer } from "./CanvasPointer"
import { BooleanWidget } from "./widgets/BooleanWidget"
import { toClass } from "./utils/type" import { toClass } from "./utils/type"
import { NodeInputSlot, NodeOutputSlot, type ConnectionColorContext } from "./NodeSlot" import { NodeInputSlot, NodeOutputSlot, type ConnectionColorContext } from "./NodeSlot"
import { ComboWidget } from "./widgets/ComboWidget"
import { NumberWidget } from "./widgets/NumberWidget"
import { ButtonWidget } from "./widgets/ButtonWidget"
import { TextWidget } from "./widgets/TextWidget"
import { SliderWidget } from "./widgets/SliderWidget"
import { BaseWidget } from "./widgets/BaseWidget"
import { WIDGET_TYPE_MAP } from "./widgets/widgetMap" import { WIDGET_TYPE_MAP } from "./widgets/widgetMap"
interface IShowSearchOptions { interface IShowSearchOptions {

View File

@@ -16,12 +16,12 @@ import type {
Size, Size,
} from "./interfaces" } from "./interfaces"
import type { LGraph } from "./LGraph" import type { LGraph } from "./LGraph"
import type { IWidget, TWidgetType, TWidgetValue } from "./types/widgets" import type { IWidget, TWidgetValue } from "./types/widgets"
import type { ISerialisedNode } from "./types/serialisation" import type { ISerialisedNode } from "./types/serialisation"
import type { LGraphCanvas } from "./LGraphCanvas" import type { LGraphCanvas } from "./LGraphCanvas"
import type { CanvasMouseEvent } from "./types/events" import type { CanvasMouseEvent } from "./types/events"
import type { DragAndScale } from "./DragAndScale" import type { DragAndScale } from "./DragAndScale"
import type { Reroute, RerouteId } from "./Reroute" import type { RerouteId } from "./Reroute"
import { import {
LGraphEventMode, LGraphEventMode,
NodeSlotType, NodeSlotType,

View File

@@ -6,7 +6,6 @@ import type { ConnectingLink, LinkReleaseContextExtended } from "../litegraph"
import type { IWidget } from "./widgets" import type { IWidget } from "./widgets"
import type { LGraphNode } from "../LGraphNode" import type { LGraphNode } from "../LGraphNode"
import type { LGraphGroup } from "../LGraphGroup" import type { LGraphGroup } from "../LGraphGroup"
import type { LGraphCanvas } from "../LGraphCanvas"
/** For Canvas*Event - adds graph space co-ordinates (property names are shipped) */ /** For Canvas*Event - adds graph space co-ordinates (property names are shipped) */
export interface ICanvasPosition { export interface ICanvasPosition {

View File

@@ -1,4 +1,4 @@
import type { Dictionary, Direction, IBoundaryNodes } from "../interfaces" import type { Direction, IBoundaryNodes } from "../interfaces"
import type { LGraphNode } from "../LGraphNode" import type { LGraphNode } from "../LGraphNode"
/** /**