w3c-html-validator 1.2.0 → 1.2.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/README.md +2 -0
- package/bin/cli.js +12 -18
- package/dist/w3c-html-validator.d.ts +10 -10
- package/dist/w3c-html-validator.js +2 -2
- package/dist/w3c-html-validator.umd.cjs +2 -2
- package/package.json +21 -16
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ Command-line flags:
|
|
|
52
52
|
| Flag | Description | Value |
|
|
53
53
|
| ----------- | ------------------------------------------------------------ | ---------- |
|
|
54
54
|
| `--exclude` | Comma separated list of strings to match in paths to skip. | **string** |
|
|
55
|
+
| `--note` | Place to add a comment only for humans. | **string** |
|
|
55
56
|
| `--quiet` | Suppress messages for successful validations. | N/A |
|
|
56
57
|
| `--trim` | Truncate validation messages to not exceed a maximum length. | **number** |
|
|
57
58
|
|
|
@@ -161,6 +162,7 @@ describe('Home page', () => {
|
|
|
161
162
|
- 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util): _Recursively copy files from one folder to another folder_
|
|
162
163
|
- 🔍 [replacer-util](https://github.com/center-key/replacer-util): _Find and replace strings or template outputs in text files_
|
|
163
164
|
- 🔢 [rev-web-assets](https://github.com/center-key/rev-web-assets): _Revision web asset filenames with cache busting content hash fingerprints_
|
|
165
|
+
- 🚆 [run-scripts-util](https://github.com/center-key/run-scripts-util): _Organize npm scripts into named groups of easy to manage commands_
|
|
164
166
|
- 🚦 [w3c-html-validator](https://github.com/center-key/w3c-html-validator): _Check the markup validity of HTML files using the W3C validator_
|
|
165
167
|
|
|
166
168
|
Feel free to submit questions at:<br>
|
package/bin/cli.js
CHANGED
|
@@ -20,24 +20,18 @@
|
|
|
20
20
|
// $ node bin/cli.js spec/**/*.html --quiet
|
|
21
21
|
|
|
22
22
|
// Imports
|
|
23
|
+
import { cliArgvUtil } from 'cli-argv-util';
|
|
23
24
|
import { w3cHtmlValidator } from '../dist/w3c-html-validator.js';
|
|
24
25
|
import chalk from 'chalk';
|
|
25
26
|
import fs from 'fs';
|
|
26
27
|
import glob from 'glob';
|
|
27
28
|
import log from 'fancy-log';
|
|
28
29
|
|
|
29
|
-
// Parameters
|
|
30
|
-
const validFlags =
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
const flagOn = Object.fromEntries(validFlags.map(flag => [flag, flag in flagMap]));
|
|
35
|
-
const invalidFlag = Object.keys(flagMap).find(key => !validFlags.includes(key));
|
|
36
|
-
const params = args.filter(arg => !/^--/.test(arg));
|
|
37
|
-
|
|
38
|
-
// Data
|
|
39
|
-
const files = params;
|
|
40
|
-
const trim = parseInt(flagMap.trim) || null;
|
|
30
|
+
// Parameters and flags
|
|
31
|
+
const validFlags = ['exclude', 'note', 'quiet', 'trim'];
|
|
32
|
+
const cli = cliArgvUtil.parse(validFlags);
|
|
33
|
+
const files = cli.params;
|
|
34
|
+
const trim = parseInt(cli.flagMap.trim) || null;
|
|
41
35
|
|
|
42
36
|
// Validator
|
|
43
37
|
const keep = (filename) => !filename.includes('node_modules/');
|
|
@@ -45,19 +39,19 @@ const readFolder = (folder) => glob.sync(folder + '**/*.html', { ignore: '**/n
|
|
|
45
39
|
const expandFolder = (file) => fs.lstatSync(file).isDirectory() ? readFolder(file + '/') : file;
|
|
46
40
|
const getFilenames = () => [...new Set(files.map(expandFolder).flat().filter(keep))].sort();
|
|
47
41
|
const list = files.length ? getFilenames() : readFolder('');
|
|
48
|
-
const excludes = flagMap.exclude?.split(',') ?? [];
|
|
42
|
+
const excludes = cli.flagMap.exclude?.split(',') ?? [];
|
|
49
43
|
const filenames = list.filter(name => !excludes.find(exclude => name.includes(exclude)));
|
|
50
44
|
const error =
|
|
51
|
-
invalidFlag ?
|
|
52
|
-
!filenames.length ?
|
|
53
|
-
flagOn.trim && !trim ? 'Value of "trim" must be a positive whole number.' :
|
|
45
|
+
cli.invalidFlag ? cli.invalidFlagMsg :
|
|
46
|
+
!filenames.length ? 'No files to validate.' :
|
|
47
|
+
cli.flagOn.trim && !trim ? 'Value of "trim" must be a positive whole number.' :
|
|
54
48
|
null;
|
|
55
49
|
if (error)
|
|
56
50
|
throw Error('[w3c-html-validator] ' + error);
|
|
57
|
-
if (filenames.length > 1 && !flagOn.quiet)
|
|
51
|
+
if (filenames.length > 1 && !cli.flagOn.quiet)
|
|
58
52
|
log(chalk.gray('w3c-html-validator'), chalk.magenta('files: ' + filenames.length));
|
|
59
53
|
const reporterOptions = {
|
|
60
|
-
quiet: flagOn.quiet,
|
|
54
|
+
quiet: cli.flagOn.quiet,
|
|
61
55
|
maxMessageLen: trim,
|
|
62
56
|
};
|
|
63
57
|
const handleReport = (report) => w3cHtmlValidator.reporter(report, reporterOptions);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//! w3c-html-validator v1.2.
|
|
1
|
+
//! w3c-html-validator v1.2.1 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export type ValidatorSettings = {
|
|
4
4
|
html: string;
|
|
5
5
|
filename: string;
|
|
6
6
|
website: string;
|
|
@@ -9,8 +9,8 @@ export declare type ValidatorSettings = {
|
|
|
9
9
|
ignoreMessages: string | RegExp;
|
|
10
10
|
output: ValidatorResultsOutput;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
12
|
+
export type ValidatorOptions = Partial<ValidatorSettings>;
|
|
13
|
+
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;
|
|
@@ -21,9 +21,9 @@ export declare type ValidatorResultsMessage = {
|
|
|
21
21
|
hiliteStart: number;
|
|
22
22
|
hiliteLength: number;
|
|
23
23
|
};
|
|
24
|
-
export
|
|
25
|
-
export
|
|
26
|
-
export
|
|
24
|
+
export type ValidatorResultsMessageType = ValidatorResultsMessage['type'];
|
|
25
|
+
export type ValidatorResultsMessageSubType = ValidatorResultsMessage['subType'];
|
|
26
|
+
export type ValidatorResults = {
|
|
27
27
|
validates: boolean;
|
|
28
28
|
mode: 'html' | 'filename' | 'website';
|
|
29
29
|
title: string;
|
|
@@ -35,13 +35,13 @@ export declare type ValidatorResults = {
|
|
|
35
35
|
messages: ValidatorResultsMessage[] | null;
|
|
36
36
|
display: string | null;
|
|
37
37
|
};
|
|
38
|
-
export
|
|
39
|
-
export
|
|
38
|
+
export type ValidatorResultsOutput = ValidatorResults['output'];
|
|
39
|
+
export type ReporterSettings = {
|
|
40
40
|
maxMessageLen: number | null;
|
|
41
41
|
quiet: boolean;
|
|
42
42
|
title: string | null;
|
|
43
43
|
};
|
|
44
|
-
export
|
|
44
|
+
export type ReporterOptions = Partial<ReporterSettings>;
|
|
45
45
|
declare const w3cHtmlValidator: {
|
|
46
46
|
version: string;
|
|
47
47
|
validate(options: ValidatorOptions): Promise<ValidatorResults>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//! w3c-html-validator v1.2.
|
|
1
|
+
//! w3c-html-validator v1.2.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';
|
|
5
5
|
import log from 'fancy-log';
|
|
6
6
|
import request from 'superagent';
|
|
7
7
|
const w3cHtmlValidator = {
|
|
8
|
-
version: '1.2.
|
|
8
|
+
version: '1.2.1',
|
|
9
9
|
validate(options) {
|
|
10
10
|
var _a;
|
|
11
11
|
const defaults = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//! w3c-html-validator v1.2.
|
|
1
|
+
//! w3c-html-validator v1.2.1 ~~ 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.2.
|
|
23
|
+
version: '1.2.1',
|
|
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.2.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Check the markup validity of HTML files using the W3C validator",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -61,20 +61,25 @@
|
|
|
61
61
|
"@typescript-eslint/no-non-null-assertion": "off"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
+
"runScriptsConfig": {
|
|
65
|
+
"build": [
|
|
66
|
+
"rimraf build dist **/.DS_Store",
|
|
67
|
+
"jshint . --exclude-path .gitignore",
|
|
68
|
+
"eslint --max-warnings 0 . --ext .ts",
|
|
69
|
+
"tsc",
|
|
70
|
+
"tsc --module UMD --outDir build/umd",
|
|
71
|
+
"copy-file build/umd/w3c-html-validator.js build/w3c-html-validator.umd.cjs",
|
|
72
|
+
"add-dist-header build dist"
|
|
73
|
+
]
|
|
74
|
+
},
|
|
64
75
|
"scripts": {
|
|
65
|
-
"
|
|
66
|
-
"step:02": "jshint . --exclude-path .gitignore",
|
|
67
|
-
"step:03": "eslint --max-warnings 0 . --ext .ts",
|
|
68
|
-
"step:10": "tsc",
|
|
69
|
-
"step:11": "tsc --module UMD --outDir build/umd",
|
|
70
|
-
"step:12": "copy-file build/umd/w3c-html-validator.js build/w3c-html-validator.umd.cjs",
|
|
71
|
-
"step:20": "add-dist-header build dist",
|
|
72
|
-
"pretest": "npm-run-all step:*",
|
|
76
|
+
"pretest": "run-scripts build",
|
|
73
77
|
"test": "mocha spec/*.spec.js --timeout 5000",
|
|
74
78
|
"examples": "node examples.js"
|
|
75
79
|
},
|
|
76
80
|
"dependencies": {
|
|
77
81
|
"chalk": "~5.1",
|
|
82
|
+
"cli-argv-util": "~0.1",
|
|
78
83
|
"fancy-log": "~2.0",
|
|
79
84
|
"glob": "~8.0",
|
|
80
85
|
"superagent": "~8.0"
|
|
@@ -82,20 +87,20 @@
|
|
|
82
87
|
"devDependencies": {
|
|
83
88
|
"@types/fancy-log": "~2.0",
|
|
84
89
|
"@types/glob": "~8.0",
|
|
85
|
-
"@types/node": "~18.
|
|
90
|
+
"@types/node": "~18.11",
|
|
86
91
|
"@types/superagent": "~4.1",
|
|
87
|
-
"@typescript-eslint/eslint-plugin": "~5.
|
|
88
|
-
"@typescript-eslint/parser": "~5.
|
|
92
|
+
"@typescript-eslint/eslint-plugin": "~5.43",
|
|
93
|
+
"@typescript-eslint/parser": "~5.43",
|
|
89
94
|
"add-dist-header": "~0.3",
|
|
90
95
|
"assert-deep-strict-equal": "~1.0",
|
|
91
96
|
"copy-file-util": "~0.1",
|
|
92
97
|
"copy-folder-util": "~0.2",
|
|
93
|
-
"eslint": "~8.
|
|
98
|
+
"eslint": "~8.28",
|
|
94
99
|
"jshint": "~2.13",
|
|
95
100
|
"merge-stream": "~2.0",
|
|
96
|
-
"mocha": "~10.
|
|
97
|
-
"npm-run-all2": "~6.0",
|
|
101
|
+
"mocha": "~10.1",
|
|
98
102
|
"rimraf": "~3.0",
|
|
99
|
-
"
|
|
103
|
+
"run-scripts-util": "~0.1",
|
|
104
|
+
"typescript": "~4.9"
|
|
100
105
|
}
|
|
101
106
|
}
|