Skip to content

Commit 8442868

Browse files
committed
fix off-by-one error
createLineTable really needs to be adjusted so everything is zero based instead of the current impl
1 parent bb628d7 commit 8442868

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

packages/tailwindcss/src/css-parser.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
11641164
color: blue;
11651165
}
11661166
`),
1167-
).toThrowErrorMatchingInlineSnapshot(`[CssSyntaxError: input.css: 9:10: Missing opening {]`)
1167+
).toThrowErrorMatchingInlineSnapshot(`[CssSyntaxError: input.css:9:11: Missing opening {]`)
11681168
})
11691169

11701170
it('should error when curly brackets are unbalanced (closing)', () => {
@@ -1193,7 +1193,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
11931193
/* ^ Missing closing } */
11941194
`),
11951195
).toThrowErrorMatchingInlineSnapshot(
1196-
`[CssSyntaxError: input.css: 6:10: Missing closing } at .bar]`,
1196+
`[CssSyntaxError: input.css:6:11: Missing closing } at .bar]`,
11971197
)
11981198
})
11991199

@@ -1217,7 +1217,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
12171217
}
12181218
`),
12191219
).toThrowErrorMatchingInlineSnapshot(
1220-
`[CssSyntaxError: input.css: 3:21: Unterminated string: "Hello world!"]`,
1220+
`[CssSyntaxError: input.css:3:22: Unterminated string: "Hello world!"]`,
12211221
)
12221222
})
12231223

@@ -1241,7 +1241,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
12411241
}
12421242
`),
12431243
).toThrowErrorMatchingInlineSnapshot(
1244-
`[CssSyntaxError: input.css: 3:21: Unterminated string: "Hello world!;"]`,
1244+
`[CssSyntaxError: input.css:3:22: Unterminated string: "Hello world!;"]`,
12451245
)
12461246
})
12471247

@@ -1251,7 +1251,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
12511251
)
12521252

12531253
expect(() => parseWithLoc('--foo')).toThrowErrorMatchingInlineSnapshot(
1254-
`[CssSyntaxError: input.css: 1:0: Invalid custom property, expected a value]`,
1254+
`[CssSyntaxError: input.css:1:1: Invalid custom property, expected a value]`,
12551255
)
12561256
})
12571257

@@ -1261,7 +1261,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
12611261
)
12621262

12631263
expect(() => parseWithLoc('.foo { --bar }')).toThrowErrorMatchingInlineSnapshot(
1264-
`[CssSyntaxError: input.css: 1:7: Invalid custom property, expected a value]`,
1264+
`[CssSyntaxError: input.css:1:8: Invalid custom property, expected a value]`,
12651265
)
12661266
})
12671267

@@ -1283,7 +1283,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
12831283
}
12841284
`),
12851285
).toThrowErrorMatchingInlineSnapshot(
1286-
`[CssSyntaxError: input.css: 3:19: Unterminated string: 'Hello world!']`,
1286+
`[CssSyntaxError: input.css:3:20: Unterminated string: 'Hello world!']`,
12871287
)
12881288
})
12891289

@@ -1293,7 +1293,7 @@ describe.each(['Unix', 'Windows'])('Line endings: %s', (lineEndings) => {
12931293
)
12941294

12951295
expect(() => parseWithLoc('.foo { bar }')).toThrowErrorMatchingInlineSnapshot(
1296-
`[CssSyntaxError: input.css: 1:7: Invalid declaration: \`bar\`]`,
1296+
`[CssSyntaxError: input.css:1:8: Invalid declaration: \`bar\`]`,
12971297
)
12981298
})
12991299
})

packages/tailwindcss/src/css-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class CssSyntaxError extends Error {
4747
if (loc) {
4848
let source = loc[0]
4949
let start = createLineTable(source.code).find(loc[1])
50-
message = `${source.file}: ${start.line}:${start.column}: ${message}`
50+
message = `${source.file}:${start.line}:${start.column + 1}: ${message}`
5151
}
5252

5353
super(message)

0 commit comments

Comments
 (0)