1
1
import js from '@eslint/js' ;
2
- import tseslint from '@typescript-eslint/eslint-plugin' ;
3
- import tsparser from '@typescript-eslint/parser' ;
4
- import prettierConfig from 'eslint-config-prettier' ;
5
- import prettierPlugin from 'eslint-plugin-prettier' ;
2
+ import tseslint from 'typescript-eslint' ;
6
3
import globals from 'globals' ;
4
+ import importPlugin from 'eslint-plugin-import' ;
5
+ import unusedImportsPlugin from 'eslint-plugin-unused-imports' ;
7
6
8
- export default [
9
- // Base JavaScript configuration
10
- js . configs . recommended ,
11
-
12
- // Global ignore patterns
7
+ export default tseslint . config (
8
+ // Global ignores.
13
9
{
14
10
ignores : [
15
11
'**/node_modules/**' ,
@@ -21,91 +17,109 @@ export default [
21
17
'**/*.config.ts' ,
22
18
'**/generated/**' ,
23
19
'.eslintrc.js' ,
24
- '**/*.spec.ts' ,
25
- '**/*.test.ts' ,
26
20
] ,
27
21
} ,
22
+
23
+ // Apply base recommended configurations.
24
+ js . configs . recommended ,
25
+ ...tseslint . configs . recommended ,
28
26
29
- // Universal TypeScript configuration for the entire monorepo
27
+ // A single, unified object for all custom rules and plugin configurations.
30
28
{
31
- files : [ '**/*.ts' , '**/*.tsx' ] ,
32
29
languageOptions : {
33
- parser : tsparser ,
34
- parserOptions : {
35
- ecmaVersion : 2021 ,
36
- sourceType : 'module' ,
37
- // Don't use project-based parsing to avoid config issues
38
- ecmaFeatures : {
39
- jsx : true ,
40
- } ,
41
- } ,
42
30
globals : {
43
- // Universal globals that work everywhere
44
31
...globals . node ,
45
- ...globals . browser ,
46
- ...globals . es2021 ,
47
- console : 'readonly' ,
48
- process : 'readonly' ,
49
- Buffer : 'readonly' ,
50
- __dirname : 'readonly' ,
51
- __filename : 'readonly' ,
52
- global : 'readonly' ,
53
- React : 'readonly' ,
54
- JSX : 'readonly' ,
32
+ ...globals . es2021 , // A modern equivalent of the 'es6' env
55
33
} ,
56
34
} ,
57
35
plugins : {
58
- '@typescript-eslint' : tseslint ,
59
- prettier : prettierPlugin ,
36
+ 'import' : importPlugin ,
37
+ 'unused-imports' : unusedImportsPlugin ,
38
+ } ,
39
+ settings : {
40
+ 'import/resolver' : {
41
+ typescript : {
42
+ // Point to all tsconfig.json files in your workspaces
43
+ project : [
44
+ 'apps/*/tsconfig.json' ,
45
+ 'packages/*/tsconfig.json' ,
46
+ './tsconfig.json' , // Also include the root tsconfig as a fallback
47
+ ] ,
48
+ } ,
49
+ node : true ,
50
+ } ,
51
+ // Allow Bun built-in modules
52
+ 'import/core-modules' : [ 'bun:test' , 'bun:sqlite' , 'bun' ] ,
60
53
} ,
61
54
rules : {
62
- // Turn off rules that conflict with TypeScript
63
- 'no-undef' : 'off' , // TypeScript handles this
64
- 'no-unused-vars' : 'off' , // Use TypeScript version instead
65
- 'no-redeclare' : 'off' , // TypeScript handles this better
66
-
67
- // Turn off rules that don't exist or cause issues
68
- 'react-hooks/exhaustive-deps' : 'off' ,
69
- '@next/next/no-sync-scripts' : 'off' ,
70
- 'no-shadow-restricted-names' : 'off' ,
71
-
72
- // TypeScript specific rules - simplified and lenient
73
- '@typescript-eslint/no-unused-vars' : [
55
+ // Manually include rules from the import plugin's recommended configs.
56
+ ...importPlugin . configs . recommended . rules ,
57
+ ...importPlugin . configs . typescript . rules ,
58
+
59
+ // Your custom rules from the original file.
60
+ 'no-console' : 'warn' ,
61
+ 'max-len' : [ 'error' , {
62
+ code : 1024 ,
63
+ ignoreComments : true ,
64
+ ignoreUrls : true ,
65
+ ignoreStrings : true ,
66
+ ignoreTemplateLiterals : true ,
67
+ } ] ,
68
+ 'key-spacing' : [ 'error' , {
69
+ align : {
70
+ beforeColon : false ,
71
+ afterColon : true ,
72
+ on : 'colon' ,
73
+ } ,
74
+ } ] ,
75
+ '@typescript-eslint/no-unused-vars' : 'off' , // Disabled to allow unused-imports plugin to handle it.
76
+ '@typescript-eslint/no-explicit-any' : 'warn' ,
77
+ '@typescript-eslint/no-require-imports' : 'warn' ,
78
+ '@typescript-eslint/ban-ts-comment' : 'warn' ,
79
+ 'unused-imports/no-unused-imports' : 'error' ,
80
+ 'unused-imports/no-unused-vars' : [
74
81
'warn' ,
75
82
{
76
- argsIgnorePattern : '^_ ' ,
83
+ vars : 'all ' ,
77
84
varsIgnorePattern : '^_' ,
78
- caughtErrorsIgnorePattern : '^_ ' ,
79
- ignoreRestSiblings : true ,
85
+ args : 'after-used ' ,
86
+ argsIgnorePattern : '^_' ,
80
87
} ,
81
88
] ,
82
- '@typescript-eslint/no-explicit-any' : 'off' ,
83
- '@typescript-eslint/explicit-function-return-type' : 'off' ,
84
- '@typescript-eslint/explicit-module-boundary-types' : 'off' ,
85
- '@typescript-eslint/no-inferrable-types' : 'off' ,
86
-
87
- // Prettier integration
88
- 'prettier/prettier' : [
89
- 'warn' ,
90
- {
91
- endOfLine : 'auto' ,
92
- trailingComma : 'all' ,
89
+ 'import/order' : [ 'error' , {
90
+ groups : [
91
+ 'builtin' ,
92
+ 'external' ,
93
+ 'internal' ,
94
+ 'parent' ,
95
+ 'sibling' ,
96
+ 'index' ,
97
+ 'object' ,
98
+ 'unknown' ,
99
+ ] ,
100
+ 'pathGroups' : [ {
101
+ pattern : '@/**' ,
102
+ group : 'internal' ,
103
+ } ] ,
104
+ pathGroupsExcludedImportTypes : [ 'builtin' ] ,
105
+ 'newlines-between' : 'always' ,
106
+ alphabetize : {
107
+ order : 'asc' ,
108
+ caseInsensitive : true ,
93
109
} ,
94
- ] ,
110
+ } ] ,
111
+ 'import/newline-after-import' : 'error' ,
112
+ 'import/no-duplicates' : 'error' ,
95
113
96
- // Relaxed rules for monorepo compatibility
97
- 'no-console' : 'off' ,
98
- 'prefer-const' : 'warn' ,
99
- 'no-constant-condition' : 'warn' ,
100
- 'no-constant-binary-expression' : 'warn' ,
101
- } ,
102
- settings : {
103
- react : {
104
- version : 'detect' ,
105
- } ,
114
+ // Spacing rules for consistency
115
+ 'space-infix-ops' : 'error' , // Enforces spaces around operators like +, =, etc.
116
+ 'keyword-spacing' : [ 'error' , { 'before' : true , 'after' : true } ] , // Enforces spaces around keywords like if, else.
117
+ 'arrow-spacing' : [ 'error' , { 'before' : true , 'after' : true } ] , // Enforces spaces around arrow in arrow functions.
118
+ 'space-before-blocks' : 'error' , // Enforces a space before opening curly braces.
119
+ 'object-curly-spacing' : [ 'error' , 'always' ] , // Enforces spaces inside curly braces: { foo } not {foo}.
120
+ 'comma-spacing' : [ 'error' , { 'before' : false , 'after' : true } ] , // Enforces space after a comma, not before.
121
+ 'space-before-function-paren' : [ 'error' , { 'anonymous' : 'always' , 'named' : 'never' , 'asyncArrow' : 'always' } ] , // Controls space before function parentheses.
122
+ 'comma-dangle' : [ 'error' , 'never' ] , // Disallows trailing commas
106
123
} ,
107
124
} ,
108
-
109
- // Prettier config (must be last to override conflicting rules)
110
- prettierConfig ,
111
- ] ;
125
+ ) ;
0 commit comments