0.7.0 • Published 10 years ago

gulp-template-lint v0.7.0

Weekly downloads
28
License
(Apache-2.0)
Repository
github
Last release
10 years ago

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

0.7.0

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.1

10 years ago

0.3.0

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago