@@ -5,6 +5,7 @@ const path = require('node:path')
5
5
const { includeIgnoreFile } = require ( '@eslint/compat' )
6
6
const js = require ( '@eslint/js' )
7
7
const tsParser = require ( '@typescript-eslint/parser' )
8
+ const { createOxcImportResolver } = require ( 'eslint-import-resolver-oxc' )
8
9
const importXPlugin = require ( 'eslint-plugin-import-x' )
9
10
const nodePlugin = require ( 'eslint-plugin-n' )
10
11
const sortDestructureKeysPlugin = require ( 'eslint-plugin-sort-destructure-keys' )
@@ -39,6 +40,32 @@ const sharedRules = {
39
40
'unicorn/consistent-function-scoping' : [ 'error' ]
40
41
}
41
42
43
+ const sharedRulesForImportX = {
44
+ 'import-x/order' : [
45
+ 'warn' ,
46
+ {
47
+ groups : [
48
+ 'builtin' ,
49
+ 'external' ,
50
+ 'internal' ,
51
+ [ 'parent' , 'sibling' , 'index' ] ,
52
+ 'type'
53
+ ] ,
54
+ pathGroups : [
55
+ {
56
+ pattern : '@socket{registry,security}/**' ,
57
+ group : 'internal'
58
+ }
59
+ ] ,
60
+ pathGroupsExcludedImportTypes : [ 'type' ] ,
61
+ 'newlines-between' : 'always' ,
62
+ alphabetize : {
63
+ order : 'asc'
64
+ }
65
+ }
66
+ ]
67
+ }
68
+
42
69
const getImportXFlatConfigs = isEsm => ( {
43
70
recommended : {
44
71
...origImportXFlatConfigs . recommended ,
@@ -49,62 +76,40 @@ const getImportXFlatConfigs = isEsm => ({
49
76
} ,
50
77
rules : {
51
78
...origImportXFlatConfigs . recommended . rules ,
52
- 'import-x/no-named-as-default-member' : 'off' ,
53
- 'import-x/order' : [
54
- 'warn' ,
55
- {
56
- groups : [
57
- 'builtin' ,
58
- 'external' ,
59
- 'internal' ,
60
- [ 'parent' , 'sibling' , 'index' ] ,
61
- 'type'
62
- ] ,
63
- pathGroups : [
64
- {
65
- pattern : '@socket{registry,security}/**' ,
66
- group : 'internal'
67
- }
68
- ] ,
69
- pathGroupsExcludedImportTypes : [ 'type' ] ,
70
- 'newlines-between' : 'always' ,
71
- alphabetize : {
72
- order : 'asc'
73
- }
74
- }
75
- ]
79
+ ...sharedRulesForImportX ,
80
+ 'import-x/no-named-as-default-member' : 'off'
76
81
}
77
82
} ,
78
83
typescript : {
79
84
...origImportXFlatConfigs . typescript ,
80
85
settings : {
81
86
...origImportXFlatConfigs . typescript . settings ,
82
- 'import-x/resolver' : {
83
- 'eslint-import-resolver-oxc' : {
87
+ 'import-x/resolver-next ' : [
88
+ createOxcImportResolver ( {
84
89
tsConfig : {
85
90
configFile : rootTsConfigPath ,
86
91
references : 'auto'
87
92
}
88
- }
89
- }
93
+ } )
94
+ ]
90
95
}
91
96
}
92
97
} )
93
98
94
99
const importFlatConfigsForScript = getImportXFlatConfigs ( false )
95
100
const importFlatConfigsForModule = getImportXFlatConfigs ( true )
101
+
96
102
module . exports = [
97
103
includeIgnoreFile ( gitignorePath ) ,
98
104
includeIgnoreFile ( prettierignorePath ) ,
99
105
{
100
106
files : [ '**/*.{c,}js' ] ,
101
107
...importFlatConfigsForScript . recommended
102
108
} ,
103
- // TODO: Make this work for our .mjs files too.
104
- // {
105
- // files: ['**/*.mjs'],
106
- // ...importFlatConfigsForModule.recommended
107
- // },
109
+ {
110
+ files : [ '**/*.mjs' ] ,
111
+ ...importFlatConfigsForModule . recommended
112
+ } ,
108
113
{
109
114
files : [ 'src/**/*.ts' , 'test/**/*.ts' ] ,
110
115
...importFlatConfigsForModule . typescript
0 commit comments