@yasainet/eslint 0.0.55 → 0.0.57

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yasainet/eslint",
3
- "version": "0.0.55",
3
+ "version": "0.0.57",
4
4
  "description": "ESLint",
5
5
  "type": "module",
6
6
  "exports": {
@@ -1,35 +1,35 @@
1
1
  const LAYER_PATTERNS = {
2
2
  queries: [
3
3
  {
4
- group: ["*/services/*", "*/services"],
4
+ group: ["**/services/*", "**/services"],
5
5
  message: "queries cannot import services (layer violation)",
6
6
  },
7
7
  {
8
- group: ["*/interactors/*", "*/interactors"],
8
+ group: ["**/interactors/*", "**/interactors"],
9
9
  message: "queries cannot import interactors (layer violation)",
10
10
  },
11
11
  {
12
- group: ["*/hooks/*", "*/hooks"],
12
+ group: ["**/hooks/*", "**/hooks"],
13
13
  message: "queries cannot import hooks (layer violation)",
14
14
  },
15
15
  ],
16
16
  services: [
17
17
  {
18
- group: ["*/interactors/*", "*/interactors"],
18
+ group: ["**/interactors/*", "**/interactors"],
19
19
  message: "services cannot import interactors (layer violation)",
20
20
  },
21
21
  {
22
- group: ["*/hooks/*", "*/hooks"],
22
+ group: ["**/hooks/*", "**/hooks"],
23
23
  message: "services cannot import hooks (layer violation)",
24
24
  },
25
25
  ],
26
26
  interactors: [
27
27
  {
28
- group: ["*/queries/*", "*/queries"],
28
+ group: ["**/queries/*", "**/queries"],
29
29
  message: "interactors cannot import queries (layer violation)",
30
30
  },
31
31
  {
32
- group: ["*/hooks/*", "*/hooks"],
32
+ group: ["**/hooks/*", "**/hooks"],
33
33
  message: "interactors cannot import hooks (layer violation)",
34
34
  },
35
35
  ],
@@ -113,25 +113,38 @@ const MAPPING_PATTERNS = [
113
113
 
114
114
  const PAGE_BOUNDARY_PATTERNS = [
115
115
  {
116
- group: ["*/queries/*", "*/queries"],
116
+ group: ["**/queries/*", "**/queries"],
117
117
  message:
118
118
  "page.tsx can only import interactors, not queries (page-boundary violation)",
119
119
  },
120
120
  {
121
- group: ["*/services/*", "*/services"],
121
+ group: ["**/services/*", "**/services"],
122
122
  message:
123
123
  "page.tsx can only import interactors, not services (page-boundary violation)",
124
124
  },
125
125
  ];
126
126
 
127
+ const ROUTE_BOUNDARY_PATTERNS = [
128
+ {
129
+ group: ["**/queries/*", "**/queries"],
130
+ message:
131
+ "route.ts can only import interactors, not queries (route-boundary violation)",
132
+ },
133
+ {
134
+ group: ["**/services/*", "**/services"],
135
+ message:
136
+ "route.ts can only import interactors, not services (route-boundary violation)",
137
+ },
138
+ ];
139
+
127
140
  const HOOKS_BOUNDARY_PATTERNS = [
128
141
  {
129
- group: ["*/queries/*", "*/queries"],
142
+ group: ["**/queries/*", "**/queries"],
130
143
  message:
131
144
  "hooks can only import interactors, not queries (hooks-boundary violation)",
132
145
  },
133
146
  {
134
- group: ["*/services/*", "*/services"],
147
+ group: ["**/services/*", "**/services"],
135
148
  message:
136
149
  "hooks can only import interactors, not services (hooks-boundary violation)",
137
150
  },
@@ -139,12 +152,12 @@ const HOOKS_BOUNDARY_PATTERNS = [
139
152
 
140
153
  const COMPONENTS_BOUNDARY_PATTERNS = [
141
154
  {
142
- group: ["*/queries/*", "*/queries"],
155
+ group: ["**/queries/*", "**/queries"],
143
156
  message:
144
157
  "components can only import interactors or hooks, not queries (components-boundary violation)",
145
158
  },
146
159
  {
147
- group: ["*/services/*", "*/services"],
160
+ group: ["**/services/*", "**/services"],
148
161
  message:
149
162
  "components can only import interactors or hooks, not services (components-boundary violation)",
150
163
  },
@@ -162,13 +175,47 @@ function makeConfig(name, files, ...patternArrays) {
162
175
  };
163
176
  }
164
177
 
178
+ // In ESLint flat config, when multiple matching configs set the same rule
179
+ // (`no-restricted-imports`), the later config's options REPLACE the earlier
180
+ // ones — patterns are not merged. Page / hooks / components boundary configs
181
+ // run after libBoundaryConfigs and would silently drop lib + mapping bans
182
+ // unless we re-include those patterns explicitly.
165
183
  /** Next.js-only: restrict page.tsx to only import interactors. */
166
184
  export const pageBoundaryConfigs = [
167
185
  {
168
186
  name: "imports/page-boundary",
169
187
  files: ["src/app/**/page.tsx"],
170
188
  rules: {
171
- "no-restricted-imports": ["error", { patterns: PAGE_BOUNDARY_PATTERNS }],
189
+ "no-restricted-imports": [
190
+ "error",
191
+ {
192
+ patterns: [
193
+ ...PAGE_BOUNDARY_PATTERNS,
194
+ ...LIB_BOUNDARY_PATTERNS,
195
+ ...MAPPING_PATTERNS,
196
+ ],
197
+ },
198
+ ],
199
+ },
200
+ },
201
+ ];
202
+
203
+ /** Next.js-only: restrict route.ts to only import interactors. */
204
+ export const routeBoundaryConfigs = [
205
+ {
206
+ name: "imports/route-boundary",
207
+ files: ["src/app/**/route.ts"],
208
+ rules: {
209
+ "no-restricted-imports": [
210
+ "error",
211
+ {
212
+ patterns: [
213
+ ...ROUTE_BOUNDARY_PATTERNS,
214
+ ...LIB_BOUNDARY_PATTERNS,
215
+ ...MAPPING_PATTERNS,
216
+ ],
217
+ },
218
+ ],
172
219
  },
173
220
  },
174
221
  ];
@@ -179,7 +226,16 @@ export const hooksBoundaryConfigs = [
179
226
  name: "imports/hooks-boundary",
180
227
  files: ["src/features/**/hooks/*.ts"],
181
228
  rules: {
182
- "no-restricted-imports": ["error", { patterns: HOOKS_BOUNDARY_PATTERNS }],
229
+ "no-restricted-imports": [
230
+ "error",
231
+ {
232
+ patterns: [
233
+ ...HOOKS_BOUNDARY_PATTERNS,
234
+ ...LIB_BOUNDARY_PATTERNS,
235
+ ...MAPPING_PATTERNS,
236
+ ],
237
+ },
238
+ ],
183
239
  },
184
240
  },
185
241
  ];
@@ -192,7 +248,13 @@ export const componentsBoundaryConfigs = [
192
248
  rules: {
193
249
  "no-restricted-imports": [
194
250
  "error",
195
- { patterns: COMPONENTS_BOUNDARY_PATTERNS },
251
+ {
252
+ patterns: [
253
+ ...COMPONENTS_BOUNDARY_PATTERNS,
254
+ ...LIB_BOUNDARY_PATTERNS,
255
+ ...MAPPING_PATTERNS,
256
+ ],
257
+ },
196
258
  ],
197
259
  },
198
260
  },
@@ -5,6 +5,7 @@ import {
5
5
  hooksBoundaryConfigs,
6
6
  libBoundaryConfigs,
7
7
  pageBoundaryConfigs,
8
+ routeBoundaryConfigs,
8
9
  } from "../common/imports.mjs";
9
10
 
10
11
  import { directivesConfigs } from "./directives.mjs";
@@ -26,6 +27,7 @@ export const eslintConfig = [
26
27
  ...createCommonConfigs("src/features"),
27
28
  ...libBoundaryConfigs,
28
29
  ...pageBoundaryConfigs,
30
+ ...routeBoundaryConfigs,
29
31
  ...hooksBoundaryConfigs,
30
32
  ...componentsBoundaryConfigs,
31
33
  ...namingConfigs,