node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

twiglint

TwigLint [WIP][ALPHA]

Twig templates linter

Install

 
    npm install twiglint -g
 

Usage

    Usage
      $ twiglint <filename>
 
    Options
      -s, --silent Show only errors
      -f, --format Use a specific output format - default: stylish [compact]
      -d, --debug Write debug file, and prepend every check with filename
      -h, --help  This help

Rules to be included

For now rules are hardwired, there will be configurable config, and external plugins in the future

  • Warn if there is no only in include function (no-only)
  • Variables declared, but not used (no-unused-vars)
  • Variables used without declaration, or docblock (no-undeclared)
  • Do not use closing bracket on selfclosing tags (\/> => >) (no-closed-self-closing-tags)
  • Prefer camelcase variable naming (prefer-camel-case-vars)
  • Do not use spaceless tag (no-spaceless)
  • Wrong tab padding on logic brackets (tags-padding)
  • use staticUrl functions for resources
  • Spelling

Roadmap

  • Write tests for plugins
  • Maximum usage of the parser
  • Visual reporter with the ability to jump to the needed line (compact)
  • Plugins as seperate modules
  • cli testing
  • Write pluggable logic for external plugin
  • Allow to use local config
  • Sublime/VSCode/PhpStorm extentions

Docblock formatting

{# @param {string} imageLink #}
{# @param {string} view_change_uri  #}
{# @param {int} user_location_id #}

or

{# 
    @param {string} imageLink
    @param {string} view_change_uri 
    @param {int} user_location_id 
#}

License

MIT