ossobv / asterisklint

Asterisk PBX configuration syntax checker
GNU General Public License v3.0
61 stars 12 forks source link

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

Open utrumo opened 4 years ago

utrumo commented 4 years ago

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

wdoekes commented 4 years ago

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:

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.

utrumo commented 4 years ago

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 }}