작성한 코드
rules: {
// eslint-disable-next-line @typescript-eslint/naming-convention
"@typescript-eslint/naming-convention": [
"warn",
{
selector: "typeAlias", // 타입선언
format: ["PascalCase"],
},
{
selector: "memberLike", // Property 멤버
format: ["camelCase"],
},
{
selector: "function", // exported function (컴포넌트 명)
format: ["PascalCase"],
modifiers: ["exported"],
},
{
selector: "function", // function
format: ["camelCase"],
},
],
},
selector는 naming convention을 적용하고자 하는 target을 말한다.
format은 convention format을 말한다. 여러가지를 설정하게 할 수도 있다.
modifiers는 특정 영역만 설정하고자 할 때 적용한다. 위에서는 컴포넌트의 가장 최상단에 export function ComponentName 형태로 할때만 Pascal 형태로 먹히게 하고자 설정하였다.
하단에 하나 function에 대해 camelCase로 해두어서, 내부에서 사용하는 function은 모두 소문자가 가능하도록 설정함.
참고 :
https://typescript-eslint.io/rules/naming-convention/#selector-options
naming-convention | typescript-eslint
Enforce naming conventions for everything across a codebase.
typescript-eslint.io
'React & TypeScript > TypeScript' 카테고리의 다른 글
[TypeScript] GENERIC Basic (그래서, T야?) (0) | 2023.08.22 |
---|---|
비공개 - [TypeScript] 활용법 Basic (이 건 뭐고, 저 건 또 뭐야? 싶을 때 보는) (0) | 2023.07.10 |
[TypeScript] as 사용에 대한 이해 (feat. Type Assertions) (1) | 2022.12.27 |
[React / TypeScript] props를 구조분해할당으로 전달받을 때 Type Error (TS2322) (0) | 2022.12.20 |
[TypeScript] Tip - 자동으로 Type 추출 (0) | 2022.12.19 |
[React / TypeScript / API] API 구조 작성은 이렇게 한다. (0) | 2022.12.16 |
[React / TypeScript] interface로 타입 정의 중 발생한 이슈 (useParams, Params) - TS2344 (0) | 2022.12.09 |
댓글