Use eslintrc from fbjs
Paul O’Shannessy committed
Aug 31, 2015 at 13:25 UTC
7645c077200ab34ee403f43987479bf1d2a365c0
18 files changed
+48
-85
.eslintrc
+19
-62
@@ -1,76 +1,33 @@
1
---
2
parser: babel-eslint
3
4
+extends:
5
+ - ./node_modules/fbjs-scripts/eslint/.eslintrc
6
+
7
plugins:
8
- react
9
- react-internal
10
8
-env:
9
- browser: true
10
- node: true
11
-
12
-globals:
13
- __DEV__: true
14
- # Jest / Jasmine
15
- describe: false
16
- xdescribe: false
17
- beforeEach: false
18
- afterEach: false
19
- it: false
20
- xit: false
21
- jest: false
22
- pit: false
23
- expect: false
24
- spyOn: false
25
- jasmine: false
26
-
11
+# We're stricter than the default config, mostly. We'll override a few rules and
12
+# then enable some React specific ones.
13
rules:
28
- # ERRORS
29
- space-before-blocks: 2
30
- indent: [2, 2, {SwitchCase: 1}]
31
- brace-style: 2
32
- space-after-keywords: 2
33
- strict: [2, global]
14
+ accessor-pairs: 0
15
+ brace-style: [2, 1tbs]
16
comma-dangle: [2, always-multiline]
35
- # Make this a warning for now. We do this in a few places so we might need to
36
- # disable
37
- no-unused-expressions: 2
38
- eol-last: 2
39
- dot-notation: 2
40
- dot-location: [2, property]
17
consistent-return: 2
42
- no-unused-vars: [2, args: none]
43
- quotes: [2, single, avoid-escape]
44
- no-shadow: 2
18
+ dot-location: [2, property]
19
+ dot-notation: 2
20
+ eol-last: 2
21
+ indent: [2, 2, {SwitchCase: 1}]
22
+ no-bitwise: 0
23
no-multi-spaces: 2
46
- no-undef: 2
47
-
48
- # WISHLIST. One day...
49
- # We'll need a custom version of this that does a subset of the whole rule.
50
- # Otherwise this is just too noisy.
51
- # valid-jsdoc: 1
52
- # Ideally, we could just warn when *new* lines are added that exceed 80 chars
53
- # while not warning about existing ones (often URLs, etc. which are
54
- # necessarily long), but we don't have a good way to do so.
55
- # max-len: [0, 80]
56
-
57
- # DISABLED. These aren't compatible with our style
58
- # We use this for private/internal variables
59
- no-underscore-dangle: 0
60
- # We pass constructors around / access them from members
61
- new-cap: 0
62
- # We do this a lot.
63
- no-use-before-define: 0
64
- # We do this in a few places to align values
65
- key-spacing: 0
66
- # It's nice to be able to leave catch blocks empty
67
- no-empty: 0
68
- # It makes code more readable to make this explicit sometimes
69
- no-undef-init: 0
70
-
71
- # BROKEN. We'd like to turn these back on.
72
- # causes a ton of noise, eslint is too picky?
73
- block-scoped-var: 0
24
+ no-shadow: 2
25
+ no-unused-expressions: 2
26
+ no-unused-vars: [2, {args: none}]
27
+ quotes: [2, single, avoid-escape]
28
+ space-after-keywords: 2
29
+ space-before-blocks: 2
30
+ strict: [2, global]
31
32
# JSX
33
# Our transforms set this automatically
grunt/config/browserify.js
+2
-2
@@ -80,7 +80,7 @@ var min = {
80
// No need to derequire because the minifier will mangle
81
// the "require" calls.
82
83
- after: [/*derequire,*/ minify, bannerify],
83
+ after: [minify, bannerify],
84
};
85
86
var transformer = {
@@ -126,7 +126,7 @@ var addonsMin = {
126
// No need to derequire because the minifier will mangle
127
// the "require" calls.
128
129
- after: [/*derequire,*/ minify, bannerify],
129
+ after: [minify, bannerify],
130
};
131
132
module.exports = {
packages/react-codemod/transforms/class.js
+1
-1
@@ -521,4 +521,4 @@ module.exports = (file, api, options) => {
521
}
522
523
return null;
524
-}
524
+};
packages/react-codemod/transforms/utils/ReactUtils.js
+1
-1
@@ -36,7 +36,7 @@ module.exports = function(j) {
36
},
37
})
38
.filter(declarator => declarator.value.source.value === module)
39
- .size() === 1
39
+ .size() === 1;
40
41
const hasReact = path => (
42
hasModule(path, 'React') ||
src/addons/__tests__/renderSubtreeIntoContainer.js
+2
-2
@@ -17,7 +17,7 @@ var renderSubtreeIntoContainer = require('renderSubtreeIntoContainer');
17
18
describe('renderSubtreeIntoContainer', function() {
19
20
- it('should pass context when rendering subtree elsewhere', function () {
20
+ it('should pass context when rendering subtree elsewhere', function() {
21
22
var portal = document.createElement('div');
23
@@ -57,7 +57,7 @@ describe('renderSubtreeIntoContainer', function() {
57
expect(portal.firstChild.innerHTML).toBe('bar');
58
});
59
60
- it('should throw if parentComponent is invalid', function () {
60
+ it('should throw if parentComponent is invalid', function() {
61
var portal = document.createElement('div');
62
63
var Component = React.createClass({
src/isomorphic/classic/class/__tests__/ReactBindOptout-test.js
+3
-3
@@ -83,7 +83,7 @@ describe('autobind optout', function() {
83
});
84
85
it('should not hold reference to instance', function() {
86
- var mouseDidClick = function () {
86
+ var mouseDidClick = function() {
87
void this.state.something;
88
};
89
@@ -129,11 +129,11 @@ describe('autobind optout', function() {
129
130
expect(mountedInstance1.onClick).toBe(mountedInstance2.onClick);
131
132
- expect(function () {
132
+ expect(function() {
133
ReactTestUtils.Simulate.click(rendered1);
134
}).toThrow();
135
136
- expect(function () {
136
+ expect(function() {
137
ReactTestUtils.Simulate.click(rendered2);
138
}).toThrow();
139
});
src/isomorphic/classic/element/__tests__/ReactElement-test.js
+3
-1
@@ -142,7 +142,9 @@ describe('ReactElement', function() {
142
143
it('merges rest arguments onto the children prop in an array', function() {
144
spyOn(console, 'error');
145
- var a = 1, b = 2, c = 3;
145
+ var a = 1;
146
+ var b = 2;
147
+ var c = 3;
148
var element = React.createFactory(ComponentClass)(null, a, b, c);
149
expect(element.props.children).toEqual([1, 2, 3]);
150
expect(console.error.argsForCall.length).toBe(0);
src/isomorphic/classic/element/__tests__/ReactElementValidator-test.js
+1
-1
@@ -212,7 +212,7 @@ describe('ReactElementValidator', function() {
212
spyOn(console, 'error');
213
var Component = React.createFactory(ComponentClass);
214
215
- Component(null, [ {}, {} ]);
215
+ Component(null, [{}, {}]);
216
217
expect(console.error.argsForCall.length).toBe(0);
218
});
src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+3
-1
@@ -119,7 +119,9 @@ describe('ReactJSXElement', function() {
119
120
it('merges JSX children onto the children prop in an array', function() {
121
spyOn(console, 'error');
122
- var a = 1, b = 2, c = 3;
122
+ var a = 1;
123
+ var b = 2;
124
+ var c = 3;
125
var element = <Component>{a}{b}{c}</Component>;
126
expect(element.props.children).toEqual([1, 2, 3]);
127
expect(console.error.argsForCall.length).toBe(0);
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
+1
-1
@@ -168,7 +168,7 @@ describe('ReactJSXElementValidator', function() {
168
it('does not warn when the child array contains non-elements', function() {
169
spyOn(console, 'error');
170
171
- void <Component>{[ {}, {} ]}</Component>;
171
+ void <Component>{[{}, {}]}</Component>;
172
173
expect(console.error.argsForCall.length).toBe(0);
174
});
src/renderers/dom/client/__tests__/ReactMount-test.js
+2
-2
@@ -145,7 +145,7 @@ describe('ReactMount', function() {
145
expect(console.error.calls.length).toBe(0);
146
});
147
148
- it('should warn when mounting into document.body', function () {
148
+ it('should warn when mounting into document.body', function() {
149
var iFrame = document.createElement('iframe');
150
document.body.appendChild(iFrame);
151
spyOn(console, 'error');
@@ -158,7 +158,7 @@ describe('ReactMount', function() {
158
);
159
});
160
161
- it('should account for escaping on a checksum mismatch', function () {
161
+ it('should account for escaping on a checksum mismatch', function() {
162
var div = document.createElement('div');
163
var markup = ReactDOMServer.renderToString(
164
<div>This markup contains an nbsp entity: server text</div>);
src/renderers/dom/client/wrappers/LinkedValueUtils.js
+1
-1
@@ -103,7 +103,7 @@ function getDeclarationErrorAddendum(owner) {
103
* this outside of the ReactDOM controlled form components.
104
*/
105
var LinkedValueUtils = {
106
- checkPropTypes: function (tagName, props, owner) {
106
+ checkPropTypes: function(tagName, props, owner) {
107
for (var propName in propTypes) {
108
if (propTypes.hasOwnProperty(propName)) {
109
var error = propTypes[propName](
src/renderers/shared/event/eventPlugins/__tests__/ResponderEventPlugin-test.js
+1
-1
@@ -216,7 +216,7 @@ var oneEventLoopTestConfig = function(readableIDToID) {
216
*/
217
var registerTestHandlers = function(eventTestConfig, readableIDToID) {
218
var runs = {dispatchCount: 0};
219
- var neverFire = function (readableID, registrationName) {
219
+ var neverFire = function(readableID, registrationName) {
220
runs.dispatchCount++;
221
expect('').toBe(
222
'Event type: ' + registrationName +
src/renderers/shared/reconciler/__tests__/ReactComponent-test.js
+4
-2
@@ -51,7 +51,8 @@ describe('ReactComponent', function() {
51
});
52
53
it('should support refs on owned components', function() {
54
- var innerObj = {}, outerObj = {};
54
+ var innerObj = {};
55
+ var outerObj = {};
56
57
var Wrapper = React.createClass({
58
@@ -101,7 +102,8 @@ describe('ReactComponent', function() {
102
});
103
104
it('should support new-style refs', function() {
104
- var innerObj = {}, outerObj = {};
105
+ var innerObj = {};
106
+ var outerObj = {};
107
108
var Wrapper = React.createClass({
109
getObject: function() {
src/renderers/shared/reconciler/__tests__/ReactComponentLifeCycle-test.js
+1
-1
@@ -285,7 +285,7 @@ describe('ReactComponentLifeCycle', function() {
285
);
286
});
287
288
- it('isMounted should return false when unmounted', function () {
288
+ it('isMounted should return false when unmounted', function() {
289
var Component = React.createClass({
290
render: function() {
291
return <div/>;
src/renderers/shared/reconciler/__tests__/ReactMultiChildReconcile-test.js
+1
-1
@@ -283,7 +283,7 @@ describe('ReactMultiChildReconcile', function() {
283
bob: 'bobStatus',
284
};
285
286
- testPropsSequence([ {usernameToStatus: usernameToStatus} ]);
286
+ testPropsSequence([{usernameToStatus: usernameToStatus}]);
287
});
288
289
it('should preserve order if children order has not changed', function() {
src/shared/utils/__tests__/adler32-test.js
+1
-1
@@ -29,7 +29,7 @@ describe('adler32', function() {
29
it('doesn\'t barf on large inputs', function() {
30
var str = '';
31
for (var i = 0; i < 100000; i++) {
32
- str = str + 'This will be repeated to be very large indeed. ';
32
+ str += 'This will be repeated to be very large indeed. ';
33
}
34
expect(adler32(str)).toBe(692898118);
35
});
src/shared/utils/traverseAllChildren.js
+1
-1
@@ -184,7 +184,7 @@ function traverseAllChildrenImpl(
184
if (ReactCurrentOwner.current) {
185
var name = ReactCurrentOwner.current.getName();
186
if (name) {
187
- addendum = ' Check the render method of `' + name + '`.'
187
+ addendum = ' Check the render method of `' + name + '`.';
188
}
189
}
190
}