File tree Expand file tree Collapse file tree 4 files changed +40
-4
lines changed
fixtures/export-default-hoc-block-arrow Expand file tree Collapse file tree 4 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -88,14 +88,19 @@ export default ({ types: t }: { types: BabelTypes }): Visitor => ({
88
88
return
89
89
}
90
90
91
- // Ignore the `if` since I can't come up with a test case to satisfy it.
92
- /* istanbul ignore if */
93
- if ( ! variable ) {
91
+ const name = ( ( ) => {
92
+ try {
93
+ return variable . get ( 'id.name' ) . node
94
+ } catch ( errr ) {
95
+ return undefined
96
+ }
97
+ } ) ( )
98
+
99
+ if ( name == null ) {
94
100
return
95
101
}
96
102
97
103
const statement = variable . getStatementParent ( )
98
- const { node : name } = variable . get ( 'id.name' )
99
104
100
105
// check to make sure we don't set displayName when already set
101
106
if ( isDisplayNameSet ( statement , name ) ) {
Original file line number Diff line number Diff line change @@ -25,6 +25,26 @@ App.displayName = \'App\';
25
25
exports.default = App;"
26
26
` ;
27
27
28
+ exports [` does not crash on block-arrow components with hoc wrapper 1` ] = `
29
+ "\' use strict\' ;
30
+
31
+ Object.defineProperty(exports, \" __esModule\" , {
32
+ value : true
33
+ } );
34
+
35
+ var _react = require(\' react\' );
36
+
37
+ var _react2 = _interopRequireDefault(_react);
38
+
39
+ function _interopRequireDefault(obj) { return obj && obj .__esModule ? obj : { default: obj }; }
40
+
41
+ exports.default = function () {
42
+ return fn (function (survey ) {
43
+ return _react2 .default .createElement (\' div\' , null);
44
+ });
45
+ };"
46
+ `;
47
+
28
48
exports [` ignores default function block when no return statement 1` ] = `
29
49
"\' use strict\' ;
30
50
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+
3
+ export default ( ) => fn ( survey => {
4
+ return < div /> ;
5
+ } ) ;
Original file line number Diff line number Diff line change @@ -162,3 +162,9 @@ test(
162
162
snapshotMacro ,
163
163
'ignore-jsx-expression-blocks' ,
164
164
)
165
+
166
+ test (
167
+ 'does not crash on block-arrow components with hoc wrapper' ,
168
+ snapshotMacro ,
169
+ 'export-default-hoc-block-arrow' ,
170
+ )
You can’t perform that action at this time.
0 commit comments