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

no-unused-styles does not work when React Native imported as whole module #227

Open
aeirola opened this issue Apr 23, 2019 · 1 comment · May be fixed by #228
Open

no-unused-styles does not work when React Native imported as whole module #227

aeirola opened this issue Apr 23, 2019 · 1 comment · May be fixed by #228

Comments

@aeirola
Copy link

aeirola commented Apr 23, 2019

Our project conventions prefer namespaced imports of libraries, meaning that we import React Native with import RN from 'react-native'; instead of import {Long, List, Of, Things} from 'react-native';. Unfortunately for us, it seems as if the no-unused-styles rule is not compatible with this type of import usage.

For example, the following code

import RN from 'react-native';

const styles = RN.StyleSheet.create({
 unusedStyle: {},
});

does not trigger the rule.

I tried configuring the react-native/style-sheet-object-names setting to ["RN.StyleSheet"], but this didn't seem to help the situation.

I wonder if it would be possible to improve the rule so that it is able to identify the cases where the StyleSheet isn't imported individually.

@aeirola aeirola linked a pull request May 2, 2019 that will close this issue
@aeirola
Copy link
Author

aeirola commented May 3, 2019

I made a PR to fix this at #228

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 a pull request may close this issue.

1 participant