Repository navigation
perf(eslint-plugin): run syntactic checks before type queries - #47
Merged
Merged
Conversation
…names prefer-native-schema-adapters now checks that the member call's static method name is a Zod or Valibot schema factory before asking the checker for the resolved signature.
… queries no-enumwaii-case-misuse resolves an identifier's type only after every syntactic exclusion, resolves a member object's type only for accesses it could report, and caches its cases-brand decision per TypeScript type.
Owner
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What changed
Two type-aware rules asked the TypeScript checker for types before running their cheap syntactic checks. Findings are unchanged.
prefer-native-schema-adapterscallsgetResolvedSignature()only when the member call's static method name is a Zod or Valibot schema factory (enum,nativeEnum,picklist). Before this, it resolved a signature for every member call that had an argument.no-enumwaii-case-misuseruns every syntactic exclusion beforegetTypeAtLocation(), which skips imports, declarations, member objects and properties, parameters and type positions. For non-.casesmember accesses, it skips the type query when the access is already an allowed case usage, unless the key is computed. It also caches its cases-brand decision per TypeScriptTypein aWeakMap. TypeScript types never change, and each program has its own type objects, so the cache cannot return a stale decision.The changeset is a patch bump of
eslint-plugin-enumwaii(1.2.1 → 1.2.2).Validation
All numbers come from the koneko monorepo (
apps/web,apps/server), linted with only theenumwaii/*rules enabled. A config wrapper outside koneko swapped in a local build of this plugin. "Before" isorigin/main(217e60d) and "after" is this branch. Nothing in koneko was changed.hyperfine (one invocation per workspace,
--warmup 1 --runs 8)The machine was quiet: no other hyperfine, Vitest or ESLint process ran, and CPU load was sampled every 30 s at 5-53% (mostly 12-23%).
The server gain (0.51 s) is outside both standard deviations. The web gain (0.70 s) is within the before run's standard deviation, so it is not claimed as a measured win.
Per-rule
TIMING=all(ms, allenumwaii/*rules in one run)ESLint
TIMINGcharges TypeScript's lazy checking to whichever rule first asks the checker about a node. Withprefer-native-schema-adaptersno longer resolving signatures, part of that shared checking moves tono-manual-enum. Use the sum to compare totals; the per-rule rows show where the time moved.Checker calls (counted by wrapping parser services)
getTypeAtLocationgetResolvedSignatureOther rules' checker calls are unchanged. A CPU profile of
no-enumwaii-case-misusealone on web shows that most of its remaining time is TypeScript'scheckExpressionbehindgetTypeAtLocationon the identifiers it must classify. The rule cannot skip those queries without changing what it reports. The per-type cache cuts the rule's owngetPropertiesscanning from 266 ms to 98 ms.Findings are identical
pnpm checkchain passed (exit 0). It ran withformat:check:corein place offormat:check, because the root Prettier check also scans an untracked local.claude/worktreescheckout that is not part of this branch.Checklist
pnpm checkpasses.