forked from jashkenas/backbone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.eslintrc.js
203 lines (199 loc) · 7.36 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
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
module.exports = {
extends: 'eslint:recommended',
parserOptions: {
sourceType: 'module',
},
env: {
browser: true,
// Allows module/require syntax
node: true,
es6: true,
},
globals: {
TOUT: false,
},
rules: {
//
// Best Practices
//
// get/set must be defined in pairs.
'accessor-pairs': 2,
// catch forgotten returns in array methods like map/reduce.
'array-callback-return': 2,
// var should be treated as block scope.
'block-scoped-var': 2,
// disable the check because it doesn't like guards
complexity: [0, 10],
// require return statements to either always or never specify values
'consistent-return': 2,
// specify curly brace conventions for all control statements
curly: [2, 'all'],
// require default case in switch statements
'default-case': 2,
// enforces consistent newlines before or after dots
'dot-location': [2, 'property'],
// encourages use of dot notation whenever possible
// But allow for snakecase for external apis
'dot-notation': [2, {'allowPattern': '^[a-z0-9]+(_[a-z0-9]+)+$'}],
// require the use of === and !== except when checking null/undefined.
eqeqeq: [2, 'smart'],
// don't make sure for-in loops have an if statement
'guard-for-in': 0,
// disallow alert/confirm/prompt
'no-alert': 2,
// disallow use of arguments.caller or arguments.callee
'no-caller': 2,
// disallow lexical declarations in case/default clauses
'no-case-declarations': 2,
// disallow division operators explicitly at beginning of regular expression
'no-div-regex': 2,
// disallow else after a return in an if statement
'no-else-return': 2,
// allow empty functions.
'no-empty-function': 0,
// disallow empty destructuring patterns
'no-empty-pattern': 2,
// allow comparisons to null without a type-checking operator
'no-eq-null': 0,
// disallow use of eval()
'no-eval': 2,
// disallow adding to native types
'no-extend-native': 2,
// disallow unnecessary function binding
'no-extra-bind': 2,
// disallow Unnecessary Labels
'no-extra-label': 2,
// disallow fallthrough of case statements
'no-fallthrough': 2,
// disallow the use of leading or trailing decimal points in numeric literals
'no-floating-decimal': 2,
// allow shorthand type conversions
'no-implicit-coercion': 0,
// disallow var and named functions in global scope
'no-implicit-globals': 2,
// disallow use of eval()-like methods
'no-implied-eval': 2,
// backbone makes heavy use of apply and call. let functions use this
'no-invalid-this': 0,
// disallow usage of __iterator__ property
'no-iterator': 2,
// disallow use of labels for anything other then loops and switches
'no-labels': 2,
// disallow unnecessary nested blocks
'no-lone-blocks': 2,
// disallow creation of functions within loops
'no-loop-func': 2,
// allow magic numbers
'no-magic-numbers': 0,
// disallow use of multiple spaces
'no-multi-spaces': ["error", {"ignoreEOLComments": true}],
// disallow use of multiline strings
'no-multi-str': 2,
// disallow reassignments of native objects
'no-native-reassign': 2,
// disallow use of new operator when not part of the assignment or comparison
'no-new': 2,
// disallow use of new operator for Function object
'no-new-func': 2,
// disallows creating new instances of String, Number, and Boolean
'no-new-wrappers': 2,
// disallow use of (old style) octal literals
'no-octal': 2,
// disallow use of octal escape sequences in string literals, such as
// var foo = 'Copyright \251';
'no-octal-escape': 2,
// disallow reassignment of function parameters
// disallow parameter object manipulation
// 'no-param-reassign': [2, { props: true }],
// no-param-reassign is great idea, but often map/reduce methods
// are easier to read/maintain if they can alter param state.
// Guards are also easer, so we are allowing them
'no-param-reassign': [0, { props: true }],
// disallow usage of __proto__ property
'no-proto': 2,
// disallow declaring the same variable more then once
'no-redeclare': 2,
// disallow use of assignment in return statement
'no-return-assign': 2,
// disallow use of `javascript:` urls.
'no-script-url': 2,
// disallow self assignment
'no-self-assign': 2,
// disallow comparisons where both sides are exactly the same
'no-self-compare': 2,
// disallow use of comma operator
'no-sequences': 2,
// restrict what can be thrown as an exception
'no-throw-literal': 2,
// disallow unmodified conditions of loops
'no-unmodified-loop-condition': 2,
// disallow usage of expressions in statement position
'no-unused-expressions': 2,
// disallow unused labels
'no-unused-labels': 2,
// disallow unnecessary .call() and .apply()
'no-useless-call': 2,
// disallow useless string concatenation
'no-useless-concat': 2,
//TODO: Turn this back on once we have tests for the regex.
// allow unnecessary string escaping
'no-useless-escape': 0,
// allow use of void operator
'no-void': 0,
// disallow use of the with statement
'no-with': 2,
// require use of the second argument for parseInt()
radix: 2,
// do not force vars at the top. It's great practice but doesn't allow guards
'vars-on-top': 0,
//
// Variables
//
// disallow delete on variables.
'no-delete-var': 2,
// disallow labels with the same name as variables.
'no-label-var': 2,
// disallow shadowing, it is hard to read and usually a mistake.
'no-shadow': 2,
// disallow showowing restructed names.
'no-shadow-restricted-names': 2,
// catch misspellings of variable and parameter names, or accidental implicit globals
'no-undef': 2,
// disallow setting variables to undefined.
'no-undef-init': 2,
// undefined can be overriden or shadowed. Don't allow it.
'no-undefined': 2,
// show vars that are no longer used as errors so they can be cleaned up.
'no-unused-vars': 2,
// require that things are declared before they are used.
'no-use-before-define': [2, 'nofunc'],
//
// Style
//
// require array blocks to have consistent spacing.
'array-bracket-spacing': [2, 'never'],
// require inline blocks to have consistent spacing.
'block-spacing': 2,
// require else/else if/catch to be on their own line.
// unless it's all single line.
'brace-style': [2, 'stroustrup', { 'allowSingleLine': true }],
// require consistent nameing of variables.
'camelcase': 2,
// Javascript allows trailing commas, IE < 9 did not.
'comma-dangle': [2, 'always-multiline'],
// require strings to use single quotes.
quotes: [2, 'single'],
// require files to use space.
'no-mixed-spaces-and-tabs': 2,
// allow identifiers to have a leading or trailing _
'no-underscore-dangle': 0,
// semicolons are required in JavaScript, don't let people use ASI.
semi: 2,
// disallow things that look like end of statements, but are really multiline.
'no-unexpected-multiline': 2,
// unary operators should not have a space.
'space-unary-ops': 2,
// require 2 space indentations; switch statements should also be indented
indent: ['error', 2, { 'SwitchCase': 1 }],
},
}