ankitd
ankitd

Reputation: 2017

get stylelint report by broken rule instead of filename

I have implemented STYLELINT in my project.

But currently this shows error by file name.

fileone.scss
Line 10:5 expected this 'rule-xyz'
Line 15:5 expected this 'rule-abc'
Line 25:5 expected this 'rule-123'

anotherfile.scss
Line 12:5 expected this 'rule-xyz'
Line 18:5 expected this 'rule-abc'
Line 26:5 expected this 'rule-123'

Is there any way one get error sorted by broken rules instead of filename?? like below?

rule-xyz
file-one.scss Line 10:5 expected bla bla
file-two.scss Line 19:5 expected bla bla
file-three.scss Line 30:5 expected bla bla

rule-abc
file-one.scss Line 10:5 expected bla bla
file-two.scss Line 19:5 expected bla bla
file-three.scss Line 30:5 expected bla bla

I checked on their website but couldn't find any answer.

Upvotes: 0

Views: 447

Answers (1)

jeddy3
jeddy3

Reputation: 3959

There is no built-in formatter that lists the violations grouped by rule.

There are other options, though:

  1. The built-in verbose formatter (stylelint "**/*.css" --formatter verbose) produces a tally of violations for each rule.
  2. The built-in json formatter (stylelint "**/*.css" --formatter json) produces a json output. By using external charting libraries, one can see data in graph format as well.
  3. Custom formatters are supported by stylelint, via the --custom-formatter CLI flag. So, it is possible to write your own formatter to list the violations exactly as you want.

Upvotes: 3

Related Questions