@yasainet/eslint 0.0.29 → 0.0.31
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 +28 -0
- package/package.json +1 -1
- package/src/common/entry-points.mjs +20 -0
- package/src/common/index.mjs +2 -1
- package/src/common/naming.mjs +19 -0
- package/src/deno/index.mjs +7 -0
- package/src/next/index.mjs +6 -0
- package/src/node/index.mjs +6 -0
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
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Ban `import * as` at entry points. */
|
|
2
|
+
export function createEntryPointConfigs(entryPointFiles, entryPointIgnores = []) {
|
|
3
|
+
return [
|
|
4
|
+
{
|
|
5
|
+
name: "entry-points/no-namespace-import",
|
|
6
|
+
files: entryPointFiles,
|
|
7
|
+
ignores: entryPointIgnores,
|
|
8
|
+
rules: {
|
|
9
|
+
"no-restricted-syntax": [
|
|
10
|
+
"error",
|
|
11
|
+
{
|
|
12
|
+
selector: "ImportDeclaration:has(ImportNamespaceSpecifier)",
|
|
13
|
+
message:
|
|
14
|
+
"Entry points must use named imports instead of `import * as`. This makes dependencies explicit.",
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
];
|
|
20
|
+
}
|
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),
|
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);
|
package/src/deno/index.mjs
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
1
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
3
|
import { denoImportsConfigs } from "./imports.mjs";
|
|
3
4
|
|
|
4
5
|
const FEATURE_ROOT = "supabase/functions/_features";
|
|
5
6
|
|
|
7
|
+
const denoEntryPointConfigs = createEntryPointConfigs(
|
|
8
|
+
["supabase/functions/**/*.ts"],
|
|
9
|
+
["supabase/functions/_*/**"],
|
|
10
|
+
);
|
|
11
|
+
|
|
6
12
|
/** Deno ESLint flat config entry point. */
|
|
7
13
|
export const eslintConfig = [
|
|
8
14
|
...createCommonConfigs(FEATURE_ROOT, { banAliasImports: true }),
|
|
9
15
|
...denoImportsConfigs,
|
|
16
|
+
...denoEntryPointConfigs,
|
|
10
17
|
];
|
package/src/next/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
1
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
3
|
import { libBoundaryConfigs } from "../common/imports.mjs";
|
|
3
4
|
|
|
@@ -5,6 +6,10 @@ import { directivesConfigs } from "./directives.mjs";
|
|
|
5
6
|
import { importPathStyleConfigs } from "./imports.mjs";
|
|
6
7
|
import { namingConfigs } from "./naming.mjs";
|
|
7
8
|
|
|
9
|
+
const nextEntryPointConfigs = createEntryPointConfigs(
|
|
10
|
+
["src/app/**/*.ts", "src/app/**/*.tsx"],
|
|
11
|
+
);
|
|
12
|
+
|
|
8
13
|
/** Next.js ESLint flat config entry point. */
|
|
9
14
|
export const eslintConfig = [
|
|
10
15
|
...createCommonConfigs("src/features"),
|
|
@@ -12,4 +17,5 @@ export const eslintConfig = [
|
|
|
12
17
|
...namingConfigs,
|
|
13
18
|
...directivesConfigs,
|
|
14
19
|
...importPathStyleConfigs,
|
|
20
|
+
...nextEntryPointConfigs,
|
|
15
21
|
];
|
package/src/node/index.mjs
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import { createEntryPointConfigs } from "../common/entry-points.mjs";
|
|
1
2
|
import { createCommonConfigs } from "../common/index.mjs";
|
|
2
3
|
|
|
4
|
+
const nodeEntryPointConfigs = createEntryPointConfigs(
|
|
5
|
+
["scripts/commands/*.ts"],
|
|
6
|
+
);
|
|
7
|
+
|
|
3
8
|
/** Node.js ESLint flat config entry point. */
|
|
4
9
|
export const eslintConfig = [
|
|
5
10
|
...createCommonConfigs("scripts/features", { banAliasImports: true }),
|
|
11
|
+
...nodeEntryPointConfigs,
|
|
6
12
|
];
|