eslint-config-kelo-nextjs 1.0.0 → 1.0.2
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.
|
@@ -81,6 +81,7 @@ export const baseBoundaryElements = [
|
|
|
81
81
|
{ type: "email-template", pattern: ["src/email-templates"] }, // React Email 등 이메일 템플릿
|
|
82
82
|
// Route Handler — Next.js App Router HTTP 엔드포인트 (GET/POST 등 export)
|
|
83
83
|
{ type: "route-handler", mode: "full", pattern: ["src/app/**/route.ts"] }, // API 진입점 (얇은 HTTP 어댑터)
|
|
84
|
-
// Page (catch-all) — 위 패턴에 매칭 안 된 src/app
|
|
85
|
-
|
|
84
|
+
// Page (catch-all) — 위 패턴에 매칭 안 된 src/app 전부.
|
|
85
|
+
// `fallback: true` — 스택·kelo.lint.json element보다도 뒤에 매칭된다 (orderBoundaryElements).
|
|
86
|
+
{ type: "page", pattern: ["src/app"], fallback: true }, // 최상위 페이지 catch-all
|
|
86
87
|
];
|
|
@@ -12,11 +12,18 @@ import {
|
|
|
12
12
|
/**
|
|
13
13
|
* boundaries 플러그인 룰 생성기. elements ↔ rules 매핑으로
|
|
14
14
|
* from→to 의존을 allow-list 검사 (default: disallow).
|
|
15
|
+
*
|
|
16
|
+
* `root`(소비 프로젝트 루트)를 받으면 그것을 경로 기준으로 삼고, 그 밖으로
|
|
17
|
+
* resolve되는 import(모노레포 형제 workspace 등)는 외부 의존으로 본다.
|
|
18
|
+
* 기준이 `process.cwd()`면 실행 위치에 따라 분류가 달라지고, 바깥 파일을
|
|
19
|
+
* glob ignore로 빼면 경로에 점 디렉터리(`~/.cache/...`)가 끼었을 때 `**`가
|
|
20
|
+
* 건너지 못해 `no-unknown-dependencies`가 오발화한다.
|
|
15
21
|
*/
|
|
16
22
|
export function buildArchitectureBoundaries(
|
|
17
23
|
elements,
|
|
18
24
|
rules,
|
|
19
25
|
ignores = baseBoundaryIgnores,
|
|
26
|
+
root = undefined,
|
|
20
27
|
) {
|
|
21
28
|
const { folderElements, fileDescriptors, classification } =
|
|
22
29
|
splitBoundaryElements(elements);
|
|
@@ -29,6 +36,12 @@ export function buildArchitectureBoundaries(
|
|
|
29
36
|
"boundaries/elements": folderElements,
|
|
30
37
|
"boundaries/files": fileDescriptors,
|
|
31
38
|
"boundaries/ignore": ignores,
|
|
39
|
+
...(root
|
|
40
|
+
? {
|
|
41
|
+
"boundaries/root-path": root,
|
|
42
|
+
"boundaries/flag-as-external": { outsideRootPath: true },
|
|
43
|
+
}
|
|
44
|
+
: {}),
|
|
32
45
|
},
|
|
33
46
|
rules: {
|
|
34
47
|
"boundaries/no-unknown-dependencies": "error",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* boundary element 목록을 분류 우선순위 순으로 정렬한다.
|
|
3
|
+
* 분류는 "목록에서 먼저 맞는 element 하나"라서, `fallback: true`인 catch-all
|
|
4
|
+
* (예: `src/app` 전체를 받는 `page`)이 앞에 있으면 뒤에 오는 스택·프로젝트
|
|
5
|
+
* element가 절대 매칭되지 않는다. fallback만 맨 뒤로 보내고 나머지는
|
|
6
|
+
* 입력 순서(base → 스택 → kelo.lint.json)를 그대로 유지한다.
|
|
7
|
+
* `fallback` 키는 플러그인 설정에 넘기지 않도록 제거한다.
|
|
8
|
+
*/
|
|
9
|
+
export function orderBoundaryElements(elements) {
|
|
10
|
+
const strip = ({ fallback: _fallback, ...element }) => element;
|
|
11
|
+
return [
|
|
12
|
+
...elements.filter((e) => !e.fallback).map(strip),
|
|
13
|
+
...elements.filter((e) => e.fallback).map(strip),
|
|
14
|
+
];
|
|
15
|
+
}
|
package/base/eslint.rules.mjs
CHANGED
|
@@ -40,6 +40,7 @@ export { baseIgnores } from "./eslint-rules/quality/ignores.mjs";
|
|
|
40
40
|
export { buildRestrictedImports } from "./eslint-rules/builders/build-restricted-imports.mjs";
|
|
41
41
|
export { buildDomainPurity } from "./eslint-rules/builders/build-domain-purity.mjs";
|
|
42
42
|
export { buildArchitectureBoundaries } from "./eslint-rules/builders/build-architecture-boundaries.mjs";
|
|
43
|
+
export { orderBoundaryElements } from "./eslint-rules/builders/order-boundary-elements.mjs";
|
|
43
44
|
|
|
44
45
|
// ─── Docs (ESLint 미참조, generator 전용) ─────────────────────────────────────
|
|
45
46
|
export { baseStructureAnnotations } from "./eslint-rules/docs/structure-annotations.mjs";
|
package/index.mjs
CHANGED
|
@@ -26,6 +26,7 @@ import {
|
|
|
26
26
|
buildArchitectureBoundaries,
|
|
27
27
|
buildDomainPurity,
|
|
28
28
|
buildRestrictedImports,
|
|
29
|
+
orderBoundaryElements,
|
|
29
30
|
} from "./base/eslint.rules.mjs";
|
|
30
31
|
import {
|
|
31
32
|
antdDomainBannedPackages,
|
|
@@ -171,12 +172,13 @@ function buildKeloBlocks(root, lintConfig) {
|
|
|
171
172
|
...baseServerComponentRules,
|
|
172
173
|
|
|
173
174
|
// [7] 아키텍처 경계 — base + 스택 + kelo.lint.json 확장
|
|
175
|
+
// catch-all(`fallback: true`)은 스택·프로젝트 element 뒤로 — first-match라 앞에 두면 가려진다
|
|
174
176
|
...buildArchitectureBoundaries(
|
|
175
|
-
[
|
|
177
|
+
orderBoundaryElements([
|
|
176
178
|
...baseBoundaryElements,
|
|
177
179
|
...pick("boundaryElements"),
|
|
178
180
|
...(lintConfig.boundaryElements ?? []),
|
|
179
|
-
],
|
|
181
|
+
]),
|
|
180
182
|
patchBoundaryRules(
|
|
181
183
|
[
|
|
182
184
|
...baseBoundaryRules,
|
|
@@ -190,6 +192,7 @@ function buildKeloBlocks(root, lintConfig) {
|
|
|
190
192
|
...pick("boundaryIgnores"),
|
|
191
193
|
...(lintConfig.boundaryIgnores ?? []),
|
|
192
194
|
],
|
|
195
|
+
root,
|
|
193
196
|
),
|
|
194
197
|
|
|
195
198
|
// [8] 프로젝트 공용 custom 룰 (conventions.md 강제)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-kelo-nextjs",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Kelo Next.js ESLint/Stylelint shareable config — architecture boundaries, domain purity, and quality rules",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"./package.json": "./package.json"
|
|
28
28
|
},
|
|
29
29
|
"bin": {
|
|
30
|
-
"kelo-lint-nextjs": "
|
|
30
|
+
"kelo-lint-nextjs": "bin/kelo-lint.mjs"
|
|
31
31
|
},
|
|
32
32
|
"files": [
|
|
33
33
|
"index.mjs",
|