HarryGogonis / eslint-plugin-template

Parses out template declarations found in js and html files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eslint-plugin-template

Parses out template declarations found in js and html files.

For example if you have a file like below, eslint will not be able to parse it normally due to the template markers. With this plugin, the linter is able to work normally. Note that whatever is inside the markers is replaced with {}.

  {# Set data in the JS variable data #}
  {% import json %}
  var x = {{ json.dumps(data) }}

Installation

You'll first need to install ESLint:

$ npm install eslint --save-dev

Next, install eslint-plugin-template:

$ npm install eslint-plugin-template --save-dev

Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-template globally.

Usage

Add template to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:

{
    "plugins": [
        "template"
    ]
}

This automatically extracts JS from HTML files via eslint-plugin-html. So you do not need to include the "html" template.

Tests

$ npm test

Release

  • Update the version in package.json
  • Commit to the master branch and push
  • Run npm publish

About

Parses out template declarations found in js and html files.


Languages

Language:JavaScript 100.0%