-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patheslint.config.js
More file actions
166 lines (162 loc) · 4.46 KB
/
Copy patheslint.config.js
File metadata and controls
166 lines (162 loc) · 4.46 KB
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
import js from "@eslint/js"
import tseslint from "@typescript-eslint/eslint-plugin"
import tsparser from "@typescript-eslint/parser"
import reactHooks from "eslint-plugin-react-hooks"
import react from "eslint-plugin-react"
import globals from "globals"
import astro from "eslint-plugin-astro"
import { plugin as localPlugin } from "./eslint-local-rules/index.js"
let commonRules = {
"@typescript-eslint/no-unused-vars": ["error", { argsIgnorePattern: "^_" }],
"@typescript-eslint/no-explicit-any": "error",
}
let reactRules = {
...react.configs.recommended.rules,
...reactHooks.configs.recommended.rules,
"react/react-in-jsx-scope": "off",
}
let browserGlobals = {
...globals.browser,
...globals.serviceworker,
React: "readonly",
}
export default [
js.configs.recommended,
{
files: ["src/**/*.{ts,tsx,js,jsx}"],
languageOptions: {
parser: tsparser,
parserOptions: { ecmaVersion: "latest", sourceType: "module", jsx: true },
globals: browserGlobals,
},
plugins: {
"@typescript-eslint": tseslint,
"react-hooks": reactHooks,
react,
local: localPlugin,
},
rules: {
...tseslint.configs.recommended.rules,
...reactRules,
...commonRules,
"local/exported-top-down": "warn",
},
settings: { react: { version: "detect" } },
},
{
// Features expose a public surface via their barrel (index.ts).
// App-level code (widgets, screens, parts, hooks, routes,
// top-level components) must go through it.
//
// Exceptions — these layers legitimately reach past barrels:
// - src/app/features/<self>/**: a feature reaches its own internals.
// - src/app/features/*/lib/**: internal cross-feature plumbing.
// Lib code often touches schemas + leaf operations, where
// barrels would create load cycles or pull in browser-only code.
// - src/schema/**: composes per-feature schemas; barrels cycle.
// - src/cli/**: Node runtime; needs surgical imports.
files: ["src/**/*.{ts,tsx}"],
ignores: ["src/app/features/*/**", "src/schema/**", "src/cli/**"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: [
"@/app/features/*/lib/*",
"@/app/features/*/widgets/*",
"@/app/features/*/screens/*",
"@/app/features/*/parts/*",
"@/app/features/*/hooks/*",
],
message:
"Import from the feature barrel (@/app/features/<feature>). Deep paths bypass the public interface.",
},
],
},
],
},
},
{
// Cross-feature discipline for app-level layers inside a feature.
// widgets, screens, parts, hooks may only reach other features
// through their barrel (index.ts).
files: [
"src/app/features/*/widgets/**/*.{ts,tsx}",
"src/app/features/*/screens/**/*.{ts,tsx}",
"src/app/features/*/parts/**/*.{ts,tsx}",
"src/app/features/*/hooks/**/*.{ts,tsx}",
],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: [
"@/app/features/*/lib/*",
"@/app/features/*/widgets/*",
"@/app/features/*/screens/*",
"@/app/features/*/parts/*",
"@/app/features/*/hooks/*",
],
message:
"Import from the feature barrel (@/app/features/<feature>). Deep paths bypass the public interface.",
},
],
},
],
},
},
{
// Lib-to-lib cross-feature: may reach into other features' lib/
// (for schemas, leaf ops) but NOT into widgets/screens/parts/hooks.
files: ["src/app/features/*/lib/**/*.{ts,tsx}"],
rules: {
"no-restricted-imports": [
"error",
{
patterns: [
{
group: [
"@/app/features/*/widgets/*",
"@/app/features/*/screens/*",
"@/app/features/*/parts/*",
"@/app/features/*/hooks/*",
],
message:
"Lib code may cross-feature into lib/, but not into widgets/screens/parts/hooks. Use the barrel or move the dependency to lib/.",
},
],
},
],
},
},
...astro.configs.recommended,
{
files: ["src/**/*.astro"],
languageOptions: {
parser: astro.parser,
parserOptions: { parser: tsparser, extraFileExtensions: [".astro"] },
globals: { ...browserGlobals, Astro: "readonly" },
},
plugins: { "@typescript-eslint": tseslint },
rules: { ...tseslint.configs.recommended.rules, ...commonRules },
},
{
ignores: [
"dist/",
"build/",
"node_modules/",
".reference/",
"*.config.{js,mjs,ts}",
"src/routeTree.gen.ts",
"src/app/routeTree.gen.ts",
".astro/",
"eslint-local-rules/",
".vercel/",
".claude/",
],
},
]