Commit f900a5d
authored
fix(stylelint): resolve extends/plugins against tool install directory (#2757)
Fixes #2700.
## Summary
Users on stylelint ≥17 hit `ConfigurationError: Could not find
"stylelint-config-standard"` even though qlty had installed the package
into its tool cache via `package_filters`. This PR makes two small,
targeted fixes:
1. **`qlty-plugins/plugins/linters/stylelint/plugin.toml`** — pass
`--config-basedir "${linter}"` to the `lint` (both version matchers) and
`format` scripts. `${linter}` interpolates to the plugin's tool install
directory, which is where qlty already installs the user's filtered npm
deps.
2. **`qlty-check/src/parser/stylelint.rs`** — harden the JSON parser to
skip leading non-JSON lines (Node 21 emits `ExperimentalWarning` to
stderr before stylelint's JSON report; stylelint ≥16 routes its report
to stderr). Slice from the first `[` so the parser tolerates the warning
while still surfacing genuinely malformed input.
## Why both changes are necessary
Without (1), the user hits the reported `ConfigurationError`. Stylelint
17's `resolveSilent` uses `import-meta-resolve` exclusively, which
doesn't honor `NODE_PATH`; stylelint 16 fell back to `resolve-from`
which did, which is why stylelint 16 users don't see the bug. Setting
`configBasedir` to the tool dir makes it stylelint's first resolution
root.
Without (2), applying (1) alone exchanges the `ConfigurationError` for a
parser failure, because Node 21 prints `ExperimentalWarning: Importing
JSON modules ...` to stderr before stylelint's JSON. The reporter would
hit this second error immediately after (1) lands.
## Verification
Added a plugin test fixture at
`qlty-plugins/plugins/linters/stylelint/fixtures/extends.in/` pinning
stylelint 17.3.0 + stylelint-config-standard 39.0.0. End-to-end
behaviour confirmed:
- **With both fixes applied:** test passes; `block-no-empty` violation
reported as expected. Snapshot: `__snapshots__/extends_v17.3.0.shot`.
- **Plugin.toml fix reverted (parser fix kept):** test fails with the
exact `ConfigurationError` from #2700. Confirms the plugin.toml change
is load-bearing.
- **Both reverted:** test fails with the parser error, confirming fix
(2) is also load-bearing.
Existing `basic` fixture at 14.6.1 and 16.15.0 still passes — no
regression.
Also added a `parse_strips_node_warning_prefix` unit test in
`qlty-check/src/parser/stylelint.rs`.
## Test plan
- [x] `cargo check` — clean
- [x] `cargo test --workspace` — all pass
- [x] `cd qlty-plugins/plugins && npm test --
--testPathPattern='linters/stylelint'` — 3/3 pass
- [x] Revert-and-reproduce verified the fixture genuinely exercises the
bug path at stylelint 17.3.0
- [x] `qlty fmt` / `qlty check --level=low --fix` on touched files —
clean
## Notes / caveats
- The `${linter}` interpolation is quoted (`"${linter}"`) to survive
tool-cache paths with spaces, matching the `editorconfig-checker`
plugin's pattern.
- `--config-basedir` has been a stylelint CLI flag since 7.x (2017), so
both `<16.0.0` and `>=16.0.0` version matchers are safe.
- The parser's `extract_json_array` helper uses a simple `find('[')`
rather than line-by-line scanning. Stylelint's top-level output is
always a JSON array, and any leading `[` inside a warning message would
be rare and would still produce a parse error on the right-hand slice.
If this proves fragile we can tighten to line-scan.1 parent b42dfac commit f900a5d
7 files changed
Lines changed: 91 additions & 4 deletions
File tree
- qlty-check/src/parser
- qlty-plugins/plugins/linters/stylelint
- fixtures
- __snapshots__
- extends.in
- .qlty
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
62 | 63 | | |
63 | 64 | | |
64 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
65 | 79 | | |
66 | 80 | | |
67 | 81 | | |
| |||
168 | 182 | | |
169 | 183 | | |
170 | 184 | | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
171 | 206 | | |
Lines changed: 27 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
Lines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
| |||
0 commit comments