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
1 change: 1 addition & 0 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
- Use ESLint to check for JavaScript errors.
- Rollup is used for building the project.
- Node v20 is used for development.
- Core code is in TypeScript v4.
10 changes: 5 additions & 5 deletions dist/cli/htmlhint.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/cli/htmlhint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ program.on('--help', () => {
console.log(' htmlhint www/test.html')
console.log(' htmlhint www/**/*.xhtml')
console.log(' htmlhint www/**/*.{htm,html}')
console.log(' htmlhint http://www.alibaba.com/')
console.log(' htmlhint https://www.example.com/')
console.log(' cat test.html | htmlhint stdin')
console.log(' htmlhint --list')
console.log(
Expand Down Expand Up @@ -110,13 +110,13 @@ hintTargets(arrTargets, {
// list all rules
function listRules() {
const rules = HTMLHint.rules
let rule
const ruleIds = Object.keys(rules).sort() // Sort rule IDs alphabetically

console.log(' All rules:')
console.log(' ==================================================')

for (const id in rules) {
rule = rules[id]
for (const id of ruleIds) {
const rule = rules[id]
console.log(' %s : %s', chalk.bold(rule.id), rule.description)
}
}
Expand Down
6 changes: 3 additions & 3 deletions test/rules/href-abs-or-rel.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ describe(`Rules: ${ruleId}`, () => {

it('Href value is absolute with abs mode should not result in an error', () => {
const code =
'<a href="http://www.alibaba.com/">aaa</a><a href="https://www.alibaba.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'
'<a href="https://www.example.com/">aaa</a><a href="https://www.example.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'
ruleOptions[ruleId] = 'abs'
const messages = HTMLHint.verify(code, ruleOptions)
expect(messages.length).toBe(0)
})

it('Href value is not relative with rel mode should result in an error', () => {
const code =
'<a href="http://www.alibaba.com/">aaa</a><a href="https://www.alibaba.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'
'<a href="https://www.example.com/">aaa</a><a href="https://www.example.com/">bbb</a><a href="tel:12345678">ccc</a><a href="javascript:void()">ddd</a>'
ruleOptions[ruleId] = 'rel'
const messages = HTMLHint.verify(code, ruleOptions)
expect(messages.length).toBe(2)
Expand All @@ -37,7 +37,7 @@ describe(`Rules: ${ruleId}`, () => {
expect(messages[0].col).toBe(3)
expect(messages[1].rule.id).toBe(ruleId)
expect(messages[1].line).toBe(1)
expect(messages[1].col).toBe(44)
expect(messages[1].col).toBe(45)
})

it('Href value is relative with rel mode should not result in an error', () => {
Expand Down