Giter Site home page Giter Site logo

Comments (13)

AleksandrZhukov avatar AleksandrZhukov commented on May 18, 2024 2

Added this new rule #201

from eslint-plugin-react-native.

pagkt2 avatar pagkt2 commented on May 18, 2024 2

Awesome! I was just searching for a rule like that. One question: Will this also prevent the following example:

const foo = ''
...
foo && <Component />

React Native does not evaluate foo as falsy but tries to render an empty string here.

I am using eslint-plugin-jsx-expressions to manage this issue. Cf. jsx-eslint/eslint-plugin-react#2073 (comment)

from eslint-plugin-react-native.

lefloh avatar lefloh commented on May 18, 2024 1

Awesome! I was just searching for a rule like that.
One question: Will this also prevent the following example:

const foo = ''
...
foo && <Component />

React Native does not evaluate foo as falsy but tries to render an empty string here.

from eslint-plugin-react-native.

asmeikal avatar asmeikal commented on May 18, 2024 1

#205 only works with styled components if the styled Text component is called StyledText, does not work if several StyledText are defined, unless each of them is skipped...

from eslint-plugin-react-native.

Intellicode avatar Intellicode commented on May 18, 2024

Excellent idea! I'll see if I can have a go at it

from eslint-plugin-react-native.

AleksandrZhukov avatar AleksandrZhukov commented on May 18, 2024

no, this one is the only case that can't be handled or I didn't understand how 😄
just use !!foo or foo.lenght > 0 for your case

from eslint-plugin-react-native.

lefloh avatar lefloh commented on May 18, 2024

Yes, I know. Problem is to not forget about that while writing code...
Would be great if eslint could remind you ;)
Thanks anyways!

from eslint-plugin-react-native.

dantman avatar dantman commented on May 18, 2024

Needs the ability to configure it. i.e. So you can add 'CustomStyledText' to valid text nodes if you use a Text wrapper to provide standardized text styles through your app.

Sadly even with that this quickly falls apart for me because I use styled.Text a lot to provide locally styled Text components. And there are a few outliers like react-native-paper providing a <Button> that accepts text.

from eslint-plugin-react-native.

AleksandrZhukov avatar AleksandrZhukov commented on May 18, 2024

can you provide a code example?

yeah, seems this rule doesn't support styled components, but need to investigate

from eslint-plugin-react-native.

dantman avatar dantman commented on May 18, 2024

Styled example:

const ContentText = styled.Text`
	${material.body1Object}
	color: ${colors.primaryText};
`;

Example of a "standard" wrapper:
https://github.com/material-native/material-native/blob/master/src/MaterialText.js

<MaterialText body1>Foo</MaterialText>

Or a port of MUI's Typography: https://material-ui.com/style/typography/

from eslint-plugin-react-native.

AleksandrZhukov avatar AleksandrZhukov commented on May 18, 2024

@dantman Fixed here #205

PS. Quite funny that you call your library as standard 😄

from eslint-plugin-react-native.

dantman avatar dantman commented on May 18, 2024

Standardized within an app, anyone can make their own with the typography rules for their app. That's just an example of an old one I made to wrap Text with Material Design typography classes.

from eslint-plugin-react-native.

the0ffh avatar the0ffh commented on May 18, 2024

@dantman Fixed here #205

PS. Quite funny that you call your library as standard 😄

Quite funny that you call it a fix 😄

from eslint-plugin-react-native.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.