-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(linter): allow codes to be ignored for remainder of file
closes #655
- Loading branch information
1 parent
5f33d08
commit 4637a0f
Showing
9 changed files
with
64 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"""Test linter code H005. | ||
poetry run pytest tests/test_linter/test_ignore_rules.py | ||
""" | ||
import pytest | ||
|
||
from src.djlint.lint import linter | ||
from tests.conftest import lint_printer | ||
|
||
test_data = [ | ||
pytest.param( | ||
("<img>{# djlint:off H004,H006,H013 #}\n" "<img>\n"), | ||
( | ||
[ | ||
{ | ||
"code": "H006", | ||
"line": "1:0", | ||
"match": "<img>", | ||
"message": "Img tag should have height and width attributes.", | ||
}, | ||
{ | ||
"code": "H013", | ||
"line": "1:0", | ||
"match": "<img>", | ||
"message": "Img tag should have an alt attribute.", | ||
}, | ||
] | ||
), | ||
id="one", | ||
), | ||
] | ||
|
||
|
||
@pytest.mark.parametrize(("source", "expected"), test_data) | ||
def test_base(source, expected, basic_config): | ||
filename = "test.html" | ||
output = linter(basic_config, source, filename, filename) | ||
|
||
lint_printer(source, expected, output[filename]) | ||
|
||
mismatch = list(filter(lambda x: x not in expected, output[filename])) + list( | ||
filter(lambda x: x not in output[filename], expected) | ||
) | ||
|
||
assert len(mismatch) == 0 |