Update eslint-related dependencies
- babel-eslint ^3.1.14 fixes babel/babel-eslint#120 - babel updated from ^5.3.3 to ^3.5.5, which changes stuff, I guess - eslint updated from ^0.21.2 to ^0.22.1, which makes `no-shadow` also check class declarations
Benjamin Woodruff committed
Jun 5, 2015 at 10:18 UTC
52eca1eb69b02735e24b1b437ea3b94c0603a199
3 files changed
+42
-66
package.json
+3
-3
@@ -29,8 +29,8 @@
29
"jstransform": "^11.0.0"
30
},
31
"devDependencies": {
32
- "babel": "^5.3.3",
33
- "babel-eslint": "3.1.9",
32
+ "babel": "^5.5.5",
33
+ "babel-eslint": "^3.1.14",
34
"benchmark": "~1.0.0",
35
"browserify": "^9.0.3",
36
"bundle-collapser": "^1.1.1",
@@ -39,7 +39,7 @@
39
"derequire": "^2.0.0",
40
"envify": "^3.0.0",
41
"es5-shim": "^4.0.0",
42
- "eslint": "^0.21.2",
42
+ "eslint": "^0.22.1",
43
"eslint-plugin-react": "^2.5.0",
44
"eslint-tester": "^0.7.0",
45
"grunt": "~0.4.2",
src/isomorphic/modern/element/__tests__/ReactJSXElement-test.js
+7
-17
@@ -116,7 +116,7 @@ describe('ReactJSXElement', function() {
116
it('allows static methods to be called using the type property', function() {
117
spyOn(console, 'error');
118
119
- class Component {
119
+ class StaticMethodComponent {
120
static someStaticMethod() {
121
return 'someReturnValue';
122
}
@@ -125,18 +125,12 @@ describe('ReactJSXElement', function() {
125
}
126
}
127
128
- var element = <Component />;
128
+ var element = <StaticMethodComponent />;
129
expect(element.type.someStaticMethod()).toBe('someReturnValue');
130
expect(console.error.argsForCall.length).toBe(0);
131
});
132
133
it('identifies valid elements', function() {
134
- class Component {
135
- render() {
136
- return <div />;
137
- }
138
- }
139
-
134
expect(React.isValidElement(<div />)).toEqual(true);
135
expect(React.isValidElement(<Component />)).toEqual(true);
136
@@ -154,11 +148,6 @@ describe('ReactJSXElement', function() {
148
});
149
150
it('should use default prop value when removing a prop', function() {
157
- class Component {
158
- render() {
159
- return <span />;
160
- }
161
- }
151
Component.defaultProps = {fruit: 'persimmon'};
152
153
var container = document.createElement('div');
@@ -173,17 +162,18 @@ describe('ReactJSXElement', function() {
162
});
163
164
it('should normalize props with default values', function() {
176
- class Component {
165
+ class NormalizingComponent {
166
render() {
167
return <span>{this.props.prop}</span>;
168
}
169
}
181
- Component.defaultProps = {prop: 'testKey'};
170
+ NormalizingComponent.defaultProps = {prop: 'testKey'};
171
183
- var instance = ReactTestUtils.renderIntoDocument(<Component />);
172
+ var instance = ReactTestUtils.renderIntoDocument(<NormalizingComponent />);
173
expect(instance.props.prop).toBe('testKey');
174
186
- var inst2 = ReactTestUtils.renderIntoDocument(<Component prop={null} />);
175
+ var inst2 =
176
+ ReactTestUtils.renderIntoDocument(<NormalizingComponent prop={null} />);
177
expect(inst2.props.prop).toBe(null);
178
});
179
src/isomorphic/modern/element/__tests__/ReactJSXElementValidator-test.js
+32
-46
@@ -20,6 +20,7 @@ var ReactTestUtils;
20
21
describe('ReactJSXElementValidator', function() {
22
var Component;
23
+ var RequiredPropComponent;
24
25
beforeEach(function() {
26
require('mock-modules').dumpCache();
@@ -33,6 +34,14 @@ describe('ReactJSXElementValidator', function() {
34
return <div />;
35
}
36
};
37
+
38
+ RequiredPropComponent = class {
39
+ render() {
40
+ return <span>{this.props.prop}</span>;
41
+ }
42
+ };
43
+ RequiredPropComponent.displayName = 'RequiredPropComponent';
44
+ RequiredPropComponent.propTypes = {prop: React.PropTypes.string.isRequired};
45
});
46
47
function frag(obj) {
@@ -245,71 +254,48 @@ describe('ReactJSXElementValidator', function() {
254
it('should check default prop values', function() {
255
spyOn(console, 'error');
256
248
- class Component {
249
- render() {
250
- return <span>{this.props.prop}</span>;
251
- }
252
- }
253
- Component.defaultProps = {prop: null};
254
- Component.propTypes = {prop: React.PropTypes.string.isRequired};
257
+ RequiredPropComponent.defaultProps = {prop: null};
258
256
- ReactTestUtils.renderIntoDocument(<Component />);
259
+ ReactTestUtils.renderIntoDocument(<RequiredPropComponent />);
260
261
expect(console.error.calls.length).toBe(1);
262
expect(console.error.calls[0].args[0]).toBe(
263
'Warning: Failed propType: ' +
261
- 'Required prop `prop` was not specified in `Component`.'
264
+ 'Required prop `prop` was not specified in `RequiredPropComponent`.'
265
);
266
});
267
268
it('should not check the default for explicit null', function() {
269
spyOn(console, 'error');
270
268
- class Component {
269
- render() {
270
- return <span>{this.props.prop}</span>;
271
- }
272
- }
273
- Component.defaultProps = {prop: 'text'};
274
- Component.propTypes = {prop: React.PropTypes.string.isRequired};
275
-
276
- ReactTestUtils.renderIntoDocument(<Component prop={null} />);
271
+ ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop={null} />);
272
273
expect(console.error.calls.length).toBe(1);
274
expect(console.error.calls[0].args[0]).toBe(
275
'Warning: Failed propType: ' +
281
- 'Required prop `prop` was not specified in `Component`.'
276
+ 'Required prop `prop` was not specified in `RequiredPropComponent`.'
277
);
278
});
279
280
it('should check declared prop types', function() {
281
spyOn(console, 'error');
282
288
- class Component {
289
- render() {
290
- return <span>{this.props.prop}</span>;
291
- }
292
- }
293
- Component.propTypes = {
294
- prop: React.PropTypes.string.isRequired,
295
- };
296
-
297
- ReactTestUtils.renderIntoDocument(<Component />);
298
- ReactTestUtils.renderIntoDocument(<Component prop={42} />);
283
+ ReactTestUtils.renderIntoDocument(<RequiredPropComponent />);
284
+ ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop={42} />);
285
286
expect(console.error.calls.length).toBe(2);
287
expect(console.error.calls[0].args[0]).toBe(
288
'Warning: Failed propType: ' +
303
- 'Required prop `prop` was not specified in `Component`.'
289
+ 'Required prop `prop` was not specified in `RequiredPropComponent`.'
290
);
291
292
expect(console.error.calls[1].args[0]).toBe(
293
'Warning: Failed propType: ' +
294
'Invalid prop `prop` of type `number` supplied to ' +
309
- '`Component`, expected `string`.'
295
+ '`RequiredPropComponent`, expected `string`.'
296
);
297
312
- ReactTestUtils.renderIntoDocument(<Component prop="string" />);
298
+ ReactTestUtils.renderIntoDocument(<RequiredPropComponent prop="string" />);
299
300
// Should not error for strings
301
expect(console.error.calls.length).toBe(2);
@@ -321,51 +307,51 @@ describe('ReactJSXElementValidator', function() {
307
// actually occurs. Since this step is skipped in production, we should just
308
// warn instead of throwing for this case.
309
spyOn(console, 'error');
324
- class Component {
310
+ class NullPropTypeComponent {
311
render() {
312
return <span>{this.props.prop}</span>;
313
}
314
}
329
- Component.propTypes = {
315
+ NullPropTypeComponent.propTypes = {
316
prop: null,
317
};
332
- ReactTestUtils.renderIntoDocument(<Component />);
318
+ ReactTestUtils.renderIntoDocument(<NullPropTypeComponent />);
319
expect(console.error.calls.length).toBe(1);
320
expect(console.error.calls[0].args[0]).toContain(
335
- 'Invariant Violation: Component: prop type `prop` is invalid; ' +
336
- 'it must be a function, usually from React.PropTypes.'
321
+ 'Invariant Violation: NullPropTypeComponent: prop type `prop` is ' +
322
+ 'invalid; it must be a function, usually from React.PropTypes.'
323
);
324
});
325
326
it('should warn on invalid context types', function() {
327
spyOn(console, 'error');
342
- class Component {
328
+ class NullContextTypeComponent {
329
render() {
330
return <span>{this.props.prop}</span>;
331
}
332
}
347
- Component.contextTypes = {
333
+ NullContextTypeComponent.contextTypes = {
334
prop: null,
335
};
350
- ReactTestUtils.renderIntoDocument(<Component />);
336
+ ReactTestUtils.renderIntoDocument(<NullContextTypeComponent />);
337
expect(console.error.calls.length).toBe(1);
338
expect(console.error.calls[0].args[0]).toContain(
353
- 'Invariant Violation: Component: context type `prop` is invalid; ' +
354
- 'it must be a function, usually from React.PropTypes.'
339
+ 'Invariant Violation: NullContextTypeComponent: context type `prop` is ' +
340
+ 'invalid; it must be a function, usually from React.PropTypes.'
341
);
342
});
343
344
it('should warn if getDefaultProps is specificed on the class', function() {
345
spyOn(console, 'error');
360
- class Component {
346
+ class GetDefaultPropsComponent {
347
render() {
348
return <span>{this.props.prop}</span>;
349
}
350
}
365
- Component.getDefaultProps = () => ({
351
+ GetDefaultPropsComponent.getDefaultProps = () => ({
352
prop: 'foo',
353
});
368
- ReactTestUtils.renderIntoDocument(<Component />);
354
+ ReactTestUtils.renderIntoDocument(<GetDefaultPropsComponent />);
355
expect(console.error.calls.length).toBe(1);
356
expect(console.error.calls[0].args[0]).toContain(
357
'getDefaultProps is only used on classic React.createClass definitions.' +