Skip to content

feat(stylelint-plugin): support stylelint v17#346

Merged
mizdra merged 5 commits intomizdra:mainfrom
tobigumo:feat/support-stylelint-v17
Feb 23, 2026
Merged

feat(stylelint-plugin): support stylelint v17#346
mizdra merged 5 commits intomizdra:mainfrom
tobigumo:feat/support-stylelint-v17

Conversation

@tobigumo
Copy link
Copy Markdown
Contributor

@tobigumo tobigumo commented Feb 23, 2026

Summary

  • 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 (test-stylelint-v16) to test stylelint-plugin with stylelint v16 for backward compatibility

Background

In stylelint v17, utils.report() was refactored to call node.rangeBy({ index, endIndex }) directly instead of passing position arguments through to the PostCSS Warning constructor. This means index/endIndex are now interpreted as node-relative offsets by PostCSS's rangeBy().

Previously in v16, word took priority over index/endIndex inside PostCSS's rangeBy(), 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 build passes
  • npm run test passes with stylelint v17
  • stylelint-plugin tests pass with stylelint v16 (npm install stylelint@16 --no-save)
  • CI test-stylelint-v16 job passes

🤖 Generated with Claude Code

- 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-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 23, 2026

🦋 Changeset detected

Latest commit: 60ace75

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 6 packages
Name Type
@css-modules-kit/stylelint-plugin Minor
@css-modules-kit/core Minor
@css-modules-kit/ts-plugin Minor
@css-modules-kit/codegen Minor
@css-modules-kit/eslint-plugin Minor
css-modules-kit-vscode Minor

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

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,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

mizdra and others added 4 commits February 23, 2026 21:35
…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>
Copy link
Copy Markdown
Owner

@mizdra mizdra left a comment

Choose a reason for hiding this comment

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

Thank you for contributing! LGTM!

@mizdra mizdra added the Type: Feature New Feature label Feb 23, 2026
@mizdra mizdra merged commit 02d1e48 into mizdra:main Feb 23, 2026
16 checks passed
@github-actions github-actions bot mentioned this pull request Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Feature New Feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants