djlint / djLint

✨ HTML Template Linter and Formatter. Django - Jinja - Nunjucks - Handlebars - GoLang
https://djLint.com
GNU General Public License v3.0
688 stars 84 forks source link

[FEATURE] Custom rules #46

Closed jayvdb closed 3 years ago

jayvdb commented 3 years ago

Feature Request

( fyi, you have fixed all of the false positives I can find in my rather large project. )

IMO it would be helpful if I could configure djlint to load an additional rules.yaml. Specifically I would be quite interested in re-creating https://github.com/amandasaurus/django-template-i18n-lint using custom djlint rules if that were possible. The project looks to be unmaintained and unlikely to change given some comments on the PRs.

I am using c.f. https://github.com/appannie/eslint-plugin-gettext/pull/22 and https://github.com/gramener/eslint-plugin-template to ensure my .po has all annotated l10n strings, but I need a tool to detect un-annotated l10n strings.

I would be keen to submit the rules here once they are polished, but it will be easier to develop them solely for my own project first.

Also django projects often have their own do's and don'ts and djlint seems like a great framework to help projects bake them into CI.

christopherpickering commented 3 years ago

Nice, thats a good idea. It would probably be good to create another "profile" > django-i18n, with a new rule prefix, maybe di?, so that the rules are there, but not enabled for other template languages.

I'll add an option for a custom rules file shortly.

christopherpickering commented 3 years ago

I thought about using pyproject.toml to hold custom rules, but that would make that file into a really big mess if you had a lot of rules :) You can do a .djlint_rules.yaml along side your pyproject.toml file.

If you install from git you can test it out?

christopherpickering commented 3 years ago

35474de

christopherpickering commented 3 years ago

Since you are also familiar with the translate feature in django, would you mind joining the discussion on #26 ?

jayvdb commented 3 years ago

You can do a .djlint_rules.yaml along side your pyproject.toml file.

Nice!

If you install from git you can test it out? .. would you mind joining the discussion on #26 ?

It is getting late; I will do both tmr.

christopherpickering commented 2 years ago

:tada: This issue has been resolved in version 1.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: