updated regex on H024. Added test. closes #78

This commit is contained in:
Christopher Pickering 2021-10-07 09:44:14 +02:00
parent 242b67898e
commit 34fb305b6b
No known key found for this signature in database
GPG key ID: E14DB3B0A0FACF84
2 changed files with 13 additions and 3 deletions

View file

@ -298,7 +298,7 @@
message: Omit type on scripts and styles.
flags: re.I
patterns:
- <(?:script|style)[^>]*?type=["|'][^>]*?>
- <(?:script|style)[^>]*?type=[\"|'](?:(?:text/css)|(?:text/javascript))[^>]*?>
- rule:
name: H025
message: Tag seems to be an orphan.

View file

@ -7,7 +7,7 @@ run::
# for a single test
pytest tests/test_linter.py::test_H025 --cov=src/djlint --cov-branch \
pytest tests/test_linter.py::test_H024 --cov=src/djlint --cov-branch \
--cov-report xml:coverage.xml --cov-report term-missing
"""
@ -312,7 +312,17 @@ def test_H024(runner: CliRunner, tmp_file: TextIO) -> None:
write_to_file(tmp_file.name, b'<script type="hare">')
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 1
assert "H024 1:" in result.output
assert "H024" not in result.output
write_to_file(tmp_file.name, b'<script type="text/javascript">')
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 1
assert "H024" in result.output
write_to_file(tmp_file.name, b'<script type="text/css">')
result = runner.invoke(djlint, [tmp_file.name])
assert result.exit_code == 1
assert "H024" in result.output
def test_H025(runner: CliRunner, tmp_file: TextIO) -> None: