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

Fix Pre-push hook to disallow improper formatting #78

Merged
merged 2 commits into from
May 15, 2020
Merged

Conversation

JasonChong96
Copy link
Contributor

Problem

The current pre-push hook runs npm run lint which runs eslint with the --fix flag. This allows the linter to run successfully even though the pushed code contains formatting issues that are fixed by the --fix flag. Since the commit has already been done, the flag does nothing to truly resolve the issue.

Closes [#75]

Solution

  • Changed the lint/lint-ts/lint-js scripts to exclude the --fix flag.
  • Added lint:fix/lint-ts:fix/lint-js:fix which include the --fix flag.

This way, the pre-push hook will be running the linter without the --fix flag and disallow improper formatting from getting pushed.

Tests

  1. Change any .ts/.js file to have 4 space indentation
  2. Create a commit
  3. Attempt to push to upstream (Github)
  4. The pre-push commit should exit with a non-zero exit code and the code should not be pushed.

@JasonChong96 JasonChong96 requested a review from liangyuanruo May 14, 2020 04:12
package.json Show resolved Hide resolved
@JasonChong96 JasonChong96 requested a review from yong-jie May 14, 2020 11:04
@JasonChong96 JasonChong96 merged commit 72359b3 into develop May 15, 2020
@JasonChong96 JasonChong96 deleted the husky-fix branch May 15, 2020 08:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants