Repository navigation
fix: report a CSS syntax error and a thrown parse error at their position (#1306, #1308) - #1344
Merged
jonkwheeler merged 3 commits intoNov 14, 2026
Conversation
A CSS syntax error (TSRX3013) was a plain `Error` with no position, so a build, Prettier and ESLint gave it no line or column, and the loose compile the editor runs dropped it while keeping the rules before it. The CSS parser now records where it stopped, `parseStyle` gives the error that position (`pos`, and `loc` with a `body` origin), and the parser throws it there, collecting too. A loose parse records it and keeps the rules before it, as it did; an unclosed `<style>`, still being typed, gets its TSRX1001 alone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
ESLint reads a parser error's `lineNumber` and `column`, which the parser
set only for a recorded unclosed or mismatched tag, from `loc.start`. A
syntax error the TSRX parser throws has acorn's flat `loc { line, column }`,
so it was wrapped as `Failed to parse TSRX file: …` with no position and
ESLint showed it at 0:0. Read both shapes (and `pos` when there's no
`loc`), drop acorn's `(line:column)` from the message, and set `index`
from `pos`, which TSRX errors carry, not `start`.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rrors Three of the sources came from tsrx-org#1308's table: an unclosed `<div>` or `<b>` that a collecting parse can't recover, so it throws TS1012 at the code after it. tsrx-org#1305's open fix records those as TSRX1001 instead, which ESLint already reports at its place, so they wouldn't keep testing a thrown error. Use JavaScript syntax errors that a collecting parse throws. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
jonkwheeler
marked this pull request as ready for review
November 14, 2026 13:52
jonkwheeler
added a commit
to jonkwheeler/tsrx
that referenced
this pull request
Nov 14, 2026
tsrx-org#1344 on main parses a <style> body strictly and, on a CSS syntax error, throws it or records it and reparses loosely. This branch parsed an unclosed <style>'s partial body loosely. Keeps tsrx-org#1344's handling and treats an unclosed <style> like a loose parse there: it gets its TSRX1001 alone, in every mode. Keeps both sides' new tests in the ESLint parser and Prettier plugin test files. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
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.
Summary
A syntax error the TSRX parser throws now reaches every tool at its line and column.
<style>block ([Bug]: tsrx-core: a CSS syntax error in a<style>block has no position, and the editor doesn't report it #1306). A CSS syntax error (TSRX3013) was a plainErrorwith no position, and the loose compile the editor runs dropped it. The CSS parser now records where it stopped,parseStylegives the errorpos(andlocfor a sheet with abodyorigin, which every sheetparseModulemakes has), and the parser throws it there, in a strict and a collecting parse. A loose parse records it and keeps the rules before it, as it already kept them; an unclosed<style>, whose body is still being typed, gets its TSRX1001 alone.@tsrx/eslint-parsergave ESLint a line and column only for a recorded unclosed or mismatched tag, read fromloc.start. An error the parser throws has acorn's flatloc { line, column }, so it was wrapped asFailed to parse TSRX file: …and ESLint showed it at 0:0.to_eslint_parse_errornow reads both shapes (andposwhen there is noloc), drops acorn's(line:column)from the message, and setsindexfrompos, which TSRX errors carry, instead ofstart. An error with no position at all keeps theFailed to parse TSRX file:wrapper.The two issues share their CSS row: #1308 lists the stray
}in a<style>body, which has no position until #1306's change, and #1306's ESLint row needs #1308's change.Before / after
<style>body with a stray}(.a { color: red; }then}on its own line, line 5, column 3) in a template,@tsrx/react:compileError: Expected identifier,code: 'TSRX3013', nolocorposSyntaxError: Expected identifier (5:3),code: 'TSRX3013',loc { line: 5, column: 3 },pos: 67compilewithcollect: truecompilewithloose: true,compile_to_volar_mappingslooseExpected identifierat 5:3 (pos67,end68)compileErrorDiagnosticPlugin)>(the editor's code has no<style>body, so an error on a body line with no code shows on the nearest code before it); on the}itself for a one-line<style>(export const a = <style>.a { color: red; } }</style>;)@tsrx/content-mapperon the native language server)}itselfExpected identifier, no locationExpected identifier (5:4),loc { start: 5:4 }0:0 Parsing error: Failed to parse TSRX file: Expected identifier5:4 Parsing error: Expected identifierA missing
}(.a { color: red;then</style>) is reported the same way at the end of the rule,Expected } (4:19)(ESLint and Prettier4:20).ESLint 10.3.0, the rows of #1308:
const a = ;0:0 … Failed to parse TSRX file: Unexpected token (2:11)2:12 Parsing error: Unexpected tokenreturn (\n<div>\n);0:0 … Unexpected token (5:0)5:1 Parsing error: Unexpected tokenreturn <div>{props.x ? <b> : null}</div>;0:0 … Unexpected token (2:34)2:35 Parsing error: Unexpected tokenreturn [<div>];0:0 … Unexpected token (3:0)3:1 Parsing error: Unexpected token<style>body with a stray}0:0 … Failed to parse TSRX file: Expected identifier5:4 Parsing error: Expected identifierreturn <div>{<b>}</div>;(recorded TSRX1001)2:16 Parsing error: Unclosed tag '<b>'. …Tests
packages/tsrx/tests/utils/parser.test.js: three CSS errors (a stray}in a template and outside one, a missing}) throw TSRX3013 at the CSS that fails, with acorn'slocand message suffix, in a strict and a collecting parse; a loose parse records each at its offset and keeps the rules before it; an unclosed<style>with partial CSS records only TSRX1001.packages/tsrx/tests/utils/style-parse.test.js:parseStylegivesposin the body without abodyorigin, andposandlocin the file with one.@tsrx/hono/dom.packages/eslint-parser/tests/index.test.ts: four JavaScript syntax errors (const a = ;,let b = 1 +;, a missing comma in an object,if (a {) and the stray}in a<style>body reachLinter#verifyat their line and column with the bare message, and a thrown error gets its offset asindex. The test doesn't use the three markup rows of [Bug]: eslint-parser: a syntax error the TSRX parser throws is reported at 0:0, with its position only in the message #1308: fix(core): report an unclosed tag without a later error from the code after it #1353 ([Bug]: tsrx-core: for some unclosed tags, the editor, Prettier or ESLint show a later error (Unexpected token,Expected identifier,'}' expected) instead of TSRX1001 #1305) makes a collecting parse record those as TSRX1001 instead of throwing at the code after them, and ESLint already reports a recorded TSRX1001 at its place.<style>case, which pins what main already does in a loose parse.vitest run(225 files, 14,213 passed, 102 skipped),format:check,typecheckandchangeset:checkpass locally.Codex (
gpt-5.6-sol) reviewed both commits (8812893, acfc947) and found no bugs or regressions. It checked that the strict-then-loose parse gives a loose parse the same sheet for valid CSS, the unclosed<style>case in collect and loose modes, positions at the end of input and with CRLF, a<style>in<head>, the message suffix stripping, and the changesets.Fixes #1306
Fixes #1308
🤖 Generated with Claude Code
https://claude.ai/code/session_01FRKmwAwuyPbGQ1ejNqiJ46
Note
Medium Risk
Touches the core TSRX parser,
<style>compile paths, and ESLint’s fatal parse error contract, so mis-positioned or double-reported errors could affect editor, build, and lint UX.Overview
TS/CSS and ESLint now surface parser-thrown syntax errors at real line and column instead of silent drops or
0:0.In
parseStyle/<style>handling, CSS failures (TSRX3013) getposand filelocwhen the style body origin is known. Strict compiles throw at that offset; the editor’s loose compile records the error and keeps valid rules above it, while an unclosed<style>still only reports TSRX1001.@tsrx/eslint-parserreworksto_eslint_parse_errorso thrown JS/CSS errors mappos/loc(including deriving location from source when needed), setindex, strip acorn’s(line:column)suffix from messages, and throw positionedSyntaxErrors instead of the genericFailed to parse TSRX file:at0:0.Coverage is extended in core, ESLint, Prettier, language-server, and shared compile tests for both CSS-in-style and typical JS parse mistakes.
Reviewed by Cursor Bugbot for commit dfcbc2c. Bugbot is set up for automated code reviews on this repo. Configure here.