Repository navigation
fix(lint): respect --config in Rslint plugin workers - #592
Merged
Merged
Conversation
Rslint runs JS plugin rules in worker threads that import the internal lint config again in a fresh realm. The --config path only lived in the main thread's global state, so the workers searched cwd instead. From a directory without rstack.config.*, linting failed with "worker exited during init", and when a config in cwd registered the same plugin name, the workers silently ran that config's implementation. Before starting Rslint, set an environment variable to the resolved --config path and pass it to loadRstackConfig() in the internal lint config. Only that config reads it, so other commands and programmatic loadRstackConfig() calls are unchanged. Clear the variable when --config is absent so an inherited value is ignored.
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.
Motivation
Rslint runs JS plugin rules in worker threads that import Rstack's internal lint config again. The
--configpath only exists in the main thread's state, so the workers look forrstack.config.*in cwd. If the selected config has JS plugin rules,rs lint -c <path>from a directory without a config fails withworker exited during init, and if a config in cwd registers the same plugin name, the workers silently run that config's implementation instead.rs check -cis affected the same way. See #591.Changes
Before starting Rslint,
rs lintandrs checksetRSTACK_CLI_CONFIG_PATHto the resolved--configpath, and the internal lint config passes it toloadRstackConfig(). Worker threads inherit the variable. Nothing else reads it, so other commands and programmaticloadRstackConfig()calls are unchanged. Without--config, the variable is cleared, so an inherited value is ignored.The new tests cover a cwd without a config, a cwd config that registers the same plugin name, and an inherited variable without
--config.rs check -cwas checked by hand.files,ignoresand the implicittsconfig.jsonlookup still resolve from cwd when--configpoints elsewhere. That is left to #591.