forked from trezor/trezor-suite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
138 lines (138 loc) · 4.67 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
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
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
// latest is best, because it's backwards compatible and we have linted everything
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
plugins: ['import', '@typescript-eslint', 'react-hooks', 'prettier'],
extends: [
'airbnb',
'plugin:@typescript-eslint/recommended',
'plugin:import/typescript',
'prettier',
],
settings: {
react: {
version: 'detect',
},
},
ignorePatterns: [
'**/lib/*',
'**/dist/*',
'**/coverage/*',
'**/build/*',
'**/build-electron/*',
'**/node_modules/*',
'packages/suite-data/files/*',
],
overrides: [
{
files: ['**/*.js'],
rules: {
// JS files are usually configs or scripts where require is OK
'@typescript-eslint/no-var-requires': 'off',
},
},
],
rules: {
// I believe type is enforced by callers.
'@typescript-eslint/explicit-function-return-type': 'off',
// Enforce arrow functions only is afaik not possible. But this helps.
'func-style': [
'error',
'declaration',
{
allowArrowFunctions: true,
},
],
// Fix for TypeScript.
'react/jsx-filename-extension': [
'error',
{
extensions: ['.tsx'],
},
],
'react/jsx-indent': [2, 4],
// I believe shadowing is a nice language feature.
'no-shadow': 'off',
'import/order': 'off',
// Does not work with TypeScript export type.
'import/prefer-default-export': 'off',
// Does not work with Babel react-native to react-native-web
'import/no-unresolved': 'off',
'import/extensions': [
'error',
'never',
{
ignorePackages: true,
pattern: {
// it's nice to explicitly know we are dealing with JSON
json: 'always',
},
},
],
'import/no-extraneous-dependencies': 'off',
'import/no-cycle': 'error',
'import/no-anonymous-default-export': [
'error',
{
allowArray: true,
allowLiteral: true,
allowObject: true,
},
],
// We have types.
'react/prop-types': 'off',
// It's fine.
'react/no-multi-comp': 'off',
'react/no-unescaped-entities': 'off',
// This is fine.
'class-methods-use-this': 'off',
'lines-between-class-members': 'off',
// We use it for immer. It should be checked by readonly anyway.
'no-param-reassign': 'off',
// Irrelevant.
'no-plusplus': 'off',
'no-return-assign': 'off',
'consistent-return': 'off',
'no-console': 'off',
// TSC checks it.
'@typescript-eslint/no-unused-vars': 'off',
'no-undef': 'off',
'react/jsx-no-undef': 'off',
// React Hooks.
'react-hooks/rules-of-hooks': 'error',
'react-hooks/exhaustive-deps': 'error',
// Reconsider, maybe enable later:
'@typescript-eslint/explicit-member-accessibility': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'react/destructuring-assignment': 'off',
'prettier/prettier': 'off',
'func-names': 'off',
'react/require-default-props': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
// We use this syntax
'@typescript-eslint/triple-slash-reference': 'off',
// new rules (eslint 6) temporary disabled until components-v2 and ts-ignore resolve
'react/jsx-props-no-spreading': 'off',
'@typescript-eslint/ban-ts-ignore': 'off',
// We need empty functions for mocking modules for react-native
'@typescript-eslint/no-empty-function': 'off',
'no-useless-constructor': 'off',
'@typescript-eslint/no-useless-constructor': 'error',
// valid case of class method overloads in typescript
'no-dupe-class-members': 'off',
'@typescript-eslint/ban-ts-comment': 'off',
// Missing return type on function
'@typescript-eslint/explicit-module-boundary-types': 'off',
// note you must disable the base rule as it can report incorrect errors
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
'require-await': ['error'],
},
};