Skip to content

Suggestion: Flag unused imports after inlining platform checks #2602

Open
@tido64

Description

@tido64
import { DateTimePickerAndroid } from "@react-native-community/datetimepicker";
import { Platform } from "react-native";

export default () => {
  if (Platform.OS === "android") {
    return DateTimePickerAndroid.open(datePickerOptions);
  } else if (Platform.OS === "ios") {
    // return something iOS specific
  } else {
    // return something else
  }
};

Metro can inline platform checks with a plugin. In the above example, targeting ios will make DateTimePickerAndroid unused. However, the import statement will remain and we will still import @react-native-community/datetimepicker on iOS. There should be a way to flag this as unused on certain platforms.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions