2.0.1 • Published 4 years ago

gulp-html-conformance v2.0.1

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

License: MIT npm.io npm.io npm.io npm.io

Gulp-html-conformance

Gulp plugin for checking out whether html files conform to the HTML spec (with the help of v.Nu checker) or your formatting preferences (with the help of HTMLHint). npm.io

Prerequisites

  1. Node engine >= 8.2.0
  2. Gulp task runner
  3. The Nu Html Checker requires an environment with Java 8 or above. How to install on Windows, Mac OS & Ubuntu

Installing

npm i -D gulp-html-conformance

Usage

This plugin supports a lot of options for Nu Checker and HTMLHint, but you can also use it without any options, in which case the default options will be used. See options for v.Nu See options for HTMLHint Default rulesset for HTMLHint :no_entry_sign: Please, do not mix the compilation process with the linting. Any lint tool in such a case needs a final compilation result. The gulp pipes look like they are performed synchronously, but this is not so! Do not do this.. Do this instead..:thumbsup:

Examples

1.Without options:
const gulp = require('gulp');
const conform = require('gulp-html-conformance');

gulp.task('lintHtml', () =>
  gulp
    .src('./src/*.html')
    .pipe(conform())
    .pipe(gulp.dest('./dest'))
);
2. With options:
// Example for options object.
// This object can contain three top-level keys and any of them can be omitted.
{
  logToFile: './pathtologfile',
  vnu:{
   // ... v.Nu options here
  },
  htmlhint:{
    // ... HTMLHint options here
  }
}

Some comments on "vnu" options:

  • The "version" and "verbose" options will always fall back to false. These options are of little use, but cause some problems, so they are disabled. The "verbose" option just prints path to file being checked, anyway this plugin does it by itself.
  • There is no need to set the "format" option for v.Nu, this option will always be "json". Other formats for v.Nu are not supported, as they are useless for console output but require parsing, formatting, and so on. If for some reason you need those formats, define the "logToFile" option with the path to log file, then you can parse that file to any format you need.
  • The "user-agent" option will always be "Validator.nu/LV". Checking HTTPS/HTTP URLs is not supported.
  • To avoid confusion with regular expressions, always use the recommended pattern for "filterpattern" option, like this: '.*someword.*'. If you want to filter multiple messages, just define "filterfile" option and then filter out as many messages as you want.
const gulp = require('gulp');
const conform = require('gulp-html-conformance');

gulp.task('lintHtml', () =>
  gulp
    .src('./src/*.html')
    .pipe(
      conform({
        logToFile: './logs/lintHtml.log',
        vnu: {
          filterpattern: '.*name.*'
        },
        htmlhint: {
          'space-tab-mixed-disabled': 'space'
        }
      })
    )
    .pipe(gulp.dest('./dest'))
);

See also

gulp-html :arrow_backward: source of inspiration gulp-htmlhint