@insaeng/eslint-config 0.0.0-stage → 0.0.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/dist/boundaries.d.ts +5 -0
- package/dist/boundaries.d.ts.map +1 -0
- package/dist/boundaries.js +131 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/package.json +43 -3
- package/src/boundaries.ts +150 -0
- package/src/index.ts +31 -0
- package/README.md +0 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boundaries.d.ts","sourceRoot":"","sources":["../src/boundaries.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAyCD,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,0CAsGzD"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { createConfig } from "@boundaries/eslint-plugin/config";
|
|
3
|
+
import { defineConfig } from "eslint/config";
|
|
4
|
+
const typescriptResolver = createRequire(import.meta.url).resolve("eslint-import-resolver-typescript");
|
|
5
|
+
const bannedDomainPackages = [
|
|
6
|
+
"hono",
|
|
7
|
+
"@hono/.+",
|
|
8
|
+
"pg",
|
|
9
|
+
"pino",
|
|
10
|
+
"node-pg-migrate",
|
|
11
|
+
];
|
|
12
|
+
const bannedDomainNodeModules = [
|
|
13
|
+
"child_process",
|
|
14
|
+
"cluster",
|
|
15
|
+
"dgram",
|
|
16
|
+
"dns",
|
|
17
|
+
"fs",
|
|
18
|
+
"http",
|
|
19
|
+
"http2",
|
|
20
|
+
"https",
|
|
21
|
+
"inspector",
|
|
22
|
+
"net",
|
|
23
|
+
"os",
|
|
24
|
+
"process",
|
|
25
|
+
"readline",
|
|
26
|
+
"repl",
|
|
27
|
+
"sqlite",
|
|
28
|
+
"stream",
|
|
29
|
+
"tls",
|
|
30
|
+
"tty",
|
|
31
|
+
"v8",
|
|
32
|
+
"vm",
|
|
33
|
+
"worker_threads",
|
|
34
|
+
"zlib",
|
|
35
|
+
];
|
|
36
|
+
const bannedDomainGlobals = ["fetch", "WebSocket", "EventSource"];
|
|
37
|
+
export function boundaries(options = {}) {
|
|
38
|
+
const { rootDir } = options;
|
|
39
|
+
return defineConfig({
|
|
40
|
+
name: "insaeng/boundaries-resolver",
|
|
41
|
+
files: ["src/**"],
|
|
42
|
+
settings: {
|
|
43
|
+
"import/resolver": {
|
|
44
|
+
[typescriptResolver]: {
|
|
45
|
+
alwaysTryTypes: true,
|
|
46
|
+
...(rootDir !== undefined && { project: rootDir }),
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
}, createConfig({
|
|
51
|
+
name: "insaeng/boundaries",
|
|
52
|
+
files: ["src/**"],
|
|
53
|
+
settings: {
|
|
54
|
+
"boundaries/files": [
|
|
55
|
+
{
|
|
56
|
+
category: "domain",
|
|
57
|
+
pattern: "src/domain/*/{entity,repo,use-case}.ts",
|
|
58
|
+
},
|
|
59
|
+
{ category: "data", pattern: "src/data/**" },
|
|
60
|
+
{ category: "app", pattern: "src/app/**" },
|
|
61
|
+
{ category: "main", pattern: "src/main.ts" },
|
|
62
|
+
],
|
|
63
|
+
...(rootDir !== undefined && { "boundaries/root-path": rootDir }),
|
|
64
|
+
},
|
|
65
|
+
rules: {
|
|
66
|
+
"boundaries/dependencies": [
|
|
67
|
+
"error",
|
|
68
|
+
{
|
|
69
|
+
default: "disallow",
|
|
70
|
+
checkUnknownLocals: true,
|
|
71
|
+
policies: [
|
|
72
|
+
{
|
|
73
|
+
from: { file: { categories: ["domain", "data", "app"] } },
|
|
74
|
+
allow: { to: { file: { categories: "domain" } } },
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
from: { file: { categories: "data" } },
|
|
78
|
+
allow: { to: { file: { categories: "data" } } },
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
from: { file: { categories: "app" } },
|
|
82
|
+
allow: { to: { file: { categories: "app" } } },
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
from: { file: { categories: "main" } },
|
|
86
|
+
allow: {
|
|
87
|
+
to: { file: { categories: ["domain", "data", "app"] } },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
"boundaries/no-unknown-files": "error",
|
|
94
|
+
},
|
|
95
|
+
}), {
|
|
96
|
+
name: "insaeng/domain-imports",
|
|
97
|
+
files: ["src/domain/**"],
|
|
98
|
+
rules: {
|
|
99
|
+
"no-restricted-imports": [
|
|
100
|
+
"error",
|
|
101
|
+
{
|
|
102
|
+
patterns: [
|
|
103
|
+
{
|
|
104
|
+
regex: `^(${bannedDomainPackages.join("|")})(/.*)?$`,
|
|
105
|
+
message: "The domain layer must not depend on frameworks or I/O libraries.",
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
regex: `^(node:)?(${bannedDomainNodeModules.join("|")})(/.*)?$`,
|
|
109
|
+
message: "The domain layer must not do I/O.",
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
"no-restricted-globals": [
|
|
115
|
+
"error",
|
|
116
|
+
...bannedDomainGlobals.map((name) => ({
|
|
117
|
+
name,
|
|
118
|
+
message: "The domain layer must not do I/O.",
|
|
119
|
+
})),
|
|
120
|
+
],
|
|
121
|
+
"no-restricted-properties": [
|
|
122
|
+
"error",
|
|
123
|
+
...["globalThis", "global"].flatMap((object) => bannedDomainGlobals.map((property) => ({
|
|
124
|
+
object,
|
|
125
|
+
property,
|
|
126
|
+
message: "The domain layer must not do I/O.",
|
|
127
|
+
}))),
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
export interface InsaengOptions {
|
|
3
|
+
tsconfigRootDir?: string;
|
|
4
|
+
allowDefaultProject?: string[];
|
|
5
|
+
}
|
|
6
|
+
export type InsaengConfig = ReturnType<typeof defineConfig>;
|
|
7
|
+
export declare function insaeng(options?: InsaengOptions): InsaengConfig;
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAK7C,MAAM,WAAW,cAAc;IAC7B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;CAChC;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;AAE5D,wBAAgB,OAAO,CAAC,OAAO,GAAE,cAAmB,GAAG,aAAa,CAkBnE"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import { boundaries } from "./boundaries.js";
|
|
5
|
+
export function insaeng(options = {}) {
|
|
6
|
+
const { tsconfigRootDir, allowDefaultProject } = options;
|
|
7
|
+
return defineConfig(tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked, {
|
|
8
|
+
languageOptions: {
|
|
9
|
+
parserOptions: {
|
|
10
|
+
projectService: allowDefaultProject === undefined ? true : { allowDefaultProject },
|
|
11
|
+
...(tsconfigRootDir !== undefined && { tsconfigRootDir }),
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
}, boundaries({ rootDir: tsconfigRootDir }), eslintConfigPrettier);
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@insaeng/eslint-config",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Strict, type-aware ESLint flat config for insaeng services",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/my-insaeng/insaeng-service-config.git",
|
|
8
|
+
"directory": "packages/eslint-config"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"default": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public",
|
|
19
|
+
"provenance": true
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"src"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@boundaries/eslint-plugin": "7.4.5",
|
|
27
|
+
"eslint-config-prettier": "10.1.9",
|
|
28
|
+
"eslint-import-resolver-typescript": "4.4.5",
|
|
29
|
+
"typescript-eslint": "8.74.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"eslint": "^9.22.0 || ^10.0.0",
|
|
33
|
+
"typescript": ">=4.8.4 <6.1.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@insaeng/tsconfig": "0.0.0",
|
|
37
|
+
"@types/node": "24.19.4",
|
|
38
|
+
"eslint": "10.16.0",
|
|
39
|
+
"typescript": "6.0.3",
|
|
40
|
+
"vitest": "5.1.2"
|
|
41
|
+
},
|
|
42
|
+
"scripts": {
|
|
43
|
+
"build": "tsc -p tsconfig.build.json",
|
|
44
|
+
"typecheck": "tsc"
|
|
45
|
+
}
|
|
6
46
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { createConfig } from "@boundaries/eslint-plugin/config";
|
|
3
|
+
import { defineConfig } from "eslint/config";
|
|
4
|
+
|
|
5
|
+
export interface BoundariesOptions {
|
|
6
|
+
rootDir?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const typescriptResolver = createRequire(import.meta.url).resolve(
|
|
10
|
+
"eslint-import-resolver-typescript",
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const bannedDomainPackages = [
|
|
14
|
+
"hono",
|
|
15
|
+
"@hono/.+",
|
|
16
|
+
"pg",
|
|
17
|
+
"pino",
|
|
18
|
+
"node-pg-migrate",
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const bannedDomainNodeModules = [
|
|
22
|
+
"child_process",
|
|
23
|
+
"cluster",
|
|
24
|
+
"dgram",
|
|
25
|
+
"dns",
|
|
26
|
+
"fs",
|
|
27
|
+
"http",
|
|
28
|
+
"http2",
|
|
29
|
+
"https",
|
|
30
|
+
"inspector",
|
|
31
|
+
"net",
|
|
32
|
+
"os",
|
|
33
|
+
"process",
|
|
34
|
+
"readline",
|
|
35
|
+
"repl",
|
|
36
|
+
"sqlite",
|
|
37
|
+
"stream",
|
|
38
|
+
"tls",
|
|
39
|
+
"tty",
|
|
40
|
+
"v8",
|
|
41
|
+
"vm",
|
|
42
|
+
"worker_threads",
|
|
43
|
+
"zlib",
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
const bannedDomainGlobals = ["fetch", "WebSocket", "EventSource"];
|
|
47
|
+
|
|
48
|
+
export function boundaries(options: BoundariesOptions = {}) {
|
|
49
|
+
const { rootDir } = options;
|
|
50
|
+
|
|
51
|
+
return defineConfig(
|
|
52
|
+
{
|
|
53
|
+
name: "insaeng/boundaries-resolver",
|
|
54
|
+
files: ["src/**"],
|
|
55
|
+
settings: {
|
|
56
|
+
"import/resolver": {
|
|
57
|
+
[typescriptResolver]: {
|
|
58
|
+
alwaysTryTypes: true,
|
|
59
|
+
...(rootDir !== undefined && { project: rootDir }),
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
createConfig({
|
|
65
|
+
name: "insaeng/boundaries",
|
|
66
|
+
files: ["src/**"],
|
|
67
|
+
settings: {
|
|
68
|
+
"boundaries/files": [
|
|
69
|
+
{
|
|
70
|
+
category: "domain",
|
|
71
|
+
pattern: "src/domain/*/{entity,repo,use-case}.ts",
|
|
72
|
+
},
|
|
73
|
+
{ category: "data", pattern: "src/data/**" },
|
|
74
|
+
{ category: "app", pattern: "src/app/**" },
|
|
75
|
+
{ category: "main", pattern: "src/main.ts" },
|
|
76
|
+
],
|
|
77
|
+
...(rootDir !== undefined && { "boundaries/root-path": rootDir }),
|
|
78
|
+
},
|
|
79
|
+
rules: {
|
|
80
|
+
"boundaries/dependencies": [
|
|
81
|
+
"error",
|
|
82
|
+
{
|
|
83
|
+
default: "disallow",
|
|
84
|
+
checkUnknownLocals: true,
|
|
85
|
+
policies: [
|
|
86
|
+
{
|
|
87
|
+
from: { file: { categories: ["domain", "data", "app"] } },
|
|
88
|
+
allow: { to: { file: { categories: "domain" } } },
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
from: { file: { categories: "data" } },
|
|
92
|
+
allow: { to: { file: { categories: "data" } } },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
from: { file: { categories: "app" } },
|
|
96
|
+
allow: { to: { file: { categories: "app" } } },
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
from: { file: { categories: "main" } },
|
|
100
|
+
allow: {
|
|
101
|
+
to: { file: { categories: ["domain", "data", "app"] } },
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
"boundaries/no-unknown-files": "error",
|
|
108
|
+
},
|
|
109
|
+
}),
|
|
110
|
+
{
|
|
111
|
+
name: "insaeng/domain-imports",
|
|
112
|
+
files: ["src/domain/**"],
|
|
113
|
+
rules: {
|
|
114
|
+
"no-restricted-imports": [
|
|
115
|
+
"error",
|
|
116
|
+
{
|
|
117
|
+
patterns: [
|
|
118
|
+
{
|
|
119
|
+
regex: `^(${bannedDomainPackages.join("|")})(/.*)?$`,
|
|
120
|
+
message:
|
|
121
|
+
"The domain layer must not depend on frameworks or I/O libraries.",
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
regex: `^(node:)?(${bannedDomainNodeModules.join("|")})(/.*)?$`,
|
|
125
|
+
message: "The domain layer must not do I/O.",
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
"no-restricted-globals": [
|
|
131
|
+
"error",
|
|
132
|
+
...bannedDomainGlobals.map((name) => ({
|
|
133
|
+
name,
|
|
134
|
+
message: "The domain layer must not do I/O.",
|
|
135
|
+
})),
|
|
136
|
+
],
|
|
137
|
+
"no-restricted-properties": [
|
|
138
|
+
"error",
|
|
139
|
+
...["globalThis", "global"].flatMap((object) =>
|
|
140
|
+
bannedDomainGlobals.map((property) => ({
|
|
141
|
+
object,
|
|
142
|
+
property,
|
|
143
|
+
message: "The domain layer must not do I/O.",
|
|
144
|
+
})),
|
|
145
|
+
),
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
);
|
|
150
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineConfig } from "eslint/config";
|
|
2
|
+
import eslintConfigPrettier from "eslint-config-prettier";
|
|
3
|
+
import tseslint from "typescript-eslint";
|
|
4
|
+
import { boundaries } from "./boundaries.js";
|
|
5
|
+
|
|
6
|
+
export interface InsaengOptions {
|
|
7
|
+
tsconfigRootDir?: string;
|
|
8
|
+
allowDefaultProject?: string[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type InsaengConfig = ReturnType<typeof defineConfig>;
|
|
12
|
+
|
|
13
|
+
export function insaeng(options: InsaengOptions = {}): InsaengConfig {
|
|
14
|
+
const { tsconfigRootDir, allowDefaultProject } = options;
|
|
15
|
+
|
|
16
|
+
return defineConfig(
|
|
17
|
+
tseslint.configs.strictTypeChecked,
|
|
18
|
+
tseslint.configs.stylisticTypeChecked,
|
|
19
|
+
{
|
|
20
|
+
languageOptions: {
|
|
21
|
+
parserOptions: {
|
|
22
|
+
projectService:
|
|
23
|
+
allowDefaultProject === undefined ? true : { allowDefaultProject },
|
|
24
|
+
...(tsconfigRootDir !== undefined && { tsconfigRootDir }),
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
boundaries({ rootDir: tsconfigRootDir }),
|
|
29
|
+
eslintConfigPrettier,
|
|
30
|
+
);
|
|
31
|
+
}
|
package/README.md
DELETED