Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop after first N error messages #166

Open
Qix- opened this issue Nov 18, 2016 · 8 comments
Open

Stop after first N error messages #166

Qix- opened this issue Nov 18, 2016 · 8 comments

Comments

@Qix-
Copy link

Qix- commented Nov 18, 2016

So. Made the mistake of including a few of Stack Overflow's generated Javascript files in a repository for a few tests (long story, yes they belong there) but forgot XO recurses into directories (as it should!).

However, the result was... well, terrifying. It locked up my terminal and just puked error messages.

Dear god send help

Just like with Clang, we should stop after N error messages (like.. idk, 100?) or else I could have let this go on for hours (okay, maybe tens of minutes) with no control (ultimately had to open up another terminal and kill xo manually).

@sindresorhus
Copy link
Member

Hmm, weird. Why would it hang your terminal? I've had that happened before to and simple did Ctrl+C.

@Qix-
Copy link
Author

Qix- commented Nov 18, 2016

Control+C did not work :( Might have been because it was running through NPM instead of directly?

@vadimdemedes
Copy link

I think this is a nice idea. But I'd increase the N to something way bigger (like 300?), so that behavior kicks in less often. When N is >= 300, we stop the linter (not sure if that's possible though), print errors and show some message telling that there are more errors.

@sindresorhus sindresorhus changed the title Stop after first N error messages. Stop after first N error messages Jan 5, 2017
@YuvalGat
Copy link

YuvalGat commented Sep 24, 2018

An option idea, closing this issue: xo file.js will, by default, limit the number of error messages printed to 300. The new option, called --limit, will work as follows:

  • xo file.js --limit=N will limit the number of error messages to N.
  • xo file.js --limit=0 will print all error messages.

If this option seems like a good idea, I can start working on it.

@YuvalGat
Copy link

@sindresorhus Would love to hear your opinion on the idea above ^^ 😄

@sindresorhus
Copy link
Member

Sounds ok. I don't see any point in having a way to set the limit. I would make it have a limit of 1000 by default (so it won't affect normal usage) and add a --no-limit flag to disable the limit.

@pvdlg
Copy link
Contributor

pvdlg commented Oct 7, 2018

To solve the situation described above where too many errors are printed in the output, should one just use Ctrl+C to stop the process?
And if Ctrl+C doesn't work, maybe we should fix that, rather than limiting the output.

There is cases where you want to output all the errors, like when XO run on a CI (so you want to look at the logs afterward) and you have a lot of legacy linting errors that you are progressively fixing.

@Qix-
Copy link
Author

Qix- commented Oct 7, 2018

@pvdlg Not so simple. If the program has already outputted its text, Ctrl+C does nothing until the terminal emulator catches up. That's what most people face when seeing this class of problem.

This is why you want to limit the source of the errors.

@sindresorhus another alternative is to check trows and output that many errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants