Forbid private static members and refactor existing usages to module scope#5884
Open
iclanton wants to merge 3 commits into
Open
Forbid private static members and refactor existing usages to module scope#5884iclanton wants to merge 3 commits into
private static members and refactor existing usages to module scope#5884iclanton wants to merge 3 commits into
Conversation
…d-syntax rule Enforce the new ESLint rule in decoupled-local-node-rig that forbids `private static` methods and properties (kept at "error" severity alongside the existing `export *` restriction). Convert every `private static` violation across all rig-consuming projects to module-scoped functions and variables: - private static method -> module-scoped function - private static property -> module-scoped const (or let if reassigned) Edge cases handled without changing public behavior: - Helpers needing private instance members / private constructors kept as private instance methods, or return data for an in-class caller to construct (e.g. JsonSchema, LockFile, RigConfig, MinimalRushConfiguration). - Stateful singletons (e.g. EnvironmentConfiguration) moved to module state. - Async lazy-init caches suppressed with require-atomic-updates where needed. - Module declarations placed to preserve TSDoc/API-Extractor doc association and avoid no-use-before-define. - Test seams exported where tests referenced moved members. Full `rush build` passes with zero errors and zero warnings.
Moving `_tarUtilityPromise` from a `private static` field to a module-scoped variable silently invalidated the test's `Reflect.set(OperationBuildCache, '_tarUtilityPromise', ...)` mock injection, causing the restore test to run the real tar/untar path (EACCES on mkdir '/repo'). Add an exported `@internal` test seam `_setTarUtilityPromiseForTesting` and use it from the test instead of poking the class internals.
iclanton
requested review from
TheLarkInn,
apostolisms,
bmiddha,
dmichon-msft,
jxanthony and
octogonz
as code owners
July 19, 2026 02:17
iclanton
enabled auto-merge (squash)
July 19, 2026 02:30
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
Adds an ESLint rule that forbids
private staticmethods and properties (indecoupled-local-node-rig's flat profile), steering code toward module-scoped functions and variables, and refactors every existing violation across the repo to satisfy it.Motivation
A
private staticmember is really just module-scoped state or a helper expressed as a class member. Plain module-scoped functions/consts are simpler, avoid unnecessaryClassName.qualification, and are friendlier to bundlers.What changed
no-restricted-syntaxrule now also forbidsprivate staticmethods and properties. It stays aterrorseverity, alongside the existingexport * from '...'restriction (a single rule instance can't have per-selector severities).private staticviolation across all rig-consuming projects was converted:private staticmethod → module-scopedfunctionprivate staticproperty → module-scopedconst(orletwhen reassigned)Notable edge cases (behavior preserved)
privateinstance methods, or changed to return data so an in-class caller performs the construction (e.g.JsonSchema,LockFile,RigConfig,MinimalRushConfiguration).EnvironmentConfiguration) moved to module-scoped state.require-atomic-updatessuppression where appropriate (matching existing repo convention)..api.mdchurn) and avoidno-use-before-define.@internaltest seams where tests previously reached into private statics viaReflect.set/ bracket access (LockFile,OperationBuildCache).Testing
rush buildpasses with zero errors and zero warnings.rush-libtest suite passes (706 tests).