-
Notifications
You must be signed in to change notification settings - Fork 789
Description
🚀 Feature request
Description
I want to use multiple formatters for my report, e.g.
htmlformatter to generatehint-report/mysite.htmljsonformatter to generatehint-report/output.jsoncodeframeformatter for logs during executionsummaryformatter for logs during execution
Details
Today, if I specify a --output parameter, then this will throw errors, because json codeframe and summary all try to write to the same file.
html correctly generates a dynamic file name, allowing me to use it + another one.
I need to be able to tell each formatter whether to output to file: html yes, json yes (preferably with a different path than html), codeframe no, and summary no; because I want the latter two to output to console.
As a workaround, I've had to replace formatters: ["html"] with formatters: ["./path/to/custom-html.js"] and this implementation:
import HTMLFormatter from '@hint/formatter-html';
import type { Problem } from '@hint/utils-types';
import type { FormatterOptions } from 'hint';
export default class PatchedHTMLFormatter extends HTMLFormatter.default {
override format(
problems: Problem[],
options: FormatterOptions = {},
): ReturnType<HTMLFormatter.default['format']> {
return super.format(problems, {
...options,
output: options.output ?? 'MY/CUSTOM/PATH/HERE', // <-- ⚠️
});
}
}This isn't ideal, but hopefully it unblocks anyone else experiencing this error.
The optimal solution is likely to pass { "name": "html", "options": { "output": "..." } } the same way connectors supports options.