@yasainet/eslint 0.0.61 → 0.0.63
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
package/src/common/constants.mjs
CHANGED
|
@@ -23,10 +23,10 @@ const PROJECT_ROOT = findProjectRoot();
|
|
|
23
23
|
/**
|
|
24
24
|
* Files / basenames that should never become a prefix:
|
|
25
25
|
*
|
|
26
|
-
* - `types.ts`: 型定義のみで lib の役割を持たない
|
|
26
|
+
* - `types.ts` / `type.ts`: 型定義のみで lib の役割を持たない (単複どちらの命名でも除外)
|
|
27
27
|
* - `proxy.ts`: middleware adapter (Next.js の proxy.ts と意味が衝突するため queries から呼ばせない)
|
|
28
28
|
*/
|
|
29
|
-
const EXCLUDE_LIST = ["types.ts", "proxy.ts"];
|
|
29
|
+
const EXCLUDE_LIST = ["types.ts", "type.ts", "proxy.ts"];
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
* Scan lib directory and build prefix-to-lib-relative-path mapping:
|
|
@@ -34,7 +34,7 @@ const EXCLUDE_LIST = ["types.ts", "proxy.ts"];
|
|
|
34
34
|
* - single-client lib (`lib/<dir>/index.ts`): prefix = dir 名、entry のみ登録 — 同 dir 内の他ファイル (parser 等 sub-module) は自動除外
|
|
35
35
|
* - multi-client lib (index.ts なし): dir 内の全 `<role>.ts` を登録 (e.g., supabase の admin / server / client)
|
|
36
36
|
* - 多重拡張子 (`.test.ts` 等) を持つファイルは sub-module / 非 lib として除外
|
|
37
|
-
* - types.ts / proxy.ts のような lib として queries から呼ばせたくないものは EXCLUDE_LIST で除外
|
|
37
|
+
* - types.ts / type.ts / proxy.ts のような lib として queries から呼ばせたくないものは EXCLUDE_LIST で除外
|
|
38
38
|
*/
|
|
39
39
|
export function generatePrefixLibMapping(featureRoot) {
|
|
40
40
|
const libRoot = featureRoot.replace(/features$/, "lib");
|
package/src/common/imports.mjs
CHANGED
|
@@ -137,6 +137,19 @@ const ROUTE_BOUNDARY_PATTERNS = [
|
|
|
137
137
|
},
|
|
138
138
|
];
|
|
139
139
|
|
|
140
|
+
const SITEMAP_BOUNDARY_PATTERNS = [
|
|
141
|
+
{
|
|
142
|
+
group: ["**/queries/*", "**/queries"],
|
|
143
|
+
message:
|
|
144
|
+
"sitemap.ts can only import entries, not queries (sitemap-boundary violation)",
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
group: ["**/services/*", "**/services"],
|
|
148
|
+
message:
|
|
149
|
+
"sitemap.ts can only import entries, not services (sitemap-boundary violation)",
|
|
150
|
+
},
|
|
151
|
+
];
|
|
152
|
+
|
|
140
153
|
const HOOKS_BOUNDARY_PATTERNS = [
|
|
141
154
|
{
|
|
142
155
|
group: ["**/queries/*", "**/queries"],
|
|
@@ -220,6 +233,26 @@ export const routeBoundaryConfigs = [
|
|
|
220
233
|
},
|
|
221
234
|
];
|
|
222
235
|
|
|
236
|
+
/** Next.js-only: restrict sitemap.ts to only import entries. */
|
|
237
|
+
export const sitemapBoundaryConfigs = [
|
|
238
|
+
{
|
|
239
|
+
name: "imports/sitemap-boundary",
|
|
240
|
+
files: ["src/app/sitemap.ts", "src/app/**/sitemap.ts"],
|
|
241
|
+
rules: {
|
|
242
|
+
"no-restricted-imports": [
|
|
243
|
+
"error",
|
|
244
|
+
{
|
|
245
|
+
patterns: [
|
|
246
|
+
...SITEMAP_BOUNDARY_PATTERNS,
|
|
247
|
+
...LIB_BOUNDARY_PATTERNS,
|
|
248
|
+
...MAPPING_PATTERNS,
|
|
249
|
+
],
|
|
250
|
+
},
|
|
251
|
+
],
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
];
|
|
255
|
+
|
|
223
256
|
/** Next.js-only: restrict hooks to only import entries (not queries or services). */
|
|
224
257
|
export const hooksBoundaryConfigs = [
|
|
225
258
|
{
|
|
@@ -271,7 +304,6 @@ export const libBoundaryConfigs = [
|
|
|
271
304
|
ignores: [
|
|
272
305
|
"src/lib/**",
|
|
273
306
|
"src/proxy.ts",
|
|
274
|
-
"src/app/sitemap.ts",
|
|
275
307
|
"src/app/**/route.ts",
|
|
276
308
|
"src/features/**",
|
|
277
309
|
],
|
|
@@ -110,18 +110,16 @@ export const featureNameRule = {
|
|
|
110
110
|
// Prefer the Supabase types file adjacent to `featureRoot` (e.g. `src/lib/...`
|
|
111
111
|
// for `src/features`). Fall back to `src/lib/...` at the project root so that
|
|
112
112
|
// non-`src` feature roots (e.g. `scripts/features`) can reuse the same
|
|
113
|
-
// generated types without duplicating the file.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
featureRoot.replace(/features$/, "lib/supabase/types.ts"),
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
projectRoot,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
? computedTypePath
|
|
124
|
-
: fallbackTypePath;
|
|
113
|
+
// generated types without duplicating the file. Both `types.ts` (plural) and
|
|
114
|
+
// `type.ts` (singular) are accepted to match either naming convention.
|
|
115
|
+
const candidateTypePaths = [
|
|
116
|
+
path.join(projectRoot, featureRoot.replace(/features$/, "lib/supabase/types.ts")),
|
|
117
|
+
path.join(projectRoot, featureRoot.replace(/features$/, "lib/supabase/type.ts")),
|
|
118
|
+
path.join(projectRoot, "src/lib/supabase/types.ts"),
|
|
119
|
+
path.join(projectRoot, "src/lib/supabase/type.ts"),
|
|
120
|
+
];
|
|
121
|
+
const supabaseTypePath =
|
|
122
|
+
candidateTypePaths.find((p) => fs.existsSync(p)) ?? candidateTypePaths[0];
|
|
125
123
|
|
|
126
124
|
const tableNames = extractTableNames(supabaseTypePath);
|
|
127
125
|
const allowedNames = ["shared", "auth", ...tableNames.map(toKebab)];
|
package/src/next/index.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
libBoundaryConfigs,
|
|
7
7
|
pageBoundaryConfigs,
|
|
8
8
|
routeBoundaryConfigs,
|
|
9
|
+
sitemapBoundaryConfigs,
|
|
9
10
|
} from "../common/imports.mjs";
|
|
10
11
|
|
|
11
12
|
import { directivesConfigs } from "./directives.mjs";
|
|
@@ -29,6 +30,7 @@ export const eslintConfig = [
|
|
|
29
30
|
...libBoundaryConfigs,
|
|
30
31
|
...pageBoundaryConfigs,
|
|
31
32
|
...routeBoundaryConfigs,
|
|
33
|
+
...sitemapBoundaryConfigs,
|
|
32
34
|
...hooksBoundaryConfigs,
|
|
33
35
|
...componentsBoundaryConfigs,
|
|
34
36
|
...namingConfigs,
|