jrabbe / htmllint-loader

htmllint loader for webpack

Home Page:https://www.npmjs.com/package/htmllint-loader

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

htmllint loader for webpack

Example

Example handlebars/php code:

Example error:

$ npm install htmllint-loader
or
$ yarn add htmllint-loader

Usage

Documentation: using loaders

Within your webpack configuration, you'll need to add the htmllint-loader to the list of modules:

module.exports = {
  // ...
  module: {
    preloaders: [
      {
          test: /\(htm|html|xhtml|hbs|handlebars|php)$/,
          loader: "htmllint-loader",
          include: '_src/markup/',
      }
    ]
  }
  // ...
}

Optional query parameters:

module.exports = {
  // ...
  module: {
    preloaders: [
      {
        test: /\(htm|html|xhtml|hbs|handlebars|php)$/,
        loader: "htmllint-loader",
        include: '_src/markup/',
        query: {
          config: '.htmllintrc',
          failOnError: true,
          failOnWarning: false,
        }
      }
    ]
  }
  // ...
}

.htmllintrc

.htmllintrc should live in your project root. This file should be a valid JSON file that contains options defined on the htmllint wiki.

Default htmllint-loader options:

{
  "attr-bans": [
      "align",
      "background",
      "bgcolor",
      "border",
      "dynsrc",
      "id",
      "frameborder",
      "longdesc",
      "lowsrc",
      "onclick",
      "ondblclick",
      "onload",
      "marginwidth",
      "marginheight",
      "scrolling",
      "style",
      "width"
  ],
  "attr-name-ignore-regex": false,
  "attr-name-style": "dash",
  "attr-no-dup": true,
  "attr-no-unsafe-chars": true,
  "attr-quote-style": "double",
  "attr-req-value": true,
  "class-no-dup": true,
  "class-style": "dash",
  "csslint": false,
  "doctype-first": false,
  "doctype-html5": false,
  "fig-req-figcaption": true,
  "focusable-tabindex-style": false,
  "head-req-title": true,
  "href-style": false,
  "html-req-lang": true,
  "id-class-ignore-regex": false,
  "id-class-no-ad": true,
  "id-class-style": "underscore",
  "id-no-dup": true,
  "input-radio-req-name": true,
  "img-req-alt": true,
  "img-req-src": true,
  "indent-style": "spaces",
  "indent-width": 2,
  "indent-width-cont": true,
  "input-req-label": false,
  "label-req-for": true,
  "lang-style": "case",
  "line-end-style": "lf",
  "line-max-len": 120,
  "line-max-len-ignore-regex": "/href/g",
  "page-title": true,
  "spec-char-escape": true,
  "table-req-caption": false,
  "table-req-header": true,
  "tag-bans": [
      "b",
      "i",
      "keygen",
      "style"
  ],
  "tag-close": true,
  "tag-name-lowercase": true,
  "tag-name-match": true,
  "tag-self-close": "never",
  "text-escape-spec-char": true,
  "title-max-len": 60,
  "title-no-dup": true
}

About

htmllint loader for webpack

https://www.npmjs.com/package/htmllint-loader

License:MIT License


Languages

Language:JavaScript 100.0%