forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.yaml
191 lines (166 loc) · 6.72 KB
/
.eslintrc.yaml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
parser: babel-eslint
extends:
- airbnb
- plugin:jest/recommended
- ./tools/formatting.eslintrc.yaml
plugins:
- jest
- flowtype
# - react-native # see commented-out rules config below
env:
browser: true
mocha: true
node: true
jest: true
globals: # true/false means mutable/const
__DEV__: false
__TEST__: false
settings:
# This setting is shared by the rules `import/*`. For details, see:
# https://github.com/benmosher/eslint-plugin-import#resolvers
# https://www.npmjs.com/package/eslint-import-resolver-node
import/resolver:
node:
extensions: [.js, .ios.js, .android.js, .json]
rules:
# Formatting and naming
camelcase: off
no-await-in-loop: off # Promise.all is not always desirable
# Permit dangling underscores in class property names, to denote "private"
# fields. (These should be replaced with true private fields per the TC39
# class fields proposal [1], once that's available to us.)
#
# [1]: https://github.com/tc39/proposal-class-fields
no-underscore-dangle: ["error", { allowAfterThis: true } ]
# Disallow double underscores and trailing underscores.
id-match: ["error", "^_?([a-zA-Z0-9$]+_?)*$", { "properties": true }]
# Disable a bunch of rules that should be taken care of by prettier.
arrow-parens: off
comma-dangle: off
function-paren-newline: off
indent: off
lines-between-class-members: off
max-len: off
no-mixed-operators: off
object-curly-newline: off
quote-props: off
# For more formatting rules, see tools/formatting.eslintrc.yaml .
# Repeal some rather absurd rules that make some code impossible to write in
# the most reasonable way.
no-else-return: off
prefer-destructuring:
- error
- AssignmentExpression: {array: false, object: false}
# Tricky code. We repeal several bans from the Airbnb style.
no-bitwise: off
no-confusing-arrow: off
no-continue: off
no-plusplus: off
no-nested-ternary: off
# We also partly repeal AirBnB's forbidden-syntax subrules. (This must be done
# in the `overrides:` section.)
#
# no-restricted-syntax: ...
# Likely-wrong code
no-unused-vars: [warn, {vars: local, args: none}]
# no-param-reassign seems well-intentioned... but fires on common uses
# of Array#reduce. Too noisy.
no-param-reassign: off
# Imports
import/prefer-default-export: off
import/no-extraneous-dependencies:
- error
- devDependencies: ['**/__tests__/**/*.js', tools/**]
no-restricted-imports:
- error
- patterns: ['**/__tests__/**']
import/no-cycle: off # This would be nice to fix; but isn't easy.
# Jest
# This rule could be useful if it fired only on new instances; but we
# don't have a way to do that, and it doesn't make sense to keep these
# out of the repo.
jest/no-disabled-tests: off
# React
react/jsx-filename-extension: off # Like RN upstream, we call the files *.js.
react/destructuring-assignment: off # The opposite is often much cleaner.
react/no-multi-comp: off # This often just forces making code worse.
react/no-unused-prop-types: off # This can be perfectly appropriate.
react/default-props-match-prop-types: off # We handle this better with types.
react/prop-types: off # We handle this better with types.
react/require-default-props: off # We handle this better with types.
# These two could be good to fix.
react/prefer-stateless-function: off
react/sort-comp: off
# React Native.
#
# This plugin isn't included in the airbnb config, and it doesn't
# itself enable any rules by default, so this config is it.
#
# (From the docs as of 2020-03, these are the rules we'd like to use.
# Plugin disabled only because the rules are; bring it back when
# reviving either of them.)
#
# react-native/no-unused-styles: error # This is buggy on the `this.styles` pattern.
# react-native/no-color-literals: error # TODO eliminate these and enable.
# Flow
flowtype/boolean-style: [error, boolean]
flowtype/define-flow-type: warn
flowtype/delimiter-dangle: off
flowtype/generic-spacing: [error, never]
flowtype/no-dupe-keys: error
flowtype/no-primitive-constructor-types: error
flowtype/no-types-missing-file-annotation: error
################# flowtype/no-weak-types: error
# flowtype/require-parameter-type: error
flowtype/require-readonly-react-props: error
# flowtype/require-return-type: [error, always, {annotateUndefined: never}]
flowtype/require-valid-file-annotation: error
flowtype/semi: [error, always]
flowtype/space-before-generic-bracket: [error, never]
flowtype/space-before-type-colon: [error, never]
# For more formatting rules, see tools/formatting.eslintrc.yaml.
flowtype/type-id-match: [error, '^([A-Z][a-z0-9]+)+$']
flowtype/union-intersection-spacing: [error, always]
flowtype/use-flow-type: warn
flowtype/valid-syntax: warn
# spellcheck/spell-checker: see tools/spellcheck.eslintrc.yaml .
overrides:
# Global overrides
- files: ["*.js"]
rules:
# Here we repeal several AirBnB subrules.
#
# - The AirBnB rule disallowing labeled statements arises largely from their
# controversial hardcore anti-loop position [1], which we don't share.
#
# - The AirBnB rule disallowing `for..of` statements is partly based on the
# above. More reasonably, though, it cites the `regenerator-runtime`
# library (which Babel uses to implement them) as being too heavyweight.
# Unfortunately, we're already including `regenerator-runtime` for other
# reasons, and there's no easy way to find out what. (In for a penny, in
# for a pound.)
#
# - The AirBnB rule disallowing `with` statements has a shorter built-in
# equivalent. (And the parser enforces it in strict mode, anyway.)
#
# Alas, ESLint does not allow these repeals to be done surgically; we must
# duplicate the entire acceptable portion of the rule. The original text
# thereof can be found at [2].
# [1]: https://github.com/airbnb/javascript/issues/1103
# [2]: https://github.com/airbnb/javascript/blob/dee4f17/packages/eslint-config-airbnb-base/rules/style.js#L334
no-restricted-syntax:
- error
- selector: ForInStatement
message: 'for..in loops iterate over the entire prototype chain, which
is virtually never what you want. Use Object.{keys,values,entries}, and
iterate over the resulting array.'
# They're also slightly buggy in JSC [1], on which react-native is
# built... and, surprisingly, their semantics weren't fully nailed down
# until as late as 2019-12 [2]. But the above is reason enough.
# [1]: https://bugs.webkit.org/show_bug.cgi?id=38970
# [2]: https://github.com/tc39/proposals/commit/cb9c6e50
no-with: error
# Test file overrides
- files: ['**/__tests__/**']
rules:
no-restricted-imports: off