-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.js
143 lines (140 loc) · 4.76 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
const OFF = 0
const WARNING = 1
const ERROR = 2
module.exports = {
root: true, // So parent files don't get applied
env: {
es6: true,
},
extends: ['plugin:import/recommended', 'airbnb', 'prettier'],
parser: 'babel-eslint', // Specifies the ESLint parser
parserOptions: {
ecmaVersion: 8, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
ecmaFeatures: {
jsx: true, // Allows for the parsing of JSX
},
},
plugins: ['react', 'react-hooks', 'react-native'],
settings: {
'import/resolver': {
'babel-module': {},
alias: [
['src', './src/**'],
['components', './src/components/'],
['containers', './src/containers/'],
['screens', './src/screens/'],
['styles', './src/styles/'],
['constants', './src/constants/'],
['navigation', './src/styles/'],
['i18n', './src/i18n/'],
['hooks', './src/hooks/'],
['storage', './src/storage/'],
['utils', './src/utils/'],
['blocks', './src/blocks/'],
],
node: {
extensions: [
'.js',
'.jsx',
'.ts',
'.tsx',
'.d.ts',
'.android.js',
'.android.jsx',
'.android.ts',
'.android.tsx',
'.ios.js',
'.ios.jsx',
'.ios.ts',
'.ios.tsx',
'.web.js',
'.web.jsx',
'.web.ts',
'.web.tsx',
],
},
},
react: {
version: 'detect', // Tells eslint-plugin-react to automatically detect the version of React to use
},
},
/**
* Sorted alphanumerically within each group. built-in and each plugin form
* their own groups.
*/
rules: {
'arrow-body-style': OFF, // Don't enforce, readability firsthand.
'consistent-this': [ERROR, 'self'],
'linebreak-style': OFF, // Doesn't play nicely with Windows
'no-use-before-define': OFF,
// just as bad as "max components per file"
'max-classes-per-file': OFF,
'no-alert': ERROR,
// Strict, airbnb is using warn; allow warn and error for dev environments
'no-console': [ERROR, { allow: ['warn', '2'] }],
'no-constant-condition': ERROR,
// Airbnb use error
'no-param-reassign': OFF,
'no-prototype-builtins': OFF,
'nonblock-statement-body-position': ERROR,
// Airbnb restricts isNaN and isFinite which are necessary for IE 11
// we have to be disciplined about the usage and ensure the Number type for its
// arguments
'no-underscore-dangle': ERROR,
'prefer-arrow-callback': [ERROR, { allowNamedFunctions: true }],
'prefer-destructuring': OFF, // Destructuring harm grep potential.
// This rule is great for raising people awareness of what a key is and how it works.
'react/no-array-index-key': OFF,
'react/destructuring-assignment': OFF,
// 'react/jsx-indent-props': [WARNING, 'tab'],
// It's buggy
'react/forbid-prop-types': OFF,
'react/jsx-curly-brace-presence': OFF,
'react/jsx-filename-extension': [ERROR, { extensions: ['.js'] }], // airbnb is using .jsx
'react/jsx-handler-names': [
ERROR,
{
// airbnb is disabling this rule
eventHandlerPrefix: 'handle',
eventHandlerPropPrefix: 'on',
},
],
// not a good rule for components close to the DOM
'react/jsx-props-no-spreading': OFF,
'react/no-danger': ERROR,
// Strict, airbnb is using off
'react/no-direct-mutation-state': ERROR,
'react/no-find-dom-node': OFF,
'react/no-multi-comp': OFF,
'react/style-prop-object': OFF,
'react/require-default-props': OFF,
'react/sort-prop-types': OFF,
// This depends entirely on what you're doing. There's no universal pattern
'react/state-in-constructor': OFF,
// stylistic opinion. For conditional assignment we want it outside, otherwise as static
'react/static-property-placement': OFF,
'import/prefer-default-export': OFF,
'import/no-absolute-path': [ERROR, { esmodule: false, commonjs: false, amd: false }],
'import/namespace': [ERROR, { allowComputed: true }],
'import/no-extraneous-dependencies': OFF, // It would be better to enable this rule.
'import/order': [
ERROR,
{
groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'],
'newlines-between': 'never',
},
],
'react-hooks/rules-of-hooks': ERROR,
'react-hooks/exhaustive-deps': [ERROR, { additionalHooks: 'useEnhancedEffect' }],
'jsx-a11y/anchor-is-valid': OFF,
'react-native/no-unused-styles': WARNING,
'react-native/split-platform-components': ERROR,
'react-native/no-inline-styles': WARNING,
'react-native/no-color-literals': OFF,
'react-native/no-raw-text': OFF,
},
globals: {
__DEV__: true,
},
}