-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow indentation inside template tags #6
Comments
Hey @robertpro! Well that seems more like a bug to me, for the rule to not treat opening and closing template tags as needing indentation. The I suspect the problem would be around here: curlylint/curlylint/rules/indent/indent.py Lines 198 to 211 in 77f01d5
The first step in fixing this will be to write unit tests for this rule – currently there are no tests at all so I’d be weary of making any changes that break it further. |
Sounds good @thibaudcolas I will take a look this weekend. |
I've arrived at curlylint looking at a Jinja2 linter, and this hit me out of the box. Curlylint doesn't seem to like my indentation no matter what I use. I can't turn off the indentation checker either. |
@jace 👋 how have you configured the linter? Due to the experimental nature of it all linting rules are "opt-in", so you’d need to not "turn on" the indentation check. |
@thibaudcolas I missed your last comment. My pre-commit config (using an outdated curlylint version since the hook was disabled): repos:
- repo: https://github.com/thibaudcolas/curlylint
rev: v0.12.0
hooks:
- id: curlylint And in [tool.curlylint]
include = '\.jinja2$'
exclude = '''
/(
\.eggs
| \.git
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| __pycache__
| buck-out
| build
| dist
| node_modules
| funnel/assets
)/
'''
[tool.curlylint.rules]
# Indent 2 spaces
indent = 2
# All role attributes must be valid.
# See https://www.curlylint.org/docs/rules/aria_role.
aria_role = true
# The `alt` attribute must be present.
# See https://www.curlylint.org/docs/rules/image_alt.
image_alt = true |
Alright, in this case you should be able to turn off the indentation check by removing: indent = 2 |
Feeling like a necromancer, but my issue is related. Indentation seems really broken atm. Given the following template (included line numbers on purpose!) 1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 {% block html_head %}
5 {% block html_meta %}
6 <meta charset="utf-8" />
7 <meta name="viewport" content="width=device-width, initial-scale=1" />
8 {% block html_meta_desc required %}
9 {#
10 <meta name="description" content="foo" />
11 <meta name="keywords" content="bar" />
12 #}
13 {% endblock html_meta_desc %}
14 {% endblock html_meta %}
15 <title>{% block page_title %}fnord{% endblock page_title %}</title>
16 {% endblock html_head %}
17 </head>
18 <body>
19 {% block html_body %}
20 <div id="main">
21 <strong>base.html</strong>: block "html-body"
22 </div>
23 {% endblock html_body %}
24 </body>
25 </html> using this configuration [tool.curlylint.rules]
# FIXME: ``true`` means: all roles must be valid. However, providing a list of
# roles allows limitation to the actual roles in use.
aria_role = true
# FIXME: ``true`` means: the ``lang`` attribute must be present. However,
# providing a list of accepted values allows finer control.
html_has_lang = true
# Require all ``<img>`` tags to have the ``alt`` attribute (even empty).
image_alt = true
# use 2 spaces for indentation.
# NOTE: This must be synchronized with ``.editorconfig``.
indent = 2
# allow users to zoom
meta_viewport = true
# don't use the ``autofocus`` attribute on any element
no_autofocus = true
# TODO: Needs investigation!
# Don't use positive values for ``tabindex`` attributes
tabindex_no_positive = true and running through
I understand that this is experimental, and I will just turn that option off. But it may provide additional context for anybody who might give this a shot! Thank you for |
Ditto. Necromancer. This fails with
This works:
The difference is the second sample has one less level of Very strange error. |
Is your proposal related to a problem?
Yes
Describe the solution you’d like
I would like to indent inside template tags
Describe alternatives you’ve considered
setting
curlylint --rule 'indent: 4'
Additional context
Given this code:
I get these errors:
Which I can fix like this:
Result:
Can we add this feature?
The text was updated successfully, but these errors were encountered: