-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslint.config.js
91 lines (76 loc) · 2.57 KB
/
eslint.config.js
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
import js from '@eslint/js';
import globals from 'globals';
import react from 'eslint-plugin-react';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import jsxA11y from 'eslint-plugin-jsx-a11y';
// @ts-expect-error: WiP: https://github.com/import-js/eslint-plugin-import/issues/3123
import importPlugin from 'eslint-plugin-import';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
const eslintConfig = tseslint.config(
{ ignores: ['**/dist', '**/build'] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
react.configs.flat.recommended,
react.configs.flat['jsx-runtime'],
jsxA11y.flatConfigs.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
eslintPluginPrettierRecommended,
],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2021,
globals: globals.browser,
// https://typescript-eslint.io/getting-started/typed-linting
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
// TODO: simplify after updates?
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
settings: {
react: { version: 'detect' },
// will not work without specified projects, replace with commented line to make it work:
'import/resolver': { typescript: true },
// 'import/resolver': { typescript: { project: ['**/tsconfig.json', '**/tsconfig.app.json'] } },
},
rules: {
// plugins
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
// import sort
'import/order': [
1,
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'always',
alphabetize: { order: 'asc' },
},
],
// dx
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
caughtErrorsIgnorePattern: '^_',
},
],
'no-shadow': 'error',
'no-shadow-restricted-names': 'error',
// react-hook-form onSubmit
'@typescript-eslint/no-misused-promises': [2, { checksVoidReturn: { attributes: false } }],
// we're using typescript
'react/prop-types': 'off',
},
},
);
export default eslintConfig;