w3c-html-validator 1.8.1 → 1.8.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/README.md +1 -1
- package/bin/cli.js +1 -1
- package/dist/w3c-html-validator.d.ts +2 -2
- package/dist/w3c-html-validator.js +12 -12
- package/package.json +11 -30
package/README.md
CHANGED
|
@@ -207,7 +207,7 @@ describe('Home page', () => {
|
|
|
207
207
|
- 🪺 [recursive-exec](https://github.com/center-key/recursive-exec): _Run a command on each file in a folder and its subfolders_
|
|
208
208
|
- 🔍 [replacer-util](https://github.com/center-key/replacer-util): _Find and replace strings or template outputs in text files_
|
|
209
209
|
- 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets): _Revision web asset filenames with cache busting content hash fingerprints_
|
|
210
|
-
- 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util): _Organize npm package.json scripts into
|
|
210
|
+
- 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util): _Organize npm package.json scripts into groups of easy to manage commands_
|
|
211
211
|
- 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator): _Check the markup validity of HTML files using the W3C validator_
|
|
212
212
|
|
|
213
213
|
Feel free to submit questions at:<br>
|
package/bin/cli.js
CHANGED
|
@@ -54,7 +54,7 @@ const error =
|
|
|
54
54
|
cli.flagOn.trim && !trim ? 'Value of "trim" must be a positive whole number.' :
|
|
55
55
|
null;
|
|
56
56
|
if (error)
|
|
57
|
-
throw Error('[w3c-html-validator] ' + error);
|
|
57
|
+
throw new Error('[w3c-html-validator] ' + error);
|
|
58
58
|
if (dryRunMode)
|
|
59
59
|
w3cHtmlValidator.dryRunNotice();
|
|
60
60
|
if (filenames.length > 1 && !cli.flagOn.quiet)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! w3c-html-validator v1.8.
|
|
1
|
+
//! w3c-html-validator v1.8.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
|
|
2
2
|
|
|
3
3
|
export type ValidatorSettings = {
|
|
4
4
|
html: string;
|
|
@@ -14,7 +14,7 @@ export type ValidatorResultsMessage = {
|
|
|
14
14
|
type: 'info' | 'error' | 'non-document-error' | 'network-error';
|
|
15
15
|
subType?: 'warning' | 'fatal' | 'io' | 'schema' | 'internal';
|
|
16
16
|
message: string;
|
|
17
|
-
extract
|
|
17
|
+
extract?: string;
|
|
18
18
|
lastLine: number;
|
|
19
19
|
firstColumn: number;
|
|
20
20
|
lastColumn: number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! w3c-html-validator v1.8.
|
|
1
|
+
//! w3c-html-validator v1.8.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';
|
|
@@ -6,7 +6,7 @@ import log from 'fancy-log';
|
|
|
6
6
|
import request from 'superagent';
|
|
7
7
|
import slash from 'slash';
|
|
8
8
|
const w3cHtmlValidator = {
|
|
9
|
-
version: '1.8.
|
|
9
|
+
version: '1.8.2',
|
|
10
10
|
validate(options) {
|
|
11
11
|
const defaults = {
|
|
12
12
|
checkUrl: 'https://validator.w3.org/nu/',
|
|
@@ -17,11 +17,11 @@ const w3cHtmlValidator = {
|
|
|
17
17
|
};
|
|
18
18
|
const settings = { ...defaults, ...options };
|
|
19
19
|
if (!settings.html && !settings.filename && !settings.website)
|
|
20
|
-
throw Error('[w3c-html-validator] Must specify the "html", "filename", or "website" option.');
|
|
20
|
+
throw new Error('[w3c-html-validator] Must specify the "html", "filename", or "website" option.');
|
|
21
21
|
if (![null, 'info', 'warning'].includes(settings.ignoreLevel))
|
|
22
|
-
throw Error(
|
|
22
|
+
throw new Error(`[w3c-html-validator] Invalid ignoreLevel option: ${settings.ignoreLevel}`);
|
|
23
23
|
if (settings.output !== 'json' && settings.output !== 'html')
|
|
24
|
-
throw Error('[w3c-html-validator] Option "output" must be "json" or "html".');
|
|
24
|
+
throw new Error('[w3c-html-validator] Option "output" must be "json" or "html".');
|
|
25
25
|
const filename = settings.filename ? slash(settings.filename) : null;
|
|
26
26
|
const mode = settings.html ? 'html' : filename ? 'filename' : 'website';
|
|
27
27
|
const readFile = (filename) => fs.readFileSync(filename, 'utf-8').replace(/\r/g, '');
|
|
@@ -37,7 +37,7 @@ const w3cHtmlValidator = {
|
|
|
37
37
|
const json = settings.output === 'json';
|
|
38
38
|
const success = '<p class="success">';
|
|
39
39
|
const titleLookup = {
|
|
40
|
-
html:
|
|
40
|
+
html: `HTML String (characters: ${inputHtml?.length})`,
|
|
41
41
|
filename: filename,
|
|
42
42
|
website: settings.website,
|
|
43
43
|
};
|
|
@@ -83,7 +83,7 @@ const w3cHtmlValidator = {
|
|
|
83
83
|
log(chalk.gray('w3c-html-validator'), chalk.yellowBright('dry run mode:'), chalk.whiteBright('validation being bypassed'));
|
|
84
84
|
},
|
|
85
85
|
summary(numFiles) {
|
|
86
|
-
log(chalk.gray('w3c-html-validator'), chalk.magenta('files: ' + numFiles));
|
|
86
|
+
log(chalk.gray('w3c-html-validator'), chalk.magenta('files: ' + String(numFiles)));
|
|
87
87
|
},
|
|
88
88
|
reporter(results, options) {
|
|
89
89
|
const defaults = {
|
|
@@ -94,11 +94,11 @@ const w3cHtmlValidator = {
|
|
|
94
94
|
};
|
|
95
95
|
const settings = { ...defaults, ...options };
|
|
96
96
|
if (typeof results?.validates !== 'boolean')
|
|
97
|
-
throw Error('[w3c-html-validator] Invalid results for reporter(): ' + String(results));
|
|
97
|
+
throw new Error('[w3c-html-validator] Invalid results for reporter(): ' + String(results));
|
|
98
98
|
const messages = results.messages ?? [];
|
|
99
99
|
const title = settings.title ?? results.title;
|
|
100
100
|
const status = results.validates ? chalk.green.bold('✔ pass') : chalk.red.bold('✘ fail');
|
|
101
|
-
const count = results.validates ? '' :
|
|
101
|
+
const count = results.validates ? '' : `(messages: ${messages.length})`;
|
|
102
102
|
if (!results.validates || !settings.quiet)
|
|
103
103
|
log(chalk.gray('w3c-html-validator'), status, chalk.blue.bold(title), chalk.white(count));
|
|
104
104
|
const typeColorMap = {
|
|
@@ -107,7 +107,7 @@ const w3cHtmlValidator = {
|
|
|
107
107
|
info: chalk.white.bold,
|
|
108
108
|
};
|
|
109
109
|
const logMessage = (message) => {
|
|
110
|
-
const type =
|
|
110
|
+
const type = message.subType ?? message.type;
|
|
111
111
|
const typeColor = typeColorMap[type] ?? chalk.redBright.bold;
|
|
112
112
|
const location = `line ${message.lastLine}, column ${message.firstColumn}:`;
|
|
113
113
|
const lineText = message.extract?.replace(/\n/g, '\\n');
|
|
@@ -119,11 +119,11 @@ const w3cHtmlValidator = {
|
|
|
119
119
|
messages.forEach(logMessage);
|
|
120
120
|
const failDetails = () => {
|
|
121
121
|
const toString = (message) => `${message.subType ?? message.type} line ${message.lastLine} column ${message.firstColumn}`;
|
|
122
|
-
const fileDetails = () => results.filename
|
|
122
|
+
const fileDetails = () => `${results.filename} -- ${results.messages.map(toString).join(', ')}`;
|
|
123
123
|
return !results.filename ? results.messages[0].message : fileDetails();
|
|
124
124
|
};
|
|
125
125
|
if (!settings.continueOnFail && !results.validates)
|
|
126
|
-
throw Error('[w3c-html-validator] Failed: ' + failDetails());
|
|
126
|
+
throw new Error('[w3c-html-validator] Failed: ' + failDetails());
|
|
127
127
|
return results;
|
|
128
128
|
},
|
|
129
129
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "w3c-html-validator",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Check the markup validity of HTML files using the W3C validator",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -38,32 +38,13 @@
|
|
|
38
38
|
"node": true,
|
|
39
39
|
"mocha": true
|
|
40
40
|
},
|
|
41
|
-
"eslintConfig": {
|
|
42
|
-
"ignorePatterns": [
|
|
43
|
-
"build",
|
|
44
|
-
"dist",
|
|
45
|
-
"node_modules"
|
|
46
|
-
],
|
|
47
|
-
"root": true,
|
|
48
|
-
"parser": "@typescript-eslint/parser",
|
|
49
|
-
"plugins": [
|
|
50
|
-
"@typescript-eslint"
|
|
51
|
-
],
|
|
52
|
-
"extends": [
|
|
53
|
-
"eslint:recommended",
|
|
54
|
-
"plugin:@typescript-eslint/recommended"
|
|
55
|
-
],
|
|
56
|
-
"rules": {
|
|
57
|
-
"@typescript-eslint/no-non-null-assertion": "off"
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
41
|
"runScriptsConfig": {
|
|
61
42
|
"clean": [
|
|
62
43
|
"rimraf build dist"
|
|
63
44
|
],
|
|
64
45
|
"lint": [
|
|
65
46
|
"jshint . --exclude-path .gitignore",
|
|
66
|
-
"eslint --max-warnings 0
|
|
47
|
+
"eslint --max-warnings 0"
|
|
67
48
|
],
|
|
68
49
|
"build": [
|
|
69
50
|
"tsc",
|
|
@@ -79,26 +60,26 @@
|
|
|
79
60
|
"chalk": "~5.3",
|
|
80
61
|
"cli-argv-util": "~1.2",
|
|
81
62
|
"fancy-log": "~2.0",
|
|
82
|
-
"glob": "~
|
|
63
|
+
"glob": "~11.0",
|
|
83
64
|
"slash": "~5.1",
|
|
84
65
|
"superagent": "~9.0"
|
|
85
66
|
},
|
|
86
67
|
"devDependencies": {
|
|
68
|
+
"@eslint/js": "~9.9",
|
|
87
69
|
"@types/fancy-log": "~2.0",
|
|
88
|
-
"@types/node": "~
|
|
70
|
+
"@types/node": "~22.2",
|
|
89
71
|
"@types/superagent": "~8.1",
|
|
90
|
-
"@typescript-eslint/eslint-plugin": "~7.7",
|
|
91
|
-
"@typescript-eslint/parser": "~7.7",
|
|
92
72
|
"add-dist-header": "~1.4",
|
|
93
73
|
"assert-deep-strict-equal": "~1.2",
|
|
94
74
|
"copy-file-util": "~1.2",
|
|
95
75
|
"copy-folder-util": "~1.1",
|
|
96
|
-
"eslint": "
|
|
76
|
+
"eslint": "~9.9",
|
|
97
77
|
"jshint": "~2.13",
|
|
98
78
|
"merge-stream": "~2.0",
|
|
99
|
-
"mocha": "~10.
|
|
100
|
-
"rimraf": "~
|
|
101
|
-
"run-scripts-util": "~1.
|
|
102
|
-
"typescript": "~5.
|
|
79
|
+
"mocha": "~10.7",
|
|
80
|
+
"rimraf": "~6.0",
|
|
81
|
+
"run-scripts-util": "~1.3",
|
|
82
|
+
"typescript": "~5.5",
|
|
83
|
+
"typescript-eslint": "~8.0"
|
|
103
84
|
}
|
|
104
85
|
}
|