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-commit bug #68

Open
skgndi12 opened this issue Oct 26, 2023 · 3 comments
Open

Fix pre-commit bug #68

skgndi12 opened this issue Oct 26, 2023 · 3 comments
Assignees
Labels
bug Something isn't working ui Something about UI

Comments

@skgndi12
Copy link
Collaborator

문제 상황

api 내에서 작업한 내용을 커밋하려고 했을때, 다음과 같은 에러 로그가 뜨며 커밋에 실패했습니다.

> git -c user.useConfigOnly=true commit --quiet --allow-empty-message --file -
file:///Users/gimseong-won/coding/Mr.C/ui/node_modules/listr2/dist/index.js:206
    this.options.fields ??= {};
                        ^^^

SyntaxError: Unexpected token '??='
    at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
husky - pre-commit hook exited with code 1 (error)

대처한 내용

상황을 @2wheeh 님에게 공유드렸고, 논의한 결과 commit 하기 전에 stage 된 변경사항의 linting 작업을 수행하는 husky 의 버그인 것 같다는 잠정적 결론이 나왔습니다. 이후, husky 를 임시로 제거 조치하고나서는 정상적으로 commit 이 되는 것도 확인했습니다. 조치한 내용은 임시적이고 추후 확실한 대처는 @2wheeh 께서 맡기로 하셨습니다.

@skgndi12 skgndi12 added bug Something isn't working ui Something about UI labels Oct 26, 2023
@skgndi12
Copy link
Collaborator Author

skgndi12 commented Nov 8, 2023

에러가 발생한 PR: #59
에러가 발생한 Commit: bd75f8c

@2wheeh
Copy link
Collaborator

2wheeh commented Nov 8, 2023

현재 huskypre-commit hook을 통해 lint-staged 를 실행하고 있는데,
이때 lint-staged 에서 발생하는 문제입니다.

아래는 해당 에러 로그에 관련된 lint-staged 의 이슈 링크입니다.
lint-staged/lint-staged#1315
lint-staged/lint-staged#1313

최신 버전의 lint-staged 가 node v14 에 대한 지원을 중단하면서 발생한 에러로 얘기하는데, 왜 우리 환경에서 발생했는 지는 잘모르겠네요... (**현재 재현 안됨 😕)

혹시나 이 에러가 반복해서 발생하면 lint-staged 쪽 이슈를 트래킹 해보겠습니다.
그때를 대비해서 이슈는 계속 열어두겠습니다.

@2wheeh
Copy link
Collaborator

2wheeh commented Nov 9, 2023

별개로, api 에서 git hooks 기능을 사용하게 되면 새로운 세팅이 필요해보입니다.

아래 내용 참고 부탁드립니다.

.git/hooks 디렉토리는 git 의 특정 이벤트(ex. pre-commit)에 트리거되는 hooks 스크립트 파일들의 default 경로 입니다. .git/hooks는 리포지토리에서 관리되지 않고 IDE에도 표시되지 않으므로 husky 는 이 경로를 .husky 로 변경하는 방식입니다. (참고: git-config.txt-corehooksPath)

Mr.C 의 경우 api와 ui 가 공통으로 사용하는 .git 의 hooks 경로를 ui/.husky 로 변경합니다.

따라서 공통으로 사용하는 .githooks 가 ui 디렉토리 내부에 의존하므로, api 에서 git hooks 기능이 필요하게 되면 husky (혹은 커스텀한 hooks 폴더)의 경로를 최상단(api와 ui 의 밖)으로 옮겨야 합니다.

yarn remove husky && git config --unset core.hooksPath # husky 제거 시
git config core.hooksPath [--fixed-value] # core.hooksPath 설정 시

(참고: uninstall, githooks#_description)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ui Something about UI
Projects
Status: Done
Development

No branches or pull requests

2 participants