Skip to content

Commit 817638b

Browse files
committed
refactor: update ESLint configuration to use typescript-eslint and improve TypeScript support
1 parent d8de5a6 commit 817638b

File tree

1 file changed

+24
-34
lines changed

1 file changed

+24
-34
lines changed

eslint.config.mjs

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,61 @@
11
import eslint from '@eslint/js'
2-
import tseslint from '@typescript-eslint/eslint-plugin'
3-
import tsparser from '@typescript-eslint/parser'
2+
import tseslint from 'typescript-eslint'
43
import jestPlugin from 'eslint-plugin-jest'
54
import githubPlugin from 'eslint-plugin-github'
65
import prettierPlugin from 'eslint-plugin-prettier'
76
import importPlugin from 'eslint-plugin-import'
7+
import globals from 'globals'
88

99
export default [
1010
// Global ignores
1111
{
1212
ignores: ['**/node_modules/**', '**/dist/**', '**/coverage/**', '**/*.json']
1313
},
1414

15-
// Base configuration for all files
15+
// Base ESLint recommended config for all files
1616
eslint.configs.recommended,
1717

1818
// TypeScript files configuration
1919
{
2020
files: ['**/*.ts'],
2121
languageOptions: {
22-
parser: tsparser,
22+
parser: tseslint.parser,
2323
parserOptions: {
2424
ecmaVersion: 2023,
2525
sourceType: 'module',
26-
project: ['./.github/linters/tsconfig.json', './tsconfig.json']
26+
project: ['./.github/linters/tsconfig.json', './tsconfig.json'],
27+
tsconfigRootDir: import.meta.dirname
2728
},
2829
globals: {
29-
Atomics: 'readonly',
30-
SharedArrayBuffer: 'readonly',
31-
console: 'readonly',
32-
process: 'readonly',
33-
__dirname: 'readonly',
34-
__filename: 'readonly',
35-
module: 'readonly',
36-
require: 'readonly',
37-
exports: 'readonly',
38-
Buffer: 'readonly',
39-
global: 'readonly'
30+
...globals.node,
31+
...globals.es2021,
32+
...globals.jest
4033
}
4134
},
4235
plugins: {
43-
'@typescript-eslint': tseslint,
36+
'@typescript-eslint': tseslint.plugin,
4437
jest: jestPlugin,
4538
github: githubPlugin,
4639
prettier: prettierPlugin
4740
},
4841
rules: {
49-
// Spread recommended rules from plugins
50-
...tseslint.configs['eslint-recommended'].overrides[0].rules,
51-
...tseslint.configs.recommended.rules,
42+
// TypeScript recommended rules
43+
...tseslint.configs.recommended[0].rules,
44+
...tseslint.configs.stylistic[0].rules,
45+
46+
// Jest recommended rules
5247
...jestPlugin.configs.recommended.rules,
5348

54-
// Custom rules
49+
// Prettier integration
50+
'prettier/prettier': 'error',
51+
52+
// Custom overrides
5553
camelcase: 'off',
5654
'no-console': 'off',
5755
'no-unused-vars': 'off',
58-
'prettier/prettier': 'error',
5956
semi: ['error', 'never'],
57+
58+
// TypeScript-specific custom rules
6059
'@typescript-eslint/array-type': 'error',
6160
'@typescript-eslint/await-thenable': 'error',
6261
'@typescript-eslint/ban-ts-comment': 'error',
@@ -99,22 +98,13 @@ export default [
9998

10099
// JavaScript files configuration
101100
{
102-
files: ['**/*.js'],
101+
files: ['**/*.js', '**/*.mjs'],
103102
languageOptions: {
104103
ecmaVersion: 2023,
105104
sourceType: 'module',
106105
globals: {
107-
Atomics: 'readonly',
108-
SharedArrayBuffer: 'readonly',
109-
console: 'readonly',
110-
process: 'readonly',
111-
__dirname: 'readonly',
112-
__filename: 'readonly',
113-
module: 'readonly',
114-
require: 'readonly',
115-
exports: 'readonly',
116-
Buffer: 'readonly',
117-
global: 'readonly'
106+
...globals.node,
107+
...globals.es2021
118108
}
119109
},
120110
plugins: {

0 commit comments

Comments
 (0)