-
Notifications
You must be signed in to change notification settings - Fork 0
/
eslint.yaml
148 lines (140 loc) · 4.27 KB
/
eslint.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
parserOptions:
parser: '@typescript-eslint/parser'
extends:
- 'google'
- 'plugin:@typescript-eslint/recommended'
- 'plugin:vue/recommended'
plugins:
- '@typescript-eslint'
rules:
### Google overrides ###
# Google's 80 char limit is a bit aggressive for TypeScript, which has
# particularly long lines because of all the typings
max-len:
- error
- code: 120
ignorePattern: '^import '
ignoreUrls: true
# Use the TypesScript-safe version
indent: off
# Google enforces this, but TypeScript is enough documentation for us
require-jsdoc: off
valid-jsdoc: off
# This is a good rule in general, but a lot of our 3rd party libraries
# are naughty about this, so let's turn it off
new-cap: off
# Needs to be disabled, so the TypeScript-safe version can be used
semi: off
# We control most of the objects we need to iterate over, so let's not
# bother with these checks
guard-for-in: off
# Let's reduce the amount of boring typing we have to do
quote-props:
- error
- as-needed
# The default rules are a bit liberal (eg allow unnecessary backticks)
quotes:
- error
- single
- avoidEscape: true
# We use @typescript/naming-convention instead
camelcase: off
# Keep consistent spacing
no-multiple-empty-lines:
- error
- max: 1
lines-between-class-members:
- error
- always
- exceptAfterSingleLine: true
function-paren-newline:
- error
- multiline-arguments
# Consistent operator spacing
space-infix-ops: error
# Reminder to remove console statements
no-console: warn
### TYPESCRIPT ###
# Disabling explicit any is pretty annoying when also using
# no implicit any
'@typescript-eslint/no-explicit-any': off
# Even according to the docs, it's safe to hoist functions, so
# let's allow it so we can hide functions at the bottoms of files
'@typescript-eslint/no-use-before-define':
- error
- functions: false
classes: false
# Sometimes modules don't have type definitions, so we need to require them
'@typescript-eslint/no-var-requires': off
'@typescript-eslint/naming-convention':
- error
# Makes it clear which files are interfaces, and leaves the un-prefixed
# name available to be a class (without needing eg an 'Impl' suffix)
- selector: interface
format:
- PascalCase
custom:
regex: ^I[A-Z]
match: true
'@typescript-eslint/no-empty-interface':
- error
- allowSingleExtends: true
# Let's allow expressions (eg arrow functions), because adding type
# definitions can often decrease readability, and type safety is
# typically less important in these situations
'@typescript-eslint/explicit-function-return-type':
- warn
- allowExpressions: true
'@typescript-eslint/no-unused-vars':
- error
- argsIgnorePattern: '^_'
'@typescript-eslint/semi':
- error
- always
'@typescript-eslint/explicit-member-accessibility':
- error
# 2 spaces means nested code doesn't drift too far across the screen
'@typescript-eslint/indent':
- error
- 2
- SwitchCase: 1
'@typescript-eslint/explicit-module-boundary-types':
- warn
# We should trust ourselves to use any when appropriate
- allowArgumentsExplicitlyTypedAsAny: true
allowHigherOrderFunctions: true
allowTypedFunctionExpressions: true
# The default options are a bit aggressive and ban eg Function, which
# sometimes has legitimate use
'@typescript-eslint/ban-types': off
'@typescript-eslint/member-ordering':
- "error"
- default:
- signature
- public-abstract-field
- protected-abstract-field
- private-abstract-field
- public-abstract-method
- protected-abstract-method
- private-abstract-method
- public-static-field
- protected-static-field
- private-static-field
- public-field
- protected-field
- private-field
- protected-static-method
- public-static-method
- private-static-method
- public-constructor
- protected-constructor
- private-constructor
- public-method
- protected-method
- private-method
overrides:
- files:
- '*.spec.ts'
rules:
# We use a lot of empty functions in tests (as stubs, etc.)
'@typescript-eslint/no-empty-function': off