w3c-html-validator 1.8.3 → 1.9.1
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/bin/cli.js +12 -12
- package/dist/w3c-html-validator.d.ts +1 -1
- package/dist/w3c-html-validator.js +4 -4
- package/package.json +12 -12
package/bin/cli.js
CHANGED
|
@@ -29,25 +29,25 @@ import fs from 'fs';
|
|
|
29
29
|
import slash from 'slash';
|
|
30
30
|
|
|
31
31
|
// Parameters and flags
|
|
32
|
-
const validFlags =
|
|
32
|
+
const validFlags =
|
|
33
|
+
['continue', 'delay', 'dry-run', 'exclude', 'ignore', 'ignore-config', 'note', 'quiet', 'trim'];
|
|
33
34
|
const cli = cliArgvUtil.parse(validFlags);
|
|
34
|
-
const files = cli.params;
|
|
35
|
+
const files = cli.params.length ? cli.params.map(cliArgvUtil.cleanPath) : ['.'];
|
|
36
|
+
const excludeList = cli.flagMap.exclude ? cli.flagMap.exclude.split(',') : [];
|
|
35
37
|
const ignore = cli.flagMap.ignore ?? null;
|
|
36
38
|
const ignoreConfig = cli.flagMap.ignoreConfig ?? null;
|
|
37
39
|
const delay = Number(cli.flagMap.delay) || 500; //default half second debounce pause
|
|
38
40
|
const trim = Number(cli.flagMap.trim) || null;
|
|
39
41
|
const dryRunMode = cli.flagOn.dryRun || process.env.w3cHtmlValidator === 'dry-run'; //bash: export w3cHtmlValidator=dry-run
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
const excludes = cli.flagMap.exclude?.split(',') ?? [];
|
|
50
|
-
const filenames = list.filter(name => !excludes.find(exclude => name.includes(exclude)));
|
|
43
|
+
const getFilenames = () => {
|
|
44
|
+
const readFilenames = (file) => globSync(file, { ignore: '**/node_modules/**/*' }).map(slash);
|
|
45
|
+
const readHtmlFiles = (folder) => readFilenames(folder + '/**/*.html');
|
|
46
|
+
const addHtml = (file) => fs.lstatSync(file).isDirectory() ? readHtmlFiles(file) : file;
|
|
47
|
+
const keep = (file) => excludeList.every(exclude => !file.includes(exclude));
|
|
48
|
+
return files.map(readFilenames).flat().map(addHtml).flat().filter(keep).sort();
|
|
49
|
+
};
|
|
50
|
+
const filenames = getFilenames();
|
|
51
51
|
const error =
|
|
52
52
|
cli.invalidFlag ? cli.invalidFlagMsg :
|
|
53
53
|
!filenames.length ? 'No files to validate.' :
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! w3c-html-validator v1.
|
|
1
|
+
//! w3c-html-validator v1.9.1 ~~ 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.
|
|
9
|
+
version: '1.9.1',
|
|
10
10
|
validate(options) {
|
|
11
11
|
const defaults = {
|
|
12
12
|
checkUrl: 'https://validator.w3.org/nu/',
|
|
@@ -94,7 +94,7 @@ const w3cHtmlValidator = {
|
|
|
94
94
|
};
|
|
95
95
|
const settings = { ...defaults, ...options };
|
|
96
96
|
if (typeof results?.validates !== 'boolean')
|
|
97
|
-
throw new Error(
|
|
97
|
+
throw new Error(`[w3c-html-validator] Invalid results for reporter(): ${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');
|
|
@@ -123,7 +123,7 @@ const w3cHtmlValidator = {
|
|
|
123
123
|
return !results.filename ? results.messages[0].message : fileDetails();
|
|
124
124
|
};
|
|
125
125
|
if (!settings.continueOnFail && !results.validates)
|
|
126
|
-
throw new Error(
|
|
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.
|
|
3
|
+
"version": "1.9.1",
|
|
4
4
|
"description": "Check the markup validity of HTML files using the W3C validator",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -57,29 +57,29 @@
|
|
|
57
57
|
"examples": "node examples.js"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"chalk": "~5.
|
|
61
|
-
"cli-argv-util": "~1.
|
|
60
|
+
"chalk": "~5.5",
|
|
61
|
+
"cli-argv-util": "~1.3",
|
|
62
62
|
"fancy-log": "~2.0",
|
|
63
63
|
"glob": "~11.0",
|
|
64
64
|
"slash": "~5.1",
|
|
65
|
-
"superagent": "~10.
|
|
65
|
+
"superagent": "~10.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
|
-
"@eslint/js": "~9.
|
|
68
|
+
"@eslint/js": "~9.33",
|
|
69
69
|
"@types/fancy-log": "~2.0",
|
|
70
|
-
"@types/node": "~
|
|
70
|
+
"@types/node": "~24.2",
|
|
71
71
|
"@types/superagent": "~8.1",
|
|
72
|
-
"add-dist-header": "~1.
|
|
72
|
+
"add-dist-header": "~1.5",
|
|
73
73
|
"assert-deep-strict-equal": "~1.2",
|
|
74
|
-
"copy-file-util": "~1.
|
|
74
|
+
"copy-file-util": "~1.3",
|
|
75
75
|
"copy-folder-util": "~1.1",
|
|
76
|
-
"eslint": "~9.
|
|
76
|
+
"eslint": "~9.33",
|
|
77
77
|
"jshint": "~2.13",
|
|
78
78
|
"merge-stream": "~2.0",
|
|
79
|
-
"mocha": "~11.
|
|
79
|
+
"mocha": "~11.7",
|
|
80
80
|
"rimraf": "~6.0",
|
|
81
81
|
"run-scripts-util": "~1.3",
|
|
82
|
-
"typescript": "~5.
|
|
83
|
-
"typescript-eslint": "~8.
|
|
82
|
+
"typescript": "~5.9",
|
|
83
|
+
"typescript-eslint": "~8.39"
|
|
84
84
|
}
|
|
85
85
|
}
|