eslint-plugin-react-native
eslint-plugin-react-native copied to clipboard
Add fix suggestion for inline style (#1)
Fixes #254
This is an attempt to add a suggestion for the rule no-inline-styles
. there are two different ways that the suggestion would act.
- if there are no StyleSheet.create nodes are defined in the document creates one and puts the styles in.
from
<View style={{flex:1}} />
to
<View style={styles.viewStyle} />
const styles = Stylesheet.create({ viewStyle: { flex: 1 } });
second, if there is already a StyleSheet node defined:
from
<View style={{flex:1}} />
const styles = Stylesheet.create({ container: { flex: 1 } });
to
<View style={styles.viewStyle} />
const styles = Stylesheet.create({container: { flex: 1 }, viewStyle: { flex: 1 } });
@Intellicode any chance you could take a look at this?
It would be an incredible auto-fix for productivity.
@ahoseinian Thanks for your PR! @andreialecu I will have to check it, I personally have not worked on react native for a long time, so judging this will take a bit longer, sorry!