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

lint flag to make warnings exit with non-zero #853

Closed
georgevarghese185 opened this issue Sep 6, 2020 · 2 comments · Fixed by #858
Closed

lint flag to make warnings exit with non-zero #853

georgevarghese185 opened this issue Sep 6, 2020 · 2 comments · Fixed by #858
Labels
kind: feature New feature or request PR welcome

Comments

@georgevarghese185
Copy link
Contributor

georgevarghese185 commented Sep 6, 2020

Current Behavior

If you have lint warnings and run yarn lint or tsdx lint, the warnings are printed but the command exits without an error

Desired Behavior

It would be nice to have tsdx lint take a flag to exit with a non-zero code if warnings are found so that a pre-commit hook can prevent a commit from going through and require the user to fix the warnings.

Who does this impact? Who is this for?

This is for people who want to force all lint errors and warnings to be cleared before committing code.

@georgevarghese185 georgevarghese185 changed the title Optional lint flag to require warnings to be fixed Feature request: Optional lint flag to require warnings to be fixed Sep 6, 2020
@agilgur5 agilgur5 changed the title Feature request: Optional lint flag to require warnings to be fixed lint flag to require warnings to be fixed Sep 7, 2020
@agilgur5 agilgur5 added the kind: feature New feature or request label Sep 7, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Sep 7, 2020

ESLint has the --max-warnings flag, but it seems like there is no config option via eslintrc for this -- that would be optimal.

Without such a change upstream TSDX would need to forward the flag. Would prefer to forward all flags to ESLint as we do with tsdx test and Jest but IIRC there's a limitation; had thought to do so some time ago

@agilgur5 agilgur5 changed the title lint flag to require warnings to be fixed lint flag to make warnings exit with non-zero Sep 7, 2020
@agilgur5
Copy link
Collaborator

agilgur5 commented Sep 16, 2020

Ah, right, we use ESLint's CLIEngine API, which doesn't support all flags or converting all flags 😕

That being said, --max-warnings would be fairly easy to implement in TSDX. Can use report.warningCount and add a small check after this line:

https://github.com/formium/tsdx/blob/116a043a221ef5a8d8dd3db0453c0b864fe3c368/src/index.ts#L597-L599

Would welcome a PR for --max-warnings along with a test and update to API docs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New feature or request PR welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants