Skip to content

Commit a9e0dea

Browse files
committed
Update eslint config
1 parent 4fb48b1 commit a9e0dea

File tree

2 files changed

+40
-35
lines changed

2 files changed

+40
-35
lines changed

.config/rollup.base.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { readPackageUpSync } from 'read-package-up'
99
import rangesIntersect from 'semver/ranges/intersects.js'
1010
import { purgePolyfills } from 'unplugin-purge-polyfills'
1111

12-
import { isRelative } from '@socketsecurity/registry/lib/path'
13-
import { escapeRegExp } from '@socketsecurity/registry/lib/regexps'
1412
import {
1513
isValidPackageName,
1614
readPackageJsonSync
1715
} from '@socketsecurity/registry/lib/packages'
16+
import { isRelative } from '@socketsecurity/registry/lib/path'
17+
import { escapeRegExp } from '@socketsecurity/registry/lib/regexps'
1818

1919
import constants from '../scripts/constants.js'
2020
import socketModifyPlugin from '../scripts/rollup/socket-modify-plugin.js'

eslint.config.js

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const path = require('node:path')
55
const { includeIgnoreFile } = require('@eslint/compat')
66
const js = require('@eslint/js')
77
const tsParser = require('@typescript-eslint/parser')
8+
const { createOxcImportResolver } = require('eslint-import-resolver-oxc')
89
const importXPlugin = require('eslint-plugin-import-x')
910
const nodePlugin = require('eslint-plugin-n')
1011
const 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+
4269
const 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

9499
const importFlatConfigsForScript = getImportXFlatConfigs(false)
95100
const importFlatConfigsForModule = getImportXFlatConfigs(true)
101+
96102
module.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

Comments
 (0)