From ecb95bbee075c880942799a7c32246c6e8c0015f Mon Sep 17 00:00:00 2001
From: Christopher Pickering
Date: Fri, 16 Sep 2022 09:54:17 +0200
Subject: [PATCH 1/7] feat(linter t034): added linter T034 to check for {% ...
}% typo
closes #385
---
docs/src/docs/linter.md | 1 +
docs/src/fr/docs/linter.md | 1 +
docs/src/ru/docs/linter.md | 1 +
requirements.txt | 6 +++---
src/djlint/rules.yaml | 6 ++++++
tests/test_linter/test_linter.py | 12 +++++++++++-
6 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/docs/src/docs/linter.md b/docs/src/docs/linter.md
index 2fe447e..f2666bb 100644
--- a/docs/src/docs/linter.md
+++ b/docs/src/docs/linter.md
@@ -76,6 +76,7 @@ A good rule follows this pattern:
| H031 | Consider adding meta keywords. |
| T032 | Extra whitespace found in template tags. |
| H033 | Extra whitespace found in form action. |
+| T034 | Did you intend to use {% ... %} instead of {% ... }%? |
### Adding Rules
diff --git a/docs/src/fr/docs/linter.md b/docs/src/fr/docs/linter.md
index 8a9f19f..750fb83 100644
--- a/docs/src/fr/docs/linter.md
+++ b/docs/src/fr/docs/linter.md
@@ -76,6 +76,7 @@ Une bonne règle suit ce modèle :
| H031 | Pensez à ajouter des méta keywords. |
| T032 | Espace blanc supplémentaire trouvé dans les balises du modèle. |
| H033 | Espace supplémentaire dans l'action du formulaire. |
+| T034 | Aviez-vous l'intention d'utiliser {% ... %} au lieu de {% ... }% ? |
### Ajout de règles
diff --git a/docs/src/ru/docs/linter.md b/docs/src/ru/docs/linter.md
index 175c9fc..c90a841 100644
--- a/docs/src/ru/docs/linter.md
+++ b/docs/src/ru/docs/linter.md
@@ -76,6 +76,7 @@ djlint /path/to/this.html.j2 --profile=jinja
| H031 | Рассмотрите возможность добавления мета-ключевых слов. |
| T032 | В тегах шаблона обнаружены лишние пробелы. |
| H033 | В действии формы обнаружен лишний пробел. |
+| T034 | Вы намеревались использовать {% ... %} вместо {% ... }%? |
### Добавление правил
diff --git a/requirements.txt b/requirements.txt
index 7fcc4dd..8af618a 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -18,7 +18,7 @@ iniconfig==1.1.1; python_version >= "3.7"
isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0"
jsbeautifier==1.14.6
lazy-object-proxy==1.7.1; python_version >= "3.6" and python_full_version >= "3.7.2"
-mccabe==0.7.0; python_full_version >= "3.7.2" and python_version >= "3.7"
+mccabe==0.6.1; python_full_version >= "3.7.2" and python_version >= "3.7"
mypy-extensions==0.4.3; python_full_version >= "3.6.2" and python_version >= "3.6"
mypy==0.971; python_version >= "3.6"
packaging==21.3; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
@@ -27,8 +27,8 @@ pep8-naming==0.13.2; python_version >= "3.7"
platformdirs==2.5.2; python_version >= "3.7" and python_full_version >= "3.7.2" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7")
pluggy==1.0.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
py==1.11.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pycodestyle==2.9.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pyflakes==2.5.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
+pycodestyle==2.7.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
+pyflakes==2.3.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
pylint==2.15.2; python_full_version >= "3.7.2"
pyparsing==3.0.9; python_full_version >= "3.6.8" and python_version >= "3.7"
pytest-cov==3.0.0; python_version >= "3.6"
diff --git a/src/djlint/rules.yaml b/src/djlint/rules.yaml
index 884d8d7..3b1fffd 100644
--- a/src/djlint/rules.yaml
+++ b/src/djlint/rules.yaml
@@ -251,3 +251,9 @@
patterns:
-
+"""
+ )
+
+ write_to_file(
+ tmp_file.name,
+ b"""
+""",
+ )
+ runner.invoke(djlint, [tmp_file.name, "--reformat"])
+
+ assert (
+ Path(tmp_file.name).read_text(encoding="utf8")
+ == """
"""
)
From e5cbe6af1e9dee4eeba095df40a556963e54bb1a Mon Sep 17 00:00:00 2001
From: Christopher Pickering
Date: Fri, 16 Sep 2022 11:01:50 +0200
Subject: [PATCH 5/7] test(tox): removed useless line
---
tox.ini | 6 ------
1 file changed, 6 deletions(-)
diff --git a/tox.ini b/tox.ini
index 910e867..e16acc4 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,11 +1,9 @@
[tox]
-envlist = py3{7,8,9,10}-test
skip_missing_interpreters = True
isolated_build = True
setenv =
PYTHONDONTWRITEBYTECODE=1
-
[testenv:isort]
commands =
isort src/djlint
@@ -48,16 +46,12 @@ allowlist_externals =
mypy
pylint
-
-
[testenv]
commands =
pytest --cov=src/djlint --cov-branch --cov-report xml:coverage.xml --cov-report term-missing {posargs:} -n auto --dist loadgroup
skip_install: false
allowlist_externals = pytest
-
-
[testenv:test-fast]
commands =
pytest -n 4
From 6225dcd3c7d0abc96533e96d1ffcca4da2597110 Mon Sep 17 00:00:00 2001
From: Christopher Pickering
Date: Fri, 16 Sep 2022 11:03:57 +0200
Subject: [PATCH 6/7] ci(removed requirements.txt.): file was unused
---
.pre-commit-config.yaml | 6 -----
requirements.txt | 50 -----------------------------------------
2 files changed, 56 deletions(-)
delete mode 100644 requirements.txt
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index e19ae09..16a879c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -43,9 +43,3 @@ repos:
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix, --indent, '2']
-repos:
- - repo: https://github.com/christopherpickering/pre-commit-hooks
- rev: 0.0.6
- hooks:
- - id: poetry-to-requirements
- args: [--output=requirements.txt]
\ No newline at end of file
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index 8af618a..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-astroid==2.12.9; python_full_version >= "3.7.2"
-attrs==22.1.0; python_version >= "3.7"
-black==22.8.0; python_full_version >= "3.6.2"
-click==8.1.3; python_version >= "3.7"
-colorama==0.4.5; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
-coverage==6.4.4; python_version >= "3.7"
-cssbeautifier==1.14.6
-dill==0.3.5.1; python_full_version >= "3.7.2"
-distlib==0.3.6; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
-editorconfig==0.12.3
-execnet==1.9.0; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
-filelock==3.8.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-flake8==3.9.2; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-html-tag-names==0.1.2; python_version >= "3.7" and python_version < "4.0"
-html-void-elements==0.1.0; python_version >= "3.7" and python_version < "4.0"
-importlib-metadata==4.12.0; python_version >= "3.7"
-iniconfig==1.1.1; python_version >= "3.7"
-isort==5.10.1; python_full_version >= "3.6.1" and python_version < "4.0"
-jsbeautifier==1.14.6
-lazy-object-proxy==1.7.1; python_version >= "3.6" and python_full_version >= "3.7.2"
-mccabe==0.6.1; python_full_version >= "3.7.2" and python_version >= "3.7"
-mypy-extensions==0.4.3; python_full_version >= "3.6.2" and python_version >= "3.6"
-mypy==0.971; python_version >= "3.6"
-packaging==21.3; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pathspec==0.10.1; python_version >= "3.7"
-pep8-naming==0.13.2; python_version >= "3.7"
-platformdirs==2.5.2; python_version >= "3.7" and python_full_version >= "3.7.2" and (python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7")
-pluggy==1.0.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-py==1.11.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pycodestyle==2.7.0; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pyflakes==2.3.1; python_version >= "3.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.7"
-pylint==2.15.2; python_full_version >= "3.7.2"
-pyparsing==3.0.9; python_full_version >= "3.6.8" and python_version >= "3.7"
-pytest-cov==3.0.0; python_version >= "3.6"
-pytest-forked==1.4.0; python_version >= "3.6"
-pytest-xdist==2.5.0; python_version >= "3.6"
-pytest==7.1.3; python_version >= "3.7"
-pyyaml==6.0; python_version >= "3.6"
-regex==2022.9.11; python_version >= "3.6"
-six==1.16.0; python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0"
-tomli==2.0.1; python_full_version <= "3.11.0a6" and python_full_version >= "3.7.2" and python_version >= "3.7" and python_version < "3.11" and (python_version >= "2.7" and python_full_version < "3.0.0" or python_full_version >= "3.5.0") or python_version < "3.11"
-tomlkit==0.11.4; python_version >= "3.6" and python_version < "4.0" and python_full_version >= "3.7.2"
-tox==3.26.0; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.5.0")
-tqdm==4.64.1; (python_version >= "2.7" and python_full_version < "3.0.0") or (python_full_version >= "3.4.0")
-typed-ast==1.5.4; python_version < "3.8" and implementation_name == "cpython" and python_full_version >= "3.7.2" and python_version >= "3.6"
-types-pyyaml==6.0.11
-typing-extensions==4.3.0; python_version < "3.8" and python_version >= "3.7" and python_full_version >= "3.7.2" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.5.0" and python_version < "3.8" and python_version >= "3.7")
-virtualenv==20.16.5; python_version >= "3.6" and python_full_version < "3.0.0" or python_full_version >= "3.5.0" and python_version >= "3.6"
-wrapt==1.14.1
-zipp==3.8.1; python_version < "3.8" and python_version >= "3.7" and (python_version >= "3.7" and python_full_version < "3.0.0" and python_version < "3.8" or python_full_version >= "3.5.0" and python_version < "3.8" and python_version >= "3.7")
From 838b8e66be2406cbed855bb6bc9f8a7d6c2cb7c1 Mon Sep 17 00:00:00 2001
From: Christopher Pickering
Date: Fri, 16 Sep 2022 11:09:49 +0200
Subject: [PATCH 7/7] fixed tests
---
docs/src/docs/linter.md | 2 +-
docs/src/fr/docs/linter.md | 2 +-
docs/src/ru/docs/linter.md | 2 +-
tox.ini | 1 +
4 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/docs/src/docs/linter.md b/docs/src/docs/linter.md
index f2666bb..b607f76 100644
--- a/docs/src/docs/linter.md
+++ b/docs/src/docs/linter.md
@@ -76,7 +76,7 @@ A good rule follows this pattern:
| H031 | Consider adding meta keywords. |
| T032 | Extra whitespace found in template tags. |
| H033 | Extra whitespace found in form action. |
-| T034 | Did you intend to use {% ... %} instead of {% ... }%? |
+| T034 | Did you intend to use {% raw %}{% ... %} instead of {% ... }%? {% endraw %} |
### Adding Rules
diff --git a/docs/src/fr/docs/linter.md b/docs/src/fr/docs/linter.md
index 750fb83..ef46b46 100644
--- a/docs/src/fr/docs/linter.md
+++ b/docs/src/fr/docs/linter.md
@@ -76,7 +76,7 @@ Une bonne règle suit ce modèle :
| H031 | Pensez à ajouter des méta keywords. |
| T032 | Espace blanc supplémentaire trouvé dans les balises du modèle. |
| H033 | Espace supplémentaire dans l'action du formulaire. |
-| T034 | Aviez-vous l'intention d'utiliser {% ... %} au lieu de {% ... }% ? |
+| T034 | Aviez-vous l'intention d'utiliser {% raw %}{% ... %} au lieu de {% ... }% ? {% endraw %} |
### Ajout de règles
diff --git a/docs/src/ru/docs/linter.md b/docs/src/ru/docs/linter.md
index c90a841..7fc4985 100644
--- a/docs/src/ru/docs/linter.md
+++ b/docs/src/ru/docs/linter.md
@@ -76,7 +76,7 @@ djlint /path/to/this.html.j2 --profile=jinja
| H031 | Рассмотрите возможность добавления мета-ключевых слов. |
| T032 | В тегах шаблона обнаружены лишние пробелы. |
| H033 | В действии формы обнаружен лишний пробел. |
-| T034 | Вы намеревались использовать {% ... %} вместо {% ... }%? |
+| T034 | Вы намеревались использовать {% raw %}{% ... %} вместо {% ... }%? {% endraw %} |
### Добавление правил
diff --git a/tox.ini b/tox.ini
index e16acc4..624d5a8 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,4 +1,5 @@
[tox]
+envlist = test
skip_missing_interpreters = True
isolated_build = True
setenv =