How to produce less logging output when running via lint-staged?
See original GitHub issueHello, thank you for this awesome project! 👋
I’m finding that the default reporter produces a lot of duplication when running it with lint-staged:
\ | / _ _ _
'-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __
---ooooo--- | '_ \/ _ \ __| __/ _ \ '__/ _ \ '__|
.-'ooo'-. | |_)| __/ |_| || __/ | | __/ |
/ | \ |_.__/\___|\__|\__\___|_| \___|_|
🌟 Betterer (12ms): 14 tests running...
🤔 test1: running "test1"!
🤔 test2: running "test2"!
\ | / _ _ _
'-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __
---ooooo--- | '_ \/ _ \ __| __/ _ \ '__/ _ \ '__|
.-'ooo'-. | |_)| __/ |_| || __/ | | __/ |
/ | \ |_.__/\___|\__|\__\___|_| \___|_|
🌟 Betterer (112ms): 14 tests running...
🤔 test1: running "test1"!
🤔 test2: running "test2"!
\ | / _ _ _
'-.ooo.-' | |__ ___| |_| |_ ___ _ __ ___ _ __
---ooooo--- | '_ \/ _ \ __| __/ _ \ '__/ _ \ '__|
.-'ooo'-. | |_)| __/ |_| || __/ | | __/ |
/ | \ |_.__/\___|\__|\__\___|_| \___|_|
🌟 Betterer (214ms): 14 tests running...
🤔 test1: running "test1"!
🤔 test2: running "test2"!
I guess this is due to refreshing the screen which doesn’t work the same way in a non interactive mode?
This output is normally hidden, but if the code got worse then I would see a lot of logging output mixed in with the error message, which is not ideal.
I’ve tried to write a console reporter to replace the default reporter, with the following code:
import { BettererReporter } from '@betterer/betterer';
export const reporter: BettererReporter = createReporter();
function createReporter (): BettererReporter {
return {
contextError (ctx, error) {
console.error(error);
}
}
}
However this doesn’t produce any output, betterer
exits with 1. I’ve tried running this under Node 12, 14 & 16 with the same result.
Is there an alternative reporter I could use to print errors only? Or did I miss something from my custom reporter definition?
Many thanks 🙂
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (3 by maintainers)
Hmm okay, there’s definitely something weird going on because that’s pretty much what it should be printing. I’ll dig in a little bit more.
For this particular case though, you might want to use
@betterer/eslint
and use https://eslint.org/docs/rules/no-console#no-console and https://eslint.org/docs/rules/no-restricted-imports or https://eslint.org/docs/rules/no-restricted-properties ?Thanks, I’ll give that a try. 🙂