[Cleanup] Update ESLint rules with stricter auto-fixes (#614)

Stylistic plugin falls short in a few areas when it comes to consistent
lists and chaining. Replaced some key rules with antfu's personal
variants.

`eslint` can now be run repo-wide without params.
This commit is contained in:
filtered
2025-02-26 22:12:03 +11:00
committed by GitHub
parent 867b9ed316
commit 6224d2dc06
15 changed files with 37 additions and 16 deletions

View File

@@ -27,7 +27,7 @@ jobs:
npm run build
- name: Run lint
run: |
npm run lint
npm run lint:ci
- name: Run typecheck
run: |
npm run typecheck

View File

@@ -20,6 +20,7 @@ const antfuLint = {
}
export default tseslint.config(
{ ignores: [".*/**", "dist/**", "scripts/**"] },
{ files: ["**/*.{js,mjs,ts,mts}"] },
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
@@ -131,10 +132,6 @@ export default tseslint.config(
"error",
{ consistent: true, multiline: true },
],
"@stylistic/object-curly-newline": [
"error",
{ consistent: true, multiline: true },
],
// "@stylistic/object-property-newline": ["error", { allowAllPropertiesOnSameLine: true }],
// "@stylistic/object-property-newline": "error",
"@stylistic/one-var-declaration-per-line": "error",
@@ -226,6 +223,7 @@ export default tseslint.config(
{
rules: {
"antfu/consistent-chaining": "error",
"antfu/consistent-list-newline": "error",
},
},

View File

@@ -27,8 +27,9 @@
"watch": "vite build --watch",
"release": "node scripts/release.js",
"test": "vitest",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"lint": "eslint",
"lint:fix": "eslint --fix",
"lint:ci": "eslint src",
"format": "prettier --check './src/*.{js,ts,tsx,vue,mts}'",
"format:fix": "prettier --write './src/*.{js,ts,tsx,vue,mts}'"
},

View File

@@ -1,5 +1,7 @@
import { describe } from "vitest"
import { LGraph } from "@/litegraph"
import { dirtyTest } from "./testExtensions"
describe("LGraph configure()", () => {

View File

@@ -1,5 +1,7 @@
import { describe } from "vitest"
import { LGraph, LiteGraph } from "@/litegraph"
import { test } from "./testExtensions"
describe("LGraph", () => {

View File

@@ -1,5 +1,7 @@
import { describe, expect } from "vitest"
import { LGraphGroup } from "@/litegraph"
import { test } from "./testExtensions"
describe("LGraphGroup", () => {

View File

@@ -1,6 +1,8 @@
import { describe, expect } from "vitest"
import { LGraphNode } from "@/litegraph"
import { NodeInputSlot, NodeOutputSlot } from "@/NodeSlot"
import { test } from "./testExtensions"
describe("LGraphNode", () => {

View File

@@ -1,5 +1,7 @@
import { describe } from "vitest"
import { LGraph } from "@/litegraph"
import { dirtyTest } from "./testExtensions"
describe("LGraph (constructor only)", () => {

View File

@@ -1,5 +1,7 @@
import { describe, expect } from "vitest"
import { LLink } from "@/litegraph"
import { test } from "./testExtensions"
describe("LLink", () => {

View File

@@ -1,6 +1,7 @@
import { describe, it, expect } from "vitest"
import { serializeSlot } from "@/NodeSlot"
import { describe, expect, it } from "vitest"
import { INodeInputSlot, INodeOutputSlot } from "@/interfaces"
import { serializeSlot } from "@/NodeSlot"
describe("NodeSlot", () => {
describe("serializeSlot", () => {

View File

@@ -1,6 +1,8 @@
import { describe, expect } from "vitest"
import { clamp, LGraphCanvas, LiteGraph } from "@/litegraph"
import { LiteGraphGlobal } from "@/LiteGraphGlobal"
import { test } from "./testExtensions"
describe.concurrent("Litegraph module", () => {

View File

@@ -1,8 +1,11 @@
import { describe } from "vitest"
import { LGraph, LGraphGroup, LGraphNode } from "@/litegraph"
import { test } from "./testExtensions"
import type { ISerialisedGraph } from "@/types/serialisation"
import { describe } from "vitest"
import { LGraph, LGraphGroup, LGraphNode } from "@/litegraph"
import { test } from "./testExtensions"
describe("LGraph Serialisation", () => {
test("can (de)serialise node / group titles", ({ expect, minimalGraph }) => {
const nodeTitle = "Test Node"

View File

@@ -1,9 +1,12 @@
import { test as baseTest } from "vitest"
import type { ISerialisedGraph, SerialisableGraph } from "../src/types/serialisation"
import { test as baseTest } from "vitest"
import { LGraph } from "@/LGraph"
import { basicSerialisableGraph, minimalSerialisableGraph, oldSchemaGraph } from "./assets/testGraphs"
import { LiteGraph } from "@/litegraph"
import { basicSerialisableGraph, minimalSerialisableGraph, oldSchemaGraph } from "./assets/testGraphs"
interface LitegraphFixtures {
minimalGraph: LGraph
minimalSerialisableGraph: SerialisableGraph

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest"
import { type SpaceRequest, distributeSpace } from "@/utils/spaceDistribution"
import { distributeSpace, type SpaceRequest } from "@/utils/spaceDistribution"
describe("distributeSpace", () => {
it("should distribute space according to minimum sizes when space is limited", () => {

View File

@@ -1,6 +1,6 @@
/// <reference types='vitest' />
import { defineConfig } from "vite"
import path from "path"
import { defineConfig } from "vite"
import dts from "vite-plugin-dts"
export default defineConfig({