Fix expected end offset of a rule with spaces before its own semicolon - #32
Merged
Merged
Conversation
Signed-off-by: maximilliangrand <214999687+maximilliangrand@users.noreply.github.com>
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.
Companion to postcss/postcss#2135, which fixes
source.end.offsetfor a rule that owns a stray semicolon preceded by whitespace. That PR's CI is red until this one lands and is released — its only failing test isparses semicolons.css, reading the fixture below.cases/semicolons.jsonrecords the pre-fix value for thea{b:c} ;case added in 8.9.0, and that value is self-contradictory today. Incases/semicolons.css, line 8 is:The rule node's recorded end is:
column: 8, line: 8is the;, which is at offset 61.end.offsetis exclusive, so it must be 62.@of the next line — it is also the recordedstart.offsetof the following at-rule node, 30 lines further down in the same file. Two sibling nodes cannot both own byte 63.css.slice(54, 63)is"a{b:c} ;\n", while the node's own text is"a{b:c} ;"— the range claims the newline that is the at-rule'sraws.before.So this one number is wrong independently of the parser change; the parser change is just what makes a test notice it.
"source": { "end": { "column": 8, "line": 8, - "offset": 63 + "offset": 62 },Only the
a{b:c} ;rule changes. The otherownSemicolonnode in the same file,a{b:cc};on line 7 (ownSemicolon: ";", no space), is already consistent — its;is at offset 52 and its recordedend.offsetis 53 — and is untouched, as is the at-rule'sstart.offset: 63.pnpm testpasses here (lint + 4 unit tests). This repo's own suite does not re-parse the fixtures, so it is green both before and after; the failure this unblocks isparses semicolons.cssin postcss itself.Precedent for the two-repo sequence: the 8.8 changelog entry is "Update
offsetaccording to fix inpostcss", and postcss commit be364fd8 bumped this package 8.5.0 → 8.5.1 alongside a parser position fix.What I did not verify
I have not run any third-party parser that consumes these fixtures (postcss-scss, postcss-less, …) against the new value. They would only be affected if they reproduce the same
ownSemicolonarithmetic; I did not check their sources.Signed-off-by: maximilliangrand 214999687+maximilliangrand@users.noreply.github.com