0

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.

ankitd
  • 1,967
  • 3
  • 26
  • 44

1 Answers1

3

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.
Janak
  • 4,986
  • 4
  • 27
  • 45
jeddy3
  • 3,451
  • 1
  • 12
  • 21
  • Also see [stylelint-formatter-stats](https://www.npmjs.com/package/stylelint-formatter-stats) for an example of a custom formatter that groups results by rule. – tekniskt Jan 11 '18 at 12:04
  • Voted up. Thanks @jeddy3 atleast it gives me summary of broken rules. Will keep it open for a while. – ankitd Jan 12 '18 at 05:19