forked from desktop/desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.eslintrc.yml
223 lines (206 loc) · 6.38 KB
/
.eslintrc.yml
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
root: true
parser: '@typescript-eslint/parser'
plugins:
- '@typescript-eslint'
- react
- json
- jsdoc
settings:
react:
version: '16.3'
extends:
- prettier
- prettier/react
- plugin:@typescript-eslint/recommended
- prettier/@typescript-eslint
- plugin:github/react
rules:
##########
# CUSTOM #
##########
insecure-random: error
react-no-unbound-dispatcher-props: error
react-readonly-props-and-state: error
react-proper-lifecycle-methods: error
no-loosely-typed-webcontents-ipc: error
###########
# PLUGINS #
###########
# TYPESCRIPT
'@typescript-eslint/naming-convention':
- error
- selector: interface
format:
- PascalCase
custom:
regex: '^I[A-Z]'
match: true
- selector: class
format:
- PascalCase
- selector: variableLike
format: null
custom:
# Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Lexical_grammar we
# should probably be using the following expression here (newlines added for readability)
#
# ^(break|case|catch|class|const|continue|debugger|default|delete|do|else|export|
# extends|finally|for|function|if|import|in|instanceof|new|return|super|switch|this|
# throw|try|typeof|var|void|while|with|yield|enum|implements|interface|let|package|
# private|protected|public|static|await|abstract|boolean|byte|char|double|final|float|
# goto|int|long|native|short|synchronized|throws|transient|volatile|null|true|false)$
#
# But that'll cause a bunch of errors, for now we'll stick with replicating what the
# variable-name ban-keywords rule did for us in tslint
# see https://palantir.github.io/tslint/rules/variable-name/
regex: '^(any|Number|number|String|string|Boolean|boolean|Undefined|undefined)$'
match: false
'@typescript-eslint/consistent-type-assertions':
- error
- assertionStyle: 'as'
'@typescript-eslint/no-unused-expressions': error
'@typescript-eslint/explicit-member-accessibility': error
'@typescript-eslint/no-unused-vars':
- error
- args: 'none'
'@typescript-eslint/no-use-before-define':
- error
- functions: false
variables: false
typedefs: false
'@typescript-eslint/member-ordering':
- error
- default:
- static-field
- static-method
- field
- abstract-method
- constructor
- method
'@typescript-eslint/no-extraneous-class': error
'@typescript-eslint/no-empty-interface': error
# Would love to be able to turn this on eventually
'@typescript-eslint/no-non-null-assertion': off
# This rule does a lot of good but right now it catches way
# too many cases, we're gonna want to pay down this debt
# incrementally if we want to enable it.
'@typescript-eslint/ban-types': off
# It'd be nice to be able to turn this on eventually
'@typescript-eslint/no-var-requires': off
# Don't particularly care about these
'@typescript-eslint/triple-slash-reference': off
'@typescript-eslint/explicit-module-boundary-types': off
'@typescript-eslint/no-explicit-any': off
'@typescript-eslint/no-inferrable-types': off
'@typescript-eslint/no-empty-function': off
'@typescript-eslint/no-redeclare': error
# React
react/jsx-boolean-value:
- error
- always
react/jsx-key: error
react/jsx-no-bind: error
react/no-string-refs: error
react/jsx-uses-vars: error
react/jsx-uses-react: error
react/no-unused-state: error
react/no-unused-prop-types: error
react/prop-types:
- error
- ignore: ['children']
# JSDoc
jsdoc/check-alignment: error
jsdoc/check-tag-names: error
jsdoc/check-types: error
jsdoc/implements-on-classes: error
jsdoc/tag-lines:
- error
- any
- startLines: 1
jsdoc/no-undefined-types: error
jsdoc/valid-types: error
# Would love to enable these at some point but
# they cause way to many issues now.
#jsdoc/check-param-names: error
#jsdoc/require-jsdoc:
# - error
# - publicOnly: true
###########
# BUILTIN #
###########
curly: error
no-new-wrappers: error
# We'll use no-redeclare from @typescript/eslint-plugin instead as that
# supports overloads
no-redeclare: off
no-eval: error
no-sync: error
no-var: error
prefer-const: error
eqeqeq:
- error
- smart
strict:
- error
- global
no-buffer-constructor: error
no-restricted-imports:
- error
- paths:
- name: electron
importNames: ['ipcRenderer']
message:
"Please use 'import * as ipcRenderer' from 'ipc-renderer' instead to
get strongly typed IPC methods."
- name: electron/renderer
importNames: ['ipcRenderer']
message:
"Please use 'import * as ipcRenderer' from 'ipc-renderer' instead to
get strongly typed IPC methods."
- name: electron
importNames: ['ipcMain']
message:
"Please use 'import * as ipcMain' from 'ipc-main' instead to get
strongly typed IPC methods."
- name: electron/main
importNames: ['ipcMain']
message:
"Please use 'import * as ipcMain' from 'ipc-main' instead to get
strongly typed IPC methods."
###########
# SPECIAL #
###########
no-restricted-syntax:
- error
# no-default-export
- selector: ExportDefaultDeclaration
message: Use of default exports is forbidden
###########
# jsx-a11y #
###########
# autofocus is fine when it is being used to set focus to something in a way
# that doesn't skip any context or inputs. For example, in a named dialog, if you had
# a close button, a heading reflecting the name, and a labelled text input,
# focusing the text input wouldn't disadvantage a user because they're not
# missing anything of importance before it. The problem is when it is used on
# larger web pages, e.g. to focus a form field in the main content, entirely
# skipping the header and often much else besides.
jsx-a11y/no-autofocus:
- warn
- ignoreNonDOM: true
overrides:
- files: '*.d.ts'
rules:
strict:
- error
- never
- files: 'app/test/**/*'
rules:
'@typescript-eslint/no-non-null-assertion': off
- files: 'script/**/*'
rules:
'@typescript-eslint/no-non-null-assertion': off
parserOptions:
sourceType: module
ecmaFeatures:
jsx: true