Prettier를 단일 파일에만 수동으로 적용하고 싶을 때
2025. 5. 19. 17:01ㆍVue 실습
728x90
단일 파일에만 Prettier 실행하기
경로 지정 방식
1. 절대 경로
- 프로젝트 루트부터 시작하는 전체 경로를 그대로 적습니다.
- 예: /c/Users/admin/Desktop/user/remote-maestro-user/src/.../SecurityGroupSelect.vue
# 예시 (Git Bash 절대 경로)
yarn prettier --write "/c/Users/admin/Desktop/user/remote-maestro-user/src/views/workspace/serviceCatalog/service/resource-request/components/AWS/ui/SecurityGroupSelect.vue"
2. 상대 경로
- 현재 터미널(CWD: Current Working Directory)이 프로젝트 루트(remote-maestro-user)라고 가정할 때, src/...부터 적습니다.
- 예: src/views/.../SecurityGroupSelect.vue
# 예시 (Git Bash 상대 경로)
yarn prettier --write "src/views/workspace/serviceCatalog/service/resource-request/components/AWS/ui/SecurityGroupSelect.vue"
Tip(Windows Git Bash 한정)
- 경로를 '\'(백슬래시) 대신 '/'(슬래시)로 입력해야 합니다.
- 만약 Windows CMD나 PowerShell이라면 \로 작성해도 동작하지만, Git Bash에서는 /를 쓰는 편이 안전합니다.
따옴표(Quotation) 처리
- **큰따옴표(")**나 **작은따옴표(')**를 파일 경로에 감싸는 이유는, 경로에 공백(space)이나 특수문자(예: &, (, ))가 포함될 때 터미널이 온전히 하나의 인수(argument)로 인식하게 하기 위함입니다.
- 일반적으로 Windows Git Bash에서는 큰따옴표를 사용하고, 만약 중간에 따옴표를 또 써야 할 상황이 생기면 작은따옴표를 조합할 수도 있습니다.
# 따옴표를 쓰지 않으면 아래와 같이 공백 때문에 인식 실패 가능
yarn prettier --write src/views/workspace/serviceCatalog/service/resource-request/components/AWS/ui/SecurityGroupSelect.vue
# 보통은 이렇게 큰따옴표로 감싸는 편
yarn prettier --write "src/views/workspace/serviceCatalog/service/resource-request/components/AWS/ui/SecurityGroupSelect.vue"
--write 옵션 외 자주 쓰는 옵션
- --check
- 파일을 실제 수정하지 않고, “포맷팅이 필요한지”만 검사합니다.
- 예:
# 단일 파일 검사
npx prettier --check "src/views/.../SecurityGroupSelect.vue"
# 여러 파일 검사 (글로벌 패턴)
npx prettier --check "src/**/*.{js,ts,vue}"
- --list-different
- --check와 유사하지만, 포맷이 달라서 수정이 필요한 파일 목록만 출력합니다.
- 예:
npx prettier --list-different "src/**/*.js"
- --config <경로>
- 기본적으로 프로젝트 루트에 있는 .prettierrc(또는 prettier.config.js)를 참조하지만, 특정 설정 파일을 따로 지정하려면 이 옵션을 쓸 수 있습니다.
- 예:
yarn prettier --config "./configs/my-prettier-config.json" --write "src/..."
- --ignore-path <파일>
- 기본적으로 .prettierignore 파일을 찾아 사용합니다.
- 다른 이름의 ignore 파일을 쓰고 싶을 때 지정합니다.
- 예:
yarn prettier --ignore-path ".custom-prettierignore" --write "src/..."
728x90
'Vue 실습' 카테고리의 다른 글
[Vue.js] 재귀를 이용한 댓글 구현 (0) | 2025.03.07 |
---|---|
[모듈 페더레이션]mhome과 remote2를 연결하여 모듈 페더레이션 by vue.cofig.js (0) | 2024.12.31 |
[모듈 페더레이션과 모노레포 구성] vite(host) + webpack(remote)로 모둘 페더레이션 구성 - 1 (0) | 2024.12.29 |
모노레포 구성 정리 (0) | 2024.12.24 |
[vue.js] components을 이용한 동적 렌더링 - 1 (2) | 2024.12.07 |