@yasainet/eslint 0.0.38 → 0.0.39
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 +24 -0
- package/src/next/index.mjs +2 -1
package/package.json
CHANGED
package/src/common/imports.mjs
CHANGED
|
@@ -102,6 +102,19 @@ const LIB_BOUNDARY_PATTERNS = [
|
|
|
102
102
|
},
|
|
103
103
|
];
|
|
104
104
|
|
|
105
|
+
const PAGE_BOUNDARY_PATTERNS = [
|
|
106
|
+
{
|
|
107
|
+
group: ["*/repositories/*", "*/repositories"],
|
|
108
|
+
message:
|
|
109
|
+
"page.tsx can only import actions, not repositories (page-boundary violation)",
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
group: ["*/services/*", "*/services"],
|
|
113
|
+
message:
|
|
114
|
+
"page.tsx can only import actions, not services (page-boundary violation)",
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
|
|
105
118
|
function makeConfig(name, files, ...patternArrays) {
|
|
106
119
|
const patterns = patternArrays.flat();
|
|
107
120
|
if (patterns.length === 0) return null;
|
|
@@ -114,6 +127,17 @@ function makeConfig(name, files, ...patternArrays) {
|
|
|
114
127
|
};
|
|
115
128
|
}
|
|
116
129
|
|
|
130
|
+
/** Next.js-only: restrict page.tsx to only import actions. */
|
|
131
|
+
export const pageBoundaryConfigs = [
|
|
132
|
+
{
|
|
133
|
+
name: "imports/page-boundary",
|
|
134
|
+
files: ["src/app/**/page.tsx"],
|
|
135
|
+
rules: {
|
|
136
|
+
"no-restricted-imports": ["error", { patterns: PAGE_BOUNDARY_PATTERNS }],
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
|
|
117
141
|
/** Next.js-only: restrict @/lib imports to repositories. */
|
|
118
142
|
export const libBoundaryConfigs = [
|
|
119
143
|
{
|
package/src/next/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
2
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
3
|
-
import { libBoundaryConfigs } from "../common/imports.mjs";
|
|
3
|
+
import { libBoundaryConfigs, pageBoundaryConfigs } from "../common/imports.mjs";
|
|
4
4
|
|
|
5
5
|
import { directivesConfigs } from "./directives.mjs";
|
|
6
6
|
import { importPathStyleConfigs } from "./imports.mjs";
|
|
@@ -14,6 +14,7 @@ const nextEntryPointConfigs = createEntryPointConfigs(
|
|
|
14
14
|
export const eslintConfig = [
|
|
15
15
|
...createCommonConfigs("src/features"),
|
|
16
16
|
...libBoundaryConfigs,
|
|
17
|
+
...pageBoundaryConfigs,
|
|
17
18
|
...namingConfigs,
|
|
18
19
|
...directivesConfigs,
|
|
19
20
|
...importPathStyleConfigs,
|