-
Notifications
You must be signed in to change notification settings - Fork 155
/
Copy patheslint.config.mjs
121 lines (114 loc) · 2.82 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// @ts-check
/* Globals */
import globals from 'globals';
/* Plugins */
import js from '@eslint/js';
import ts from 'typescript-eslint';
import i18next from 'eslint-plugin-i18next';
import prettierConfig from 'eslint-config-prettier';
import importPlugin from 'eslint-plugin-import-x';
import reactPlugin from 'eslint-plugin-react';
import hooksPlugin from 'eslint-plugin-react-hooks';
import vitest from '@vitest/eslint-plugin';
import testingLibrary from 'eslint-plugin-testing-library';
export default ts.config(
{
ignores: ['dist/', 'coverage/'],
},
js.configs.recommended,
...ts.configs.recommended,
importPlugin.flatConfigs.recommended,
importPlugin.flatConfigs.typescript,
reactPlugin.configs.flat.recommended,
i18next.configs['flat/recommended'],
prettierConfig,
// Application files
{
plugins: {
'react-hooks': hooksPlugin,
vitest,
},
languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: {
...globals.browser,
},
},
settings: {
react: { version: 'detect' },
},
rules: {
...vitest.configs.recommended.rules,
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'warn',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description',
minimumDescriptionLength: 3,
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
fixStyle: 'inline-type-imports',
},
],
'@typescript-eslint/consistent-type-definitions': ['error', 'type'],
'import-x/no-absolute-path': 'error',
'import-x/no-cycle': ['error', { ignoreExternal: true }],
'import-x/no-duplicates': [
'error',
{
'prefer-inline': true,
considerQueryString: true,
},
],
'react/prop-types': 'off',
'i18next/no-literal-string': [
'error',
{
markupOnly: true,
ignoreAttribute: [
'path',
'to',
'displayMode',
'role',
'href',
'autoComplete',
'kind',
'size',
],
ignoreComponent: [
'FormattedMessage',
'FormattedDate',
'HeaderSettings',
],
},
],
},
},
// Storybook and test files
{
files: ['*.{stories,test}.{js,jsx,ts,tsx}'],
rules: {
'i18next/no-literal-string': 'off',
},
},
// Just test files
{
files: ['*.test.{js,jsx,ts,tsx}'],
...testingLibrary.configs['flat/react'],
},
// Node-based config files
{
files: ['**/*.config.{js,ts}'],
languageOptions: {
globals: globals.node,
ecmaVersion: 2015,
sourceType: 'commonjs',
},
},
);