-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.config.js
146 lines (140 loc) · 3.69 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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
const eslintParser = require('@typescript-eslint/parser')
const eslintPluginImport = require('eslint-plugin-import')
const eslintPluginJest = require('eslint-plugin-jest')
const eslintPluginPrettier = require('eslint-plugin-prettier')
const eslintPluginPromise = require('eslint-plugin-promise')
const eslintPluginReact = require('eslint-plugin-react')
const eslintPluginReactHooks = require('eslint-plugin-react-hooks')
const tseslint = require('typescript-eslint')
const config = [
{
files: ['**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx'],
languageOptions: {
parser: eslintParser,
ecmaVersion: 2020,
sourceType: 'module'
},
plugins: {
prettier: eslintPluginPrettier,
promise: eslintPluginPromise,
jest: eslintPluginJest,
import: eslintPluginImport
},
rules: {
'no-console': 'error',
'no-param-reassign': 'warn',
'prettier/prettier': [
'error',
{
arrowParens: 'avoid',
endOfLine: 'auto',
semi: false,
singleQuote: true,
trailingComma: 'none'
}
],
'spaced-comment': ['error', 'always', { block: { exceptions: ['*'] } }],
'jest/no-focused-tests': 'error',
'jest/no-disabled-tests': 'warn',
'import/order': [
'warn',
{
alphabetize: { order: 'asc' },
groups: [
'builtin',
'external',
'internal',
['parent', 'sibling', 'index']
],
pathGroups: [
{
pattern: '{@cozy/**,cozy/**,cozy-**/**,cozy-**}',
group: 'external',
position: 'after'
},
{
pattern: '**/*.styles',
group: 'index',
position: 'after'
},
{
pattern: '@/**',
group: 'internal',
position: 'after'
}
],
distinctGroup: true,
pathGroupsExcludedImportTypes: [
'{@cozy/**,cozy/**,cozy-**/**,cozy-**}'
],
'newlines-between': 'always',
warnOnUnassignedImports: true
}
],
'import/no-extraneous-dependencies': ['warn']
}
},
// Extended settings for React (JSX)
{
files: ['**/*.jsx', '**/*.tsx'],
settings: {
react: { version: 'detect' }
},
plugins: {
react: eslintPluginReact,
'react-hooks': eslintPluginReactHooks
}
},
// TypeScript configuration
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: tseslint.parser,
parserOptions: {
project: true
}
},
plugins: {
'@typescript-eslint': tseslint.plugin
},
rules: {
'@typescript-eslint/no-unsafe-argument': 'error',
'@typescript-eslint/no-unsafe-assignment': 'error',
'@typescript-eslint/no-unsafe-call': 'error',
'@typescript-eslint/no-unsafe-member-access': 'error',
'@typescript-eslint/no-unsafe-return': 'error',
'@typescript-eslint/explicit-function-return-type': 'error',
'@typescript-eslint/no-explicit-any': 'error',
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true }
]
}
},
// Specific rules for test files
{
files: ['**/*.spec.jsx', '**/*.spec.js', '**/*.spec.tsx', '**/*.spec.ts'],
rules: {
'react/display-name': 'off'
}
}
]
const ignores = [
'**/node_modules/**',
'**/dist/**',
'**/coverage/**',
'**/__testfixtures__/**',
'**/__tests__/**',
'**/build/**',
'*.output.js',
'jest-setup.ts',
'jest.config.ts',
'rsbuild.config.ts',
'src/env.d.ts'
]
module.exports = [
...config,
{
ignores: [...ignores]
}
]