Coder Social home page Coder Social logo

gulp-template-lint's Introduction

gulp-template-lint

logo

Wrap of template-lint as a simple gulp plugin in order to sanity check html

NPM version NPM downloads Travis Status

install

npm install gulp-template-lint

usage

var gulp = require('gulp');
var linter = require('gulp-template-lint');

gulp.task('lint-template-html', function () {
    return gulp.src('**/*.html')
        .pipe(linter())
        .pipe(gulp.dest('output'));
});
 

configure rules

you can override the default set of rules by supplying an array of rules.

var gulp = require('gulp');
var linter = require('gulp-template-lint');

var SelfClose = require('template-lint').SelfCloseRule;

var rules = [new SelfClose()];

gulp.task('build-html', function () {
    return gulp.src('**/*.html')
        .pipe(linter(rules))
        .pipe(gulp.dest('output'));
});

adding obsolete tags and attributes

the obsolete rules aren't part of the default rule-set; you can add them in and define obsolete tags and attributes

var gulp = require('gulp');
var linter = require('gulp-template-lint');

var SelfClose = require('template-lint').SelfCloseRule;
var ParserRule = require('template-lint').ParserRule;
var ObsoleteTagRule = require('template-lint').ObsoleteTagRule;
var ObsoleteAttributeRule = require('template-lint').ObsoleteAttributeRule;

var obsoleteTags = [
    {tag:'my-old-tag', msg:'its really old....'}
];
var obsoleteAttributes = [
    {attr:'myattribute'}, 
    {attr:'moo', tag:'my-old-tag'}, //obsolete only when on for my-old-tag 
    {attr:'fubar', msg:'uh uh... '}
];

var rules = [
    new SelfClose(),
    new ParserRule(),
    new ObsoleteTagRule(obsoleteTags), 
    new ObsoleteAttributeRule(obsoleteAttributes)
];

gulp.task('build-html', function () {
    return gulp.src('**/*.html')
        .pipe(linter(rules))
        .pipe(gulp.dest('output'));
});

##Icon

Icon courtesy of The Noun Project

gulp-template-lint's People

Contributors

meirionhughes avatar

Watchers

Daniel Rothmaler avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.