@yasainet/eslint 0.0.30 → 0.0.32
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/README.md
CHANGED
|
@@ -10,6 +10,34 @@ Shared ESLint configuration for Next.js, Node.js and Deno.
|
|
|
10
10
|
| `@yasainet/eslint/node` | `scripts/features/` | Common rules only (WIP) |
|
|
11
11
|
| `@yasainet/eslint/deno` | `supabase/functions/features/` | Common rules only (WIP) |
|
|
12
12
|
|
|
13
|
+
## Directory Structure
|
|
14
|
+
|
|
15
|
+
```text
|
|
16
|
+
src/
|
|
17
|
+
├── common/ # Shared rules for all environments
|
|
18
|
+
├── next/ # Next.js-specific rules (hooks, components, directives)
|
|
19
|
+
├── node/ # Node.js entry point (common rules only)
|
|
20
|
+
└── deno/ # Deno entry point (entry-point boundary, _utils boundary, _lib boundary)
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Each entry point enforces a feature-based architecture with the following convention in consuming projects:
|
|
24
|
+
|
|
25
|
+
```text
|
|
26
|
+
{featureRoot}/
|
|
27
|
+
├── {feature}/
|
|
28
|
+
│ ├── actions/ # *.action.ts — entry points (handleXxx)
|
|
29
|
+
│ ├── services/ # *.service.ts — business logic
|
|
30
|
+
│ ├── repositories/ # *.repo.ts — data access
|
|
31
|
+
│ ├── types/ # *.type.ts
|
|
32
|
+
│ ├── schemas/ # *.schema.ts
|
|
33
|
+
│ ├── utils/ # *.util.ts
|
|
34
|
+
│ └── constants/ # *.constant.ts
|
|
35
|
+
├── shared/ # Cross-feature shared modules
|
|
36
|
+
├── ...
|
|
37
|
+
{libRoot}/ # *.lib.ts — library wrappers (e.g., supabase.lib.ts)
|
|
38
|
+
{utilsRoot}/ # *.util.ts — top-level utilities
|
|
39
|
+
```
|
|
40
|
+
|
|
13
41
|
## Setup
|
|
14
42
|
|
|
15
43
|
### Next.js + Node.js + Deno
|
package/package.json
CHANGED
package/src/common/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { generatePrefixLibMapping } from "./constants.mjs";
|
|
|
2
2
|
import { createImportsConfigs } from "./imports.mjs";
|
|
3
3
|
import { createJsdocConfigs } from "./jsdoc.mjs";
|
|
4
4
|
import { createLayersConfigs } from "./layers.mjs";
|
|
5
|
-
import { createLibNamingConfigs, createNamingConfigs } from "./naming.mjs";
|
|
5
|
+
import { createLibNamingConfigs, createNamingConfigs, createUtilsNamingConfigs } from "./naming.mjs";
|
|
6
6
|
import { rulesConfigs } from "./rules.mjs";
|
|
7
7
|
|
|
8
8
|
/** Build common configs scoped to the given feature root. */
|
|
@@ -15,6 +15,7 @@ export function createCommonConfigs(
|
|
|
15
15
|
...rulesConfigs,
|
|
16
16
|
...createNamingConfigs(featureRoot, prefixLibMapping),
|
|
17
17
|
...createLibNamingConfigs(featureRoot),
|
|
18
|
+
...createUtilsNamingConfigs(featureRoot),
|
|
18
19
|
...createLayersConfigs(featureRoot),
|
|
19
20
|
...createImportsConfigs(featureRoot, prefixLibMapping, { banAliasImports }),
|
|
20
21
|
...createJsdocConfigs(featureRoot),
|
|
@@ -51,7 +51,7 @@ function parseImportSource(importPath, featureRoot) {
|
|
|
51
51
|
if (segments.length < 2) return null;
|
|
52
52
|
|
|
53
53
|
const featureDir = segments[0];
|
|
54
|
-
const fileName = segments[segments.length - 1].replace(/\.
|
|
54
|
+
const fileName = segments[segments.length - 1].replace(/\.[jt]sx?$/, "");
|
|
55
55
|
|
|
56
56
|
const dotIdx = fileName.indexOf(".");
|
|
57
57
|
if (dotIdx === -1) return null;
|
package/src/common/naming.mjs
CHANGED
|
@@ -21,6 +21,25 @@ export function createLibNamingConfigs(featureRoot) {
|
|
|
21
21
|
];
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
/** Scope utils naming rules to the utils root derived from the given feature root. */
|
|
25
|
+
export function createUtilsNamingConfigs(featureRoot) {
|
|
26
|
+
const utilsRoot = featureRoot.replace(/features$/, "utils");
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
name: "naming/top-level-utils",
|
|
30
|
+
files: [`${utilsRoot}/**/*.ts`],
|
|
31
|
+
ignores: [`${utilsRoot}/**/*.type.ts`],
|
|
32
|
+
plugins: { "check-file": checkFile },
|
|
33
|
+
rules: {
|
|
34
|
+
"check-file/filename-naming-convention": [
|
|
35
|
+
"error",
|
|
36
|
+
{ "**/*.ts": "*.util" },
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
}
|
|
42
|
+
|
|
24
43
|
/** Scope naming rules to the given feature root. */
|
|
25
44
|
export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
26
45
|
const prefixes = Object.keys(prefixLibMapping);
|