@reasonabletech/eslint-config 0.1.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 (61) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +89 -0
  3. package/dist/src/base-configs.d.ts +53 -0
  4. package/dist/src/base-configs.js +105 -0
  5. package/dist/src/custom-rules/architecture-patterns.d.ts +193 -0
  6. package/dist/src/custom-rules/architecture-patterns.js +344 -0
  7. package/dist/src/custom-rules/code-quality.d.ts +201 -0
  8. package/dist/src/custom-rules/code-quality.js +388 -0
  9. package/dist/src/custom-rules/error-handling.d.ts +103 -0
  10. package/dist/src/custom-rules/error-handling.js +349 -0
  11. package/dist/src/custom-rules/index.d.ts +79 -0
  12. package/dist/src/custom-rules/index.js +119 -0
  13. package/dist/src/custom-rules/null-undefined-checks.d.ts +20 -0
  14. package/dist/src/custom-rules/null-undefined-checks.js +153 -0
  15. package/dist/src/custom-rules/platform-conventions.d.ts +115 -0
  16. package/dist/src/custom-rules/platform-conventions.js +249 -0
  17. package/dist/src/custom-rules/test-quality.d.ts +38 -0
  18. package/dist/src/custom-rules/test-quality.js +68 -0
  19. package/dist/src/custom-rules/type-safety.d.ts +71 -0
  20. package/dist/src/custom-rules/type-safety.js +121 -0
  21. package/dist/src/custom-rules/ui-library-imports.d.ts +21 -0
  22. package/dist/src/custom-rules/ui-library-imports.js +31 -0
  23. package/dist/src/custom-rules/utils.d.ts +95 -0
  24. package/dist/src/custom-rules/utils.js +146 -0
  25. package/dist/src/index.d.ts +73 -0
  26. package/dist/src/index.js +80 -0
  27. package/dist/src/next/config.d.ts +26 -0
  28. package/dist/src/next/config.js +76 -0
  29. package/dist/src/next/ignores.d.ts +37 -0
  30. package/dist/src/next/ignores.js +69 -0
  31. package/dist/src/next/plugins.d.ts +44 -0
  32. package/dist/src/next/plugins.js +104 -0
  33. package/dist/src/next/rules.d.ts +39 -0
  34. package/dist/src/next/rules.js +48 -0
  35. package/dist/src/next/settings.d.ts +41 -0
  36. package/dist/src/next/settings.js +45 -0
  37. package/dist/src/next.d.ts +33 -0
  38. package/dist/src/next.js +74 -0
  39. package/dist/src/plugin.d.ts +48 -0
  40. package/dist/src/plugin.js +30 -0
  41. package/dist/src/react/config.d.ts +30 -0
  42. package/dist/src/react/config.js +40 -0
  43. package/dist/src/react/plugins.d.ts +24 -0
  44. package/dist/src/react/plugins.js +46 -0
  45. package/dist/src/react/rules.d.ts +30 -0
  46. package/dist/src/react/rules.js +35 -0
  47. package/dist/src/react.d.ts +27 -0
  48. package/dist/src/react.js +35 -0
  49. package/dist/src/shared/parser-options.d.ts +3 -0
  50. package/dist/src/shared/parser-options.js +19 -0
  51. package/dist/src/shared/plugin-utils.d.ts +8 -0
  52. package/dist/src/shared/plugin-utils.js +23 -0
  53. package/dist/src/shared/react-rules.d.ts +97 -0
  54. package/dist/src/shared/react-rules.js +126 -0
  55. package/dist/src/shared/strict-rules.d.ts +27 -0
  56. package/dist/src/shared/strict-rules.js +54 -0
  57. package/dist/src/shared-ignores.d.ts +15 -0
  58. package/dist/src/shared-ignores.js +68 -0
  59. package/dist/src/shared-rules.d.ts +29 -0
  60. package/dist/src/shared-rules.js +163 -0
  61. package/package.json +122 -0
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Shared ignore patterns for ESLint configurations
3
+ *
4
+ * This module defines the standard ignore patterns used across all ESLint
5
+ * configurations in the monorepo to ensure consistent behavior
6
+ * and avoid linting generated files, build outputs, and dependencies.
7
+ */
8
+ /**
9
+ * Standard ignore patterns for all ESLint configurations.
10
+ *
11
+ * These patterns exclude common build outputs, generated files,
12
+ * and dependencies that should not be linted.
13
+ */
14
+ export const sharedIgnores = [
15
+ // Build outputs
16
+ "**/dist/**",
17
+ "**/build/**",
18
+ "**/out/**",
19
+ "**/.next/**",
20
+ "**/.nuxt/**",
21
+ "**/coverage/**",
22
+ // Dependencies
23
+ "**/node_modules/**",
24
+ // Generated files
25
+ "**/*.generated.*",
26
+ "**/*.d.ts",
27
+ "**/*.d.ts.map",
28
+ "**/*.js",
29
+ "**/*.mts",
30
+ "**/generated/**",
31
+ "**/schema.ts",
32
+ "**/types/generated/**",
33
+ "**/.webpack/**",
34
+ // Config files that don't need linting
35
+ "**/tsconfig*.json",
36
+ "**/package.json",
37
+ "**/package-lock.json",
38
+ "**/yarn.lock",
39
+ "**/pnpm-lock.yaml",
40
+ "**/*.config.*",
41
+ "**/vitest.config.*",
42
+ "**/vite.config.*",
43
+ "**/eslint.config.*",
44
+ "**/postcss.config.*",
45
+ "**/next.config.*",
46
+ "**/webpack.config.*",
47
+ "**/tsup.config.*",
48
+ "**/vitest.setup.ts",
49
+ // IDE and editor files
50
+ "**/.vscode/**",
51
+ "**/.idea/**",
52
+ "**/*.log",
53
+ // Test outputs
54
+ "**/test-results/**",
55
+ "**/playwright-report/**",
56
+ // Platform-specific outputs
57
+ "**/.expo/**",
58
+ "**/.vercel/**",
59
+ "**/.netlify/**",
60
+ // Cache directories
61
+ "**/.turbo/**",
62
+ "**/.cache/**",
63
+ "**/tmp/**",
64
+ "**/temp/**",
65
+ // Examples and documentation code
66
+ "**/examples/**",
67
+ ];
68
+ //# sourceMappingURL=shared-ignores.js.map
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Shared ESLint rules for the monorepo
3
+ *
4
+ * This module defines the standard ESLint rules used across all configurations
5
+ * to ensure consistent code quality and style throughout the monorepo.
6
+ */
7
+ import type { Linter } from "eslint";
8
+ /**
9
+ * Base ESLint rules applied to all JavaScript and TypeScript files.
10
+ *
11
+ * These rules focus on code quality, consistency, and catching common errors
12
+ * without requiring TypeScript type information.
13
+ */
14
+ export declare const baseRules: Linter.RulesRecord;
15
+ /**
16
+ * TypeScript-aware ESLint rules that require type information.
17
+ *
18
+ * These rules leverage TypeScript's type system to catch more sophisticated
19
+ * errors and enforce type safety best practices. They are essential for
20
+ * AI-generated code safety and maintaining high code quality standards.
21
+ *
22
+ * Each rule is carefully selected to:
23
+ * - Prevent runtime errors that static analysis alone cannot catch
24
+ * - Enforce consistent code patterns that improve maintainability
25
+ * - Catch subtle bugs that are common in AI-generated or rapidly written code
26
+ * - Ensure type safety without being overly restrictive
27
+ */
28
+ export declare const typeAwareRules: Linter.RulesRecord;
29
+ //# sourceMappingURL=shared-rules.d.ts.map
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Shared ESLint rules for the monorepo
3
+ *
4
+ * This module defines the standard ESLint rules used across all configurations
5
+ * to ensure consistent code quality and style throughout the monorepo.
6
+ */
7
+ /**
8
+ * Base ESLint rules applied to all JavaScript and TypeScript files.
9
+ *
10
+ * These rules focus on code quality, consistency, and catching common errors
11
+ * without requiring TypeScript type information.
12
+ */
13
+ export const baseRules = {
14
+ // Possible Problems
15
+ "no-await-in-loop": "error",
16
+ "no-duplicate-imports": "error",
17
+ "no-self-compare": "error",
18
+ "no-template-curly-in-string": "error",
19
+ "no-unmodified-loop-condition": "error",
20
+ "no-unreachable-loop": "error",
21
+ "no-unused-private-class-members": "error",
22
+ "require-atomic-updates": "error",
23
+ // Suggestions
24
+ "consistent-return": "error",
25
+ curly: "error",
26
+ "default-case-last": "error",
27
+ eqeqeq: ["error", "always", { null: "ignore" }],
28
+ "no-else-return": "error",
29
+ "no-implicit-coercion": "error",
30
+ "no-lonely-if": "error",
31
+ "no-nested-ternary": "error",
32
+ "no-param-reassign": "error",
33
+ "no-return-assign": "error",
34
+ "no-unneeded-ternary": "error",
35
+ "no-useless-concat": "error",
36
+ "no-useless-return": "error",
37
+ "no-var": "error",
38
+ "object-shorthand": "error",
39
+ "one-var": ["error", "never"],
40
+ "prefer-arrow-callback": "error",
41
+ "prefer-const": "error",
42
+ "prefer-object-spread": "error",
43
+ "prefer-promise-reject-errors": "error",
44
+ "prefer-template": "error",
45
+ "spaced-comment": [
46
+ "error",
47
+ "always",
48
+ {
49
+ markers: ["/"], // Allow /// for TypeScript triple-slash directives
50
+ },
51
+ ],
52
+ };
53
+ /**
54
+ * TypeScript-aware ESLint rules that require type information.
55
+ *
56
+ * These rules leverage TypeScript's type system to catch more sophisticated
57
+ * errors and enforce type safety best practices. They are essential for
58
+ * AI-generated code safety and maintaining high code quality standards.
59
+ *
60
+ * Each rule is carefully selected to:
61
+ * - Prevent runtime errors that static analysis alone cannot catch
62
+ * - Enforce consistent code patterns that improve maintainability
63
+ * - Catch subtle bugs that are common in AI-generated or rapidly written code
64
+ * - Ensure type safety without being overly restrictive
65
+ */
66
+ export const typeAwareRules = {
67
+ // TypeScript-specific rules for consistency and safety
68
+ "@typescript-eslint/array-type": ["error", { default: "array-simple" }], // Consistent array syntax: T[] over Array<T>
69
+ "@typescript-eslint/ban-ts-comment": [
70
+ "error",
71
+ {
72
+ // Allow TS comments but require descriptive explanations to prevent abuse
73
+ "ts-expect-error": "allow-with-description",
74
+ "ts-ignore": "allow-with-description",
75
+ "ts-nocheck": "allow-with-description",
76
+ "ts-check": false,
77
+ minimumDescriptionLength: 10,
78
+ },
79
+ ],
80
+ // Critical TypeScript safety rules
81
+ "@typescript-eslint/no-explicit-any": "error", // Prevent any usage
82
+ "@typescript-eslint/no-unused-vars": [
83
+ "error",
84
+ {
85
+ argsIgnorePattern: "^_",
86
+ varsIgnorePattern: "^_",
87
+ caughtErrorsIgnorePattern: "^_",
88
+ },
89
+ ], // Catch unused variables; underscore prefix marks intentionally unused
90
+ "@typescript-eslint/explicit-function-return-type": "error", // Require explicit return types
91
+ "@typescript-eslint/no-require-imports": "error", // Use ES6 imports only
92
+ "@typescript-eslint/no-non-null-assertion": "error", // Prevent dangerous ! operator
93
+ "@typescript-eslint/require-array-sort-compare": "error", // Require compare function for array.sort()
94
+ "@typescript-eslint/consistent-type-definitions": ["error", "interface"], // Prefer interfaces over type aliases for objects
95
+ "@typescript-eslint/consistent-type-imports": [
96
+ "error",
97
+ { prefer: "type-imports", fixStyle: "separate-type-imports" }, // Import types as types for better bundling
98
+ ],
99
+ // Runtime safety rules - catch dangerous operations
100
+ "@typescript-eslint/no-base-to-string": "error", // Prevent "[object Object]" in string conversions
101
+ "@typescript-eslint/no-confusing-void-expression": "error", // Prevent accidentally using void in expressions
102
+ "@typescript-eslint/no-duplicate-type-constituents": "error", // Clean up redundant union/intersection types
103
+ "@typescript-eslint/no-floating-promises": "error", // Ensure promises are properly handled
104
+ "@typescript-eslint/no-for-in-array": "error", // Use for-of loops for arrays, not for-in
105
+ "@typescript-eslint/no-meaningless-void-operator": "error", // Prevent unnecessary void operator usage
106
+ "@typescript-eslint/no-misused-promises": "error", // Prevent using promises where sync values expected
107
+ "@typescript-eslint/no-redundant-type-constituents": "error", // Remove redundant types from unions
108
+ // Code quality and optimization rules
109
+ "@typescript-eslint/no-unnecessary-boolean-literal-compare": "error", // Simplify boolean comparisons
110
+ "@typescript-eslint/no-unnecessary-condition": "error", // Remove conditions that are always true/false
111
+ "@typescript-eslint/no-unnecessary-type-assertion": "error", // Remove redundant type assertions
112
+ // Critical type safety rules - prevent `any` contamination and unsafe operations
113
+ "@typescript-eslint/no-unsafe-argument": "error", // Prevent passing `any` as arguments
114
+ "@typescript-eslint/no-unsafe-assignment": "error", // Prevent assigning `any` to typed variables
115
+ "@typescript-eslint/no-unsafe-call": "error", // Prevent calling `any` as function
116
+ "@typescript-eslint/no-unsafe-member-access": "error", // Prevent accessing properties on `any`
117
+ "@typescript-eslint/no-unsafe-return": "error", // Prevent returning `any` from typed functions
118
+ // Modern JavaScript/TypeScript best practices
119
+ "@typescript-eslint/prefer-includes": "error", // Use .includes() instead of .indexOf() >= 0
120
+ "@typescript-eslint/prefer-nullish-coalescing": "error", // Use ?? instead of || for null checks
121
+ "@typescript-eslint/prefer-optional-chain": "error", // Use ?. instead of manual null checks
122
+ "@typescript-eslint/prefer-readonly": "error", // Make class properties readonly when possible
123
+ "@typescript-eslint/prefer-reduce-type-parameter": "error", // Better generics in reduce calls
124
+ "@typescript-eslint/prefer-string-starts-ends-with": "error", // Use .startsWith()/.endsWith() instead of regex
125
+ "@typescript-eslint/require-await": "error", // Async functions must use await
126
+ "@typescript-eslint/restrict-plus-operands": "error", // Prevent mixing types in + operations
127
+ "@typescript-eslint/restrict-template-expressions": [
128
+ "error",
129
+ {
130
+ // Allow safe types in template literals, prevent dangerous ones
131
+ allowNumber: true,
132
+ allowBoolean: true,
133
+ allowAny: false, // Critical: prevent `any` in templates
134
+ allowNullish: false, // Prevent null/undefined interpolation
135
+ allowRegExp: false,
136
+ },
137
+ ],
138
+ "@typescript-eslint/strict-boolean-expressions": [
139
+ "error",
140
+ {
141
+ // Require explicit boolean checks - critical for AI-generated code safety
142
+ allowString: false, // Prevent truthy string checks
143
+ allowNumber: false, // Prevent truthy number checks
144
+ allowNullableObject: false, // Require explicit null checks
145
+ allowNullableBoolean: false,
146
+ allowNullableString: false,
147
+ allowNullableNumber: false,
148
+ allowAny: false, // Critical: prevent `any` in conditions
149
+ },
150
+ ],
151
+ "@typescript-eslint/switch-exhaustiveness-check": "error", // Ensure all enum cases are handled
152
+ "@typescript-eslint/unbound-method": "error", // Prevent method extraction without binding
153
+ // Overrides for base rules when using TypeScript - use TypeScript-aware versions
154
+ "no-implied-eval": "off", // Disable base rule
155
+ "@typescript-eslint/no-implied-eval": "error", // Use TypeScript-aware version that understands types
156
+ "dot-notation": "off", // Disable base rule
157
+ "@typescript-eslint/dot-notation": "error", // Use TypeScript version that respects optional properties
158
+ "no-return-await": "off", // Disable base rule
159
+ "@typescript-eslint/return-await": ["error", "always"], // Always return await for better stack traces
160
+ "no-throw-literal": "off", // Disable deprecated base rule
161
+ "@typescript-eslint/only-throw-error": "error", // Type-aware replacement that validates thrown values
162
+ };
163
+ //# sourceMappingURL=shared-rules.js.map
package/package.json ADDED
@@ -0,0 +1,122 @@
1
+ {
2
+ "name": "@reasonabletech/eslint-config",
3
+ "version": "0.1.0",
4
+ "description": "Shared ESLint configuration",
5
+ "keywords": [
6
+ "reasonabletech",
7
+ "config",
8
+ "typescript",
9
+ "eslint",
10
+ "linter",
11
+ "eslint-config",
12
+ "flat-config",
13
+ "code-quality"
14
+ ],
15
+ "type": "module",
16
+ "main": "./dist/src/index.js",
17
+ "publishConfig": {
18
+ "access": "public",
19
+ "registry": "https://registry.npmjs.org/"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/src/index.d.ts",
24
+ "import": "./dist/src/index.js"
25
+ },
26
+ "./next": {
27
+ "types": "./dist/src/next.d.ts",
28
+ "import": "./dist/src/next.js"
29
+ },
30
+ "./react": {
31
+ "types": "./dist/src/react.d.ts",
32
+ "import": "./dist/src/react.js"
33
+ },
34
+ "./custom-rules": {
35
+ "types": "./dist/src/custom-rules/index.d.ts",
36
+ "import": "./dist/src/custom-rules/index.js"
37
+ }
38
+ },
39
+ "author": "Reasonable Tech Company <contact@reasonabletech.co>",
40
+ "dependencies": {
41
+ "@eslint/js": "10.0.1",
42
+ "eslint-config-prettier": "10.1.8",
43
+ "eslint-plugin-jsdoc": "62.7.1",
44
+ "typescript-eslint": "8.56.1"
45
+ },
46
+ "peerDependencies": {
47
+ "eslint": ">=10.0.0",
48
+ "typescript": ">=5.5.0",
49
+ "@next/eslint-plugin-next": ">=16.0.0",
50
+ "eslint-config-next": ">=16.0.0",
51
+ "eslint-plugin-react": ">=7.37.0",
52
+ "eslint-plugin-react-refresh": ">=0.5.0"
53
+ },
54
+ "peerDependenciesMeta": {
55
+ "@next/eslint-plugin-next": {
56
+ "optional": true
57
+ },
58
+ "eslint-config-next": {
59
+ "optional": true
60
+ },
61
+ "eslint-plugin-react": {
62
+ "optional": true
63
+ },
64
+ "eslint-plugin-react-refresh": {
65
+ "optional": true
66
+ }
67
+ },
68
+ "devDependencies": {
69
+ "@eslint/eslintrc": "3.3.4",
70
+ "@next/eslint-plugin-next": "16.1.6",
71
+ "@types/node": "25.3.1",
72
+ "@typescript-eslint/utils": "8.56.1",
73
+ "@vitest/coverage-v8": "4.0.18",
74
+ "eslint": "10.0.2",
75
+ "eslint-config-next": "16.1.6",
76
+ "eslint-plugin-react": "7.37.5",
77
+ "eslint-plugin-react-refresh": "0.5.2",
78
+ "globals": "17.3.0",
79
+ "tsup": "8.5.1",
80
+ "typescript": "5.9.3",
81
+ "vitest": "4.0.18",
82
+ "@reasonabletech/config-typescript": "0.1.1"
83
+ },
84
+ "license": "MIT",
85
+ "repository": {
86
+ "type": "git",
87
+ "url": "https://github.com/ReasonableTech/core-utils.git",
88
+ "directory": "packages/eslint-config"
89
+ },
90
+ "bugs": {
91
+ "url": "https://github.com/ReasonableTech/core-utils/issues"
92
+ },
93
+ "homepage": "https://github.com/ReasonableTech/core-utils/tree/main/packages/eslint-config",
94
+ "files": [
95
+ "dist",
96
+ "!dist/**/*.map",
97
+ "!dist/**/*.tsbuildinfo",
98
+ "README.md",
99
+ "CHANGELOG.md"
100
+ ],
101
+ "sideEffects": false,
102
+ "engines": {
103
+ "node": ">=22"
104
+ },
105
+ "scripts": {
106
+ "build": "tsc -p tsconfig.build.json",
107
+ "clean": "rimraf dist .turbo node_modules coverage .next .webpack out && rm -f tsconfig.tsbuildinfo",
108
+ "dev": "tsc --watch",
109
+ "docs:coverage": "tsx ../../../scripts/analysis/check-doc-coverage.ts --html",
110
+ "lint": "eslint . --fix",
111
+ "lint:check": "eslint .",
112
+ "test": "vitest run",
113
+ "test:coverage": "vitest run --coverage",
114
+ "test:e2e": "vitest run tests/e2e",
115
+ "test:integration": "vitest run tests/integration",
116
+ "test:ui": "vitest --ui",
117
+ "test:unit": "vitest run tests/unit",
118
+ "test:watch": "vitest --watch",
119
+ "typecheck": "tsc --noEmit",
120
+ "verify:release": "pnpm typecheck && pnpm lint:check && pnpm test && pnpm build"
121
+ }
122
+ }