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

chore: add pre-commit hook that does eslint before commit only on files that has been changed #15753

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

peter-sanderson
Copy link
Contributor

@peter-sanderson peter-sanderson commented Dec 3, 2024


if ! bash "$script_dir/eslint.sh"; then
exit 1
fi
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jvaclavik you can add precommit hook for commit message after that here. I tried and got some ugly error so I leave it to you :D

@@ -84,17 +85,8 @@
"ios": "yarn native:ios",
"p": "yarn native:prebuild",
"ports": "yarn native:reverse-ports",
"s": "yarn native:start"
},
"lint-staged": {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to me as dead code. I have checked the lint-staged library and I do not think we need it. The simple script shall work the same way. Or am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I came across lint-staged I tried to make it work, but didn't succeed.


script_dir=$(dirname "$(realpath "$0")")

if ! bash "$script_dir/eslint.sh"; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also prettier shall be somehow added

Copy link

github-actions bot commented Dec 3, 2024

🚀 Expo preview is ready!

  • Project → trezor-suite-preview
  • Platforms → android, ios
  • Scheme → trezorsuitelite
  • Runtime Version → 17
  • More info

Learn more about 𝝠 Expo Github Action

.husky/eslint.sh Outdated
@@ -0,0 +1,23 @@
#!/bin/bash

STAGED_FILED=$(git diff --cached --name-only --diff-filter=d | grep '(\.js\|\.jsx$\|\.ts\|\.tsx)$')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo (FILED)

@peter-sanderson peter-sanderson force-pushed the hook-pre-commit-eslint-fix branch 2 times, most recently from ff6b39f to fbf38a2 Compare December 3, 2024 19:59
Copy link
Contributor

@jvaclavik jvaclavik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

package.json Show resolved Hide resolved
@@ -19,7 +19,7 @@
},
"scripts": {
"_______ Hooks _______": "Yarn hooks.",
"postinstall": "yarn run patch-package",
"postinstall": "yarn run patch-package && husky",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# Yarn doesn't support `prepare`

See: https://typicode.github.io/husky/how-to.html#manual-setup

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