@yasainet/eslint 0.0.46 → 0.0.47

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.46",
3
+ "version": "0.0.47",
4
4
  "description": "ESLint",
5
5
  "type": "module",
6
6
  "exports": {
@@ -124,6 +124,32 @@ const PAGE_BOUNDARY_PATTERNS = [
124
124
  },
125
125
  ];
126
126
 
127
+ const HOOKS_BOUNDARY_PATTERNS = [
128
+ {
129
+ group: ["*/repositories/*", "*/repositories"],
130
+ message:
131
+ "hooks can only import actions, not repositories (hooks-boundary violation)",
132
+ },
133
+ {
134
+ group: ["*/services/*", "*/services"],
135
+ message:
136
+ "hooks can only import actions, not services (hooks-boundary violation)",
137
+ },
138
+ ];
139
+
140
+ const COMPONENTS_BOUNDARY_PATTERNS = [
141
+ {
142
+ group: ["*/repositories/*", "*/repositories"],
143
+ message:
144
+ "components can only import actions or hooks, not repositories (components-boundary violation)",
145
+ },
146
+ {
147
+ group: ["*/services/*", "*/services"],
148
+ message:
149
+ "components can only import actions or hooks, not services (components-boundary violation)",
150
+ },
151
+ ];
152
+
127
153
  function makeConfig(name, files, ...patternArrays) {
128
154
  const patterns = patternArrays.flat();
129
155
  if (patterns.length === 0) return null;
@@ -147,6 +173,31 @@ export const pageBoundaryConfigs = [
147
173
  },
148
174
  ];
149
175
 
176
+ /** Next.js-only: restrict hooks to only import actions (not repositories or services). */
177
+ export const hooksBoundaryConfigs = [
178
+ {
179
+ name: "imports/hooks-boundary",
180
+ files: ["src/features/**/hooks/*.ts"],
181
+ rules: {
182
+ "no-restricted-imports": ["error", { patterns: HOOKS_BOUNDARY_PATTERNS }],
183
+ },
184
+ },
185
+ ];
186
+
187
+ /** Next.js-only: restrict components to only import actions or hooks (not repositories or services). */
188
+ export const componentsBoundaryConfigs = [
189
+ {
190
+ name: "imports/components-boundary",
191
+ files: ["src/components/**/*.{ts,tsx}"],
192
+ rules: {
193
+ "no-restricted-imports": [
194
+ "error",
195
+ { patterns: COMPONENTS_BOUNDARY_PATTERNS },
196
+ ],
197
+ },
198
+ },
199
+ ];
200
+
150
201
  /**
151
202
  * Next.js-only: restrict @/lib imports and mapping imports outside features.
152
203
  * Per-feature subdir rules live in createImportsConfigs to avoid clobbering each other.
@@ -60,6 +60,11 @@ export function createLayersConfigs(featureRoot) {
60
60
  message:
61
61
  "Loops are not allowed in repositories. Repositories should be thin CRUD wrappers — iteration belongs in services.",
62
62
  },
63
+ {
64
+ selector: "ThrowStatement",
65
+ message:
66
+ "throw is not allowed in repositories. Repositories must return Supabase's { data, error } shape as-is. Error handling belongs in actions.",
67
+ },
63
68
  { selector: loggerSelector, message: loggerMessage },
64
69
  ],
65
70
  },
@@ -1,6 +1,11 @@
1
1
  import { createEntryPointConfigs } from "../common/entry-points.mjs";
2
2
  import { createCommonConfigs } from "../common/index.mjs";
3
- import { libBoundaryConfigs, pageBoundaryConfigs } from "../common/imports.mjs";
3
+ import {
4
+ componentsBoundaryConfigs,
5
+ hooksBoundaryConfigs,
6
+ libBoundaryConfigs,
7
+ pageBoundaryConfigs,
8
+ } from "../common/imports.mjs";
4
9
 
5
10
  import { directivesConfigs } from "./directives.mjs";
6
11
  import { importPathStyleConfigs } from "./imports.mjs";
@@ -21,6 +26,8 @@ export const eslintConfig = [
21
26
  ...createCommonConfigs("src/features"),
22
27
  ...libBoundaryConfigs,
23
28
  ...pageBoundaryConfigs,
29
+ ...hooksBoundaryConfigs,
30
+ ...componentsBoundaryConfigs,
24
31
  ...namingConfigs,
25
32
  ...directivesConfigs,
26
33
  ...importPathStyleConfigs,