djLint icon indicating copy to clipboard operation
djLint copied to clipboard

[FEATURE] Auto fix T002, T003, but potentially any auto-fixable issue

Open alessandro-newzoo opened this issue 2 years ago • 1 comments

  • [x] I've searched the issues
  • [x] I've read the docs

Feature Request

Perhaps similar to https://github.com/Riverside-Healthcare/djLint/issues/252, so I'm linking it for cross-reference.

I was wondering if there's a way to enable auto fixing of certain problems like for example the two mentioned below?

It does work for some problems (like adding spaces inside a variable), but it'd be really nice if it could work with these too.

Example

Given this code:

{% block name %}
   {% include 'header.twig' %}
{% endblock %}

These problems are reported, based on my .djlintrc config:

  1. Endblock should have name. Ex: {% endblock body %}. {% endblock %} (T003)
  2. Double quotes should be used in tags. {% include 'header.t (T002)

And ideally the code above should be replaced with the following on save:

{% block name %}
   {% include "header.twig" %}
              ^           ^
{% endblock name %}
            ^^^^

Thank you :)

alessandro-newzoo avatar Dec 06 '22 12:12 alessandro-newzoo

This is what I would expect for an automatic formatter. black for example, fixed the quotes of a file automatically.

rennerocha avatar Apr 11 '24 12:04 rennerocha