Skip to content

fix: give each check its own linter rather than one per module - #356

Merged
alexander-akait merged 1 commit into
mainfrom
fix/one-linter-per-check
Sep 14, 2026
Merged

alexander-akait merged 1 commit into
mainfrom
fix/one-linter-per-check

Conversation

@alexander-akait

Copy link
Copy Markdown
Member

Summary

Answering "why is there a stylelint.js and a stylelint-worker.js" turned up a bug rather than a duplicate. The worker file held the path and the options in module variables — right for a worker, which is one thread and one linter, and wrong for the plugin's own thread, where every check calls the same module's setup. Two Stylelint entries therefore both linted under whichever was written last: an entry reporting color-named next to one configured with no rules reported nothing at all (1 error alone, 0 together). It is the same family as #351, one level down.

The linter is a value now: a worker holds the one it was started with, the adapter holds one per check. That is the shape the typescript check already had around typescript-program.js, so all three pairs now agree.

The eslint pair was the actual duplication — both halves loaded the ESLint class themselves. That is loadESLintClass in the worker now, which the adapter imports; no behaviour change, since suppressions and the typed-linting cache-off already run on the plugin's thread over the worker's results.

What kind of change does this PR introduce?

fix.

Did you add tests for your changes?

Yes — test/stylelint/multiple-checks.test.js runs the reporting entry alone and then beside a silent one, and asserts the same report both times. It fails against unmodified src/.

Does this PR introduce a breaking change?

No.

If relevant, what needs to be documented once your changes are merged or what have you already documented?

n/a.

Use of AI

AI was used. It was asked why the worker files are separate, found the shared module state while answering, reproduced it as a two-entry build, and wrote the fix, the union and the test.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GzZci4NQeiqwdrVfd7dGXy


Generated by Claude Code

`stylelint-worker.js` held the path and the options in module variables,
which is right for a worker — one thread, one linter — and wrong for the
plugin's own thread, where every check calls `setup` on the same module.
Two Stylelint entries therefore both linted under whichever was written
last: an entry reporting `color-named` next to one configured with no
rules reported nothing at all.

The linter is a value now. A worker holds the one it was started with and
the adapter holds one per check, which is the shape the typescript check
already had around `typescript-program.js`.

The eslint pair loaded the `ESLint` class twice over — once in the worker
and once in the adapter. It is `loadESLintClass` in the worker now, which
the adapter imports.
@alexander-akait
alexander-akait merged commit d2a3dd2 into main Sep 14, 2026
13 checks passed
@alexander-akait
alexander-akait deleted the fix/one-linter-per-check branch September 14, 2026 13:07
This was referenced Sep 14, 2026
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.

1 participant