Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# ESLint 설정 파일들
.eslintrc.js
eslint.config.js

# 기타 설정 파일들
*.config.js
*.config.ts
prettier.config.js
vite.config.ts
docusaurus.config.ts
typedoc.json
tsconfig*.json

# 빌드 결과물
dist/
node_modules/
coverage/

# 문서
docusaurus/
docs/

# 기타
.git/
.changeset/
.github/
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const baseConfig = require('./src/configs/base.eslint.config.js');

module.exports = {
...baseConfig,
plugins: [...baseConfig.plugins, 'react-refresh'],
rules: {
...baseConfig.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
},
};
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ dist-ssr

.docusaurus
build
dist
docs

# TypeScript build cache
*.tsbuildinfo
tsconfig.*.tsbuildinfo

# Editor directories and files
.vscode/*
Expand All @@ -28,3 +30,4 @@ docs
*.njsproj
*.sln
*.sw?
CLAUDE.md
10 changes: 0 additions & 10 deletions .prettierrc

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@
개발 기여, 세팅 등에 필요한 정보는 아래 각 가이드를 참고후 작업하시면 됩니다.

- [컨벤션\_가이드](./docusaurus/convention.md)
- [개발*세팅*가이드](./docusaurus/setting.md)
- [작업\_가이드](./docusaurus/developer.md)
- [개발환경\_설정\_가이드](./docusaurus/setting.md)
- [개발\_가이드](./docusaurus/developer.md)
- [ESLint\_설정\_가이드](./docusaurus/eslint.md)

## 패키지 변경사항

Expand Down
4 changes: 2 additions & 2 deletions docusaurus/developer.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Monolith 작업 가이드
description: 프로젝트를 작업하는 가이드를 제공합니다.
title: Monolith 개발 가이드
description: 프로젝트를 개발하는 가이드를 제공합니다.
---

# Monolith 작업 가이드
Expand Down
122 changes: 122 additions & 0 deletions docusaurus/eslint-v9.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
---
title: ESLint v9(flat config) 가이드
description: Monolith 패키지에서 ESLint v9(flat config) 사용법, v8과의 차이, 마이그레이션, 호환성 문제 해결법을 안내합니다.
---

# ESLint v9(flat config) 가이드

이 문서는 Monolith 패키지에서 **ESLint v9(flat config)** 환경을 사용할 때 필요한 설정, v8과의 차이, 마이그레이션, 호환성, 문제 해결법을 안내합니다.

> **Monolith는 기본적으로 ESLint v8을 공식 지원합니다. v9(flat config)는 실험적 지원이며, 플러그인 호환성 등 이슈가 있을 수 있습니다.**

## 주요 차이점 (v8 vs v9)

| 구분 | ESLint v8 | ESLint v9(flat config) |
| ------------------ | -------------------- | ------------------------- |
| **설정 파일 구조** | 객체(.eslintrc.js) | 배열(eslint.config.js) |
| **extends** | 지원 | 제한적(FlatCompat 필요) |
| **plugins** | 직접 지원 | 제한적(FlatCompat 필요) |
| **parser** | parser 옵션 | languageOptions 내부 설정 |
| **성능** | 상대적으로 느림 | 더 빠름 |
| **호환성** | 플러그인 대부분 지원 | 일부 플러그인 호환성 문제 |

## 마이그레이션: v8 → v9(flat config)

### 1. 의존성 설치

```bash
pnpm add -D eslint@^9.0.0 @eslint/eslintrc @eslint/js
```

### 2. 설정 파일 변환

```js
// eslint.config.js (v9 flat config)
const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');
const baseConfig = require('@croquiscom/monolith/configs/base.eslint.config.js');

const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
});

module.exports = [...compat.config(baseConfig)];
```

### 3. package.json 스크립트

```json
{
"scripts": {
"lint": "eslint . --ext .ts,.tsx",
"lint:fix": "eslint . --ext .ts,.tsx --fix"
}
}
```

## v9 환경에서 발생할 수 있는 문제와 해결법

### 1. "Failed to load config" 에러

- **원인**: v8 방식 설정을 flat config에서 직접 import 시 발생
- **해결**: 반드시 FlatCompat로 변환해서 사용

### 2. 플러그인/규칙 로드 실패

- **원인**: 플러그인 로딩 방식 변경, flat config 미지원 플러그인 존재
- **해결**: FlatCompat 사용, 또는 수동 flat config 변환

### 3. Nx/Next.js 플러그인 호환성 문제

- **원인**: Nx v17~21은 v8만 공식 지원, v9에서 규칙/플러그인 미작동
- **해결**: v8 사용 권장, 실험적 사용 시 FlatCompat로 변환

### 4. 기타

- **설정이 적용되지 않는 경우**: ESLint 캐시 삭제, IDE 재시작
- **플러그인/파서 에러**: peerDependencies 설치 확인

## FlatCompat 없이 수동 변환 예시

```js
const js = require('@eslint/js');
const tseslint = require('typescript-eslint');
const reactPlugin = require('eslint-plugin-react');
const reactHooksPlugin = require('eslint-plugin-react-hooks');
const importPlugin = require('eslint-plugin-import');
const jsxA11yPlugin = require('eslint-plugin-jsx-a11y');

module.exports = [
js.configs.recommended,
...tseslint.configs.recommended,
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
ecmaFeatures: { jsx: true },
},
},
plugins: {
'react': reactPlugin,
'react-hooks': reactHooksPlugin,
'import': importPlugin,
'jsx-a11y': jsxA11yPlugin,
},
rules: {
// Monolith 설정의 규칙들을 여기에 복사
},
},
];
```

## 참고

- [ESLint 공식 문서](https://eslint.org/)
- [ESLint v9 Flat Config 가이드](https://eslint.org/docs/latest/use/configure/configuration-files-new/)
- [ESLint v8에서 v9 마이그레이션](https://eslint.org/docs/latest/use/configure/migration-guide)
- [TypeScript ESLint Flat Config](https://typescript-eslint.io/users/typed-linting/migration/)
- [ESLint FlatCompat 문서](https://eslint.org/docs/latest/use/configure/configuration-files-new#using-eslintrc-style-configs-in-flat-config)
131 changes: 131 additions & 0 deletions docusaurus/eslint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
title: ESLint 설정 가이드
description: Monolith 패키지에서 제공하는 ESLint v8 기반 설정 사용법을 안내합니다.
---

# ESLint 설정 가이드

Monolith 패키지의 ESLint 설정은 **ESLint v8**을 기본 지원합니다. (v9 관련 내용은 별도 문서 참고)

## 지원 및 권장 버전

- **ESLint**: ^8.0.0 (기본 지원)
- **@typescript-eslint/eslint-plugin**: ^6.0.0 || ^7.0.0 || ^8.0.0
- **@typescript-eslint/parser**: ^6.0.0 || ^7.0.0 || ^8.0.0
- **Prettier**: ^2.0.0 || ^3.0.0
- **React**: ^17.0.0 || ^18.0.0 || ^19.0.0

> **ESLint v9, flat config, 마이그레이션, 비교 등은 [ESLint v9 가이드](./eslint-v9.md) 문서를 참고하세요.**

## 설치

### 1. Monolith 패키지 설치

```bash
pnpm add -D @croquiscom/monolith
```

### 2. 필수 의존성 설치

```bash
pnpm add -D eslint @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint-plugin-import eslint-plugin-jsx-a11y eslint-plugin-prettier eslint-plugin-react eslint-plugin-react-hooks prettier eslint-import-resolver-typescript
```

#### Next.js 설정 사용 시 (선택)

```bash
pnpm add -D @next/eslint-plugin-next
```

#### Nx 모노레포 설정 사용 시 (선택)

```bash
pnpm add -D @nx/eslint-plugin jsonc-eslint-parser
```

## 사용법

### 1. 기본 설정 (base)

```js
// .eslintrc.js
module.exports = require('@croquiscom/monolith/configs/base.eslint.config.js');
```

### 2. Next.js 설정

```js
// .eslintrc.js
module.exports = require('@croquiscom/monolith/configs/next.eslint.config.js');
```

### 3. Nx 모노레포 설정

```js
// .eslintrc.js
module.exports = require('@croquiscom/monolith/configs/nx.eslint.config.js');
```

## Prettier 연동

```js
// prettier.config.js
module.exports = require('@croquiscom/monolith/configs/prettier.config.js');
```

## package.json 스크립트 예시

```json
{
"scripts": {
"lint": "eslint ./src --ext .ts,.tsx",
"lint:fix": "eslint ./src --ext .ts,.tsx --fix",
"format": "prettier --write .",
"format:check": "prettier --check ."
}
}
```

## 규칙 오버라이드 예시

```js
// .eslintrc.js
const baseConfig = require('@croquiscom/monolith/configs/base.eslint.config.js');
module.exports = {
...baseConfig,
rules: {
...baseConfig.rules,
'react/display-name': 'error',
},
};
```

## Nx/Next.js 프로젝트 구조 예시

```
my-nx-workspace/
├── eslint.config.js # 루트 설정 (base + nx)
├── apps/
│ ├── web-app/
│ │ └── eslint.config.js # 루트 + Next.js + 커스텀
│ └── admin-app/
│ └── eslint.config.js # 루트 + 커스텀
└── libs/
└── shared/
└── eslint.config.js # 루트 + 커스텀
```

## 문제 해결

- **설정이 적용되지 않는 경우**: ESLint 캐시 삭제, IDE 재시작
- **플러그인/파서 에러**: peerDependencies 설치 확인
- **TypeScript alias(import 경로 단축) 관련 에러**: `eslint-import-resolver-typescript`가 설치되어 있는지, 그리고 base.eslint.config.js의 settings에 `import/resolver: { typescript: {} }`가 포함되어 있는지 확인하세요.
- **Nx/Next.js 관련 규칙 에러**: 선택적 의존성 설치 확인

## 참고

- [ESLint 공식 문서](https://eslint.org/)
- [TypeScript ESLint](https://typescript-eslint.io/)
- [Next.js ESLint 설정](https://nextjs.org/docs/basic-features/eslint)
- [Nx ESLint 플러그인](https://nx.dev/recipes/eslint/eslint-plugin-nx)
- [Prettier 공식 문서](https://prettier.io/)
17 changes: 17 additions & 0 deletions docusaurus/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,20 @@
때문에 전체가 아닌 한개의 프로젝트 혹은 일부 프로젝트에서 사용되는 `Hook`, `Component`, `Util`, `Constant` 의 추가는 금지됩니다.

예외적으로 많은 프로젝트에서 사용하는 경우 `FE챕터 구성원`들과 논의후 추가는 가능합니다.

## 주요 기능

### ESLint 설정

일관된 코드 품질을 위한 ESLint 설정을 제공합니다.

- [ESLint 설정 가이드](./eslint.md) - 기본, Next.js, Nx 모노레포 설정 사용법

## 가이드 리스트

개발 기여, 세팅 등에 필요한 정보는 아래 각 가이드를 참고후 작업하시면 됩니다.

- [컨벤션\_가이드](./convention.md)
- [개발*세팅*가이드](./setting.md)
- [작업\_가이드](./developer.md)
- [ESLint 설정 가이드](./eslint.md)
2 changes: 1 addition & 1 deletion docusaurus/setting.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Monolith 개발환경 세팅
title: Monolith 개발환경 설정
description: 프로젝트개발시 설치 및 실행 가이드를 제공합니다.
---

Expand Down
25 changes: 0 additions & 25 deletions eslint.config.mjs

This file was deleted.

Loading