eslint-plugin-react-native icon indicating copy to clipboard operation
eslint-plugin-react-native copied to clipboard

Add fix suggestion for inline style (#1)

Open ahoseinian opened this issue 4 years ago • 3 comments

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 } });

ahoseinian avatar Mar 14 '20 21:03 ahoseinian

@Intellicode any chance you could take a look at this?

It would be an incredible auto-fix for productivity.

andreialecu avatar Mar 15 '21 14:03 andreialecu

@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!

Intellicode avatar Mar 23 '21 19:03 Intellicode

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Apr 02 '21 18:04 sonarqubecloud[bot]