@sarj/eslint-plugin 1.0.0 → 2.0.0

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.
Files changed (45) hide show
  1. package/README.md +7 -128
  2. package/dist/index.cjs +13512 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +115 -0
  5. package/dist/index.d.ts +115 -12
  6. package/dist/index.js +13503 -93
  7. package/dist/index.js.map +1 -0
  8. package/package.json +35 -21
  9. package/dist/index.d.ts.map +0 -1
  10. package/dist/rules/enforce-file-structure.d.ts +0 -4
  11. package/dist/rules/enforce-file-structure.d.ts.map +0 -1
  12. package/dist/rules/enforce-file-structure.js +0 -90
  13. package/dist/rules/no-enum.d.ts +0 -8
  14. package/dist/rules/no-enum.d.ts.map +0 -1
  15. package/dist/rules/no-enum.js +0 -29
  16. package/dist/rules/no-enum.test.d.ts +0 -2
  17. package/dist/rules/no-enum.test.d.ts.map +0 -1
  18. package/dist/rules/no-enum.test.js +0 -44
  19. package/dist/rules/no-raw-env.d.ts +0 -8
  20. package/dist/rules/no-raw-env.d.ts.map +0 -1
  21. package/dist/rules/no-raw-env.js +0 -33
  22. package/dist/rules/no-raw-env.test.d.ts +0 -2
  23. package/dist/rules/no-raw-env.test.d.ts.map +0 -1
  24. package/dist/rules/no-raw-env.test.js +0 -36
  25. package/dist/rules/prefer-shadcn.d.ts +0 -4
  26. package/dist/rules/prefer-shadcn.d.ts.map +0 -1
  27. package/dist/rules/prefer-shadcn.js +0 -50
  28. package/dist/rules/prefer-shadcn.test.d.ts +0 -2
  29. package/dist/rules/prefer-shadcn.test.d.ts.map +0 -1
  30. package/dist/rules/prefer-shadcn.test.js +0 -58
  31. package/dist/rules/require-assert-never.d.ts +0 -8
  32. package/dist/rules/require-assert-never.d.ts.map +0 -1
  33. package/dist/rules/require-assert-never.js +0 -53
  34. package/dist/rules/require-assert-never.test.d.ts +0 -2
  35. package/dist/rules/require-assert-never.test.d.ts.map +0 -1
  36. package/dist/rules/require-assert-never.test.js +0 -76
  37. package/dist/rules/require-zod-form-validation.d.ts +0 -8
  38. package/dist/rules/require-zod-form-validation.d.ts.map +0 -1
  39. package/dist/rules/require-zod-form-validation.js +0 -59
  40. package/dist/rules/zod-naming-convention.d.ts +0 -8
  41. package/dist/rules/zod-naming-convention.d.ts.map +0 -1
  42. package/dist/rules/zod-naming-convention.js +0 -53
  43. package/dist/rules/zod-naming-convention.test.d.ts +0 -2
  44. package/dist/rules/zod-naming-convention.test.d.ts.map +0 -1
  45. package/dist/rules/zod-naming-convention.test.js +0 -38
@@ -1,8 +0,0 @@
1
- import type { Rule } from "eslint";
2
- /**
3
- * @fileoverview Require Zod validation when parsing FormData
4
- * @description Ensures form data is validated with Zod schemas
5
- */
6
- export declare const requireZodFormValidation: Rule.RuleModule;
7
- export default requireZodFormValidation;
8
- //# sourceMappingURL=require-zod-form-validation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"require-zod-form-validation.d.ts","sourceRoot":"","sources":["../../src/rules/require-zod-form-validation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAGnC;;;GAGG;AAEH,eAAO,MAAM,wBAAwB,EAAE,IAAI,CAAC,UAkE3C,CAAC;AAEF,eAAe,wBAAwB,CAAC"}
@@ -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;
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=zod-naming-convention.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"zod-naming-convention.test.d.ts","sourceRoot":"","sources":["../../src/rules/zod-naming-convention.test.ts"],"names":[],"mappings":""}
@@ -1,38 +0,0 @@
1
- import { RuleTester } from "eslint";
2
- import { describe, it } from "vitest";
3
- import { zodNamingConvention } from "./zod-naming-convention.js";
4
- const ruleTester = new RuleTester({
5
- languageOptions: {
6
- ecmaVersion: 2022,
7
- sourceType: "module",
8
- },
9
- });
10
- describe("zod-naming-convention", () => {
11
- it("should pass valid and fail invalid cases", () => {
12
- ruleTester.run("zod-naming-convention", zodNamingConvention, {
13
- valid: [
14
- // Correct naming with Z prefix
15
- { code: 'const ZUserSchema = z.object({ name: z.string() });' },
16
- { code: 'const ZConfig = z.object({ port: z.number() });' },
17
- { code: 'const ZResponse = z.object({}).extend({});' },
18
- // Non-Zod variables are fine
19
- { code: 'const userSchema = createSchema();' },
20
- { code: 'const config = { name: "test" };' },
21
- ],
22
- invalid: [
23
- {
24
- code: 'const userSchema = z.object({ name: z.string() });',
25
- errors: [{ messageId: "zodPrefix" }],
26
- },
27
- {
28
- code: 'const schema = z.string();',
29
- errors: [{ messageId: "zodPrefix" }],
30
- },
31
- {
32
- code: 'const config = z.object({}).extend({ port: z.number() });',
33
- errors: [{ messageId: "zodPrefix" }],
34
- },
35
- ],
36
- });
37
- });
38
- });