Skip to content
Snippets Groups Projects
Select Git revision
  • renovate/glob-11.x
  • renovate/vite-5.x
  • renovate/minimatch-10.x
  • renovate/microsoft-api-extractor-7.x
  • renovate/html-validate-eslint
  • master default protected
  • feature/windows-pipeline
  • refactor/posix
  • refactor/error-code
  • feature/cli-worker
  • build-refactor
  • next protected
  • feature/implicit-closed-head-body
  • dependabot/npm_and_yarn/cross-spawn-7.0.5
  • docs/screenshots
  • feature/size-analyze
  • feature/directive-state
  • feature/wrap-root
  • feature/shared-ci
  • feature/metadata-callbacks
  • v9.2.1
  • v9.2.0
  • v9.1.3
  • v9.1.2
  • v9.1.1
  • v9.1.0
  • v9.0.1
  • v9.0.0
  • v8.29.0
  • v9.0.0-rc.8
  • v9.0.0-rc.7
  • v8.28.0
  • v9.0.0-rc.6
  • v9.0.0-rc.5
  • v9.0.0-rc.4
  • v9.0.0-rc.3
  • v9.0.0-rc.2
  • v8.27.0
  • v8.26.0
  • v8.25.1
40 results

html-validate

  • Clone with SSH
  • Clone with HTTPS
  • html-validate

    pipeline status coverage report

    Offline HTML5 validator. Validates either a full document or a smaller (incomplete) template, e.g. from an AngularJS or Vue.js component.

    Features

    • Can test fragments of HTML, for instance a component template.
    • Does not upload any data to a remote server, all testing is done locally.
    • Strict and non-forgiving parsing. It will not try to correct any incorrect markup or guess what it should do.

    Bundles

    The library comes in four flavours:

    • CommonJS full (dist/cjs/main.js)
    • CommonJS browser (dist/cjs/browser.js)
    • ESM full (dist/es/main.js)
    • ESM browser (dist/es/browser.js)

    The browser versions contains a slimmed version without CLI dependencies. Your tooling will probably use the correct version but if needed you can import the files directly.

    Do note that to run in a browser you still need to polyfill the fs nodejs library.

    Browsers and bundlers are currently not 100% supported but is possible with some tricks, see running in browser for more details.

    Usage

    npm install -g html-validate
    html-validate FILENAME..

    Configuration

    Create .htmlvalidate.json:

    {
      "extends": [
        "html-validate:recommended"
      ],
    
      "rules": {
        "close-order": "error",
        "void": ["warn", {"style": "omit"}]
      }
    }

    Example

    <p>
      <button>Click me!</button>
      <div id="show-me">
        Lorem ipsum
      </div>
    </p>
      1:1  error  Element <p> is implicitly closed by adjacent <div>  no-implicit-close
      2:2  error  Button is missing type attribute                    button-type
      6:4  error  Unexpected close-tag, expected opening tag          close-order

    Developing

    Prerequisites

    • NodeJS 12
    • NPM 7

    Generated files

    Some files are automatically generated by the toolchain but are required by many other steps such as testing and linting. This normally happens during npm run build and npm install. If you need to manually regenerate the files use:

    npm run codegen

    Test

    Testing is done using jest.

    npm test

    or call jest directly.

    Some tests are autogenerated from documentation examples, use npm run docs to build those before running.

    Lint

    Linting is done using ESLint.

    npm run eslint

    or call eslint directly.

    Build

    npm run build

    To build documentation use:

    npm run docs

    The documentation can be served locally using:

    npm start