Repository navigation
Expand file tree
/
Copy path.eslintrc.cjs
More file actions
196 lines (189 loc) · 5.09 KB
/
Copy path.eslintrc.cjs
File metadata and controls
196 lines (189 loc) · 5.09 KB
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
// eslint-disable-next-line no-undef
const tsconfigRootDir = __dirname
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
ecmaFeatures: {
jsx: true,
},
},
env: {
browser: true,
commonjs: true,
es6: true,
},
globals: {
process: false,
},
extends: ['eslint:recommended', 'prettier'],
rules: {
'no-console': 'warn',
'no-restricted-globals': ['error', 'length'],
'no-restricted-syntax': [
'error',
{
message:
'Utilisez le composant <Emoji /> plutôt que la function emoji directement importée de react-easy-emoji',
selector: "CallExpression[callee.name='emoji']",
},
],
},
settings: {
react: {
version: 'detect',
},
},
overrides: [
{
files: ['**/*.{js,jsx}'],
env: { node: true },
},
{
files: ['**/*.{ts,tsx}'],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: { jsx: true },
tsconfigRootDir,
project: ['*/tsconfig.json'],
},
extends: [
'eslint:recommended',
'standard',
'plugin:@typescript-eslint/recommended',
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
'prettier',
],
plugins: ['@typescript-eslint', 'react', 'react-hooks'],
rules: {
'no-void': 'off',
'ban-ts-comment': 'off',
'no-use-before-define': 'off',
'react/no-unescaped-entities': 'off',
'react/jsx-no-target-blank': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{ ignoreRestSiblings: true },
],
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': [
'warn',
{ additionalHooks: 'usePromise|useLazyPromise' },
],
'@typescript-eslint/no-unsafe-call': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
'@typescript-eslint/no-unsafe-member-access': 'warn',
'@typescript-eslint/no-unsafe-return': 'warn',
'@typescript-eslint/no-unsafe-assignment': 'warn',
'@typescript-eslint/member-delimiter-style': [
'error',
{ multiline: { delimiter: 'none' } },
],
'react/no-unknown-property': ['error', { ignore: ['css'] }],
/**
* Warning on props spreading cause typescript doesn't check type on it:
* https://github.com/microsoft/TypeScript/issues/18801#issuecomment-332610604
* Explicit spread is allow, example: <img {...{ prop1, prop2, prop3 }} />
*/
'react/jsx-props-no-spreading': ['warn', { explicitSpread: 'ignore' }],
// Auto fixable lint error
'prefer-const': 'error',
'padding-line-between-statements': [
'error',
// Require padding line before return statement
{ blankLine: 'always', prev: '*', next: 'return' },
//Require padding line after import
{ blankLine: 'always', prev: ['import', 'cjs-import'], next: '*' },
{
blankLine: 'any',
prev: ['import', 'cjs-import'],
next: ['import', 'cjs-import'],
},
//Require padding line before export
{ blankLine: 'always', prev: '*', next: ['export', 'cjs-export'] },
{
blankLine: 'any',
prev: ['export', 'cjs-export'],
next: ['export', 'cjs-export'],
},
],
'no-restricted-imports': [
'warn',
{
paths: [
{
name: 'styled-components',
importNames: ['default'],
message:
'Please use named import : `import { styled } from "styled-component"` instead.',
},
],
patterns: [
{
group: ['@/design-system/*', '!@/design-system'],
message: 'Importez uniquement depuis @/design-system (l\'index). Les imports directs sont interdits.',
},
{
group: ['@/contextes/*/*'],
message: 'Importez uniquement depuis l\'index du contexte. Les imports directs sont interdits.',
},
],
},
],
},
},
// Cypress rules
{
files: ['site/cypress/**/*.ts'],
parser: '@typescript-eslint/parser',
parserOptions: {
tsconfigRootDir,
project: ['site/cypress/tsconfig.json'],
},
extends: ['eslint:recommended', 'plugin:cypress/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'cypress'],
rules: {},
},
{
files: ['site/cypress/**/*.js'],
extends: ['eslint:recommended', 'plugin:cypress/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'cypress'],
rules: {},
},
// Jest rules (for Vitest)
{
files: ['site/**/*.test.{js,ts,tsx,jsx}'],
extends: [
'eslint:recommended',
'plugin:vitest/recommended',
'plugin:testing-library/react',
'prettier',
],
plugins: ['@typescript-eslint', 'vitest', 'testing-library'],
rules: {
'vitest/expect-expect': [
'error',
{
assertFunctionNames: ['expect', 'runSimulations', "expectTypeOf"],
additionalTestBlockFunctions: [],
},
],
},
},
// Accessibility rules on /site
{
files: ['site/**/*.{jsx,js,tsx,ts}'],
plugins: ['jsx-a11y'],
extends: ['plugin:jsx-a11y/strict'],
rules: {
'jsx-a11y/no-autofocus': 'warn',
},
},
],
}