Skip to content

Commit 026390b

Browse files
committed
refactor: restructure ESLint configuration by removing legacy files, introducing backend and frontend specific configurations, and updating dependencies for improved linting consistency across the project
1 parent 4900195 commit 026390b

19 files changed

+611
-363
lines changed

.eslintrc.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

apps/backend/.eslintrc.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

apps/backend/eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from '../../eslint.config.backend.js';
2+
3+
export default config;

apps/frontend/.eslintrc.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

apps/frontend/eslint.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import config from '../../eslint.config.frontend.js';
2+
3+
export default config;

bun.lock

Lines changed: 376 additions & 171 deletions
Large diffs are not rendered by default.

eslint.config.backend.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import baseConfig from './eslint.config.js';
2+
import globals from 'globals';
3+
4+
export default [
5+
...baseConfig,
6+
7+
// Backend-specific configuration
8+
{
9+
files: ['apps/backend/**/*.ts', 'packages/**/*.ts'],
10+
languageOptions: {
11+
globals: {
12+
...globals.node,
13+
...globals.jest,
14+
},
15+
},
16+
rules: {
17+
// Backend can be more relaxed about some rules
18+
'@typescript-eslint/no-explicit-any': 'warn',
19+
},
20+
},
21+
];

eslint.config.frontend.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import baseConfig from './eslint.config.js';
2+
import tsparser from '@typescript-eslint/parser';
3+
import mdx from 'eslint-plugin-mdx';
4+
5+
export default [
6+
...baseConfig,
7+
8+
// Frontend TypeScript/TSX configuration
9+
{
10+
files: ['apps/frontend/**/*.ts', 'apps/frontend/**/*.tsx'],
11+
languageOptions: {
12+
parser: tsparser,
13+
parserOptions: {
14+
ecmaVersion: 2021,
15+
sourceType: 'module',
16+
ecmaFeatures: {
17+
jsx: true,
18+
},
19+
project: './apps/frontend/tsconfig.json',
20+
},
21+
globals: {
22+
React: 'readonly',
23+
JSX: 'readonly',
24+
window: 'readonly',
25+
document: 'readonly',
26+
console: 'readonly',
27+
process: 'readonly',
28+
global: 'readonly',
29+
},
30+
},
31+
plugins: {
32+
mdx: mdx,
33+
},
34+
settings: {
35+
react: {
36+
version: 'detect',
37+
},
38+
'import/resolver': {
39+
typescript: {
40+
project: './apps/frontend/tsconfig.json',
41+
},
42+
node: {
43+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
44+
moduleDirectory: ['node_modules', 'apps/frontend/src/'],
45+
},
46+
},
47+
},
48+
rules: {
49+
// Next.js specific rules would go here
50+
// For now, inherit from base config
51+
},
52+
},
53+
54+
// MDX files configuration
55+
{
56+
files: ['apps/frontend/**/*.mdx'],
57+
...mdx.configs.recommended,
58+
settings: {
59+
'mdx/code-blocks': true,
60+
},
61+
},
62+
];

