New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix report()
for index
/endIndex
zero values
#7565
Fix report()
for index
/endIndex
zero values
#7565
Conversation
🦋 Changeset detectedLatest commit: 847f8f9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@romainmenke Thanks for the pull request! In addition to endIndex
, does also checking index
make sense?
- } else if (index) {
+ } else if (typeof index === 'number') {
stylelint/lib/utils/report.mjs
Line 105 in b05abc8
} else if (index) { |
https://github.com/stylelint/stylelint into allow-endIndex-to-be-zero--generous-caiman-66321db509
Tested with also a check for I don't think it makes a practical difference because in the absence of a start index there already are fallbacks to the start in PostCSS, so "not specified" is always equal to But I like the consistency :) I've also updated PostCSS so that the fix is complete. |
1
at the start of a stylesheetreport()
for index
/endIndex
zero values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you. LGTM 👍🏼
Besides, can you add a changelog item according to this PR title?
Fixed: `report()` for `index`/`endIndex` zero values
After adding the item, feel free to merge 👍🏼
Thank you for the feedback @ybiquitous 🙇 |
None, but related to #7518 (comment)
a {}
This stylesheet has a selector with a length
1
at the start of a stylesheet.This is passed to PostCSS as
index: 0
andendIndex: 0
sinceendIndex
is exclusive.However both Stylelint and PostCSS have boolean checks for
endIndex
instead of a check that it is a number.So the warning is reported as if no
endIndex
was set.This does a fallback to the entire length of the node.
PostCSS has already been fixed but awaiting release : postcss/postcss#1932
This should have a unit test, but I noticed that there aren't any unit tests for
report.mjs
withendIndex
.So I wasn't sure on what the best and most succinct test would be here.