Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no-unused-styles default import support #228

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

aeirola
Copy link

@aeirola aeirola commented May 2, 2019

This PR adds support for identifying unused styles when StyleSheet isn't imported separately, but instead used through the react-native default import, for example in

import RN from 'react-native';
const styles = RN.StyleSheet.create({});

Fixes #227
Replaces #218

) || (
node.callee.object.type === 'MemberExpression' &&
node.callee.object.object.type === 'Identifier' &&
astHelpers.getImportSource(node.callee.object.object) === 'react-native' &&
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can potentially be heavy operation. I wonder if it should be cached in some way. Also, maybe it should be moved as the last check?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did bump into some performance issues with unnecessary import checks. Decided to move it as the last check to improve performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no-unused-styles does not work when React Native imported as whole module
1 participant