@@ -5,6 +5,7 @@ const path = require('node:path')
55const { includeIgnoreFile } = require ( '@eslint/compat' )
66const js = require ( '@eslint/js' )
77const tsParser = require ( '@typescript-eslint/parser' )
8+ const { createOxcImportResolver } = require ( 'eslint-import-resolver-oxc' )
89const importXPlugin = require ( 'eslint-plugin-import-x' )
910const nodePlugin = require ( 'eslint-plugin-n' )
1011const sortDestructureKeysPlugin = require ( 'eslint-plugin-sort-destructure-keys' )
@@ -39,6 +40,32 @@ const sharedRules = {
3940 'unicorn/consistent-function-scoping' : [ 'error' ]
4041}
4142
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+
4269const getImportXFlatConfigs = isEsm => ( {
4370 recommended : {
4471 ...origImportXFlatConfigs . recommended ,
@@ -49,62 +76,40 @@ const getImportXFlatConfigs = isEsm => ({
4976 } ,
5077 rules : {
5178 ...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'
7681 }
7782 } ,
7883 typescript : {
7984 ...origImportXFlatConfigs . typescript ,
8085 settings : {
8186 ...origImportXFlatConfigs . typescript . settings ,
82- 'import-x/resolver' : {
83- 'eslint-import-resolver-oxc' : {
87+ 'import-x/resolver-next ' : [
88+ createOxcImportResolver ( {
8489 tsConfig : {
8590 configFile : rootTsConfigPath ,
8691 references : 'auto'
8792 }
88- }
89- }
93+ } )
94+ ]
9095 }
9196 }
9297} )
9398
9499const importFlatConfigsForScript = getImportXFlatConfigs ( false )
95100const importFlatConfigsForModule = getImportXFlatConfigs ( true )
101+
96102module . exports = [
97103 includeIgnoreFile ( gitignorePath ) ,
98104 includeIgnoreFile ( prettierignorePath ) ,
99105 {
100106 files : [ '**/*.{c,}js' ] ,
101107 ...importFlatConfigsForScript . recommended
102108 } ,
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+ } ,
108113 {
109114 files : [ 'src/**/*.ts' , 'test/**/*.ts' ] ,
110115 ...importFlatConfigsForModule . typescript
0 commit comments