Skip to content

Commit

Permalink
HTMLLintBear: Add use_spaces option
Browse files Browse the repository at this point in the history
Disable tabs rule when use_spaces = False

Closes coala#1741
  • Loading branch information
aashraybhandar1 authored and gitmate-bot committed Dec 14, 2017
1 parent c86a6d0 commit 28e4b8f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
13 changes: 10 additions & 3 deletions bears/hypertext/HTMLLintBear.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ class HTMLLintBear:
CAN_DETECT = {'Syntax', 'Formatting'}

@staticmethod
def create_arguments(filename, file, config_file,
htmllint_ignore: typed_list(str)=()):
def create_arguments(filename, file, config_file, use_spaces: bool,
htmllint_ignore: typed_list(str)=[]):
"""
:param htmllint_ignore: List of checkers to ignore.
:param use_spaces: True if spaces are to be used instead of tabs.
"""
ignore = ','.join(part.strip() for part in htmllint_ignore)
additional_ignore = []
if not use_spaces:
additional_ignore.append('tabs')

ignore = ','.join(part.strip()
for part in htmllint_ignore + additional_ignore)

return HTMLLintBear._html_lint, '--disable=' + ignore, filename
20 changes: 18 additions & 2 deletions tests/hypertext/HTMLLintBearTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,37 @@
</html>
"""

test_ignore_tabs = """
<html>
<body>
<h1>Hello, world!</h1>
</body>
</html>
"""

HTMLLintBearTest = verify_local_bear(HTMLLintBear,
valid_files=(),
invalid_files=(test_file,),
settings={'use_spaces': 'False'},
tempfile_kwargs={'suffix': '.html'})

HTMLLintBearIgnoreTest = verify_local_bear(
HTMLLintBear,
valid_files=(test_file,),
invalid_files=(),
settings={'htmllint_ignore': 'optional_tag'},
settings={'use_spaces': 'False', 'htmllint_ignore': 'optional_tag'},
tempfile_kwargs={'suffix': '.html'})

HTMLLintBearIgnoreQuotationTest = verify_local_bear(
HTMLLintBear,
valid_files=(),
invalid_files=(test_file,),
settings={'htmllint_ignore': 'quotation'},
settings={'use_spaces': 'False', 'htmllint_ignore': 'quotation'},
tempfile_kwargs={'suffix': '.html'})

HTMLLintBearIgnoreTabs = verify_local_bear(
HTMLLintBear,
valid_files=(test_file,),
invalid_files=(test_ignore_tabs,),
settings={'use_spaces': 'True', 'htmllint_ignore': 'optional_tag'},
tempfile_kwargs={'suffix': '.html'})

0 comments on commit 28e4b8f

Please sign in to comment.