Skip to content

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

Description

@aeirola

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions