Skip to content

Commit 6c52e93

Browse files
authored
fix: fix property location reporting (#495)
closes #494
1 parent 30b6f62 commit 6c52e93

File tree

4 files changed

+22
-8
lines changed

4 files changed

+22
-8
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
"code"
5050
],
5151
"dependencies": {
52-
"@projectwallace/css-parser": "^0.12.2"
52+
"@projectwallace/css-parser": "^0.12.3"
5353
},
5454
"devDependencies": {
5555
"@codecov/vite-plugin": "^1.9.1",

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,7 @@ function analyzeInternal<T extends boolean>(css: string, options: Options, useLo
471471
let { is_important, property, is_browserhack, is_vendor_prefixed } = node
472472

473473
let propertyLoc = toLoc(node)
474+
propertyLoc.length = property.length
474475

475476
properties.p(property, propertyLoc)
476477

src/properties/properties.test.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,16 @@ test('counts the amount of !important used on custom properties', () => {
209209
'--color3': 1,
210210
})
211211
})
212+
213+
test('reports locations correctly', () => {
214+
const fixture = `
215+
properties {
216+
margin: 0;
217+
}
218+
`
219+
const actual = analyze(fixture, { useLocations: true }).properties.uniqueWithLocations
220+
221+
expect(actual).toEqual({
222+
margin: [{ offset: 24, length: 6, column: 7, line: 3 }],
223+
})
224+
})

0 commit comments

Comments
 (0)