코드 컨벤션

ESLint

Rules

rules: {
  '@typescript-eslint/no-empty-interface': 'error',
  '@typescript-eslint/no-explicit-any': 'error',
  '@typescript-eslint/explicit-function-return-type': 'error',
  '@typescript-eslint/explicit-module-boundary-types': 'error',
  '@typescript-eslint/no-unused-vars': [
    'error',
    {
      argsIgnorePattern: '^_',
      varsIgnorePattern: '^_',
      caughtErrorsIgnorePattern: '^_',
    },
  ],
  '@typescript-eslint/consistent-type-imports': ['error', { prefer: 'type-imports' }],
  '@typescript-eslint/no-non-null-assertion': 'error',
},

1. @typescript-eslint/no-empty-interface

빈 인터페이스 선언을 금지합니다.

// ❌ 잘못된 예
interface Foo {}

// ✅ 좋은 예
interface Foo {
  name: string;
}

// ✅ 확장 목적의 빈 인터페이스는 허용
interface Foo extends Bar {}

2. @typescript-eslint/no-explicit-any

any 타입의 사용을 금지합니다.

// ❌ 잘못된 예
function foo(bar: any) {}
const foo: any[] = [];

// ✅ 좋은 예
function foo(bar: unknown) {}
const foo: string[] = [];

3. @typescript-eslint/explicit-function-return-type

함수의 반환 타입을 명시적으로 지정하도록 강제합니다.

// ❌ 잘못된 예
function foo() {
  return 'hello';
}

// ✅ 좋은 예
function foo(): string {
  return 'hello';
}

4. @typescript-eslint/explicit-module-boundary-types

모듈의 공개 API(exported functions/classes)에 명시적인 타입을 지정하도록 강제합니다.