This repository has been archived by the owner on Aug 3, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheslintrc-readability.js
153 lines (117 loc) · 4.26 KB
/
eslintrc-readability.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
// Rules for making our code more readable.
module.exports = {
"rules": {
// When over multiple lines, we favour:
//
// object
// .property
//
// over
//
// object.
// property
//
// for readability.
"dot-location": ["error", "property"],
// Prefer foo.bar over foo["bar"] where possible.
// This is easier to read.
"dot-notation": "warn",
// All numbers should have a name to ensure other people
// understand what they are for.
//
// We've ignored 1, because it can feature in incrementing
// and people know what it is.
//
// Magic numbers should be const'ed.
"no-magic-numbers": ["warn", { "ignore": [0, 1, 2], "enforceConst": true }],
// Don't allow use of a variable before it is defined.
// This stops us using the hoisting nature of JavaScript
// to fix our sloppy coding.
//
// We make an allowance for functions; they are hoisted,
// but allows us to write code from "least detailed to most"
// in code:
//
// function doSteps() { step1(); step2(); step3(); }
// function step1() { ... }
// ...
"no-use-before-define": ["error", { "functions": false, "classes": true }],
// Only allow require() statements to be made in the global scope.
// Ideally these are placed at the top of the file and not anywhere else.
"global-require": "error",
// Avoid callback hell.
"max-nested-callbacks": ["warn", 3],
// If you're making something `new`-able,
// use a capital letter.
"new-cap": "warn",
// It turns out that `var x = new Foo` is the same as `var x = new Foo()`.
// Let's not use that.
"new-parens": "error",
// Avoid `else` with only an `if` in it. (Use `else if`!)
"no-lonely-if": "warn",
// Nested ternary statements are sometimes useful,
// but they shouldn't be encouraged.
"no-nested-ternary": "warn",
// Tighten up ternaries if possible. Prefer:
//
// x
//
// over
//
// x ? true : false
"no-unneeded-ternary": "warn",
// Don't use `new` with Function, Array, Object, String, Number or Boolean.
// Use the literal syntax instead.
"no-new-func": "error",
"no-new-wrappers": "error",
"no-array-constructor": "error",
"no-new-object": "error",
// Avoid `foo .bar`.
"no-whitespace-before-property": "warn",
// Avoid `fn ()`; use `fn()`.
"no-spaced-func": "warn",
// Use (a, b) for comma spacing. (Not (a ,b) or (a , b) or (a,b).)
"comma-spacing": "warn",
// Enforce operator shorthand: `x = x + 1` => `x += 1`.
"operator-assignment": "warn",
// Ensure a space between function() and {}.
"space-before-blocks": ["warn", "always"],
// Ensure there is no space between function and ().
"space-before-function-paren": ["warn", "never"],
// Require a space between infix operators.
"space-infix-ops": "warn",
// Disallow `! x`. (Use `!x`.)
"space-unary-ops": "warn",
// Avoid confusing functions unless bracketed.
//
// Use brackets if you hit this error:
// x = y => (y > 10 ? true : false)
"no-confusing-arrow": ["warn", { allowParens: true }],
// Put all imports from a module on the same line.
"no-duplicate-imports": "warn",
// Avoid computed keys with constants.
"no-useless-computed-key": "warn",
// Avoid constructors that mimic the default constructor.
"no-useless-constructor": "warn",
// Prefer `{ foo }` to `{ foo: foo }`.
"object-shorthand": "warn",
// Avoid `var`: use `let` or `const` instead.
"no-var": "warn",
// ...and prefer const over let.
"prefer-const": "warn",
// Use template strings for concatenation.
"prefer-template": "warn",
// If there is a `return` in an if block, we don't need an else block.
"no-else-return": "warn",
// Avoid multiple spaces in the middle of lines.
"no-multi-spaces": "warn",
// Avoid weird type conversions.
"no-implicit-coercion": "warn",
// Statements on the end of lines can be missed.
"max-statements-per-line": ["warn", { max: 2 }],
// We have no need for tabs in our files!
"no-tabs": "error",
// Irregular spacing triggers OCD in some developers...
"no-multiple-empty-lines": ["warn", { max: 2 }]
}
};