@yasainet/eslint 0.0.34 → 0.0.36
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
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
# @yasainet/eslint
|
|
2
2
|
|
|
3
|
-
Shared ESLint configuration for Next.js, Node.js and Deno.
|
|
3
|
+
Shared ESLint configuration for Next.js, Hono, Node.js and Deno.
|
|
4
4
|
|
|
5
5
|
## Entry Points
|
|
6
6
|
|
|
7
|
-
| Entry | Feature Root | Description
|
|
8
|
-
| ----------------------- | ------------------------------ | ----------------------- |
|
|
9
|
-
| `@yasainet/eslint/next` | `src/features/` | Common rules + Next.js
|
|
10
|
-
| `@yasainet/eslint/
|
|
11
|
-
| `@yasainet/eslint/
|
|
7
|
+
| Entry | Feature Root | Entry Points | Description |
|
|
8
|
+
| ----------------------- | ------------------------------ | ----------------------- | ----------------------------- |
|
|
9
|
+
| `@yasainet/eslint/next` | `src/features/` | - | Common rules + Next.js |
|
|
10
|
+
| `@yasainet/eslint/hono` | `src/features/` | - | Common rules (web server) |
|
|
11
|
+
| `@yasainet/eslint/node` | `scripts/features/` | `scripts/commands/*.ts` | Common rules (CLI scripts) |
|
|
12
|
+
| `@yasainet/eslint/deno` | `supabase/functions/features/` | - | Common rules (Edge Functions) |
|
|
12
13
|
|
|
13
14
|
## Directory Structure
|
|
14
15
|
|
|
@@ -16,7 +17,8 @@ Shared ESLint configuration for Next.js, Node.js and Deno.
|
|
|
16
17
|
src/
|
|
17
18
|
├── common/ # Shared rules for all environments
|
|
18
19
|
├── next/ # Next.js-specific rules (hooks, components, directives)
|
|
19
|
-
├──
|
|
20
|
+
├── hono/ # Hono web server (src/features)
|
|
21
|
+
├── node/ # Node.js CLI scripts (scripts/features, scripts/commands)
|
|
20
22
|
└── deno/ # Deno entry point (entry-point boundary, _utils boundary, _lib boundary)
|
|
21
23
|
```
|
|
22
24
|
|
|
@@ -102,6 +104,19 @@ export default defineConfig([
|
|
|
102
104
|
]);
|
|
103
105
|
```
|
|
104
106
|
|
|
107
|
+
### Hono
|
|
108
|
+
|
|
109
|
+
```sh
|
|
110
|
+
npm install -D @yasainet/eslint eslint typescript-eslint
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
```js
|
|
114
|
+
// eslint.config.mjs
|
|
115
|
+
import { eslintConfig } from "@yasainet/eslint/hono";
|
|
116
|
+
|
|
117
|
+
export default [...eslintConfig];
|
|
118
|
+
```
|
|
119
|
+
|
|
105
120
|
### Node.js
|
|
106
121
|
|
|
107
122
|
```sh
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yasainet/eslint",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "ESLint",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
"types": "./src/node/index.d.mts",
|
|
13
13
|
"default": "./src/node/index.mjs"
|
|
14
14
|
},
|
|
15
|
+
"./hono": {
|
|
16
|
+
"types": "./src/hono/index.d.mts",
|
|
17
|
+
"default": "./src/hono/index.mjs"
|
|
18
|
+
},
|
|
15
19
|
"./deno": {
|
|
16
20
|
"types": "./src/deno/index.d.mts",
|
|
17
21
|
"default": "./src/deno/index.mjs"
|
|
@@ -2,6 +2,7 @@ import { actionHandleServiceRule } from "./action-handle-service.mjs";
|
|
|
2
2
|
import { featureNameRule } from "./feature-name.mjs";
|
|
3
3
|
import { importPathStyleRule } from "./import-path-style.mjs";
|
|
4
4
|
import { namespaceImportNameRule } from "./namespace-import-name.mjs";
|
|
5
|
+
import { schemaNamingRule } from "./schema-naming.mjs";
|
|
5
6
|
|
|
6
7
|
/** Single plugin object to avoid ESLint "Cannot redefine plugin" errors. */
|
|
7
8
|
export const localPlugin = {
|
|
@@ -10,5 +11,6 @@ export const localPlugin = {
|
|
|
10
11
|
"feature-name": featureNameRule,
|
|
11
12
|
"import-path-style": importPathStyleRule,
|
|
12
13
|
"namespace-import-name": namespaceImportNameRule,
|
|
14
|
+
"schema-naming": schemaNamingRule,
|
|
13
15
|
},
|
|
14
16
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enforce that exported variables in schema files use camelCase with a "Schema" suffix.
|
|
3
|
+
* e.g., `export const userSchema = z.object(...)` is valid.
|
|
4
|
+
* `export const UserSchema = ...` or `export const user = ...` are invalid.
|
|
5
|
+
* `export type` declarations are ignored (used for `z.infer` types).
|
|
6
|
+
*/
|
|
7
|
+
export const schemaNamingRule = {
|
|
8
|
+
meta: {
|
|
9
|
+
type: "problem",
|
|
10
|
+
messages: {
|
|
11
|
+
missingSuffix:
|
|
12
|
+
"Exported variable '{{ name }}' in a schema file must end with 'Schema'.",
|
|
13
|
+
invalidCasing:
|
|
14
|
+
"Exported variable '{{ name }}' must be camelCase (start with a lowercase letter).",
|
|
15
|
+
},
|
|
16
|
+
schema: [],
|
|
17
|
+
},
|
|
18
|
+
create(context) {
|
|
19
|
+
return {
|
|
20
|
+
ExportNamedDeclaration(node) {
|
|
21
|
+
if (!node.declaration || node.declaration.type !== "VariableDeclaration") {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
for (const declarator of node.declaration.declarations) {
|
|
26
|
+
const name = declarator.id.name;
|
|
27
|
+
|
|
28
|
+
if (!name.endsWith("Schema")) {
|
|
29
|
+
context.report({
|
|
30
|
+
node: declarator.id,
|
|
31
|
+
messageId: "missingSuffix",
|
|
32
|
+
data: { name },
|
|
33
|
+
});
|
|
34
|
+
} else if (name[0] !== name[0].toLowerCase()) {
|
|
35
|
+
context.report({
|
|
36
|
+
node: declarator.id,
|
|
37
|
+
messageId: "invalidCasing",
|
|
38
|
+
data: { name },
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
},
|
|
45
|
+
};
|
package/src/common/naming.mjs
CHANGED
|
@@ -167,6 +167,14 @@ export function createNamingConfigs(featureRoot, prefixLibMapping) {
|
|
|
167
167
|
],
|
|
168
168
|
},
|
|
169
169
|
},
|
|
170
|
+
{
|
|
171
|
+
name: "naming/schema-naming",
|
|
172
|
+
files: featuresGlob(featureRoot, "**/schemas/*.schema.ts"),
|
|
173
|
+
plugins: { local: localPlugin },
|
|
174
|
+
rules: {
|
|
175
|
+
"local/schema-naming": "error",
|
|
176
|
+
},
|
|
177
|
+
},
|
|
170
178
|
{
|
|
171
179
|
name: "naming/schemas-shared",
|
|
172
180
|
files: featuresGlob(featureRoot, "shared/schemas/*.ts"),
|