Git Product home page Git Product logo

gulp-htmlhint-inline's Introduction

gulp-htmlhint-inline

NPM

Usage

First, install gulp-htmlhint-inline as a development dependency:

npm install --save-dev gulp-htmlhint-inline

Then, add it to your gulpfile.js:

var gulp = require('gulp'),
    htmlhint_inline = require('gulp-htmlhint-inline');

gulp.task('htmlhint', function () {
  var options = {
        htmlhintrc: './.htmlhintrc',
        ignores: {
          '<?php': '?>'
        },
        patterns: [
          {
            match: /hoge/g,
            replacement: 'fuga'
          }
        ]
    };

  gulp.src('test/*.phtml')
      .pipe(htmlhint_inline(options))
      .pipe(htmlhint_inline.reporter())
      .pipe(htmlhint_inline.reporter('fail'));
});

Options

htmlhintrc

Type: String Default value: null

htmlhintrc file must be a valid JSON. If you specify this file, options that have been defined in it will be used in the global. If there is specified in the task options, the options in this file will be overwritten.

{
  "tagname-lowercase": true
}

ignores

Type: Object Default: {}

Remove program tag pairs.

patterns

Type: Array Default: []

Enable the replacement by the pattern

patterns.match

Type: RegExp|String

Indicates the matching expression.

patterns.replacement

Type: String | Function

reporter

Default Reporter
var gulp = require('gulp'),
    htmlhint_inline = require('gulp-htmlhint-inline');

gulp.task('htmlhint', function () {
  var options = {
        htmlhintrc: './.htmlhintrc',
        ignores: {
          '<?php': '?>'
        }
    };

  gulp.src('test/*.phtml')
      .pipe(htmlhint_inline(options))
      .pipe(htmlhint_inline.reporter());
});
Fail Reporter

In order to end the task when your task happened error of HTMLHint, please use this reporter.

var gulp = require('gulp'),
    htmlhint_inline = require('gulp-htmlhint-inline');

gulp.task('htmlhint', function () {
  var options = {
        htmlhintrc: './.htmlhintrc',
        ignores: {
          '<?php': '?>'
        }
    };

  gulp.src('test/*.phtml')
      .pipe(htmlhint_inline(options))
      .pipe(htmlhint_inline.reporter('fail'));
});
Custom Reporter

You can also use the custom reporter that you have created.

var gulp = require('gulp'),
    htmlhint_inline = require('gulp-htmlhint-inline');

gulp.task('htmlhint', function () {
  var options = {
        htmlhintrc: './.htmlhintrc',
        ignores: {
          '<?php': '?>'
        }
    };

    var cutomReporter = function (file) {
        if (!file.htmlhint_inline.success) {
            console.log('custom reporter: htmlhint-inline fail in '+ file.path);
        }
    }

    return gulp.src('test/*.phtml')
                .pipe(htmlhint_inline(options))
                .pipe(htmlhint_inline.reporter())
                .pipe(htmlhint_inline.reporter(cutomReporter));
});

License

MIT License

gulp-htmlhint-inline's People

Contributors

coliff avatar dependabot[bot] avatar fstrube avatar greenkeeperio-bot avatar kazu69 avatar nschonni 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.