w3c-html-validator 2.0.1 → 2.1.0
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 +1 -1
- package/README.md +16 -7
- package/bin/cli.js +0 -17
- package/dist/w3c-html-validator.d.ts +1 -1
- package/dist/w3c-html-validator.js +4 -3
- package/package.json +6 -6
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021-
|
|
3
|
+
Copyright (c) 2021-2026 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
|
@@ -20,7 +20,14 @@ $ npm install --save-dev w3c-html-validator
|
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
## B) Usage
|
|
23
|
-
### 1.
|
|
23
|
+
### 1. Synopsis
|
|
24
|
+
```
|
|
25
|
+
html-validator [INPUT1] [INPUT2] [INPUT3] [...]
|
|
26
|
+
```
|
|
27
|
+
Parameters:
|
|
28
|
+
Each parameter is a folder or file to be sent to the HTML validator.
|
|
29
|
+
|
|
30
|
+
### 2. npm package.json scripts
|
|
24
31
|
Run `html-validator` from the `"scripts"` section of your **package.json** file.
|
|
25
32
|
|
|
26
33
|
The parameters are folders and files to be validated.
|
|
@@ -37,7 +44,7 @@ Example **package.json** scripts:
|
|
|
37
44
|
Passing no parameters defaults to validating all HTML files in the project (skipping the
|
|
38
45
|
**node_modules** folder).
|
|
39
46
|
|
|
40
|
-
###
|
|
47
|
+
### 3. Command-line npx
|
|
41
48
|
Example terminal commands:
|
|
42
49
|
```shell
|
|
43
50
|
$ npm install --save-dev w3c-html-validator
|
|
@@ -47,7 +54,7 @@ The above `npx` line validates all the HTML files in the **docs** folder.
|
|
|
47
54
|
|
|
48
55
|
You can also install **w3c-html-validator** globally (`--global`) and then run it anywhere directly from the terminal.
|
|
49
56
|
|
|
50
|
-
###
|
|
57
|
+
### 4. CLI flags
|
|
51
58
|
Command-line flags:
|
|
52
59
|
| Flag | Description | Value |
|
|
53
60
|
| ----------------- | ------------------------------------------------------------------- | ---------- |
|
|
@@ -62,7 +69,7 @@ Command-line flags:
|
|
|
62
69
|
| `--quiet` | Suppress messages for successful validations. | N/A |
|
|
63
70
|
| `--trim` | Truncate validation messages to not exceed a maximum length. | **number** |
|
|
64
71
|
|
|
65
|
-
###
|
|
72
|
+
### 5. Examples
|
|
66
73
|
- `html-validator`<br>
|
|
67
74
|
Validates all HTML files in the project.
|
|
68
75
|
|
|
@@ -90,9 +97,10 @@ Command-line flags:
|
|
|
90
97
|
- `html-validator docs --trim=30 --continue`<br>
|
|
91
98
|
Truncates validation messages to 30 characters and does not abort CI if validation fails.
|
|
92
99
|
|
|
93
|
-
|
|
100
|
+
> [!NOTE]
|
|
101
|
+
> _Single quotes in commands are normalized so they work cross-platform and avoid the errors often encountered on Microsoft Windows._
|
|
94
102
|
|
|
95
|
-
###
|
|
103
|
+
### 6. Configuration File for Ignore Patterns
|
|
96
104
|
The optional `--ignore-config=FILENAME` flag specifies a configuration file with one string or regex per line.
|
|
97
105
|
HTML validation messages containing any of the strings or matching any of the regexes will be skipped.
|
|
98
106
|
Empty lines and lines starting with a hash sign (`#`) are treated as comments and do nothing.
|
|
@@ -108,12 +116,13 @@ Example configuration file with 3 regexes:
|
|
|
108
116
|
The caret (`^`) regex operator says to match from the beginning of the validation message.
|
|
109
117
|
The dot (`.`) regex operator says to match any one character, which is a handy way to avoid typing the special curly quote characters in some of the validation messages.
|
|
110
118
|
|
|
111
|
-
###
|
|
119
|
+
### 7. Default Ignore List
|
|
112
120
|
The optional `--default-rules` flag causes HTML validation messages to be skipped if they are on the opinionated pre-defined list of unhelpful messages.
|
|
113
121
|
|
|
114
122
|
Default ignore list:
|
|
115
123
|
| Pattern | Level | Explanation |
|
|
116
124
|
| ------------------------ | ----------- | ----------- |
|
|
125
|
+
| `with computed level` | **error** | It's ridiculous that adding an `<aside>` with an `<h2>` breaks the outer flow's outline. |
|
|
117
126
|
| `Section lacks heading.` | **warning** | Rule is sensible for traditional print publishing but absurd for modern UI components not burning in nested `<div>` hell. |
|
|
118
127
|
|
|
119
128
|
If there is an additional W3C validation message you think is ridiculous, open an issue with a note explaining why the message should be ignored.
|
package/bin/cli.js
CHANGED
|
@@ -4,23 +4,6 @@
|
|
|
4
4
|
// MIT License //
|
|
5
5
|
////////////////////////
|
|
6
6
|
|
|
7
|
-
// Usage in package.json:
|
|
8
|
-
// "scripts": {
|
|
9
|
-
// "validate": "html-validator docs flyer.html",
|
|
10
|
-
// "all": "html-validator"
|
|
11
|
-
// },
|
|
12
|
-
//
|
|
13
|
-
// Usage from command line:
|
|
14
|
-
// $ npm install --save-dev w3c-html-validator
|
|
15
|
-
// $ npx html-validator dist #validate all html files in the dist folder
|
|
16
|
-
// $ npx html-validator docs flyer.html
|
|
17
|
-
//
|
|
18
|
-
// Contributors to this project:
|
|
19
|
-
// $ cd w3c-html-validator
|
|
20
|
-
// $ npm install
|
|
21
|
-
// $ npm test
|
|
22
|
-
// $ node bin/cli.js spec --continue
|
|
23
|
-
|
|
24
7
|
import { w3cHtmlValidator } from '../dist/w3c-html-validator.js';
|
|
25
8
|
|
|
26
9
|
w3cHtmlValidator.cli();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! w3c-html-validator v2.0
|
|
1
|
+
//! w3c-html-validator v2.1.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
|
|
2
2
|
|
|
3
3
|
import { cliArgvUtil } from 'cli-argv-util';
|
|
4
4
|
import { globSync } from 'glob';
|
|
@@ -8,9 +8,10 @@ import log from 'fancy-log';
|
|
|
8
8
|
import request from 'superagent';
|
|
9
9
|
import slash from 'slash';
|
|
10
10
|
const w3cHtmlValidator = {
|
|
11
|
-
version: '2.0
|
|
11
|
+
version: '2.1.0',
|
|
12
12
|
defaultIgnoreList: [
|
|
13
|
-
'
|
|
13
|
+
'with computed level',
|
|
14
|
+
'Section lacks heading.',
|
|
14
15
|
],
|
|
15
16
|
assert(ok, message) {
|
|
16
17
|
if (!ok)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w3c-html-validator",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Check the markup validity of HTML files using the W3C validator",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -58,27 +58,27 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"chalk": "~5.6",
|
|
61
|
-
"cli-argv-util": "~1.
|
|
61
|
+
"cli-argv-util": "~1.4",
|
|
62
62
|
"fancy-log": "~2.0",
|
|
63
|
-
"glob": "~
|
|
63
|
+
"glob": "~13.0",
|
|
64
64
|
"slash": "~5.1",
|
|
65
65
|
"superagent": "~10.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@eslint/js": "~9.39",
|
|
69
69
|
"@types/fancy-log": "~2.0",
|
|
70
|
-
"@types/node": "~
|
|
70
|
+
"@types/node": "~25.0",
|
|
71
71
|
"@types/superagent": "~8.1",
|
|
72
72
|
"add-dist-header": "~1.6",
|
|
73
73
|
"assert-deep-strict-equal": "~1.2",
|
|
74
74
|
"copy-file-util": "~1.3",
|
|
75
|
-
"copy-folder-util": "~1.
|
|
75
|
+
"copy-folder-util": "~1.2",
|
|
76
76
|
"eslint": "~9.39",
|
|
77
77
|
"jshint": "~2.13",
|
|
78
78
|
"mocha": "~11.7",
|
|
79
79
|
"rimraf": "~6.1",
|
|
80
80
|
"run-scripts-util": "~1.3",
|
|
81
81
|
"typescript": "~5.9",
|
|
82
|
-
"typescript-eslint": "~8.
|
|
82
|
+
"typescript-eslint": "~8.51"
|
|
83
83
|
}
|
|
84
84
|
}
|