@sarj/eslint-plugin 0.1.1 → 0.1.2
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.
|
@@ -4,10 +4,10 @@ module.exports = {
|
|
|
4
4
|
docs: {
|
|
5
5
|
description: "Enforce Zod schemas to be named with a Z prefix",
|
|
6
6
|
category: "Stylistic Issues",
|
|
7
|
-
recommended: false
|
|
7
|
+
recommended: false,
|
|
8
8
|
},
|
|
9
|
-
fixable: "code",
|
|
10
|
-
schema: []
|
|
9
|
+
// fixable: "code", <- Remove this line
|
|
10
|
+
schema: [],
|
|
11
11
|
},
|
|
12
12
|
create(context) {
|
|
13
13
|
return {
|
|
@@ -17,31 +17,31 @@ module.exports = {
|
|
|
17
17
|
node.init &&
|
|
18
18
|
node.init.type === "CallExpression" &&
|
|
19
19
|
node.init.callee &&
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
node.init.callee.object.name === "z") ||
|
|
20
|
+
// Check direct calls like z.object()
|
|
21
|
+
((node.init.callee.type === "MemberExpression" &&
|
|
22
|
+
node.init.callee.object &&
|
|
23
|
+
node.init.callee.object.name === "z") ||
|
|
25
24
|
// Check chained calls like z.object().extend()
|
|
26
|
-
(node.init.callee.type === "MemberExpression" &&
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
25
|
+
(node.init.callee.type === "MemberExpression" &&
|
|
26
|
+
node.init.callee.object &&
|
|
27
|
+
node.init.callee.object.callee &&
|
|
28
|
+
node.init.callee.object.callee.object &&
|
|
29
|
+
node.init.callee.object.callee.object.name === "z"))
|
|
32
30
|
) {
|
|
33
31
|
const variableName = node.id.name;
|
|
34
32
|
if (!variableName.startsWith("Z")) {
|
|
35
33
|
context.report({
|
|
36
34
|
node: node.id,
|
|
37
35
|
message: "Zod schema names should start with Z",
|
|
38
|
-
fix
|
|
39
|
-
|
|
40
|
-
}
|
|
36
|
+
// Remove the fix function below
|
|
37
|
+
// fix(fixer) {
|
|
38
|
+
// return fixer.replaceText(node.id, `Z${variableName}`);
|
|
39
|
+
// },
|
|
41
40
|
});
|
|
42
41
|
}
|
|
43
42
|
}
|
|
44
43
|
},
|
|
45
44
|
};
|
|
46
45
|
},
|
|
47
|
-
};
|
|
46
|
+
};
|
|
47
|
+
|