@txstack/dev-guide 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @txstack/dev-guide
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - bfe934e: eslint 프리셋에 import 규칙 셋을 더했다 — `import/no-duplicates` · `import/first` · `import/no-self-import` (오류). 파일 하나만 보는 규칙이라 경로 해석기가 필요 없다. `eslint-plugin-import` 를 선택 peer 로 설치한다. `node()` 에 `decorators: true` 를 주면 `consistent-type-imports` 를 끈다 — NestJS 처럼 생성자 인자의 타입을 런타임에 읽어 주입하는 서버를 위한 것이다.
8
+
3
9
  ## 0.2.0
4
10
 
5
11
  ### Minor Changes
package/README.md CHANGED
@@ -85,7 +85,7 @@ prettier · eslint · commitlint · lint-staged 설정을 그대로 가져다
85
85
  pnpm add -D prettier
86
86
  pnpm add -D @commitlint/cli @commitlint/config-conventional
87
87
  pnpm add -D lint-staged husky
88
- pnpm add -D eslint @eslint/js typescript-eslint typescript globals eslint-config-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh eslint-plugin-jsx-a11y
88
+ pnpm add -D eslint @eslint/js typescript-eslint typescript globals eslint-config-prettier eslint-plugin-react eslint-plugin-react-hooks eslint-plugin-react-refresh eslint-plugin-jsx-a11y eslint-plugin-import
89
89
  ```
90
90
 
91
91
  ```js
@@ -110,14 +110,14 @@ eslint 는 조각으로 제공합니다. 앱 폴더 이름은 프로젝트마다
110
110
  // eslint.config.js
111
111
  import { base, react, node } from "@txstack/dev-guide/eslint";
112
112
 
