-
Notifications
You must be signed in to change notification settings - Fork 1
/
eslint.config.mjs
88 lines (85 loc) · 2.09 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import eslint from "@eslint/js";
import typescriptPlugin from "@typescript-eslint/eslint-plugin";
import projectStructurePlugin, { createIndependentModules } from "eslint-plugin-project-structure";
import tseslint from "typescript-eslint";
/**
* @satisfies {Record<string, string[]>}>}
*/
const patterns = {
app: ["src/app/**"],
shared: ["src/shared/*/**"],
features: ["src/features/*/**"],
"feature:profile": ["src/features/profile/**"],
"feature:post": ["src/features/post/**"],
"feature:feed": ["src/features/feed/**"],
family_3: ["{family_3}/**"],
};
/**
* @type {{ [K in keyof typeof patterns]?: { allowImportsFrom: (keyof typeof patterns)[] } }}
*/
const boundaries = {
app: {
allowImportsFrom: ["app", "shared", "features"],
},
shared: {
allowImportsFrom: ["shared"],
},
"feature:profile": {
allowImportsFrom: ["feature:profile", "feature:feed", "shared"],
},
"feature:post": {
allowImportsFrom: ["feature:post", "shared"],
},
"feature:feed": {
allowImportsFrom: ["feature:feed", "feature:post", "shared"],
},
};
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
{
rules: {
"no-inner-declarations": "off",
"no-undefined": "error",
},
},
{
plugins: { "@typescript-eslint": typescriptPlugin },
rules: {
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-this-alias": "off",
"@typescript-eslint/no-wrapper-object-types": "off",
},
},
{
plugins: { "project-structure": projectStructurePlugin },
rules: {
"project-structure/independent-modules": [
"error",
createIndependentModules({
pathAliases: {
baseUrl: "./project/app",
paths: {
"~/*": ["src/*"],
},
},
modules: [
...Object.keys(boundaries).map((key) => ({
name: key,
pattern: patterns[key],
allowImportsFrom: boundaries[key].allowImportsFrom
.map((key) => patterns[key])
.flat(),
})),
{
name: "unknown",
pattern: "src/**",
allowImportsFrom: [],
allowExternalImports: false,
},
],
}),
],
},
},
);