Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions dist/cli/formatter.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 8 additions & 11 deletions dist/cli/htmlhint.js

Large diffs are not rendered by default.

94 changes: 57 additions & 37 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"async": "3.2.6",
"chalk": "4.1.2",
"commander": "11.1.0",
"glob": "^8.1.0",
"glob": "^9.0.0",
"is-glob": "^4.0.3",
"node-sarif-builder": "^3.2.0",
"strip-json-comments": "3.1.1",
Expand All @@ -62,7 +62,6 @@
"@rollup/plugin-node-resolve": "16.0.1",
"@rollup/plugin-terser": "^0.4.4",
"@types/async": "^3.2.25",
"@types/glob": "^8.1.0",
"@types/is-glob": "4.0.4",
"@types/xml": "^1.0.11",
"@typescript-eslint/eslint-plugin": "8.43.0",
Expand Down
4 changes: 1 addition & 3 deletions src/cli/formatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import * as chalk from 'chalk'
import { EventEmitter } from 'events'
import { sync as globSync } from 'glob'
import { globSync } from 'glob'
import { parse, resolve } from 'path'
import type { HTMLHint as IHTMLHint } from '../core/core'
import type { Hint, Ruleset } from '../core/types'
Expand All @@ -24,8 +24,6 @@ function loadFormatters() {
cwd: __dirname,
dot: false,
nodir: true,
strict: false,
silent: true,
})

const mapFormatters: { [name: string]: FormatterCallback } = {}
Expand Down
35 changes: 14 additions & 21 deletions src/cli/htmlhint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import { queue as asyncQueue, series as asyncSeries } from 'async'
import * as chalk from 'chalk'
import { Command } from 'commander'
import { existsSync, readFileSync, statSync, writeFileSync } from 'fs'
import * as glob from 'glob'
import { IGlob } from 'glob'
import { globStream, globSync } from 'glob'
import { parseGlob } from './parse-glob'
import { dirname, resolve, sep } from 'path'
// Native fetch is available in Node.js 18+
Expand Down Expand Up @@ -223,13 +222,11 @@ function loadCustomRules(rulesdir: string) {
if (statSync(rulesdir).isDirectory()) {
rulesdir += /\/$/.test(rulesdir) ? '' : '/'
rulesdir += '**/*.js'
const arrFiles = glob.sync(rulesdir, {
const arrFiles = globSync(rulesdir, {
dot: false,
nodir: true,
strict: false,
silent: true,
})
arrFiles.forEach((file) => {
arrFiles.forEach((file: string) => {
Copy link

Copilot AI Sep 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The explicit type annotation string is redundant here. TypeScript can infer the type from globSync() return value, and the original code didn't have this annotation.

Suggested change
arrFiles.forEach((file: string) => {
arrFiles.forEach((file) => {

Copilot uses AI. Check for mistakes.
loadRule(file)
})
} else {
Expand Down Expand Up @@ -467,22 +464,14 @@ function walkPath(
})
}

const walk: IGlob = glob(
pattern,
{
cwd: base,
dot: false,
ignore: arrIgnores,
nodir: true,
strict: false,
silent: true,
},
() => {
onFinish()
}
)
const walk = globStream(pattern, {
cwd: base,
dot: false,
ignore: arrIgnores,
nodir: true,
})

walk.on('match', (file: string) => {
walk.on('data', (file: string) => {
base = base.replace(/^.\//, '')

if (sep !== '/') {
Expand All @@ -491,6 +480,10 @@ function walkPath(

callback(base + file)
})

walk.on('end', () => {
onFinish()
})
}

// hint file
Expand Down
4 changes: 2 additions & 2 deletions test/cli/formatters/sarif.sarif
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"helpUri": "https://htmlhint.com/rules/attr-no-duplication",
"help": {
"text": "Elements cannot have duplicate attributes.",
"markdown": "\nThe same attribute can't be specified twice.\n\nLevel: Error\n\n## Config value\n\n- `true`: enable rule\n- `false`: disable rule\n\n### The following patterns are **not** considered rule violations\n\n```html\n`<img src=\"a.png\" />`\n```\n\n### The following pattern is considered a rule violation:\n\n```html\n`<img src=\"a.png\" src=\"b.png\" />`\n```"
"markdown": "\nThe same attribute can't be specified twice.\n\nLevel: Error\n\n## Config value\n\n- `true`: enable rule\n- `false`: disable rule\n\n### The following patterns are **not** considered rule violations\n\n```html\n`<img src=\"a.png\" />`\n```\n\n### The following pattern is considered a rule violation:\n\n```html\n`<img src=\"a.png\" src=\"b.png\" />`\n```\n\n### Why this rule is important\n\nDuplicate attributes can cause unexpected behavior and make the code harder to read and maintain."
}
},
{
Expand All @@ -52,7 +52,7 @@
}
}
],
"version": "1.5.1",
"version": "1.7.0",
"informationUri": "https://htmlhint.com/"
}
},
Expand Down
3 changes: 0 additions & 3 deletions website/.htmlhintrc
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
"frame-title-require": true,
"h1-require": true,
"head-script-disabled": false,
"href-abs-or-rel": false,
"html-lang-require": true,
"id-class-ad-disabled": true,
"id-class-value": false,
"id-unique": true,
"inline-script-disabled": false,
"inline-style-disabled": false,
Expand All @@ -29,7 +27,6 @@
"meta-description-require": true,
"meta-viewport-require": true,
"script-disabled": false,
"space-tab-mixed-disabled": false,
"spec-char-escape": false,
"src-not-empty": true,
"style-disabled": false,
Expand Down
Loading