Skip to content
This repository was archived by the owner on Mar 7, 2019. It is now read-only.

Commit 843b755

Browse files
Sort out all of the undecided rules!
1 parent 759db9e commit 843b755

File tree

7 files changed

+67
-73
lines changed

7 files changed

+67
-73
lines changed

coding-styles/base.js

+22-5
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ module.exports = {
138138
]
139139
}],
140140

141+
// Validate Indentation
142+
// This rule is aimed to enforce consistent indentation style.
143+
'indent': [1, 2, {
144+
SwitchCase: 1
145+
}],
146+
141147
// Enforce Property Spacing
142148
// This rule will warn when spacing in properties does not match the specified options. In the case
143149
// of long lines, it is acceptable to add a new line wherever whitespace is allowed.
@@ -147,6 +153,12 @@ module.exports = {
147153
mode: 'strict'
148154
}],
149155

156+
// This rule will enforce consistency of spacing around keywords and keyword-like tokens
157+
'keyword-spacing': [1, {
158+
before: true,
159+
after: true
160+
}],
161+
150162
// Disallow mixing CRLF and LF linebreaks
151163
// This rule aims to ensure having consistent line endings independent of operating system.
152164
'linebreak-style': [2, 'unix'],
@@ -290,14 +302,19 @@ module.exports = {
290302
// This rule is aimed at ensuring there are spaces around infix operators.
291303
'space-infix-ops': 1,
292304

293-
// This rule will enforce consistency of spacing around keywords and keyword-like tokens
294-
'keyword-spacing': [1, {
295-
before: true,
296-
after: true
305+
// Require or disallow spaces before/after unary operators
306+
// This rule enforces consistency regarding the spaces after words unary operators and after/before
307+
// nonwords unary operators.
308+
'space-unary-ops': [1, {
309+
words: true,
310+
nonwords: false
297311
}],
298312

299313
// Require or disallow a whitespace beginning a comment
300314
// This rule will enforce consistency of spacing after the start of a comment // or /*.
301-
'spaced-comment': 1
315+
'spaced-comment': 1,
316+
317+
// Require IIFEs to be Wrapped
318+
'wrap-iife': [1, 'inside']
302319
}
303320
}

environments/nodejs/best-practices.js

+4
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ module.exports = {
5151
// modified after the initial assignment. This helps v8 to better optimise code at runtime.
5252
'prefer-const': 1,
5353

54+
// Suggest using Reflect methods where applicable
55+
// Reflection API is still unsupported in Node.js (as of v5.5)
56+
'prefer-reflect': 0,
57+
5458
// Suggest using the spread operator instead of .apply()
5559
// This rule is aimed to flag usage of Function.prototype.apply() that can be replaced with the
5660
// spread operator.

standard/best-practices.js

+10
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ module.exports = {
1414
// Never allow trailing commas
1515
'comma-dangle': [2, 'never'],
1616

17+
// Require Function Expressions to have a Name
18+
// If you provide the optional name for a function expression then you will get the name of the
19+
// function expression in the stack trace.
20+
// If you are tempted to create anonymous function expression, consider using arrow function
21+
// instead.
22+
'func-names': 1,
23+
1724
// Disallow lexical declarations in case/default clauses
1825
// This rule disallows lexical declarations (let, const, function and class) in case/default
1926
// clauses. The reason is that the lexical declaration is visible in the entire switch block but it
@@ -171,6 +178,9 @@ module.exports = {
171178
// Additionally, the with statement cannot be used in strict mode.
172179
'no-with': 2,
173180

181+
// Suggest using Reflect methods where applicable
182+
'prefer-reflect': 1,
183+
174184
// Require Variable Declarations to be at the top of their scope
175185
// This rule aims to keep all variable declarations in the leading series of statements. Allowing
176186
// multiple declarations helps promote maintainability.

standard/known-errors.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,9 @@ module.exports = {
260260
'no-unused-expressions': [2, {
261261
allowShortCircuit: true,
262262
allowTernary: true
263-
}]
263+
}],
264+
265+
// Disallow generator functions that do not have yield
266+
'require-yield': 2
264267
}
265268
}

standard/optional.js

+10
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,22 @@ module.exports = {
3535
location: 'anywhere'
3636
}],
3737

38+
// Limit Maximum Depth
39+
// This rule aims to reduce the complexity of your code by allowing you to configure the maximum
40+
// depth blocks can be nested in a function.
41+
'max-depth': [1, 4],
42+
3843
// Limit Maximum Length of Line
3944
// Very long lines of code in any language can be difficult to read. In order to aid in readability
4045
// and maintainability many coders have developed a convention to limit lines of code to a certain
4146
// number of characters.
4247
'max-len': [1, 100, 2],
4348

49+
// Limit Maximum Number of Parameters
50+
// Functions that take numerous parameters can be difficult to read and write because it requires
51+
// the memorization of what each parameter is, its type, and the order they should appear in.
52+
'max-params': [1, 3],
53+
4454
// Disallow Bitwise Operators
4555
// This rule is aimed at catching typos that end up as bitwise operators, but are meant to be the
4656
// much more common &&, ||, <, > operators.

undecided.js

-62
This file was deleted.

unused.js

+17-5
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ module.exports = {
7171
// Unused, these operators are quite useful as long as whitespace is used responsibly around them.
7272
'no-plusplus': 0,
7373

74+
// Disallow use of the void operator
75+
// void is quite useful with IIFEs and for discarding return values when using return for
76+
// short-circuiting.
77+
'no-void': 0,
78+
7479
// Require IDs to match a pattern
7580
// Unused, too restrictive.
7681
'id-match': 0,
@@ -92,10 +97,6 @@ module.exports = {
9297
// Unused, too restrictive.
9398
'no-negated-condition': 0,
9499

95-
// Disallow certain syntax
96-
// Unused, no use case.
97-
'no-restricted-syntax': 0,
98-
99100
// Disallow Ternary Operators
100101
// You kidding me? Ternaries are great!
101102
'no-ternary': 0,
@@ -108,6 +109,17 @@ module.exports = {
108109
// Unused, too restrictive. It was flagging i.e. `array.indexOf('a') !== -1` (is 'a' in this array?)
109110
// as errors. Also, status code checks in HTTP responses were being reported as issues.
110111
// While I generally like the idea, current implementation simply won't fly well.
111-
'no-magic-numbers': 0
112+
'no-magic-numbers': 0,
113+
114+
// Require Radix Parameter
115+
// This rule is aimed at preventing the unintended conversion of a string to a number of a
116+
// different base than intended.
117+
// Unused, too restrictive. Front-end team might have some interest in this as the whole radix
118+
// issue started with different browsers using different radix for different numbers.
119+
'radix': 0,
120+
121+
// Require Regex Literals to be Wrapped
122+
// Unused, too restrictive.
123+
'wrap-regex': 0
112124
}
113125
}

0 commit comments

Comments
 (0)