-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
147 lines (128 loc) · 4 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
139
140
141
142
143
144
145
146
147
module.exports = {
root: true,
extends: ['@react-native-community', 'airbnb', 'airbnb/hooks', 'prettier'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'detox'],
ignorePatterns: ['*.graphql', 'graphql.ts', 'src/locales/'],
globals: { React: true, JSX: true },
env: { jest: true },
rules: {
'prefer-template': 'off',
// allow the use of dev dependencies in dev scripts
'import/no-extraneous-dependencies': [
2,
{
devDependencies: [
'**/*.{stories,story}.[jt]s?(x)',
'**/*.spec.[jt]s?(x)',
],
},
],
// allow the import of React, while disalowing use-before-define in general
'no-use-before-define': 'off',
'@typescript-eslint/no-use-before-define': ['error'],
// don't use non-null assertion, prefer defensive programming in case you are wrong
'@typescript-eslint/no-non-null-assertion': 'error',
// don't use semicolons.
semi: ['error', 'never'],
// format arrow body methods as required
'arrow-body-style': 'off',
// use typescript by default
'react/jsx-filename-extension': ['error', { extensions: ['.jsx', '.tsx'] }],
'import/extensions': [
'error',
'ignorePackages',
{
js: 'never',
jsx: 'never',
ts: 'never',
tsx: 'never',
},
],
'no-shadow': 'off',
'@typescript-eslint/no-shadow': 'error',
// import by default when necessary
'import/prefer-default-export': 'off',
// break lines at 80
'max-len': ['error', 120],
// don't commit console statements
'no-console': ['warn'], // warn when using console statements
// don't use unused var except with _ prefix
'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
// forbid to use 'any' type
'@typescript-eslint/no-explicit-any': ['error'],
// use of curlies
'object-curly-spacing': [2, 'always'],
'react/jsx-curly-newline': 'off',
// allow prop spreading
'react/jsx-props-no-spreading': 'off',
// react specific settings
'react/prop-types': 0,
'react/jsx-one-expression-per-line': 'off',
'react/require-default-props': 'off',
'react/jsx-uses-react': 1,
'react/jsx-uses-vars': 1,
'react/no-unescaped-entities': 'off',
'react/jsx-wrap-multilines': 'off',
'react/jsx-fragments': ['error', 'element'],
// prefer to not use array index as key, it is not the best for performance
'react/no-array-index-key': 'warn',
// allow inconsistent returns
'consistent-return': 'off',
// allow underscore dangle for apollo / graphql
'no-underscore-dangle': [2, { allow: ['__typename'] }],
// allow switch without default case
'default-case': 'off',
// Arrange components consistently
'react/sort-comp': [
2,
{
order: [
'static-variables',
'static-methods',
'lifecycle',
'everything-else',
'render',
],
groups: {
lifecycle: [
'displayName',
'propTypes',
'contextTypes',
'childContextTypes',
'mixins',
'statics',
'defaultProps',
'constructor',
'getDefaultProps',
'state',
'getInitialState',
'getChildContext',
'getDerivedStateFromProps',
'componentWillMount',
'UNSAFE_componentWillMount',
'componentDidMount',
'componentWillReceiveProps',
'UNSAFE_componentWillReceiveProps',
'shouldComponentUpdate',
'componentWillUpdate',
'UNSAFE_componentWillUpdate',
'getSnapshotBeforeUpdate',
'componentDidUpdate',
'componentDidCatch',
'componentWillUnmount',
],
},
},
],
},
settings: {
'import/resolver': {
node: {
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
typescript: {},
},
},
}