perf: skip rules below the minimum visible severity - #581
Merged
Conversation
In CLI mode without includeSuggestionsInTsc, suggestion- and message-severity diagnostics were filtered out of the output only after their rules had already run. Pass the minimum surfaceable severity into rulerunner.Run so such rules are skipped before execution, unless a directive in the file references them (a directive can raise their severity and must be marked used for unusedDirective tracking). transformDiagnostics now filters by the same threshold instead of consulting global CLI-mode state, making the runner mode-agnostic and the skip logic unit-testable. Emitted diagnostics are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 9, 2026
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
In
tscCLI mode withoutincludeSuggestionsInTsc, suggestion- and message-severity diagnostics are dropped from the output — but only after their rules had already executed, wasting their type-checker queries on every file. This PR skips those rules before execution:rulerunner.Runnow takes aminSeverityargument: the least visible severity the caller can surface, computed via the newrulerunner.MinVisibleSeverity(config)helper (CLI withoutincludeSuggestionsInTsc→warning; LSP/tests/oxlint and CLI with suggestions enabled →message, i.e. nothing is skipped).*, at file/section/next-line level, regardless of assigned severity). This guard is needed for two reasons: a directive like// @effect-diagnostics ruleName:errorcan raise the rule above the threshold, and a suppression directive must still be marked used sounusedDirectivereporting stays accurate (skipping the rule would fabricate a spurious "directive has no effect" warning).transformDiagnosticsnow filters by the same threshold instead of consulting global CLI-mode state, so the runner is mode-agnostic and the previously hard-to-test CLI behavior is covered by plain unit tests.Severity.AtLeastAsVisibleAsinetscorewith an explicit visibility ranking (error > warning > suggestion > message > off/skip-file), since the constants' declaration order is not a visibility ordering.skipDisabledOptimizationescape hatch also disables this skip, matching the off-severity skip.Example
Verification
tsc -b --diagnosticsbuild of the Effect monorepo.HasAnyDirectiveForRule), andMinVisibleSeverityunder CLI mode toggled viaetscore.EnterCommandLineMode— the CLI-mode test that previously blocked this optimization.pnpm lint,pnpm check, and the fullpnpm testsuite pass.🤖 Generated with Claude Code