Skip to content

Commit 1f82e78

Browse files
committed
fix: display validation links inline
closes #39
1 parent f2a5db9 commit 1f82e78

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

src/validator.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,17 @@ export const useChecker = (
5050
? await import('html-validate/dist/formatters/codeframe').then(r => r.default || /* istanbul ignore next */ r)
5151
: await import('html-validate/dist/formatters/stylish').then(r => r.default || /* istanbul ignore next */ r)
5252

53-
const formattedResult = formatter(results)
53+
const rules = Array.from(new Set(results[0]?.messages.map(({ ruleId }) => ruleId)))
5454

55-
const urls =
56-
results[0]?.messages.map(
57-
({ ruleId }: any) => `https://html-validate.org/rules/${ruleId}.html`
58-
) || []
55+
let formattedResult = formatter(results)
56+
rules.forEach((ruleId) => {
57+
formattedResult = formattedResult.replace(new RegExp(ruleId, 'g'), `https://html-validate.org/rules/${ruleId}.html`)
58+
})
5959

6060
reporter.error(
6161
[
6262
`HTML validation errors found for ${chalk.bold(url)}`,
63-
formattedResult,
64-
urls.length ? `${chalk.bold('More information:')}` : '',
65-
...urls
63+
formattedResult
6664
].join('\n')
6765
)
6866
}

0 commit comments

Comments
 (0)