Skip to content

Commit c3781a3

Browse files
authored
Merge pull request Intellicode#274 from keyoai/fix-unused-style-fragment-shorthand
Fix unused style fragment shorthand
2 parents e99936a + 5890f4e commit c3781a3

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

lib/util/Components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ function componentRule(rule, context) {
152152
}
153153

154154
const returnsJSX = node[property]
155-
&& node[property].type === 'JSXElement';
155+
&& (node[property].type === 'JSXElement' || node[property].type === 'JSXFragment');
156156
const returnsReactCreateElement = node[property]
157157
&& node[property].callee
158158
&& node[property].callee.property

tests/lib/rules/no-unused-styles.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,16 @@ const tests = {
276276
errors: [{
277277
message: 'Unused style detected: styles.bar',
278278
}],
279+
}, {
280+
code: `
281+
const styles = StyleSheet.create({
282+
text: {}
283+
})
284+
const Hello = () => (<><Text style={styles.b}>Hello</Text></>);
285+
`,
286+
errors: [{
287+
message: 'Unused style detected: styles.text',
288+
}],
279289
}],
280290
};
281291

0 commit comments

Comments
 (0)