antfu / eslint-config

Anthony's ESLint config preset

Home Page:https://eslint-config.antfu.me/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

XML formatter

zanfee opened this issue · comments

Clear and concise description of the problem

As a SAPUI5 (a JavaScript framework) developer I define views (based on the MVC pattern) for my web apps using XML (as described in the SAPUI5 docs). Currently I use a fork of @antfu/eslint-config which includes the @html-eslint plugin and parser that work for both HTML and XML. I created this fork before you included formatters in @antfu/eslint-config and I think that I could migrate back to @antfu/eslint-config once XML is supported. Since XML is a common format for many use-cases, I believe that it would benefit other developers too.

I'd be happy to submit a PR for this.

Suggested solution

I think we could use eslint-plugin-format based on Prettier and dprint to support XML as you already do for HTML. I haven't checked if there's anything else you need to do to make it work, but I'd be happy to give it a try.

Alternative

No response

Additional context

No response

Validations

Prettier does not support XML by default but with a community plugin (plugin-xml).

Maybe we could use dprint? I am ok to have it as opt-in if it's not too complicated to maintain

There's no XML plugin listed on dprint's plugin site and I couldn't find one either. Are you suggesting creating a plugin for XML from scratch? Dprint also has a Prettier wrapper, but since eslint-plugin-format supports both Prettier and dprint, there's probably no point in using that but rather just Prettier with the community plugin. But I'm not familiar with dprint, so maybe you know more than I do and could elaborate.

Having XML support as opt-in is fine for me.

Oh, I thought Dprint had it built in. I am fine with Prettier, but the problem I see is because XML support is provided as an external plugin which would make the configuration tricky - If you managed to get it work, we could then discuss it with in the PR.