-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Best way to ensure no console.log on precommit? #4684
Comments
Can you elaborate a little bit more on your question? |
With Husky and Lint-staged, you can run commands with a precommit hook, for example Prettier, Flow, ESLint, etc. In doing so, if you have a Flow or ESLint error in your code, Husky will block the commit process. I do it inside projects bootstrapped with CRA and it works pretty well. Now I'd like to block the commit process if there are remaining The easiest way would be to add https://eslint.org/docs/rules/no-console to the ESLint config. But we can't edit this config without ejecting. So I'm wondering how people achieve this. |
Sure, its actually fairly simple:
|
@bugzpodder, I see no fix option for https://eslint.org/docs/rules/no-console compare to |
Yes, it will not automatically fix it. So if you left out a console.log in your code, precommit with eslint --fix will fail if you have the no-console enabled and the developer needs to manually addreess it by removing it or add an eslint-ignore comment. This should address the author's intent of blocking commits with console.log. The --fix option is meant to address the other most common issues. |
@bugzpodder It sounds good. Let me try it then I'll close the issue. :) |
Question
Since we can't update the ESLint config without ejecting, I'm curious how people achieve this?
Run something like detect-log with Husky?
The text was updated successfully, but these errors were encountered: