Open Bug 1900689 Opened 2 years ago Updated 2 years ago

Add a linter for SVG files

Categories

(Developer Infrastructure :: Lint and Formatting, enhancement)

enhancement

Tracking

(Not tracked)

People

(Reporter: calixte, Unassigned)

Details

It'd be useful at least to have the right indent (see for reference: https://phabricator.services.mozilla.com/D212027?id=871563#inline-1177577).

I vaguely remember discussions in the past about doing things with svgs, but I've got a feeling that was more on the svg optimisation side, rather than the formatting.

The piece required here would be a tool that formats the svg files how we like. It looks like Prettier either doesn't really support it and would probably treat it in a way we don't like, e.g. like this for lines that would be long:

<radialGradient
    id="a"
    cx="71.531"
  >

I did a very quick scan, and I can't see any simple formatters off-hand. svgo might be a possibility if you can turn off all the optimisation functions.

There are few alternatives proposed here:
https://firefox-source-docs.mozilla.org/code-quality/coding-style/svg_guidelines.html#tools
That said it shouldn't be that hard to have a tool to just auto-format in following these rules:
https://firefox-source-docs.mozilla.org/code-quality/coding-style/svg_guidelines.html#basics

You need to log in before you can comment on or make changes to this bug.