Open lb- opened 2 years ago
Hi @lb- :) I’ve been working on such a blocktrans trimmed
rule, but with a JS version of curlylint, not the Python one currently available here.
Technically what you’re describing is already possible – Curlylint creates an AST from templates with nodes for DTL/Jinja syntax, as well as HTML. The node you’re looking for here is JinjaTag, specifically its content
property.
The main issue to implementing this is that Curlylint currently provides the raw AST to each and every linting rules – most linters implement the visitor design pattern, which makes implementations much simpler.
Hmmmm interesting - a JS version - I guess it's just html so doesn't really matter what is used.
Now I see why you were not a fan of the make lint rule server / client separation.
However, it does add another ecosystem for template linting that some projects may not be keen on adopting.
Nonetheless - I might try to understand what you mean by visitor pattern and see what is possible with this library instead
@lb- it’s definitely possible with this library, visitor pattern or otherwise. The visitor pattern is just one of the most common ways to structure code working on tree structures, ASTs in particular. Here’s an example Python implementation. The consequence of not having it is "just" that every linting rule currently needs to reimplement its own variant of AST parsing :)
The main reasons I’m keen on trying out a JS version of curlylint is that:
Is your proposal related to a problem?
Describe the solution you’d like
{% ... %}
Describe alternatives you’ve considered
Additional context