113
- export default [...base({ ignores: ["vendor/**"] }), ...react({ files: ["apps/web/**/*.{ts,tsx}"] }), ...node({ files: ["apps/api/**/*.ts", "scripts/**/*.mjs"] })];
113
+ export default [...base({ ignores: ["vendor/**"] }), ...react({ files: ["apps/web/**/*.{ts,tsx}"] }), ...node({ files: ["apps/api/**/*.ts", "scripts/**/*.mjs"], decorators: true })];
114
114
  ```
115
115
 
116
- | 조각 | 담는 것 |
117
- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
118
- | `base()` | 무시 경로 · `@eslint/js` · `typescript-eslint` recommended · 공통 TS 규칙 · `*.d.ts` 완화 · 설정 파일과 스크립트의 Node 전역 · `eslint-config-prettier` |
119
- | `react()` | 브라우저 전역 · `react` · `react-hooks` · `react-refresh` · `jsx-a11y` recommended(`anchor-is-valid` · `alt-text` 제외) — 의도된 예외는 그 줄에서 끄고 이유를 적습니다 |
120
- | `node()` | Node 전역 — 규칙은 `base` 그대로 |
116
+ | 조각 | 담는 것 |
117
+ | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
118
+ | `base()` | 무시 경로 · `@eslint/js` · `typescript-eslint` recommended · 공통 TS 규칙 · import 규칙 셋(`no-duplicates` · `first` · `no-self-import`) · `*.d.ts` 완화 · 설정 파일과 스크립트의 Node 전역 · `eslint-config-prettier` |
119
+ | `react()` | 브라우저 전역 · `react` · `react-hooks` · `react-refresh` · `jsx-a11y` recommended(`anchor-is-valid` · `alt-text` 제외) — 의도된 예외는 그 줄에서 끄고 이유를 적습니다 |
120
+ | `node()` | Node 전역 — 규칙은 `base` 그대로. NestJS 처럼 데코레이터 메타데이터로 주입하는 서버는 `decorators: true` 로 `consistent-type-imports` 를 끕니다 |
121
121
 
122
122
  무시할 파일 목록은 프리셋으로 줄 수 없어(prettier 가 패키지에서 읽지 않습니다) [templates/prettierignore](templates/prettierignore) 를
123
123
  저장소 루트의 `.prettierignore` 로 복사합니다. 커밋 훅(`.husky/pre-commit` · `commit-msg`)의 내용은 [rules/commits.md](rules/commits.md) 5장에 있습니다.
package/config/eslint.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * export default [
8
8
  * ...base({ ignores: ["vendor/**"] }),
9
9
  * ...react({ files: ["apps/web/**\/*.{ts,tsx}"] }),
10
- * ...node({ files: ["apps/api/**\/*.ts"] })
10
+ * ...node({ files: ["apps/api/**\/*.ts"], decorators: true })
11
11
  * // 프로젝트 고유의 것은 그 아래에
12
12
  * ];
13
13
  *
@@ -18,6 +18,7 @@
18
18
  */
19
19
  import js from "@eslint/js";
20
20
  import prettier from "eslint-config-prettier";
21
+ import importPlugin from "eslint-plugin-import";
21
22
  import jsxA11y from "eslint-plugin-jsx-a11y";
22
23
  import reactPlugin from "eslint-plugin-react";
23
24
  import reactHooks from "eslint-plugin-react-hooks";
@@ -28,7 +29,7 @@ import tseslint from "typescript-eslint";
28
29
  /** @typedef {import("eslint").Linter.Config} Config */
29
30
 
30
31
  /**
31
- * 모든 저장소의 바탕 — ignores · `@eslint/js` · `typescript-eslint` recommended · 공통 TS 규칙 ·
32
+ * 모든 저장소의 바탕 — ignores · `@eslint/js` · `typescript-eslint` recommended · 공통 TS 규칙 · import 규칙 셋 ·
32
33
  * `*.d.ts` 완화 · 설정 파일 · 스크립트에 Node 전역 · 맨 끝에 `eslint-config-prettier`.
33
34
  *
34
35
  * @param {{ ignores?: string[] }} [options] 더 무시할 경로 (`vendor/**` 등)
@@ -57,6 +58,18 @@ export function base({ ignores = [] } = {}) {
57
58
  "no-constant-condition": "off"
58
59
  }
59
60
  },
61
+ {
62
+ // 파일 하나만 보고 판단하는 셋만 켠다 — 경로 해석기가 필요 없고 느려지지 않는다.
63
+ // no-cycle(순환 import)은 파일 사이를 따라가야 해서 해석기 · 시간이 든다. 필요하면 프로젝트가 켠다
64
+ files: ["**/*.{js,mjs,cjs,jsx,ts,tsx,mts,cts}"],
65
+ plugins: { import: importPlugin },
66
+ rules: {
67
+ // 같은 모듈을 두 줄로 import 하지 않는다. `import type` 줄은 따로 센다 (consistent-type-imports 와 맞물린다)
68
+ "import/no-duplicates": "error",
69
+ "import/first": "error",
70
+ "import/no-self-import": "error"
71
+ }
72
+ },
60
73
  {
61
74
  // 선언 파일은 앰비언트 계약이라 쓰지 않는 이름과 any 가 자연스럽다
62
75
  files: ["**/*.d.ts"],
@@ -106,9 +119,13 @@ export function react({ files }) {
106
119
  /**
107
120
  * Node 코드 — 서버 · 워커 · 스크립트. 전역만 바꾸고 규칙은 `base` 그대로다.
108
121
  *
109
- * @param {{ files: string[] }} options Node 코드가 있는 경로 (`apps/api/**\/*.ts` 등)
122
+ * `decorators: true` 는 데코레이터 메타데이터로 주입하는 서버(NestJS 등)를 위한 것이다.
123
+ * 생성자 인자의 타입을 런타임에 읽으므로 `import type` 으로 바꾸면 주입이 깨진다 — `consistent-type-imports` 를 끈다.
124
+ *
125
+ * @param {{ files: string[], decorators?: boolean }} options Node 코드가 있는 경로 (`apps/api/**\/*.ts` 등)
110
126
  * @returns {Config[]}
111
127
  */
112
- export function node({ files }) {
113
- return [{ files, languageOptions: { globals: { ...globals.node } } }];
128
+ export function node({ files, decorators = false }) {
129
+ const rules = decorators ? { "@typescript-eslint/consistent-type-imports": "off" } : {};
130
+ return [{ files, languageOptions: { globals: { ...globals.node } }, rules }];
114
131
  }
package/llms.txt CHANGED
@@ -31,7 +31,7 @@
31
31
 
32
32
  ## 설정 프리셋
33
33
 
34
- - [config/eslint.js](config/eslint.js): `@txstack/dev-guide/eslint` — base() · react({ files }) · node({ files }) 조각. eslint 9 flat config
34
+ - [config/eslint.js](config/eslint.js): `@txstack/dev-guide/eslint` — base() · react({ files }) · node({ files, decorators? }) 조각. eslint 9 flat config
35
35
  - [config/prettier.js](config/prettier.js): `@txstack/dev-guide/prettier` — printWidth 250 · 큰따옴표 · semi · 끝 쉼표 없음
36
36
  - [config/commitlint.js](config/commitlint.js): `@txstack/dev-guide/commitlint` — config-conventional + 한글 제목 · 긴 본문 허용
37
37
  - [config/lint-staged.js](config/lint-staged.js): `@txstack/dev-guide/lint-staged` — 코드는 eslint --fix · prettier --write, 나머지는 prettier --write
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@txstack/dev-guide",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Shared development guide — script naming, code and commit rules, a document-driven workflow (requirements → plans → verification → reports) and document templates",
5
5
  "keywords": [
6
6
  "conventions",
@@ -53,7 +53,8 @@
53
53
  "eslint-plugin-react-hooks": ">=5",
54
54
  "eslint-plugin-react-refresh": ">=0.4",
55
55
  "eslint-plugin-jsx-a11y": ">=6",
56
- "@commitlint/config-conventional": ">=19"
56
+ "@commitlint/config-conventional": ">=19",
57
+ "eslint-plugin-import": ">=2.31"
57
58
  },
58
59
  "peerDependenciesMeta": {
59
60
  "prettier": {
@@ -88,6 +89,9 @@
88
89
  },
89
90
  "@commitlint/config-conventional": {
90
91
  "optional": true
92
+ },
93
+ "eslint-plugin-import": {
94
+ "optional": true
91
95
  }
92
96
  },
93
97
  "devDependencies": {
@@ -101,7 +105,8 @@
101
105
  "eslint-plugin-react-hooks": "^7.0.1",
102
106
  "eslint-plugin-react-refresh": "^0.4.24",
103
107
  "eslint-plugin-jsx-a11y": "^6.10.2",
104
- "@commitlint/config-conventional": "^20.5.0"
108
+ "@commitlint/config-conventional": "^20.5.0",
109
+ "eslint-plugin-import": "^2.32.0"
105
110
  },
106
111
  "publishConfig": {
107
112
  "access": "public"