alexkuz / eslint-plugin-jinja

This plugin treats Jinja template expressions as Javascript literals and ignores template statements and comments
MIT License
3 stars 11 forks source link

Upgraded plugin to work with modern (8.0+) ESLint #7

Open eladavron opened 2 years ago

eladavron commented 2 years ago

Since ESLint 8+ doesn't use CLIEngine anymore, and the alternative to it (ESLint) is async, I had to get creative with the quotes.

Instead of trying to determine which quotes the user will be using and converting the Jinja expression into a string, I just convert it to a regex expression - which is independent of quote type.

I make it all 0s to avoid invalid regex expressions, and pad it to the length of the original expression to avoid misaligning anything that comes after it.