/
.eslintrc.cjs
128 lines (124 loc) · 3.42 KB
/
.eslintrc.cjs
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
122
123
124
125
126
127
128
module.exports = {
globals: {
vi: true,
},
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react-hooks/recommended',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: ['react-refresh', 'react', 'simple-import-sort', 'import', 'prettier'],
rules: {
// suppress errors for missing 'import React' in files
'react/react-in-jsx-scope': 'off',
// allow jsx syntax in js files (for next.js project)
'react/jsx-filename-extension': [1, { extensions: ['.ts', '.tsx'] }],
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
'import/first': 'error',
'import/newline-after-import': 'error',
'import/no-duplicates': 'error',
'react-refresh/only-export-components': 'warn',
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['..*', './*'],
message:
"Please import components using namespace directly. E.G: `import { MyComponent } from '@/<path-from-src-folder>'` instead of `import { MyComponent } from './<path-from-src-folder>'`",
},
],
paths: [
{
name: '@testing-library/react',
importNames: ['render'],
message: 'Please use `import { renderWithQueryProvider } from "@test/testUtils"` instead',
},
],
},
],
'prefer-const': 'error',
'no-duplicate-imports': ['error', { includeExports: false }],
'no-dupe-keys': 'error',
'no-implicit-coercion': 'error',
'prefer-arrow-callback': ['error', { allowNamedFunctions: true }],
'prettier/prettier': 'error',
'prefer-destructuring': [
'error',
{
VariableDeclarator: {
array: false,
object: true,
},
AssignmentExpression: {
array: true,
object: false,
},
},
{
enforceForRenamedProperties: false,
},
],
'no-restricted-properties': [
2,
{
object: 'Object',
property: 'create',
message: 'Please use Object destructuring instead. E.G. `const data = {...defaultValues, newValue: true }`',
},
],
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_', varsIgnorePattern: '^_', args: 'all' }],
'react/destructuring-assignment': [
'error',
'always',
{ ignoreClassFields: false, destructureInSignature: 'always' },
],
},
overrides: [
{
files: ['!vite.config.ts'],
rules: {
'import/no-default-export': 'error',
},
},
{
files: ['!src/queries/*.ts'],
rules: {
'no-restricted-globals': [
'error',
{
name: 'fetch',
message: '`fetch()` usage is only allowed inside `@/queries` folder',
},
],
},
},
{
files: ['!src/utils/storage.ts'],
rules: {
'no-restricted-imports': [
'error',
{
patterns: [
{
group: ['use-local-storage-state'],
message: '`use-local-storage-state` usage is only allowed inside `@/utils/storage` file',
},
],
},
],
},
},
],
};