Skip to content

Commit e546008

Browse files
committed
Update coding style rules
1 parent 1ed5633 commit e546008

13 files changed

+83
-77
lines changed

.eslintrc

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"rules": {
1313
// Possible Errors
14-
"no-comma-dangle": 2,
14+
"comma-dangle": [2, "never"],
1515
"no-cond-assign": 2,
1616
"no-console": 2,
1717
"no-constant-condition": 2,
@@ -31,15 +31,15 @@
3131
"no-negated-in-lhs": 2,
3232
"no-obj-calls": 2,
3333
"no-regex-spaces": 2,
34-
"no-reserved-keys": 2,
34+
"no-reserved-keys": 0,
3535
"no-sparse-arrays": 2,
3636
"no-unreachable": 2,
3737
"use-isnan": 2,
3838
"valid-jsdoc": 0,
3939
"valid-typeof": 2,
4040
// Best Practices
4141
"block-scoped-var": 2,
42-
"complexity": [2, 10],
42+
"complexity": 0,
4343
"consistent-return": 2,
4444
"curly": 2,
4545
"default-case": 2,
@@ -86,9 +86,7 @@
8686
"wrap-iife": 2,
8787
"yoda": 2,
8888
// Strict Mode
89-
"global-strict": [2, "always"],
90-
"no-extra-strict": 2,
91-
"strict": 2,
89+
"strict": [2, "global"],
9290
// Variables
9391
"no-catch-shadow": 2,
9492
"no-delete-var": 2,
@@ -101,16 +99,22 @@
10199
"no-unused-vars": 2,
102100
"no-use-before-define": 2,
103101
// Stylistic Issues
102+
"indent": [2, 2, {
103+
"indentSwitchCase": true
104+
}],
104105
"brace-style": 2,
105106
"camelcase": 0,
106107
"comma-spacing": 2,
107108
"comma-style": 2,
108109
"consistent-this": 0,
109-
"eol-last": 0,
110+
"eol-last": 2,
110111
"func-names": 0,
111112
"func-style": 0,
112-
"key-spacing": 2,
113-
"max-nested-callbacks": [2, 3],
113+
"key-spacing": [2, {
114+
"beforeColon": false,
115+
"afterColon": true
116+
}],
117+
"max-nested-callbacks": 0,
114118
"new-cap": 2,
115119
"new-parens": 2,
116120
"no-array-constructor": 2,
@@ -119,7 +123,10 @@
119123
"no-mixed-spaces-and-tabs": 2,
120124
"no-nested-ternary": 2,
121125
"no-new-object": 2,
122-
"no-space-before-semi": 2,
126+
"semi-spacing": [2, {
127+
"before": false,
128+
"after": true
129+
}],
123130
"no-spaced-func": 2,
124131
"no-ternary": 0,
125132
"no-trailing-spaces": 2,
@@ -130,9 +137,9 @@
130137
"operator-assignment": [2, "always"],
131138
"padded-blocks": 0,
132139
"quotes": [2, "single"],
133-
"quote-props": 0,
140+
"quote-props": [2, "as-needed"],
134141
"semi": [2, "always"],
135-
"sort-vars": 0,
142+
"sort-vars": [2, "ignoreCase"],
136143
"space-after-keywords": 2,
137144
"space-before-blocks": 2,
138145
"space-in-brackets": 2,
@@ -143,11 +150,10 @@
143150
"spaced-line-comment": 2,
144151
"wrap-regex": 0,
145152
// Legacy
146-
"max-depth": [2, 3],
153+
"max-depth": 0,
147154
"max-len": [2, 120],
148-
"max-params": [2, 10],
149-
"max-statements": [2, 10],
150-
"no-bitwise": 2,
155+
"max-params": 0,
156+
"max-statements": 0,
151157
"no-plusplus": 0
152158
}
153159
}

