-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
47 lines (45 loc) · 1.23 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
const hasReact = (() => {
try {
require('react/package.json');
return true;
} catch (e) {
return false;
}
})();
const ifReact = (obj) => (hasReact ? obj : Array.isArray(obj) ? [] : {});
module.exports = {
parser: '@typescript-eslint/parser',
parserOptions: {
sourceType: 'module',
ecmaFeatures: {
...ifReact({ jsx: true }),
},
},
extends: ['eslint:recommended', 'prettier', ...ifReact(['prettier/react']), 'prettier/@typescript-eslint'],
plugins: ['prettier', '@typescript-eslint', ...ifReact(['react', 'react-hooks'])],
settings: {
...ifReact({ react: { version: 'detect' } }),
},
rules: {
'no-console': 'error',
'no-redeclare': 'off',
'no-unused-vars': 'off',
'no-dupe-class-members': 'off',
'no-undef': 'off',
'prettier/prettier': ['error', require('./.prettierrc.json'), { usePrettierrc: false }],
'@typescript-eslint/prefer-interface': 'off',
'@typescript-eslint/no-unused-vars': [
'error',
{
args: 'after-used',
argsIgnorePattern: '^_',
},
],
...ifReact({
'react/jsx-uses-vars': 1,
'react/jsx-uses-react': 1,
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'off',
}),
},
};