feat(stylelint-plugin): support stylelint v17#346
Merged
mizdra merged 5 commits intomizdra:mainfrom Feb 23, 2026
Merged
Conversation
- Fix `utils.report()` index/endIndex to use node-relative offsets instead of absolute file offsets, as required by stylelint v17's stricter position argument handling (stylelint/stylelint#8217) - Update devDependency to stylelint v17 - Add CI job to test with stylelint v16 for backward compatibility - Add changeset Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 60ace75 The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
mizdra
reviewed
Feb 23, 2026
| index: classSelector.loc.start.offset, | ||
| endIndex: classSelector.loc.end.offset, | ||
| index: classSelector.loc.start.offset - rule.source!.start!.offset, | ||
| endIndex: classSelector.loc.end.offset - rule.source!.start!.offset, |
Owner
There was a problem hiding this comment.
memo: It seems index and endIndex were already relative to node in v16. It's surprising the tests hadn't failed until now...
Regardless of why the tests hadn't failed, I think this change is good.
https://github.com/stylelint/stylelint/blob/16.23.1/types/stylelint/index.d.ts#L1265-L1274
…cache collision `setup-node-and-node-modules` caches `node_modules` keyed by `package-lock.json`. Installing stylelint@16 beforehand changes the lock file so that the cache key differs from the stylelint@17 run, preventing the wrong `node_modules` from being restored. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The stylelint job was using `npx vitest --run --project unit` which ran all unit tests filtered by path, instead of `npm run test` which correctly runs only the specified package's tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ache collision with `test` job Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
mizdra
approved these changes
Feb 23, 2026
Owner
mizdra
left a comment
There was a problem hiding this comment.
Thank you for contributing! LGTM!
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
utils.report()index/endIndexto use node-relative offsets instead of absolute file offsets, as required by stylelint v17's stricter position argument handling (stylelint/stylelint#8217)test-stylelint-v16) to test stylelint-plugin with stylelint v16 for backward compatibilityBackground
In stylelint v17,
utils.report()was refactored to callnode.rangeBy({ index, endIndex })directly instead of passing position arguments through to the PostCSS Warning constructor. This meansindex/endIndexare now interpreted as node-relative offsets by PostCSS'srangeBy().Previously in v16,
wordtook priority overindex/endIndexinside PostCSS'srangeBy(), so the absolute offsets never caused issues. With v17's new priority order (index/endIndex>word), the offsets need to be correct node-relative values.Test plan
npm run buildpassesnpm run testpasses with stylelint v17npm install stylelint@16 --no-save)test-stylelint-v16job passes🤖 Generated with Claude Code