lib/rules/display-name.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ module.exports = function(context) {
2929

3030
return {
3131

32-
'ObjectExpression': function(node) {
32+
ObjectExpression: function(node) {
3333

3434
if (!isComponentDefinition(node.parent)) {
3535
return;

lib/rules/jsx-no-undef.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ module.exports = function(context) {
2727
* @returns {void}
2828
*/
2929
function checkIdentifierInJSX(node) {
30-
var scope = context.getScope(),
31-
variables = scope.variables,
32-
i,
33-
len;
30+
var scope = context.getScope();
31+
var variables = scope.variables;
32+
var i;
33+
var len;
3434

3535
while (scope.type !== 'global') {
3636
scope = scope.upper;
@@ -50,7 +50,7 @@ module.exports = function(context) {
5050
}
5151

5252
return {
53-
'JSXOpeningElement': function(node) {
53+
JSXOpeningElement: function(node) {
5454
if (isTagName(node.name.name)) {
5555
return;
5656
}

lib/rules/jsx-uses-react.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function(context) {
1616

1717
return {
1818

19-
'JSXOpeningElement': function() {
19+
JSXOpeningElement: function() {
2020
context.markVariableAsUsed('React');
2121
}
2222
};

lib/rules/jsx-uses-vars.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
module.exports = function(context) {
1313

1414
return {
15-
'JSXExpressionContainer': function(node) {
15+
JSXExpressionContainer: function(node) {
1616
if (node.expression.type === 'Identifier') {
1717
context.markVariableAsUsed(node.expression.name);
1818
}
1919
},
2020

21-
'JSXIdentifier': function(node) {
21+
JSXIdentifier: function(node) {
2222
context.markVariableAsUsed(node.name);
2323
}
2424

lib/rules/no-did-mount-set-state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function(context) {
1616

1717
return {
1818

19-
'CallExpression': function(node) {
19+
CallExpression: function(node) {
2020
var callee = node.callee;
2121
if (callee.type !== 'MemberExpression') {
2222
return;

lib/rules/no-did-update-set-state.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = function(context) {
1616

1717
return {
1818

19-
'CallExpression': function(node) {
19+
CallExpression: function(node) {
2020
var callee = node.callee;
2121
if (callee.type !== 'MemberExpression') {
2222
return;

lib/rules/no-multi-comp.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function(context) {
1717
// --------------------------------------------------------------------------
1818

1919
return {
20-
'MemberExpression': function(node) {
20+
MemberExpression: function(node) {
2121
if (node.object.name === 'React' && node.property.name === 'createClass' && ++componentCounter > 1) {
2222
context.report(node, 'Declare only one React component per file');
2323
}

lib/rules/prop-types.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ module.exports = function(context) {
3131

3232
return {
3333

34-
'MemberExpression': function(node) {
34+
MemberExpression: function(node) {
3535
if (node.object.type !== 'ThisExpression' || node.property.name !== 'props' || !node.parent.property) {
3636
return;
3737
}
3838
usedPropTypes.push(node.parent.property.name);
3939
},
4040

41-
'ObjectExpression': function(node) {
41+
ObjectExpression: function(node) {
4242

4343
if (!isComponentDefinition(node.parent)) {
4444
return;

lib/rules/react-in-jsx-scope.js

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,39 @@
1010

1111
module.exports = function(context) {
1212

13-
var NOT_DEFINED_MESSAGE = '\'React\' must be in scope when using JSX';
14-
15-
function findVariable(variables, name) {
16-
var i, len;
17-
for (i = 0, len = variables.length; i < len; i++) {
18-
if (variables[i].name === name) {
19-
return true;
20-
}
21-
}
22-
return false;
13+
var NOT_DEFINED_MESSAGE = '\'React\' must be in scope when using JSX';
14+
15+
function findVariable(variables, name) {
16+
var i, len;
17+
for (i = 0, len = variables.length; i < len; i++) {
18+
if (variables[i].name === name) {
19+
return true;
20+
}
2321
}
22+
return false;
23+
}
2424

25-
function variablesInScope() {
26-
var scope = context.getScope(),
27-
variables = scope.variables;
25+
function variablesInScope() {
26+
var scope = context.getScope(),
27+
variables = scope.variables;
2828

29-
while (scope.type !== 'global') {
30-
scope = scope.upper;
31-
variables = scope.variables.concat(variables);
32-
}
33-
34-
return variables;
29+
while (scope.type !== 'global') {
30+
scope = scope.upper;
31+
variables = scope.variables.concat(variables);
3532
}
3633

37-
return {
34+
return variables;
35+
}
36+
37+
return {
3838

39-
'JSXOpeningElement': function(node) {
40-
var variables = variablesInScope();
41-
if (!findVariable(variables, 'React')) {
42-
context.report(node, NOT_DEFINED_MESSAGE);
43-
}
44-
}
39+
JSXOpeningElement: function(node) {
40+
var variables = variablesInScope();
41+
if (!findVariable(variables, 'React')) {
42+
context.report(node, NOT_DEFINED_MESSAGE);
43+
}
44+
}
4545

46-
};
46+
};
4747

4848
};

0 commit comments

Comments
 (0)