diff --git a/README.md b/README.md index 99292c1..87f5d0a 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,8 @@ Example terminal commands: $ npm install --save-dev w3c-html-validator $ npx html-validator docs ``` +The above `npx` line validates all the HTML files in the **docs** folder. + You can also install **w3c-html-validator** globally (`--global`) and then run it anywhere directly from the terminal. ### 3. CLI flags @@ -62,17 +64,17 @@ Examples: - `html-validator`
Validate all HTML files in the project. - - `html-validator --exclude=build,tmp`
- Slip all files which have "build" or "tmp" anywhere in their pathname or filename. + - `html-validator docs --exclude=build,tmp`
+ Validate all HTML files in the **docs** folder except files which have "build" or "tmp" anywhere in their pathname or filename. - - `html-validator docs/*.html '--ignore=Trailing slash on void elements'`
+ - `html-validator docs '--ignore=Trailing slash on void elements'`
Allow the ugly slashes of self-closing tags despite XHTML being a hideous scourge on the web. - - `html-validator docs/*.html '--ignore=/^Duplicate ID/'`
+ - `html-validator docs '--ignore=/^Duplicate ID/'`
Use a RegEx (regular expression) to skip all validation messages that start with "Duplicate ID". - - `html-validator docs '--ignore=/^Duplicate ID|^Section lacks|^Element .blockquote. not allowed/'`
- Use a RegEx with "or" operations to skip multiple validation messages. + - `html-validator docs '--ignore=/^Duplicate ID|^Section lacks|^Element .blockquote. not allowed/'`
+ Use a RegEx with "or" operators (`|`) to skip multiple validation messages. - `html-validator --quiet`
Suppress "pass" status messages. @@ -158,7 +160,7 @@ describe('Home page', () => { it('validates', (done) => { const handleResults = (results) => { assert(results.status === 200, 'Request succeeded'); - assert(results.validates, 'Home page validates'); + assert(results.validates, 'Home page validates'); done(); }; const options = { filename: 'docs/index.html' }; @@ -171,7 +173,7 @@ describe('Home page', () => {
--- -**CLI Build Tools** +**CLI Build Tools for package.json** - 🎋 [add-dist-header](https://github.com/center-key/add-dist-header):  _Prepend a one-line banner comment (with license notice) to distribution files_ - 📄 [copy-file-util](https://github.com/center-key/copy-file-util):  _Copy or rename a file with optional package version number_ - 📂 [copy-folder-util](https://github.com/center-key/copy-folder-util):  _Recursively copy files from one folder to another folder_ diff --git a/bin/cli.js b/bin/cli.js index 8fbf16a..a9a0fb6 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -55,9 +55,9 @@ const reporterOptions = { quiet: cli.flagOn.quiet, maxMessageLen: trim, }; -const slashed = /^\/.*\/$/; //starts and ends with a slash indicating it's a regex -const skip = slashed.test(ignore) ? new RegExp(ignore.slice(1, -1)) : ignore; +const isRegex = /^\/.*\/$/; //starts and ends with a slash indicating it's a regex +const skip = isRegex.test(ignore) ? new RegExp(ignore.slice(1, -1)) : ignore; const handleReport = (report) => w3cHtmlValidator.reporter(report, reporterOptions); -const options = (file) => ({ filename: file, ignoreMessages: skip }); -const getReport = (file) => w3cHtmlValidator.validate(options(file)).then(handleReport); +const options = (filename) => ({ filename: filename, ignoreMessages: skip }); +const getReport = (filename) => w3cHtmlValidator.validate(options(filename)).then(handleReport); filenames.forEach((filename, i) => globalThis.setTimeout(() => getReport(filename), i * delay)); diff --git a/package.json b/package.json index 89bb6f4..0421d20 100644 --- a/package.json +++ b/package.json @@ -88,15 +88,15 @@ "devDependencies": { "@types/fancy-log": "~2.0", "@types/glob": "~8.1", - "@types/node": "~20.5", + "@types/node": "~20.6", "@types/superagent": "~4.1", - "@typescript-eslint/eslint-plugin": "~6.6", - "@typescript-eslint/parser": "~6.6", + "@typescript-eslint/eslint-plugin": "~6.7", + "@typescript-eslint/parser": "~6.7", "add-dist-header": "~1.3", "assert-deep-strict-equal": "~1.1", "copy-file-util": "~1.1", "copy-folder-util": "~1.1", - "eslint": "~8.48", + "eslint": "~8.49", "jshint": "~2.13", "merge-stream": "~2.0", "mocha": "~10.2",