Giter Club home page Giter Club logo

grunt-htmlhint-plus's Introduction

Grunt-htmlhint-plus

Build Status Code GPA Code style Dependency Status Dev Dependency Status NPM version NPM downloads NPM license

Grunt task to hint html code.

Getting Started

This plugin requires Grunt >=0.4.0

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-htmlhint-plus --save-dev

Or you may like yarn:

yarn add grunt-htmlhint-plus -D

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-htmlhint-plus');

Htmlhintplus Task

Run this task with the grunt htmlhintplus command.

Task targets, files and options may be specified according to the grunt Configuring tasks guide.

Options

src {String|Array}

Source path. Support file path, glob and globs.

options.rules {Object}

Htmlhint rules. Default is:

  • "tagname-lowercase": true,
  • "attr-lowercase": true,
  • "attr-value-double-quotes": true,
  • "attr-value-not-empty": true,
  • "attr-no-duplication": true,
  • "doctype-first": true,
  • "tag-pair": true,
  • "tag-self-close": false,
  • "spec-char-escape": true,
  • "id-unique": true,
  • "src-not-empty": true,
  • "head-script-disabled": false,
  • "img-alt-require": true,
  • "doctype-html5": true,
  • "id-class-value": "dash",
  • "style-disabled": false,
  • "space-tab-mixed-disabled": true,
  • "id-class-ad-disabled": true,
  • "href-abs-or-rel": true,
  • "attr-unsafe-chars": true

For the whole rules list, please see Rules page.

options.htmlhintrc {String}

Htmlhintrc file path. Has higher priority than rules option.

options.force {Boolean}

Throw fatal fail or not at the end of this task, when there is hint error. Default false.

options.newer {Boolean}

Only hint changed file and new file. Default true.

options.ignore {Object}

Ignore strings between key and value from this object. Default {}.

options.customRules {Array}

An array of paths to custom rule files to load and use in your HTMLHinting. See issue #47 on the HTMLHint project. For examples of how to write a custom rule.

options.extendRules {Boolean}

Extend the default rules instead of only running the rules specified. Default false.

options.output {String|Array}

A string or array of output file types for reporting. Multiple types can also be selected separating them with a pipe character (ex: console|checkstyle|json). Available output types include console, default (alias for console), text, json, and checkstyle. Default console.

Usage Examples

Basic

// Project configuration
htmlhintplus: {
	build: {
		options: {
			rules: {
				'tag-pair': true,
				'custom-rule': true
			},
			customRules: [
				'rules/custom-rule.js'
			],
			extendRules: true,
			output: [ 'console', 'text', 'json', 'checkstyle' ]
		}
		src: 'path/to/file'
	}
}

Use htmlhintrc file

// Project configuration
htmlhintplus: {
	html: {
		options: {
			htmlhintrc: 'path/to/file'
		}
		src: [
			'path/to/file',
			'path/to/file2'
		]
	}
}

Use global options

// Project configuration
htmlhintplus: {
	options: {
		htmlhintrc: 'path/to/file',
		newer: true
	},
	build: {
		options: {
			force: false
		},
		src: [
			'path/1/*.html',
			'path/2/**/*.html'
		]
	}
}

Demo

Run the test demo:

grunt test

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.