-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rule idea: check for known values #2
Comments
Will this help? .stylelintrc.json |
@arvigeus There is already a rule that does that: https://github.com/kristerkari/stylelint-react-native/blob/master/src/rules/css-property-no-unknown/README.md#css-property-no-unknown This idea was for checking valid values for those properties. |
@kristerkari Hi! invalid for React Native: height: '30px', valid value for React Native: height: 30, I'm just looking for an easy solution to lint for both valid properties and values for React Native styles. Thanks! |
@jason1985 No worries. Honestly, I don't see much point to add linting for the example that you gave, since it can be easily avoided if you use Typescript and add typings to your styles. |
@kristerkari Thanks so much for your response! Works great however do you know of somewhere that has these types already or do I need to manually make them? I've found this https://github.com/vhpoet/react-native-styling-cheat-sheet which is getting the info from the docs https://reactnative.dev/docs/layout-props (the link you posted). I have something like this so far: type Style = {
alignSelf?: "auto" | "flex-start" | "flex-end" | "center" | "stretch" | "baseline"
backgroundColor?: string
borderColor?: string
borderRadius?: number
borderWidth?: number
color?: string
elevation?: number
flex?: number
flexDirection?: "row" | "row-reverse" | "column" | "column-reverse"
fontFamily?: string
fontSize?: number
fontWeight?: "normal" | "bold" | "100" | "200" | "300" | "400" | "500" | "600" | "700" | "800" | "900"
height?: number
// etc.
} Thank you! |
Just an update in the off chance someone else happens to read this and not know. import {TextStyle, StyleSheet} from 'react-native'
const exampleStyles: ViewStyle | TextStyle = {
// Intellisense works here
} file location: |
@jason1985 yes, that's good way to do it. Just assign the style object the |
There could a be a rule that checks for valid values for styling properties that are supported by React Native.
React Native documentation already list the valid values and those are also probably available in the repo:
https://facebook.github.io/react-native/docs/layout-props.html
The text was updated successfully, but these errors were encountered: