You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
oxfmt: support parser option (with overrides) #17852
oxfmt currently relies on hardcoded file extension checks to determine which parser to use. Specifically, for Angular templates, it only uses the angular parser if the file ends in .component.html.
While this was true for a long time in the Angular community, the updated Style Guide in 2025 now recommends to have component templates named user.html instead of user.component.html, and this is now the default in projects generated via Angular CLI.
As files ending in just .html are treated as generic HTML, this causes formatting issues for Angular Control Flow syntax (@if, @for, @switch), which are not valid in standard HTML and are thus aggressively collapsed or incorrectly indented by the generic html parser.
In Prettier, we usually rely on overrides to work around this:
changed the title [-]oxfmt: support configuration overrides for parser selection[/-][+]oxfmt: support `parser` option (with `overrides`)[/+]on Jan 20, 2026
When using Ionic with Angular, page templates use the .page.html suffix. In these files, the new Angular control flow syntax is not being formatted correctly. It would be useful to support the parser option within overrides to ensure these files are treated as Angular templates.
Reacted by Kirill Groshkov, Ed, JanPolasek, musjj, Ajit Panigrahi and barnz
Reacted by Kirill Groshkov, Benny Böhm, musjj and barnz
Oxfmt currently treats tsconfig.json and .vscode/*.json as plain json rather than jsonc. I need this feature to format the trailing commas in them correctly. (BTW, they're treated as jsonc correctly by oxc's vscode plugin because vscode provided the file type information.)
Reacted by Shinigami, uzmoi, Gavin Elster, musjj, Ramon Martinez, lihanspace and John Bartholomew
The design concerns I raised in my first comment (kept updated since then) still stand, and feedback on them is still welcome.
For the main Angular use case, we're also watching angular/angular#67545. If Angular adopts a dedicated extension, we can support it soon, with zero configuration.
We need this configuration for Ionic's .page.html files; it's not possible to format them in Angular mode. This should be dynamic.
We are fully aware that there are cases that rely on that option but blindly copying it does not look like the best way.
Could you (and anybody else who is interested in this option) give feedbacks to the points in the first comments?
As for changing the file extension (angular/angular#67545), I guess that's not going to happen, because they don't seem to understand the idea and have ignored the thread.
But you are welcome to help. Comment, start new discussion, etc.
I agree parser inside overrides.options is the wrong shape. It picks the whole pipeline, not a format option, and in the current resolver every matched file would take the slow override path instead of sharing the cached config.
The associations idea seems right to me. A top-level map from glob to language, sitting next to overrides and ignorePatterns:
To add to the reasons why this would be beneficial, this isn't just an Angular thing, we have a similar issue with Handlebars templates in *.html files (which is what BigCommerce's Stencil template engine expects).
We're running into this in an Angular 22 workspace as well, so here's a data point with some numbers, plus a few thoughts on the design questions.
Our setup: 142 HTML files: 94 *.component.html, 47 *.feature.html (our naming convention for routed feature components) and a single index.html. With Prettier we use overrides: [{ files: "*.html", options: { parser: "angular" } }].
The Angular formatting itself already works really well. With the same options, all 94 *.component.html come out byte-identical to Prettier, and so do all 47 *.feature.html when we route them through the Angular pipeline via --stdin-filepath x.component.html. Through the HTML pipeline, 28 of them lose the indentation inside control-flow blocks, and some @if { … } @else { … } blocks and multi-line {{ … }} get reflowed like prose. The --stdin-filepath trick only helps on the CLI, since the editor formats through the LSP with the real file path.
Some thoughts on the design:
angular: true (similar to svelte: true) would cover our case completely: *.html as Angular, plus { "files": ["**/index.html"], "options": { "angular": false } } for the one exception. It also seems easy to explain, and easy to retire if Angular ever adopts a dedicated extension.
overrides[].language (feat(oxfmt): route files by language via overrides[].language #26257) would additionally help with .page.html, Handlebars and .wxml. We'd be happy with either direction. What would help us most is that the CLI, the LSP and --check pick the same pipeline for a given file.
A small thing we noticed along the way: our first attempt was parser inside overrides.options, which oxfmt accepted without any message, and --migrate prettier skips parser quietly as well. Maybe a short hint there, for example pointing to this issue, could help others who try the same. Just an idea, independent of the final design.
Activity
leaysgur commentedon Jan 11, 2026
I'm a bit skeptical about supporting this as-is.
The implementation itself isn't difficult, but here are some points I'm considering and want to discuss first:
parser.ngmltemplate file type as an alternative to.htmlangular/angular#67545If for some reason we were to support an equivalent feature,
associationsbydprintseems neat.In that case,
{ [glob]: (linguistLang?ourOriginalId?) }? How about precedence?This decision will likely impact the subsequent design of language-specific options. (1.0 milestone work? though)
[-]oxfmt: support configuration overrides for parser selection[/-][+]oxfmt: support `parser` option (with `overrides`)[/+]garytube commentedon Mar 3, 2026
Hi there,
we also faced that issue today while refactoring our App.
A parser option would be helpfule!
edlrod commentedon Mar 4, 2026
Probably switching back to prettier until this is fixed
luisbytes commentedon Mar 6, 2026
When using Ionic with Angular, page templates use the .page.html suffix. In these files, the new Angular control flow syntax is not being formatted correctly. It would be useful to support the parser option within overrides to ensure these files are treated as Angular templates.
pkurcx commentedon Mar 10, 2026
I support the request. We switched to an approach without a suffix, which makes the formatter useless for these templates.
zargham-k commentedon Mar 10, 2026
We've run into this issue, some components do not follow
*.component.htmlconvention, it would be great to have the parser override.frf-leanix commentedon Mar 10, 2026
I support this request as well, it's currently stopping us from replacing prettier with oxfmt.
pkurcx commentedon Mar 10, 2026
Alternatively Issue to introduce custom file extension for templates:
angular/angular#67545
ZWQ652 commentedon Mar 24, 2026
Has there been any progress on this feature? Without this feature, files in custom formats cannot function
balthild commentedon Mar 28, 2026
Oxfmt currently treats
tsconfig.jsonand.vscode/*.jsonas plain json rather than jsonc. I need this feature to format the trailing commas in them correctly. (BTW, they're treated as jsonc correctly by oxc's vscode plugin because vscode provided the file type information.)musjj commentedon Apr 12, 2026
Yep, hit this issue too. Going to return to prettier until this is fixed...
djarekg commentedon Apr 16, 2026
I just switched back to prettier also.
7 remaining items
luisbytes commentedon Jul 25, 2026
We need this configuration for Ionic's .page.html files; it's not possible to format them in Angular mode. This should be dynamic.
TheAlexLichter commentedon Jul 26, 2026
@luisbytes This is exactly that @leaysgur mentioned in #17852 (comment)
We are fully aware that there are cases that rely on that option but blindly copying it does not look like the best way.
Could you (and anybody else who is interested in this option) give feedbacks to the points in the first comments?
pkurcx commentedon Aug 3, 2026
As for changing the file extension (angular/angular#67545), I guess that's not going to happen, because they don't seem to understand the idea and have ignored the thread.
But you are welcome to help. Comment, start new discussion, etc.
https://discord.com/channels/748677963142135818/1481242010189828168
*.html, no.componentsuffix) #25869 as a duplicate of this issuepkurcx commentedon Sep 2, 2026
I agree
parserinsideoverrides.optionsis the wrong shape. It picks the whole pipeline, not a format option, and in the current resolver every matched file would take the slow override path instead of sharing the cached config.The
associationsidea seems right to me. A top-level map from glob to language, sitting next tooverridesandignorePatterns:{ "associations": { "**/*.html": "angular", "index.html": "html", "**/*.wxml": "html" } }PoC PR: #26257
leaysgur commentedon Sep 10, 2026
Although nothing has been decided yet, I've come up with some other ideas.
{ "angular": true }svelte: trueinto_outcomeswapshtml→angularindex.htmlexception via existingoverridesto set{ angular: false }format()API also follows*.page.html, but NOT unknown extensions (*.wxml,*.svg);Thoughts:
svelteis in the same category, so feels natural{ "overrides": [{ "files": "*.html", "language": "angular" }] }files|excludeFiles/ config-dir relativity / later-wins precedence, no new concept, no preserve_orderoverrides[].options.parserclassify() + resolve()should be merged into one pass inConfigResolverThoughts:
overridesshould not be an escape hatch?.tsascss, but pointlesslanguagepkurcx commentedon Sep 10, 2026
I've reshaped the PoC in #26257 to the first idea,
overrides[].language.Why it's the better shape:
excludeFilesgives a real way to fall back to built-in detection.preserve_orderis gone.{ "files": ["*.html"], "language": "angular", "options": { ... } }.languagesits besideoptions, not inside. It picks the pipeline, it is not a format option.angular,handlebars), not Prettier parser names.overrides[].options.parser. (migrate-prettieritself is still blocked on oxfmt: Improve--migrate prettier#18215.)language-only entry keeps the fast path, and nested configs work unchanged.Note:
filesmust be an array, so the example reads{ "files": ["*.html"], "language": "angular" }.Details in the PR comment.
Route TS/JS to oxfmt, keep Prettier for non-component templates
richardweaver commentedon Sep 28, 2026
To add to the reasons why this would be beneficial, this isn't just an Angular thing, we have a similar issue with Handlebars templates in *.html files (which is what BigCommerce's Stencil template engine expects).
Rename components to follow the modern Angular style guide
muuvmuuv commentedon Oct 6, 2026
We're running into this in an Angular 22 workspace as well, so here's a data point with some numbers, plus a few thoughts on the design questions.
Our setup: 142 HTML files: 94
*.component.html, 47*.feature.html(our naming convention for routed feature components) and a singleindex.html. With Prettier we useoverrides: [{ files: "*.html", options: { parser: "angular" } }].The Angular formatting itself already works really well. With the same options, all 94
*.component.htmlcome out byte-identical to Prettier, and so do all 47*.feature.htmlwhen we route them through the Angular pipeline via--stdin-filepath x.component.html. Through the HTML pipeline, 28 of them lose the indentation inside control-flow blocks, and some@if { … } @else { … }blocks and multi-line{{ … }}get reflowed like prose. The--stdin-filepathtrick only helps on the CLI, since the editor formats through the LSP with the real file path.Some thoughts on the design:
angular: true(similar tosvelte: true) would cover our case completely:*.htmlas Angular, plus{ "files": ["**/index.html"], "options": { "angular": false } }for the one exception. It also seems easy to explain, and easy to retire if Angular ever adopts a dedicated extension.overrides[].language(feat(oxfmt): route files by language viaoverrides[].language#26257) would additionally help with.page.html, Handlebars and.wxml. We'd be happy with either direction. What would help us most is that the CLI, the LSP and--checkpick the same pipeline for a given file.parserinsideoverrides.options, which oxfmt accepted without any message, and--migrate prettierskipsparserquietly as well. Maybe a short hint there, for example pointing to this issue, could help others who try the same. Just an idea, independent of the final design.leaysgur commentedon Oct 8, 2026
Now that recent heavy tasks are done, I'd like to move this forward.
(cc: Thanks @pkurcx for the PoC)
First, a re-evaluation of the ideas so far.
.mdas MDX in Docusaurus, Cursor's.mdc, WeChat's.wxml, Salesforce's.cmp, each would need its own flag?So I decided not to go with it.
{ language, options }case.So I can't call it the best either.
overrides.language, use Shiki ids, already used in our codebase (e.g. embedded dispatch name), probably the most familiar ones.The final shape looks like this.
{ "associations": [ { "files": ["**/*.html"], "excludeFiles": ["**/index.html"], "language": "angular-html" }, { "files": ["**/*.mdc"], "language": "markdown" } ] }Poc PR: #27437
feat(oxfmt): support `associations` config to specify language over f…