-
Notifications
You must be signed in to change notification settings - Fork 1
/
.eslintrc.js
61 lines (56 loc) · 1.41 KB
/
.eslintrc.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
const isBackendOnly = process.env.BACKEND_ONLY === 'true';
const isTestEnv = process.env.TEST_ENV === 'true';
const config = {
browser: !isBackendOnly,
get extends() {
const extensions = ['eslint:recommended', 'plugin:@typescript-eslint/recommended'];
if (!isBackendOnly) {
extensions.push('plugin:react/recommended');
}
return extensions;
},
jsx: true,
plugins: isBackendOnly ? [] : ['react', '@typescript-eslint'],
rules: isBackendOnly
? {
'@typescript-eslint/ban-ts-comment': [
'warn',
{
'ts-ignore': true,
},
],
}
: { 'react/prop-types': 'off' },
ignorePatterns: ['src/database/data', 'src/database/populate/initialData/product-images', 'test/**/*.js'],
};
if (!isTestEnv && isBackendOnly) {
config.ignorePatterns.push(
'test/', '__mocks__/', '**/__mocks__', 'src/**/*.js', 'src/database/populate/*.sh'
);
}
module.exports = {
env: {
browser: config.browser,
node: !config.browser,
es2020: true,
},
extends: config.extends,
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaFeatures: {
jsx: config.jsx,
},
ecmaVersion: 2020,
sourceType: 'module',
},
plugins: config.plugins,
rules: config.rules,
ignorePatterns: config.ignorePatterns,
settings: isBackendOnly
? undefined
: {
react: {
version: 'detect',
},
},
};