@yasainet/eslint 0.0.45 → 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 +1 -1
- package/src/common/imports.mjs +51 -0
- package/src/common/layers.mjs +31 -1
- package/src/next/index.mjs +8 -1
package/package.json
CHANGED
package/src/common/imports.mjs
CHANGED
|
@@ -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.
|
package/src/common/layers.mjs
CHANGED
|
@@ -18,7 +18,7 @@ export function createLayersConfigs(featureRoot) {
|
|
|
18
18
|
],
|
|
19
19
|
},
|
|
20
20
|
},
|
|
21
|
-
// Repositories: try-catch + if + logger
|
|
21
|
+
// Repositories: try-catch + if + loops + logger
|
|
22
22
|
{
|
|
23
23
|
name: "layers/repositories",
|
|
24
24
|
files: [`${featureRoot}/**/repositories/*.ts`],
|
|
@@ -35,6 +35,36 @@ export function createLayersConfigs(featureRoot) {
|
|
|
35
35
|
message:
|
|
36
36
|
"if statements are not allowed in repositories. Conditional logic belongs in services.",
|
|
37
37
|
},
|
|
38
|
+
{
|
|
39
|
+
selector: "ForStatement",
|
|
40
|
+
message:
|
|
41
|
+
"Loops are not allowed in repositories. Repositories should be thin CRUD wrappers — iteration belongs in services.",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
selector: "ForOfStatement",
|
|
45
|
+
message:
|
|
46
|
+
"Loops are not allowed in repositories. Repositories should be thin CRUD wrappers — iteration belongs in services.",
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
selector: "ForInStatement",
|
|
50
|
+
message:
|
|
51
|
+
"Loops are not allowed in repositories. Repositories should be thin CRUD wrappers — iteration belongs in services.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
selector: "WhileStatement",
|
|
55
|
+
message:
|
|
56
|
+
"Loops are not allowed in repositories. Repositories should be thin CRUD wrappers — iteration belongs in services.",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
selector: "DoWhileStatement",
|
|
60
|
+
message:
|
|
61
|
+
"Loops are not allowed in repositories. Repositories should be thin CRUD wrappers — iteration belongs in services.",
|
|
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
|
+
},
|
|
38
68
|
{ selector: loggerSelector, message: loggerMessage },
|
|
39
69
|
],
|
|
40
70
|
},
|
package/src/next/index.mjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
2
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
3
|
-
import {
|
|
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,
|