Skip to content

oxfmt: support parser option (with overrides) #17852

@cexbrayat

Description

@cexbrayat

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:

overrides:
  - files: "*.html"
    options:
      parser: angular
  - files: "index.html"
    options:
      parser: html

Would it be possible to have a similar feature in oxfmt?
This would allow users to explicitly map file patterns to specific parsers.

Something like:

{
  "overrides": [
    {
      "files": "*.html",
      "options": {
        "parser": "angular"
      }
    },
    {
      "files": "index.html",
      "options": {
        "parser": "html"
      }
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority

    None yet

    Start date

    None yet

    Target date

    None yet

    Effort

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions