Include filename and line numbers in CSS parse errors (#19282)

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
This commit is contained in:
Ishita SIngh 2025-11-10 23:59:23 +05:30 • committed by GitHub
parent 5a89571efd
commit 5bc90dd2e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 185 additions and 21 deletions

View file

@ -1,9 +1,12 @@
import dedent from 'dedent'
import os from 'node:os'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import { describe } from 'vitest'
import { candidate, css, html, js, json, test, ts, yaml } from '../utils'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const STANDALONE_BINARY = (() => {
switch (os.platform()) {
case 'win32':
@ -2101,6 +2104,33 @@ test(
},
)
test(
'CSS parse errors should include filename and line number',
{
fs: {
'package.json': json`
{
"dependencies": {
"tailwindcss": "workspace:^",
"@tailwindcss/cli": "workspace:^"
}
}
`,
'input.css': css`
.test {
color: red;
*/
}
`,
},
},
async ({ exec, expect }) => {
await expect(exec('pnpm tailwindcss --input input.css --output dist/out.css')).rejects.toThrow(
/CssSyntaxError: .*input.css:3:3: Invalid declaration: `\*\/`/,
)
},
)
function withBOM(text: string): string {
return '\uFEFF' + text
}