eslint.config.js

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
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 importPlugin from 'eslint-plugin-import';
6+
import prettierPlugin from 'eslint-plugin-prettier';
7+
import unusedImports from 'eslint-plugin-unused-imports';
8+
9+
export default [
10+
// Base JavaScript configuration
11+
js.configs.recommended,
12+
13+
// Global ignore patterns
14+
{
15+
ignores: [
16+
'**/node_modules/**',
17+
'**/dist/**',
18+
'**/build/**',
19+
'**/.next/**',
20+
'**/coverage/**',
21+
'**/*.config.js',
22+
'**/*.config.ts',
23+
'**/generated/**',
24+
'.eslintrc.js',
25+
],
26+
},
27+
28+
// Base TypeScript configuration
29+
{
30+
files: ['**/*.ts', '**/*.tsx'],
31+
languageOptions: {
32+
parser: tsparser,
33+
parserOptions: {
34+
ecmaVersion: 2021,
35+
sourceType: 'module',
36+
project: './tsconfig.json',
37+
},
38+
},
39+
plugins: {
40+
'@typescript-eslint': tseslint,
41+
prettier: prettierPlugin,
42+
import: importPlugin,
43+
'unused-imports': unusedImports,
44+
},
45+
rules: {
46+
// Base recommended rules
47+
...js.configs.recommended.rules,
48+
49+
// Turn off rules that conflict with TypeScript
50+
'no-undef': 'off', // TypeScript handles this
51+
'no-unused-vars': 'off', // Use TypeScript version instead
52+
53+
// TypeScript specific rules - using simplified set
54+
'@typescript-eslint/no-unused-vars': [
55+
'warn',
56+
{
57+
argsIgnorePattern: '^_',
58+
varsIgnorePattern: '^_',
59+
caughtErrorsIgnorePattern: '^_',
60+
ignoreRestSiblings: true,
61+
},
62+
],
63+
'@typescript-eslint/no-explicit-any': 'off',
64+
'@typescript-eslint/explicit-function-return-type': 'off',
65+
'@typescript-eslint/explicit-module-boundary-types': 'off',
66+
'@typescript-eslint/no-inferrable-types': 'off',
67+
68+
// Prettier integration
69+
'prettier/prettier': [
70+
'warn',
71+
{
72+
endOfLine: 'auto',
73+
trailingComma: 'all',
74+
},
75+
],
76+
77+
// Import management
78+
'unused-imports/no-unused-imports': 'warn',
79+
'sort-imports': [
80+
'warn',
81+
{
82+
ignoreCase: false,
83+
ignoreDeclarationSort: true,
84+
ignoreMemberSort: false,
85+
memberSyntaxSortOrder: ['none', 'all', 'multiple', 'single'],
86+
allowSeparatedGroups: false,
87+
},
88+
],
89+
'import/order': [
90+
'warn',
91+
{
92+
groups: [
93+
'builtin',
94+
'external',
95+
'internal',
96+
['sibling', 'parent'],
97+
'index',
98+
'unknown',
99+
],
100+
'newlines-between': 'always',
101+
alphabetize: {
102+
order: 'asc',
103+
caseInsensitive: true,
104+
},
105+
},
106+
],
107+
},
108+
settings: {
109+
'import/resolver': {
110+
typescript: true,
111+
node: {
112+
extensions: ['.js', '.jsx', '.ts', '.tsx'],
113+
moduleDirectory: ['node_modules', 'src/'],
114+
},
115+
},
116+
},
117+
},
118+
119+
// Prettier config (must be last to override conflicting rules)
120+
prettierConfig,
121+
];

package.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "@nbw/root",
3+
"type": "module",
34
"version": "1.0.0",
45
"description": "",
56
"main": "index.js",
@@ -64,16 +65,19 @@
6465
"packages/*"
6566
],
6667
"devDependencies": {
68+
"@eslint/js": "^9.35.0",
6769
"@types/bun": "^1.2.10",
6870
"@types/node": "^20.3.1",
69-
"@typescript-eslint/eslint-plugin": "^5.59.11",
70-
"@typescript-eslint/parser": "^5.59.11",
71+
"@typescript-eslint/eslint-plugin": "^8.43.0",
72+
"@typescript-eslint/parser": "^8.43.0",
7173
"concurrently": "^9.1.2",
72-
"eslint": "^8.46.0",
73-
"eslint-config-prettier": "^8.8.0",
74-
"eslint-plugin-import": "^2.29.1",
75-
"eslint-plugin-prettier": "^4.2.1",
74+
"eslint": "^9.35.0",
75+
"eslint-config-prettier": "^8.10.2",
76+
"eslint-plugin-import": "^2.32.0",
77+
"eslint-plugin-mdx": "^3.6.2",
78+
"eslint-plugin-prettier": "^4.2.5",
7679
"eslint-plugin-unused-imports": "^2.0.0",
80+
"globals": "^16.4.0",
7781
"prettier": "^2.8.8"
7882
},
7983
"dependencies": {

0 commit comments

Comments
 (0)