Skip to content

Using stylelint to lint known properties #75

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

Closed
kristerkari opened this issue Feb 10, 2018 · 15 comments
Closed

Using stylelint to lint known properties #75

kristerkari opened this issue Feb 10, 2018 · 15 comments

Comments

@kristerkari
Copy link
Contributor

I have been experimenting with the idea of using stylelint to verify that you can only use the CSS properties that css-to-react-native supports, like the standard stylelint rule https://github.com/stylelint/stylelint/tree/master/lib/rules/property-no-unknown.

I have though of creating a couple of tools to help with this.

First thing I was thinking of would be to create a new repo that would list all properties that css-to-react-native supports. The same idea as https://github.com/betit/known-css-properties, but with a simpler implementation. Those props could then be updated whenever there are new properties supported or old ones deprecated.

Next thing would be to create a stylelint plugin, e.g. react-native/no-unknown-css-properties. The rule would clearly state that it is meant to be used with tools that use this CSS parser.

There could also be a rule called react-native/no-unknown-style-properties, which would only allow properties that are supported by React Native by default.

What do you think @jacobp100 @mxstbr ?

@jacobp100
Copy link
Contributor

So a separate package that lints? I'd be down with that. If you manage to set up something, let me know and I can help out!

@kristerkari
Copy link
Contributor Author

I have the stylelint plugin almost ready. I'm mainly just wondering how to structure the project(s) and what kind of naming to use.

I'll let you know as soon as I have something out there.

@mxstbr
Copy link
Member

mxstbr commented Feb 10, 2018

@kristerkari
Copy link
Contributor Author

@mxstbr It's probably better to create a separate stylelint config for React Native, as the stylelint plugin that I'm creating only checks for React Native specific CSS properties.

@kristerkari
Copy link
Contributor Author

Here is the repo with known React Native styling properties, which I plan to use in the styling plugin:
https://github.com/kristerkari/react-native-known-styling-properties

@mxstbr
Copy link
Member

mxstbr commented Feb 10, 2018

@kristerkari hmm yeah, I guess that makes sense—so folks would extend from both stylelint-config-styled-components and stylelint-config-styled-components-native? I like that.

If you create that and it works well I'd love to make it official, move it to the s-c org and promote it! /cc @emilgoldsmith @ismay

@emilgoldsmith
Copy link
Member

Sounds cool :)

@ghost
Copy link

ghost commented Feb 10, 2018

Yeah sounds good 👌

@kristerkari
Copy link
Contributor Author

kristerkari commented Feb 10, 2018

Stylelint plugin (or plugin pack) is now out:
stylelint-react-native

This is the rule that is compatible with styled-components:
css-property-no-unknown

This is how it looks with regular (S)CSS in my React Native project:
screen shot 2018-02-10 at 23 28 42

@kristerkari
Copy link
Contributor Author

Here's a screenshot using styled-components:

screen shot 2018-02-11 at 0 42 34

@kristerkari
Copy link
Contributor Author

I had a small bug in my screenshots, display is actually supported by RN. :) But that's now fixed.

@jacobp100
Copy link
Contributor

What we could do as well is check units. For example, we allow percentages for border widths in case RN adds support for these, but they aren’t yet supported.

@kristerkari
Copy link
Contributor Author

@jacobp100 I was thinking that there could be a rule that checks for values, but I haven't had time to look at that yet. If you have ideas, you can open a new issue here: https://github.com/kristerkari/stylelint-react-native

@jacobp100
Copy link
Contributor

Is this issue resolved?

@kristerkari
Copy link
Contributor Author

Yes, it is :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants