w3c-html-validator 1.8.2 → 1.9.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021-2024 Individual contributors to w3c-html-validator
3
+ Copyright (c) 2021-2025 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
@@ -158,7 +158,7 @@ Setting `ignoreLevel` to `'warning'` skips both `'warning'` level and `'info'` l
158
158
 
159
159
  ### 3. TypeScript declarations
160
160
  See the TypeScript declarations at the top of the
161
- [w3c-html-validator.ts](w3c-html-validator.ts) file.
161
+ [w3c-html-validator.ts](src/w3c-html-validator.ts) file.
162
162
 
163
163
  The output of the `w3cHtmlValidator.validate(options: ValidatorOptions)` function is a **promise**
164
164
  for a `ValidatorResults` object:
package/bin/cli.js CHANGED
@@ -29,25 +29,23 @@ import fs from 'fs';
29
29
  import slash from 'slash';
30
30
 
31
31
  // Parameters and flags
32
- const validFlags = ['continue', 'delay', 'dry-run', 'exclude', 'ignore', 'ignore-config', 'note', 'quiet', 'trim'];
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) : ['.'];
35
36
  const ignore = cli.flagMap.ignore ?? null;
36
37
  const ignoreConfig = cli.flagMap.ignoreConfig ?? null;
37
38
  const delay = Number(cli.flagMap.delay) || 500; //default half second debounce pause
38
39
  const trim = Number(cli.flagMap.trim) || null;
39
40
  const dryRunMode = cli.flagOn.dryRun || process.env.w3cHtmlValidator === 'dry-run'; //bash: export w3cHtmlValidator=dry-run
40
41
 
41
- // Validator
42
- const globOptions = { ignore: '**/node_modules/**/*' };
43
- const keep = (filename) => !filename.includes('node_modules/');
44
- const readFolder = (folder) => globSync(slash(folder + '**/*.html'), globOptions);
45
- const getAllPaths = () => files.map(file => globSync(slash(file), globOptions)).flat();
46
- const expandFolder = (file) => fs.lstatSync(file).isDirectory() ? readFolder(file + '/') : file;
47
- const getFilenames = () => getAllPaths().map(expandFolder).flat().filter(keep).sort();
48
- const list = files.length ? getFilenames() : readFolder('');
49
- const excludes = cli.flagMap.exclude?.split(',') ?? [];
50
- const filenames = list.filter(name => !excludes.find(exclude => name.includes(exclude)));
42
+ const getFilenames = () => {
43
+ const readFilenames = (file) => globSync(file, { ignore: '**/node_modules/**/*' }).map(slash);
44
+ const readHtmlFiles = (folder) => readFilenames(folder + '/**/*.html');
45
+ const addHtml = (file) => fs.lstatSync(file).isDirectory() ? readHtmlFiles(file) : file;
46
+ return files.map(readFilenames).flat().map(addHtml).flat().sort();
47
+ };
48
+ const filenames = getFilenames();
51
49
  const error =
52
50
  cli.invalidFlag ? cli.invalidFlagMsg :
53
51
  !filenames.length ? 'No files to validate.' :
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v1.8.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.9.0 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
2
2
 
3
3
  export type ValidatorSettings = {
4
4
  html: string;
@@ -1,4 +1,4 @@
1
- //! w3c-html-validator v1.8.2 ~~ https://github.com/center-key/w3c-html-validator ~~ MIT License
1
+ //! w3c-html-validator v1.9.0 ~~ 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.2',
9
+ version: '1.9.0',
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('[w3c-html-validator] Invalid results for reporter(): ' + String(results));
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('[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.2",
3
+ "version": "1.9.0",
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.3",
61
- "cli-argv-util": "~1.2",
60
+ "chalk": "~5.4",
61
+ "cli-argv-util": "~1.3",
62
62
  "fancy-log": "~2.0",
63
63
  "glob": "~11.0",
64
64
  "slash": "~5.1",
65
- "superagent": "~9.0"
65
+ "superagent": "~10.2"
66
66
  },
67
67
  "devDependencies": {
68
- "@eslint/js": "~9.9",
68
+ "@eslint/js": "~9.30",
69
69
  "@types/fancy-log": "~2.0",
70
- "@types/node": "~22.2",
70
+ "@types/node": "~24.0",
71
71
  "@types/superagent": "~8.1",
72
72
  "add-dist-header": "~1.4",
73
73
  "assert-deep-strict-equal": "~1.2",
74
74
  "copy-file-util": "~1.2",
75
75
  "copy-folder-util": "~1.1",
76
- "eslint": "~9.9",
76
+ "eslint": "~9.30",
77
77
  "jshint": "~2.13",
78
78
  "merge-stream": "~2.0",
79
- "mocha": "~10.7",
79
+ "mocha": "~11.7",
80
80
  "rimraf": "~6.0",
81
81
  "run-scripts-util": "~1.3",
82
- "typescript": "~5.5",
83
- "typescript-eslint": "~8.0"
82
+ "typescript": "~5.8",
83
+ "typescript-eslint": "~8.36"
84
84
  }
85
85
  }