Nascent Plasticine Materialist

    @jupyterlab/eslint-plugin-jinja

    0.2.0 • Public • Published

    npm version

    eslint-plugin-jinja

    This plugin treats Jinja template expressions and statements as valid Javascript expressions, so that ESLint can check javascript code, ignoring any Jinja expression found.

    As a note, it is possible that this best effort conversion yeilds false negatives or positives because it is impossible to know the right way to insert placeholders.

    Example

    Plugin will convert (internally) this code:

      (function() {
        'use strict';
    
        {# plain jinja variables are converted into strings
          (preferred quotes are getting from .eslintrc file) #}
    
        var a = 'this is' + {{ some_variable }};
    
        {# if it is already in string, it is wrapped with spaces #}
    
        var b = 'this is {{ other_variable }}';
        var c = 'and this is {{ another_one['field']}}';
    
        {# if-else statements are converted into ( ..., ... ) expression #}
    
        var d = {% if something %} 'this is something' {% else %} null {% endif %};
    
        {# any other statements become comments #}
        
        {% for i in [1, 2, 3] %}
          console.log(a, b, c, d);
        {% endfor %}
      })();

    into this:

     (function() {
        'use strict';
    
        /* plain jinja variables are converted into strings
          (preferred quotes are getting from .eslintrc file) */
    
        var a = 'this is' + '  some_variable  ';
    
        /* if it is already in string, it is wrapped with spaces */
    
        var b = 'this is    other_variable   ';
        var c = 'and this is    another_one[ field ]  ';
    
        /* if-else statements are converted into ( ..., ... ) expression */
    
        var d = (/*if something */ 'this is something' ,/*else */ null /*endif */);
    
        /* any other statements become comments */
    
        /* for i in [1, 2, 3] */
          console.log(a, b, c, d);
        /* endfor */
      })();

    Install

    npm i @jupyterlab/eslint-plugin-jinja

    DownloadsWeekly Downloads

    4

    Version

    0.2.0

    License

    MIT

    Last publish

    Collaborators

    • jupyter-server-release-bot
    • diracs-delta
    • jupyterlab-release-bot
    • 3coins
    • jweill-aws
    • krassowski
    • darian
    • declanvk
    • markellekelly
    • zuoyuanh
    • ellisonbg
    • blink1073
    • jasongrout
    • sylvaincorlay
    • ian-r-rose
    • gnestor
    • parente
    • mpacer
    • jaipreets
    • minrk
    • saulshanabrook
    • hoo761
    • zsailer
    • telamonian
    • fcollonval
    • lresende
    • consideratio
    • ajbozarth
    • marthacryan
    • jtpio
    • echarles
    • goanpeca
    • mbektas
    • loichuder