asterisklint icon indicating copy to clipboard operation
asterisklint copied to clipboard

Add Jinja template support or comment for exclude line from checking?

Open utrumo opened this issue 5 years ago • 2 comments

Hello! Can you add support for ansible jinja2 template syntax (for example detect double brace as string)? I use ansible for change config files of asterisk and linter with this files works incorrect: jinja_syntax_error

There is link on other examples

Alternative idea: add support for line ignore comment, like it works in eslint: {{ some incorrect syntax line }} # asterisklint-disable-line // eslint-disable-line

utrumo avatar Mar 01 '20 13:03 utrumo

While I could see why you would want that. Supporting specifically jinja or any other preprocessor is not part of the scope of the project.

However, you could do one of two things:

  • Process the jinja and check the result (obviously).
  • Or, add a hook to preprocess the dialplan using jinja before running the code on it.

If you look at this example: https://github.com/ossobv/asterisklint/blob/master/contrib/commands/vg.py

You'll find a preprocessor that did some other alterations. If placed in the right ~/.local dir, it would be called as follows:

asterisklint vg dialplan-check [...]

Ideally you'll want to add line numbers translation there from the recently parsed jinja, but that might be tricky.

wdoekes avatar Mar 02 '20 10:03 wdoekes

ansible compile config only before put it to host. I don't now, how can i use this hook with it.

Can you simply add syntax for ignore problem line like it work in javascript eslint? <some problem string>; asterisklint-disable-line <error-type> or

; asterisklint-disable-next-line <error-type>
<some problem string>

my line example: dsn={{ INT_ODBC_DSN_ASTERISK }}; asterisklint-disable-line E_CONF_KEY_INVALID or

; asterisklint-disable-next-line E_CONF_KEY_INVALID
dsn={{ INT_ODBC_DSN_ASTERISK }}

utrumo avatar Mar 14 '20 08:03 utrumo