feat: honor /* exported */ in no-unused-vars, prefer-const and no-useless-assignment - #1770
Draft
swwind wants to merge 1 commit into
Draft
Conversation
Member
|
The shared scope-gating helper and all four rule integrations match ESLint's exported-directive semantics across global, block, function, module, CommonJS, destructuring, and TypeScript-only declaration shapes. No actionable correctness, regression, performance, or maintainability issue was found. |
swwind
marked this pull request as draft
August 19, 2026 07:42
swwind
force-pushed
the
feat/exported-directive-consumers-20260817
branch
from
August 20, 2026 09:25
e0fe15b to
20d8f59
Compare
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.
Summary
Consumes the inline
/* exported */API added in #1760 in the four remaining rules ESLint applies the directive to:no-unused-vars(core and@typescript-eslint),prefer-const, andno-useless-assignment.RuleContext.IsExportedGlobalBinding(decl, name)performs the lookup ESLint does before marking a variable: the name is listed by a comment, the file's top level is the global scope, anddeclbinds the name in that scope. Avarreaches the global scope from inside any block, whilelet/const/class, a function declaration, and a catch parameter belong to their nearest block scope.Each rule then reads the flag the way its upstream counterpart does:
no-unused-vars, core and TypeScript, counts the directive as a use.reportUsedIgnorePatternstill sees the binding as used, which is what turns a directive on an ignored name into ausedIgnoredVarreport. The TypeScript scope manager puts type-only declarations in the same global scope as value ones, so the directive also reachesinterface,type,enum,namespace, andimport x = require().prefer-constdeclines to judge such a global, since a separately loaded file may reassign it. Underdestructuring: "all"that holds the whole destructuring group back.no-useless-assignmenttreats it like anexport: the value can still be read from outside the file, so no assignment to it is reported.Six
/* exported */skips are removed from the coreno-unused-varsupstream suite and one fromno-useless-assignment's.Checklist