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

Suggestion: Flag unused imports after inlining platform checks #2602

Open
tido64 opened this issue Aug 14, 2023 · 0 comments
Open

Suggestion: Flag unused imports after inlining platform checks #2602

tido64 opened this issue Aug 14, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@tido64
Copy link
Member

tido64 commented Aug 14, 2023

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.

@tido64 tido64 added the enhancement New feature or request label Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant