Skip to content

fix(lint): respect --config in Rslint plugin workers - #592

Merged
chenjiahan merged 1 commit into
rstackjs:mainfrom
LucasIcarus:fix-lint-config-in-workers
Oct 24, 2026
Merged

chenjiahan merged 1 commit into
rstackjs:mainfrom
LucasIcarus:fix-lint-config-in-workers

Conversation

@LucasIcarus

Copy link
Copy Markdown
Contributor

Motivation

Rslint runs JS plugin rules in worker threads that import Rstack's internal lint config again. The --config path only exists in the main thread's state, so the workers look for rstack.config.* in cwd. If the selected config has JS plugin rules, rs lint -c <path> from a directory without a config fails with worker 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 -c is affected the same way. See #591.

Changes

Before starting Rslint, rs lint and rs check set RSTACK_CLI_CONFIG_PATH to the resolved --config path, and the internal lint config passes it to loadRstackConfig(). Worker threads inherit the variable. Nothing else reads it, so other commands and programmatic loadRstackConfig() 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 -c was checked by hand.

files, ignores and the implicit tsconfig.json lookup still resolve from cwd when --config points elsewhere. That is left to #591.

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.

@chenjiahan chenjiahan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍👍👍

@chenjiahan
chenjiahan merged commit 89ead58 into rstackjs:main Oct 24, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants