1
1
// @ts -check
2
2
3
- import { dirname } from 'path' ;
4
- import { fileURLToPath } from 'url' ;
5
-
6
- import { FlatCompat } from '@eslint/eslintrc' ;
7
- import eslint from '@eslint/js' ;
8
- import prettierConfig from 'eslint-config-prettier' ;
9
- import eslintCommentsPlugin from 'eslint-plugin-eslint-comments' ;
10
- import * as importPlugin from 'eslint-plugin-import' ;
3
+ import comments from '@eslint-community/eslint-plugin-eslint-comments/configs' ;
4
+ import js from '@eslint/js' ;
5
+ // @ts -ignore -- import is valid
6
+ import importPlugin from 'eslint-plugin-import' ;
11
7
import tseslint from 'typescript-eslint' ;
12
8
13
- const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
14
-
15
- const compat = new FlatCompat ( {
16
- baseDirectory : __dirname ,
17
- } ) ;
18
-
19
9
export default tseslint . config (
10
+ { ignores : [ 'index.js' ] } ,
20
11
{
21
12
files : [ 'src/**/*.?(c|m)js' , '*.?(c|m)js' , 'src/**/*.ts' ] ,
22
- ignores : [ 'index.js' ] ,
23
13
extends : [
24
- eslint . configs . recommended ,
25
- ... compat . extends ( 'plugin:eslint-comments/recommended' ) ,
26
- ... compat . extends ( 'plugin:import/typescript' ) ,
14
+ js . configs . recommended ,
15
+ // @ts -ignore -- type is valid
16
+ comments . recommended ,
27
17
] ,
28
- plugins : {
29
- 'eslint-comments' : eslintCommentsPlugin ,
30
- 'import' : importPlugin ,
31
- } ,
32
18
rules : {
33
- 'eslint-comments/disable-enable-pair' : [ 'error' , { allowWholeFile : true } ] ,
34
- 'eslint-comments/no-unused-disable' : 'error' ,
35
-
36
- 'import/order' : [
37
- 'error' ,
38
- {
39
- 'newlines-between' : 'always' ,
40
- 'alphabetize' : { order : 'asc' } ,
41
- } ,
42
- ] ,
43
-
44
- 'sort-imports' : [
45
- 'error' ,
46
- {
47
- ignoreDeclarationSort : true ,
48
- ignoreCase : true ,
49
- } ,
50
- ] ,
19
+ '@eslint-community/eslint-comments/disable-enable-pair' : [ 'error' , { allowWholeFile : true } ] ,
20
+ '@eslint-community/eslint-comments/no-unused-disable' : 'error' ,
51
21
} ,
52
22
} ,
23
+ // TODO Make eslint-plugin-import work with JS files (like this one)
53
24
{
54
25
files : [ 'src/**/*.ts' ] ,
55
26
extends : [
56
- //...tseslint.configs.recommended,
57
- //...tseslint.configs.recommendedTypeChecked,
58
- ...tseslint . configs . strictTypeChecked ,
59
- ...tseslint . configs . stylisticTypeChecked ,
27
+ importPlugin . flatConfigs . recommended ,
28
+ importPlugin . flatConfigs . typescript ,
29
+ // ...tseslint.configs.recommended,
30
+ ...tseslint . configs . recommendedTypeChecked ,
31
+ // ...tseslint.configs.strictTypeChecked,
32
+ // ...tseslint.configs.stylisticTypeChecked,
60
33
] ,
61
34
languageOptions : {
62
35
parserOptions : {
63
36
project : './tsconfig.test.json' ,
64
- tsconfigRootDir : __dirname ,
37
+ // projectService: {
38
+ // defaultProject: './tsconfig.test.json',
39
+ // },
40
+ tsconfigRootDir : import . meta. dirname ,
41
+ } ,
42
+ } ,
43
+ settings : {
44
+ 'import/parsers' : {
45
+ '@typescript-eslint/parser' : [ '.ts' , '.tsx' ] ,
46
+ } ,
47
+ 'import/resolver' : {
48
+ typescript : true ,
49
+ node : true ,
65
50
} ,
66
51
} ,
67
52
rules : {
@@ -84,7 +69,14 @@ export default tseslint.config(
84
69
allowShortCircuit : true ,
85
70
} ,
86
71
] ,
72
+
73
+ 'import/order' : [
74
+ 'error' ,
75
+ {
76
+ 'newlines-between' : 'always' ,
77
+ 'alphabetize' : { order : 'asc' } ,
78
+ } ,
79
+ ] ,
87
80
} ,
88
81
} ,
89
- prettierConfig ,
90
82
) ;
0 commit comments