w3c-html-validator 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2022 individual contributors to w3c-html-validator
3
+ Copyright (c) 2021-2023 Individual contributors to w3c-html-validator
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -52,7 +52,9 @@ Command-line flags:
52
52
  | Flag | Description | Value |
53
53
  | ------------ | --------------------------------------------------------------- | ---------- |
54
54
  | `--continue` | Report messages but do not throw an error if validation failed. | N/A |
55
+ | `--delay` | Debounce pause in milliseconds between each file validation. | **number** |
55
56
  | `--exclude` | Comma separated list of strings to match in paths to skip. | **string** |
57
+ | `--ignore` | Skip messages containing a string or matching a RegEx. | **string** |
56
58
  | `--note` | Place to add a comment only for humans. | **string** |
57
59
  | `--quiet` | Suppress messages for successful validations. | N/A |
58
60
  | `--trim` | Truncate validation messages to not exceed a maximum length. | **number** |
@@ -63,10 +65,14 @@ Examples:
63
65
  Validate all HTML files in the project.
64
66
  - `html-validator --exclude=build,tmp`<br>
65
67
  Slip all files which have "build" or "tmp" anywhere in their pathname or filename.
68
+ - `html-validator docs/*.html "--ignore=Trailing slash on void elements"`<br>
69
+ Allow the ugly slashes of self-closing tags despite XHTML being a hideous scourge on the web.
70
+ - `html-validator docs/*.html "--ignore=/^Duplicate ID/"`<br>
71
+ Use a RegEx (regular expression) to skip all messages that start with "Duplicate ID".
66
72
  - `html-validator --quiet`<br>
67
73
  Suppress "pass" messages.
68
- - `html-validator docs`<br>
69
- Validate HTML files in a folder.
74
+ - `html-validator docs --delay=200`<br>
75
+ Validate all HTML files in the "docs" folder at a rate of 1 file per 200 ms (default is 500 ms).
70
76
  - `html-validator docs --trim=30 --continue`<br>
71
77
  Truncate messages to 30 characters and do not abort CI if validation fails.
72
78
 
@@ -96,13 +102,13 @@ $ node examples.js
96
102
  #### w3cHtmlValidator.validate(options)
97
103
  | Name (key) | Type | Default | Description |
98
104
  | :--------------- | :---------------------- | :------------------------------- | :------------------------------------------------------------------- |
99
- | `html` | **string** | `null` | HTML string to validate. |
100
- | `filename` | **string** | `null` | HTML file to validate. |
101
- | `website` | **string** | `null` | URL of website to validate. |
102
105
  | `checkUrl` | **string** | `'https://validator.w3.org/nu/'` | W3C validation API endpoint. |
106
+ | `filename` | **string** | `null` | HTML file to validate. |
107
+ | `html` | **string** | `null` | HTML string to validate. |
103
108
  | `ignoreLevel` | `'info'` or `'warning'` | `null` | Skip unwanted messages.* |
104
109
  | `ignoreMessages` | **string** or **regex** | `null` | Skip messages containing a string or matching a regular expression.* |
105
110
  | `output` | `'json'` or `'html'` | `'json'` | Get results as an array or as a web page. |
111
+ | `website` | **string** | `null` | URL of website to validate. |
106
112
 
107
113
  *The `ignoreMessages` and `ignoreLevel` options only work for `'json'` output.&nbsp;
108
114
  Option value `'warning'` also skips `'info'`.
package/bin/cli.js CHANGED
@@ -28,9 +28,11 @@ import glob from 'glob';
28
28
  import log from 'fancy-log';
29
29
 
30
30
  // Parameters and flags
31
- const validFlags = ['continue', 'exclude', 'note', 'quiet', 'trim'];
31
+ const validFlags = ['continue', 'delay', 'exclude', 'ignore', 'note', 'quiet', 'trim'];
32
32
  const cli = cliArgvUtil.parse(validFlags);
33
33
  const files = cli.params;
34
+ const ignore = cli.flagMap.ignore ?? null;
35
+ const delay = parseInt(cli.flagMap.delay) || 500; //default half second debounce pause
34
36
  const trim = parseInt(cli.flagMap.trim) || null;
35
37
 
36
38
  // Validator
@@ -55,5 +57,9 @@ const reporterOptions = {
55
57
  quiet: cli.flagOn.quiet,
56
58
  maxMessageLen: trim,
57
59
  };
60
+ const slashed = /^\/.*\/$/; //starts and ends with a slash indicating it's a regex
61
+ const skip = slashed.test(ignore) ? new RegExp(ignore.slice(1, -1)) : ignore;
58
62
  const handleReport = (report) => w3cHtmlValidator.reporter(report, reporterOptions);
59
- filenames.forEach(file => w3cHtmlValidator.validate({ filename: file }).then(handleReport));
63
+ const options = (file) => ({ filename: file, ignoreMessages: skip });
64
+ const getReport = (file) => w3cHtmlValidator.validate(options(file)).then(handleReport);
65
+ filenames.forEach((filename, i) => globalThis.setTimeout(() => getReport(filename), i * delay));
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v1.3.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.3.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  export type ValidatorSettings = {
4
4
  html: string;
@@ -1,11 +1,11 @@
1
- //! w3c-html-validator v1.3.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.3.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  import chalk from 'chalk';
4
4
  import fs from 'fs';
5
5
  import log from 'fancy-log';
6
6
  import request from 'superagent';
7
7
  const w3cHtmlValidator = {
8
- version: '1.3.0',
8
+ version: '1.3.2',
9
9
  validate(options) {
10
10
  var _a;
11
11
  const defaults = {
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v1.3.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.3.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  const fancy_log_1 = __importDefault(require("fancy-log"));
21
21
  const superagent_1 = __importDefault(require("superagent"));
22
22
  const w3cHtmlValidator = {
23
- version: '1.3.0',
23
+ version: '1.3.2',
24
24
  validate(options) {
25
25
  var _a;
26
26
  const defaults = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "w3c-html-validator",
3
- "version": "1.3.0",
3
+ "version": "1.3.2",
4
4
  "description": "Check the markup validity of HTML files using the W3C validator",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -81,25 +81,25 @@
81
81
  "chalk": "~5.2",
82
82
  "cli-argv-util": "~0.1",
83
83
  "fancy-log": "~2.0",
84
- "glob": "~8.0",
84
+ "glob": "~8.1",
85
85
  "superagent": "~8.0"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@types/fancy-log": "~2.0",
89
89
  "@types/glob": "~8.0",
90
- "@types/node": "~18.11",
90
+ "@types/node": "~18.13",
91
91
  "@types/superagent": "~4.1",
92
- "@typescript-eslint/eslint-plugin": "~5.47",
93
- "@typescript-eslint/parser": "~5.47",
92
+ "@typescript-eslint/eslint-plugin": "~5.52",
93
+ "@typescript-eslint/parser": "~5.52",
94
94
  "add-dist-header": "~0.3",
95
95
  "assert-deep-strict-equal": "~1.0",
96
96
  "copy-file-util": "~0.1",
97
97
  "copy-folder-util": "~0.2",
98
- "eslint": "~8.31",
98
+ "eslint": "~8.34",
99
99
  "jshint": "~2.13",
100
100
  "merge-stream": "~2.0",
101
101
  "mocha": "~10.2",
102
- "rimraf": "~3.0",
102
+ "rimraf": "3",
103
103
  "run-scripts-util": "~0.1",
104
104
  "typescript": "~4.9"
105
105
  }