djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[FEATURE] Add optional output formats from linter

Open christopherpickering opened this issue 4 years ago • 7 comments

  • json
  • xml
  • ?

christopherpickering avatar Sep 16 '21 12:09 christopherpickering

A lot of lint tools are (ab)using JUnit XML report format, for which there is python library junit-xml

jayvdb avatar Oct 05 '21 01:10 jayvdb

SARIF - Static Analysis Results Interchange Format is an emerging standard for this.

jayvdb avatar Oct 29 '21 02:10 jayvdb

is there also a way to format the output in the console? I am interested to get the output this way it creates clickable links in my IDE

templates/index.html:3:2: T001 Variables should be wrapped in a single whitespace. %}
templates/index.html:5:8: H008 Attributes should be double quoted. class='capitalize w-

Benoss avatar Nov 28 '21 21:11 Benoss

@Benoss I suppose it would be possible, but how would it help? You can parse the output, something like this:

regex = ( r"^\s+?(?:(?P\w+\d+))\s" r"(?P\d+):" r"(?P\d+)\s(?P.+)" )

christopherpickering avatar Nov 29 '21 08:11 christopherpickering

When Pycharm detect something that looks like a relative filepath in the console it automagically creates a link that open the file at the correct line and offset. If the output is with the format above I can click directly to fix the linting issue (already doing it this way for flake8 and mypy)

Benoss avatar Nov 29 '21 10:11 Benoss

@Benoss I created #153 for that.

christopherpickering avatar Nov 29 '21 11:11 christopherpickering

Awesome thanks :)

Benoss avatar Nov 29 '21 19:11 Benoss

closing this for now. If a specific format is needed please open a new issue, or a pr.

christopherpickering avatar Sep 07 '22 18:09 christopherpickering