thibaudcolas / curlylint

Experimental HTML templates linting for Jinja, Nunjucks, Django templates, Twig, Liquid
https://www.curlylint.org/
MIT License
236 stars 25 forks source link

add new rule django_block_translate_trimmed #137

Open lb- opened 2 years ago

lb- commented 2 years ago

I had trouble running black, not sure if it is a config issue but no matter what I would put into Python files, black would not do anything so I just copy/pasted from the Black playground and back into the editor.

Additional items

lb- commented 2 years ago

Updated with a few more tests, not sure if I need to test malformed (e.g. unclosed) block tags.

lb- commented 1 year ago

Loic - good call about the trimmed position - I'll try to resolve this soon. I'll update the description checklist to include this and the other item.

@loicteixeira @zerolab is there anything else blocking this PR?

zerolab commented 1 year ago

Nothing from me. Nice work @lb-!

lb- commented 1 year ago

Tests updated to include scenarios listed above, just need someone to trigger the workflow.

I was getting this error locally but it does not not seem to be related to the changes I have made.

self = <curlylint.cli_test.TestCLI testMethod=test_template_tags_cli_unconfigured_fails>

    def test_template_tags_cli_unconfigured_fails(self):
        runner = self.invoke_curlylint(
            1,
            ["--template-tags", "[]", "-"],
            input="<p>{% of a %}c{% elseof %}test{% endof %}</p>",
        )
>       self.assertIn(
            "Parse error: expected one of 'autoescape', 'block', 'blocktrans', 'comment', 'filter', 'for', 'if', 'ifchanged', 'ifequal', 'ifnotequal', 'not an intermediate Jinja tag name', 'spaceless', 'verbatim', 'with' at 0:17\tparse_error",
            runner.stdout_bytes.decode(),
        )
E       AssertionError: "Parse error: expected one of 'autoescape', 'block', 'blocktrans', 'comment', 'filter', 'for', 'if', 'ifchanged', 'ifequal', 'ifnotequal', 'not an intermediate Jinja tag name', 'spaceless', 'verbatim', 'with' at 0:17\tparse_error" not found in "\x1b[4m-\x1b[0m\n\x1b[2m0:17\x1b[0m\tParse error: expected one of 'autoescape', 'block', 'blocktrans', 'blocktranslate', 'comment', 'filter', 'for', 'if', 'ifchanged', 'ifequal', 'ifnotequal', 'not an intermediate Jinja tag name', 'spaceless', 'verbatim', 'with' at 0:17\tparse_error\n\n"

curlylint/cli_test.py:97: AssertionError
=============================================================== short test summary info ===============================================================
FAILED curlylint/cli_test.py::TestCLI::test_template_tags_cli_unconfigured_fails - AssertionError: "Parse error: expected one of 'autoescape', 'bloc...
======================================================= 1 failed, 91 passed, 1 skipped in 6.97s =======================================================
make: *** [Makefile:22: test] Error 1