다음은 자주 사용하는 Prettier 설정 파일(.prettierrc)의 예시와 각 설정에 대한 설명입니다:
{
"printWidth": 80,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "es5",
"bracketSpacing": true,
"jsxBracketSameLine": false,
"arrowParens": "always",
"endOfLine": "lf"
}
각 설정의 의미는 다음과 같습니다:
printWidth: 80
tabWidth: 2
useTabs: false
semi: true
singleQuote: true
trailingComma: "es5"
es5: 객체, 배열 등에서 후행 쉼표를 사용none: 후행 쉼표를 사용하지 않음all: 가능한 모든 곳에 후행 쉼표를 사용bracketSpacing: true
{ foo: bar }jsxBracketSameLine: false
>를 다음 줄로 내립니다.false: <div
className="example"
>true: <div
className="example">arrowParens: "always"
(x) => xendOfLine: "lf"
이 설정을 적용하면, 일관된 코드 스타일을 유지할 수 있어 코드의 가독성과 유지보수성을 높일 수 있습니다. Prettier는 이러한 설정을 통해 코드 포맷팅을 자동으로 관리해주므로 개발자는 코드의 내용에 집중할 수 있습니다.