Skip to content

Commit e3832e5

Browse files
committed
Try to simplify setup
1 parent ffe43d2 commit e3832e5

File tree

4 files changed

+155
-110
lines changed

4 files changed

+155
-110
lines changed

base.js

+23-36
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
const importX = require('eslint-plugin-import-x');
22
const globals = require('globals');
3-
const tsParser = require('@typescript-eslint/parser');
43
const jestPlugin = require('eslint-plugin-jest');
54
const cypress = require('eslint-plugin-cypress');
6-
const js = require('@eslint/js');
7-
8-
const { FlatCompat } = require('@eslint/eslintrc');
9-
10-
const compat = new FlatCompat({
11-
baseDirectory: __dirname,
12-
recommendedConfig: js.configs.recommended,
13-
allConfig: js.configs.all,
14-
});
5+
const eslintConfigPrettier = require('eslint-config-prettier');
6+
const tseslint = require('typescript-eslint');
157

168
const OFF = 0;
179
const ERROR = 2;
@@ -100,12 +92,17 @@ const settings = {
10092
};
10193

10294
module.exports = [
103-
...compat.extends('prettier', 'plugin:import-x/typescript'),
95+
eslintConfigPrettier,
96+
importX.flatConfigs.typescript,
97+
{
98+
...importX.flatConfigs.errors,
99+
files: [`**/*.{${jsExtensions}}`],
100+
},
101+
{
102+
...importX.flatConfigs.warnings,
103+
files: [`**/*.{${jsExtensions}}`],
104+
},
104105
{
105-
plugins: {
106-
'import-x': importX,
107-
},
108-
109106
languageOptions: {
110107
globals: {
111108
...globals.node,
@@ -120,21 +117,17 @@ module.exports = [
120117
settings,
121118
rules: baseRules,
122119
},
123-
...compat
124-
.extends(
125-
'plugin:@typescript-eslint/recommended',
126-
'plugin:@typescript-eslint/stylistic',
127-
'prettier',
128-
)
129-
.map((config) => ({
120+
...[tseslint.configs.recommended, tseslint.configs.stylistic].map(
121+
(config) => ({
130122
...config,
131123
files: [`**/*.{${tsExtensions}}`],
132-
})),
124+
}),
125+
),
133126
{
134127
files: [`**/*.{${tsExtensions}}`],
135128

136129
languageOptions: {
137-
parser: tsParser,
130+
parser: tseslint.parser,
138131

139132
parserOptions: {
140133
projectService: true,
@@ -191,12 +184,6 @@ module.exports = [
191184
'import-x/no-duplicates': [ERROR, { 'prefer-inline': true }],
192185
},
193186
},
194-
...compat
195-
.extends('plugin:import-x/errors', 'plugin:import-x/warnings')
196-
.map((config) => ({
197-
...config,
198-
files: [`**/*.{${jsExtensions}}`],
199-
})),
200187
{
201188
files: [`**/*.{${jsExtensions}}`],
202189
languageOptions: {
@@ -214,13 +201,13 @@ module.exports = [
214201
'import-x/no-duplicates': ERROR,
215202
},
216203
},
217-
...compat.extends('plugin:jest/recommended').map((config) => ({
218-
...config,
204+
{
205+
...jestPlugin.configs['flat/recommended'],
219206
files: [
220207
`**/__tests__/**/*.{${allExtensions}}`,
221208
`**/*.@(spec|test).{${allExtensions}}`,
222209
],
223-
})),
210+
},
224211
{
225212
files: [
226213
`**/__tests__/**/*.{${allExtensions}}`,
@@ -233,10 +220,10 @@ module.exports = [
233220
},
234221
},
235222
},
236-
...compat.extends('plugin:cypress/recommended').map((config) => ({
237-
...config,
223+
{
224+
...cypress.configs.recommended,
238225
files: [`**/cypress/**/*.{${allExtensions}}`],
239-
})),
226+
},
240227
{
241228
files: [`**/cypress/**/*.{${allExtensions}}`],
242229
plugins: { cypress },

index.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,6 @@ const base = require('./base');
44
const { fixupPluginRules } = require('@eslint/compat');
55

66
const globals = require('globals');
7-
const js = require('@eslint/js');
8-
9-
const { FlatCompat } = require('@eslint/eslintrc');
10-
11-
const compat = new FlatCompat({
12-
baseDirectory: __dirname,
13-
recommendedConfig: js.configs.recommended,
14-
allConfig: js.configs.all,
15-
});
167

178
const OFF = 0;
189
const ERROR = 2;
@@ -33,7 +24,8 @@ const reactRules = {
3324
};
3425

3526
module.exports = [
36-
...compat.extends('plugin:react/recommended', 'plugin:react/jsx-runtime'),
27+
react.configs.flat.recommended,
28+
react.configs.flat['jsx-runtime'],
3729
...base,
3830
{
3931
plugins: {

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,11 @@
2525
"homepage": "https://github.com/seek-oss/eslint-config-seek#readme",
2626
"dependencies": {
2727
"@eslint/compat": "^1.1.1",
28-
"@eslint/eslintrc": "^3.1.0",
29-
"@eslint/js": "^9.9.1",
30-
"@typescript-eslint/eslint-plugin": "^8.3.0",
31-
"@typescript-eslint/parser": "^8.3.0",
28+
"typescript-eslint": "^8.6.0",
3229
"eslint-config-prettier": "^9.1.0",
3330
"eslint-import-resolver-typescript": "^3.6.3",
3431
"eslint-plugin-cypress": "^3.5.0",
35-
"eslint-plugin-import-x": "^4.0.0",
32+
"eslint-plugin-import-x": "^4.2.1",
3633
"eslint-plugin-jest": "^28.8.0",
3734
"eslint-plugin-react": "^7.35.0",
3835
"eslint-plugin-react-hooks": "^4.6.2",

0 commit comments

Comments
 (0)