-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy patheslint.config.mjs
105 lines (102 loc) · 2.94 KB
/
eslint.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { fixupConfigRules, fixupPluginRules } from '@eslint/compat';
import { FlatCompat } from '@eslint/eslintrc';
import js from '@eslint/js';
import tsParser from '@typescript-eslint/parser';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import';
import prettierPlugin from 'eslint-plugin-prettier';
import reactRefresh from 'eslint-plugin-react-refresh';
import globals from 'globals';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all,
});
export default [
{
ignores: ['**/dist', '**/eslint.config.mjs'],
},
...fixupConfigRules(
compat.extends(
'prettier',
'plugin:react/recommended',
'plugin:jsx-a11y/recommended',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'plugin:@next/next/recommended',
),
),
{
files: ['**/*.{js,mjs,cjs,jsx,ts,tsx}'],
plugins: {
'react-refresh': reactRefresh,
import: fixupPluginRules(importPlugin),
prettier: fixupPluginRules(prettierPlugin),
},
languageOptions: {
globals: {
...globals.browser,
},
parser: tsParser,
},
rules: {
'import/order': [
'error',
{
'newlines-between': 'never',
alphabetize: {
order: 'asc',
caseInsensitive: false,
},
// Enforce a specific import order
groups: ['external', 'builtin', 'parent', 'sibling', 'index', 'object', 'type', 'unknown'],
pathGroups: [
{
pattern: 'react',
group: 'external',
position: 'before',
},
{
pattern: 'next',
group: 'external',
position: 'before',
},
{
pattern: 'next/**',
group: 'external',
position: 'before',
},
{
pattern: '~/assets/**',
group: 'unknown',
position: 'after',
},
{
pattern: '~/**',
group: 'parent',
position: 'before',
},
],
pathGroupsExcludedImportTypes: ['react'],
},
],
// Prettier plugin to apply formatting rules
'prettier/prettier': 'error', // This tells ESLint to show Prettier errors as ESLint errors
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-empty-interface': 'off',
},
settings: {
// Spread Prettier config to disable conflicting ESLint rules
...prettierConfig,
react: {
version: 'detect',
},
},
},
];