Skip to content
Source
Sign inSign up
TanStack/router

perf(eslint-plugin-start): avoid repeated file and graph scans #8271

OpenLadyBluenotes(GitHub profile, opens in a new tab)wants to merge 8 commits intomain fromperf/start-eslint-scansopened

Showing 4 changed files with 236 additions and 0 deletions (loading 2).

x
0 of 4 viewed, 4 left
5 additions and 0 deletions.changeset/fast-bears-mix.mdAdded
View file
@@ -0,0 +1,5 @@
+---
+'@tanstack/eslint-plugin-start': patch
+---
+​
+Avoid repeated whole-file and whole-graph scans when checking server and async client components.
231 additions and 0 deletionspackages/eslint-plugin-start/src/__tests__/rule-performance.test.tsAdded
View file
@@ -0,0 +1,231 @@
+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'
+import { tmpdir } from 'node:os'
+import path from 'node:path'
+import { RuleTester } from '@typescript-eslint/rule-tester'
+import { TSESLint } from '@typescript-eslint/utils'
+import { afterEach, assert, expect, test, vi } from 'vitest'
+import { rule as serverRule } from '../rules/no-client-code-in-server-component/no-client-code-in-server-component.rule'
+import { rule as asyncRule } from '../rules/no-async-client-component/no-async-client-component.rule'
+import * as contextAnalyzer from '../rules/no-async-client-component/context-analyzer'
+import type * as violationDetector from '../rules/no-client-code-in-server-component/violation-detector'
+import type * as renderGraphBuilder from '../rules/no-async-client-component/render-graph-builder'
+import type * as ts from 'typescript'
+​
+const counts = vi.hoisted(() => ({ detectorNodes: 0, edgeReads: 0, builds: 0 }))
+​
+// Count work in the real detector and graph builder, without timing assertions.
+vi.mock(
+ '../rules/no-client-code-in-server-component/violation-detector',
+ async (importOriginal) => {
+ const original = await importOriginal<typeof violationDetector>()
+ return {
+ ...original,