-
lefthook으로 커밋할 때 포맷팅 자동화하기기록이라도 하자 2024. 6. 30. 23:19
- lefthook 로컬에서 실행시키기
lefthook run pre-commit
- lefthook 설정하기
# lefthook run pre-commit pre-commit: piped: true commands: lint: priority: 1 glob: "*.{js,ts,jsx,tsx}" run: pnpm eslint --cache --fix {staged_files} stage_fixed: true format: priority: 2 glob: "*.{js,ts,jsx,tsx,json,md}" run: pnpm prettier --write --cache {staged_files} stage_fixed: true # lefthook run pre-push pre-push: parallel: true commands: test: run: pnpm jest -o build: run: pnpm build
* stage_fixed를 사용하면 자동으로 eslint, prettier에서 수정한 코드를 함께 커밋시켜준다
* staged_files, push_files등 다양한 값 제공하며, 병렬 처리도 가능해서 사용하기 좋았ㄷㅏ
* 단순 piped: true만으로는 순차실행이 되지 않아서 priority 값을 지정했다.
* https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
'기록이라도 하자' 카테고리의 다른 글
스타일 관련 작업 가이드 (1) 2024.06.30 Tailwind 동적 클래스 생성이 동작하지 않을 때 (0) 2023.12.20 Netlify Git Branch 이름 기준으로 배포 무시하기 (netlify ignore) (1) 2023.10.17 빌드시 메모리 부족으로 빌드 실패하는 현상 해결 (1) 2023.10.07 드러커 엑서사이즈 (0) 2023.10.02