1
1
mirror of https://github.com/theoludwig/html-w3c-validator.git synced 2024-07-20 07:30:11 +02:00
CLI for validating multiple html pages using validator.w3.org. https://www.npmjs.com/package/html-w3c-validator
Go to file
2022-01-06 19:58:51 +01:00
.devcontainer chore: initial commit 2022-01-06 19:52:25 +01:00
.github chore(deps): bump actions/setup-node from 2.4.1 to 2.5.1 (#1) 2022-01-06 19:58:51 +01:00
.husky chore: initial commit 2022-01-06 19:52:25 +01:00
.vscode chore: initial commit 2022-01-06 19:52:25 +01:00
src chore: initial commit 2022-01-06 19:52:25 +01:00
.commitlintrc.json chore: initial commit 2022-01-06 19:52:25 +01:00
.editorconfig chore: initial commit 2022-01-06 19:52:25 +01:00
.eslintignore chore: initial commit 2022-01-06 19:52:25 +01:00
.eslintrc.json chore: initial commit 2022-01-06 19:52:25 +01:00
.gitignore chore: initial commit 2022-01-06 19:52:25 +01:00
.lintstagedrc.json chore: initial commit 2022-01-06 19:52:25 +01:00
.markdownlint.json chore: initial commit 2022-01-06 19:52:25 +01:00
.npmrc chore: initial commit 2022-01-06 19:52:25 +01:00
.prettierignore chore: initial commit 2022-01-06 19:52:25 +01:00
.prettierrc.json chore: initial commit 2022-01-06 19:52:25 +01:00
.releaserc.json chore: initial commit 2022-01-06 19:52:25 +01:00
.swcrc chore: initial commit 2022-01-06 19:52:25 +01:00
CODE_OF_CONDUCT.md chore: initial commit 2022-01-06 19:52:25 +01:00
CONTRIBUTING.md chore: initial commit 2022-01-06 19:52:25 +01:00
jest.config.json chore: initial commit 2022-01-06 19:52:25 +01:00
LICENSE chore: initial commit 2022-01-06 19:52:25 +01:00
package-lock.json chore: initial commit 2022-01-06 19:52:25 +01:00
package.json chore: initial commit 2022-01-06 19:52:25 +01:00
README.md chore: initial commit 2022-01-06 19:52:25 +01:00
tsconfig.json chore: initial commit 2022-01-06 19:52:25 +01:00

html-w3c-validator

CLI for validating multiple html pages using validator.w3.org.

Licence MIT Contributor Covenant Dependabot badge

Conventional Commits semantic-release npm version

📜 About

html-w3c-validator is a CLI tool to validate multiple html pages using validator.w3.org.

You might use a JavaScript framework or simply use HTML: you should validate your production HTML and this validation should be part of your CI/CD pipeline (tests, linting, etc.).

Why should I validate my HTML pages?

Quote from https://validator.w3.org/docs/help.html#why-validate:

One of the important maxims of computer programming is: "Be conservative in what you produce; be liberal in what you accept."

Browsers follow the second half of this maxim by accepting Web pages and trying to display them even if they're not legal HTML. Usually this means that the browser will try to make educated guesses about what you probably meant. The problem is that different browsers (or even different versions of the same browser) will make different guesses about the same illegal construct; worse, if your HTML is really pathological, the browser could get hopelessly confused and produce a mangled mess, or even crash.

⚙️ Getting Started

You can combine html-w3c-validator with start-server-and-test to validate HTML pages of your project.

Prerequisites

Installation (with start-server-and-test)

npm install --save-dev html-w3c-validator start-server-and-test

⚙️ Configuration

package.json

{
  "scripts": {
    // Command to start the server serving your HTML pages (e.g: using vercel/serve)
    "start": "serve ./build",

    // Command to validate your HTML pages
    "test:html-w3c-validator": "start-server-and-test 'start' 'http://localhost:3000' 'html-w3c-validator'"
  }
}

.html-w3c-validator.json

{
  "urls": ["http://localhost:3000/", "http://localhost:3000/about"]
}

Usage

npm run test:html-w3c-validator

Example of output:


Options

-V, --version       Output the version number.
-h, --help          Display help for command.
--config            Path to a configuration file (default: `.html-w3c-validator.json`).

💡 Contributing

Anyone can help to improve the project, submit a Feature Request, a bug report or even correct a simple spelling mistake.

The steps to contribute can be found in the CONTRIBUTING.md file.

📄 License

MIT