@sarj/eslint-plugin 1.0.1 → 2.0.1
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 +7 -128
- package/dist/index.cjs +1070 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +115 -0
- package/dist/index.d.ts +115 -12
- package/dist/index.js +1049 -95
- package/dist/index.js.map +1 -0
- package/package.json +43 -26
- package/dist/index.d.ts.map +0 -1
- package/dist/rules/enforce-file-structure.d.ts +0 -4
- package/dist/rules/enforce-file-structure.d.ts.map +0 -1
- package/dist/rules/enforce-file-structure.js +0 -90
- package/dist/rules/no-enum.d.ts +0 -8
- package/dist/rules/no-enum.d.ts.map +0 -1
- package/dist/rules/no-enum.js +0 -29
- package/dist/rules/no-raw-env.d.ts +0 -8
- package/dist/rules/no-raw-env.d.ts.map +0 -1
- package/dist/rules/no-raw-env.js +0 -33
- package/dist/rules/prefer-shadcn.d.ts +0 -4
- package/dist/rules/prefer-shadcn.d.ts.map +0 -1
- package/dist/rules/prefer-shadcn.js +0 -50
- package/dist/rules/require-assert-never.d.ts +0 -8
- package/dist/rules/require-assert-never.d.ts.map +0 -1
- package/dist/rules/require-assert-never.js +0 -53
- package/dist/rules/require-zod-form-validation.d.ts +0 -8
- package/dist/rules/require-zod-form-validation.d.ts.map +0 -1
- package/dist/rules/require-zod-form-validation.js +0 -59
- package/dist/rules/zod-naming-convention.d.ts +0 -8
- package/dist/rules/zod-naming-convention.d.ts.map +0 -1
- package/dist/rules/zod-naming-convention.js +0 -53
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Require Zod validation when parsing FormData
|
|
3
|
-
* @description Ensures form data is validated with Zod schemas
|
|
4
|
-
*/
|
|
5
|
-
export const requireZodFormValidation = {
|
|
6
|
-
meta: {
|
|
7
|
-
type: "problem",
|
|
8
|
-
docs: {
|
|
9
|
-
description: "Require Zod validation when parsing FormData",
|
|
10
|
-
recommended: true,
|
|
11
|
-
},
|
|
12
|
-
schema: [],
|
|
13
|
-
messages: {
|
|
14
|
-
missingZodValidation: "FormData parsing must use Zod schema validation (e.g., Schema.parse())",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
create(context) {
|
|
18
|
-
return {
|
|
19
|
-
CallExpression(node) {
|
|
20
|
-
const callExpr = node;
|
|
21
|
-
// Check for formData.get() calls
|
|
22
|
-
if (callExpr.callee.type !== "MemberExpression") {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
const callee = callExpr.callee;
|
|
26
|
-
if (callee.property.type !== "Identifier" ||
|
|
27
|
-
callee.property.name !== "get" ||
|
|
28
|
-
callee.object.type !== "Identifier" ||
|
|
29
|
-
callee.object.name !== "formData") {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
// Check if this is inside a Zod .parse() call
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
let parent = node.parent;
|
|
35
|
-
let hasZodValidation = false;
|
|
36
|
-
// Traverse up to find if we're inside a .parse() call
|
|
37
|
-
while (parent) {
|
|
38
|
-
if (parent.type === "CallExpression" &&
|
|
39
|
-
parent.callee.type === "MemberExpression") {
|
|
40
|
-
const parentCallee = parent.callee;
|
|
41
|
-
if (parentCallee.property.type === "Identifier" &&
|
|
42
|
-
parentCallee.property.name === "parse") {
|
|
43
|
-
hasZodValidation = true;
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
parent = parent.parent;
|
|
48
|
-
}
|
|
49
|
-
if (!hasZodValidation) {
|
|
50
|
-
context.report({
|
|
51
|
-
node: node,
|
|
52
|
-
messageId: "missingZodValidation",
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
export default requireZodFormValidation;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Rule } from "eslint";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Enforce Zod schemas to be named with a Z prefix
|
|
4
|
-
* @description Ensures consistent naming for Zod schemas (e.g., ZUserSchema instead of userSchema)
|
|
5
|
-
*/
|
|
6
|
-
export declare const zodNamingConvention: Rule.RuleModule;
|
|
7
|
-
export default zodNamingConvention;
|
|
8
|
-
//# sourceMappingURL=zod-naming-convention.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zod-naming-convention.d.ts","sourceRoot":"","sources":["../../src/rules/zod-naming-convention.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGnC;;;GAGG;AAEH,eAAO,MAAM,mBAAmB,EAAE,IAAI,CAAC,UAqDtC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @fileoverview Enforce Zod schemas to be named with a Z prefix
|
|
3
|
-
* @description Ensures consistent naming for Zod schemas (e.g., ZUserSchema instead of userSchema)
|
|
4
|
-
*/
|
|
5
|
-
export const zodNamingConvention = {
|
|
6
|
-
meta: {
|
|
7
|
-
type: "suggestion",
|
|
8
|
-
docs: {
|
|
9
|
-
description: "Enforce Zod schemas to be named with a Z prefix",
|
|
10
|
-
recommended: false,
|
|
11
|
-
},
|
|
12
|
-
schema: [],
|
|
13
|
-
messages: {
|
|
14
|
-
zodPrefix: "Zod schema names should start with 'Z' (e.g., Z{{suggestedName}})",
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
create(context) {
|
|
18
|
-
return {
|
|
19
|
-
VariableDeclarator(node) {
|
|
20
|
-
const declarator = node;
|
|
21
|
-
if (!declarator.init || declarator.init.type !== "CallExpression") {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const callExpr = declarator.init;
|
|
25
|
-
if (!callExpr.callee || callExpr.callee.type !== "MemberExpression") {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const callee = callExpr.callee;
|
|
29
|
-
const isDirectZodCall = callee.object.type === "Identifier" &&
|
|
30
|
-
callee.object.name === "z";
|
|
31
|
-
const isChainedZodCall = callee.object.type === "CallExpression" &&
|
|
32
|
-
callee.object.callee?.type === "MemberExpression" &&
|
|
33
|
-
callee.object.callee.object?.type === "Identifier" &&
|
|
34
|
-
callee.object.callee.object.name === "z";
|
|
35
|
-
if (isDirectZodCall || isChainedZodCall) {
|
|
36
|
-
if (declarator.id.type !== "Identifier") {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
const variableName = declarator.id.name;
|
|
40
|
-
if (!variableName.startsWith("Z")) {
|
|
41
|
-
const suggestedName = variableName.charAt(0).toUpperCase() + variableName.slice(1);
|
|
42
|
-
context.report({
|
|
43
|
-
node: declarator.id,
|
|
44
|
-
messageId: "zodPrefix",
|
|
45
|
-
data: { suggestedName },
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
export default zodNamingConvention;
|