mozilla/html5-lintをコマンドで実行

pythonもあるけど、gulp taskで。

参考

https://www.npmjs.com/package/gulp-html5-lint

流れ

前提

gulp taskを走らせられる環境にしておく

やること

npmで導入

npm install --save-dev gulp-html5-lint

gulpfile.jsを作成

サンプル

var gulp = require('gulp');
var html5Lint = require('gulp-html5-lint');

gulp.task('html5-lint', function() {
    return gulp.src('./*.html')
                  .pipe(html5Lint());
});

実行例

カレントディレクトリのhtmlファイルに対してlintをかけている。

$ gulp html5-lint

[13:33:06] Using gulpfile ~/xxx/work/gulpfile.js
[13:33:06] Starting 'html5-lint'...
[13:33:08] 'html5-lint' errored after 2.31 s
[13:33:08] Error in plugin 'gulp-html5-lint'
Message:

error: Almost standards mode doctype. Expected “<!DOCTYPE html>”.
    at /Users/xxx/work/xxx.html:2:40

フロントエンドエンジニアのための現在とこれからの必須知識

フロントエンドエンジニアのための現在とこれからの必須知識