-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patheslint.config.mjs
105 lines (100 loc) · 3.24 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 globals from 'globals';
import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import reactRefreshPlugin from 'eslint-plugin-react-refresh';
import typescriptParser from '@typescript-eslint/parser';
import reactPlugin from 'eslint-plugin-react';
import simpleImportSortPlugin from 'eslint-plugin-simple-import-sort';
import prettierConfig from 'eslint-config-prettier';
import reactHooksPlugin from 'eslint-plugin-react-hooks';
import testingLibraryPlugin from 'eslint-plugin-testing-library';
// Fix for AudioWorkletGlobalScope global
const GLOBALS_BROWSER_FIX = Object.assign({}, globals.browser, {
AudioWorkletGlobalScope: globals.browser['AudioWorkletGlobalScope '],
});
delete GLOBALS_BROWSER_FIX['AudioWorkletGlobalScope '];
export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
...tseslint.configs.stylisticTypeChecked,
reactPlugin.configs.flat.recommended,
reactPlugin.configs.flat['jsx-runtime'],
prettierConfig,
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
globals: {
...GLOBALS_BROWSER_FIX,
},
parser: typescriptParser,
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
sourceType: 'module',
ecmaVersion: 'latest',
ecmaFeatures: {
jsx: true,
},
},
},
settings: {
react: {
version: 'detect',
},
},
plugins: {
'react-refresh': reactRefreshPlugin,
'simple-import-sort': simpleImportSortPlugin,
'react-hooks': reactHooksPlugin,
},
rules: {
...reactHooksPlugin.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
// enforce import and export sorting
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
// disable unused vars check for variables starting with underscore _
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// disable no empty function to work with saga
'@typescript-eslint/no-empty-function': 'off',
},
},
// unit and integration testing configuration
{
files: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)'],
plugins: {
'testing-library': testingLibraryPlugin,
},
},
// import and export sorting configuration
{
files: ['**/*.js', '**/*.ts', '**/*.tsx'],
rules: {
'simple-import-sort/imports': [
'error',
{
groups: [
// `react` first, `next` second, then packages starting with a character
['^react$', '^http', '^next', '^[a-z]'],
// Packages starting with `@`
['^@'],
// Packages starting with `~`
['^~'],
// Imports starting with `../`
['^\\.\\.(?!/?$)', '^\\.\\./?$'],
// Imports starting with `./`
['^\\./(?=.*/)(?!/?$)', '^\\.(?!/?$)', '^\\./?$'],
// Style imports
['^.+\\.s?css$'],
// Side effect imports
['^\\u0000'],
],
},
],
},
},
{
ignores: ['dist', 'eslint.config.mjs', '__mocks__'],
},
);