Suggestion: Flag unused imports after inlining platform checks
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.7k
- Forks
- 119
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 52
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Metro inline platform-check plugin linked in the issue and inspect how platform-specific branches are transformed. Determine how unused imports should be detected after inlining, then verify that imports for excluded platforms are flagged or removed without affecting imports still used by the selected platform.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react-native
- Domain
- build-system, mobile, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100