eslint-plugin-react-native
eslint-plugin-react-native copied to clipboard
no-unused-styles doesn't work when imporing from file
import styles from './styles';
Should work If I import the styles from a file instead of the same js file? Or is not implemented yet.
Its only implemented for the same file at the moment
I´m also interested on this feature. Do you have it on your roadmap?
At the moment, I do not have any roadmap and I'm also not actively developing new features. If you need it fast, you could help out by writing a PR :)
@Intellicode I would like to help out with this feature.
Could you give me some hints, as I haven't written any eslint plugins for a while and never something that accessed multiple files.
@skovhus Cool to hear you want to give it a shot!
I suppose you would need to start by analyzing the file which uses the styles to detect which variables are used in style
attributes. You need to follow them back to the imports, and then parse the imported files to match the imported variable against an exported variable. In this file you would also need to check which variables have a StyleSheet.create call assigned to them. Currently, I also don't have hands-on experience with parsing an imported file, but hope this is enough for you to get started!
Are there any updates on this?
@Intellicode I would like to help out with this feature.
Could you give me some hints, as I haven't written any eslint plugins for a while and never something that accessed multiple files.
is there any update for it ?
I never got this wrapped up unfortunately. And I’m not working with React Native currently. :)
I created a PR https://github.com/Intellicode/eslint-plugin-react-native/pull/303 to fix this issue:
Docs: https://github.com/retyui/eslint-plugin-react-native/blob/no-unused-styles-and-imports/docs/rules/no-unused-styles.md#options
If you want to test it you can install the version from Github:
yarn add -D retyui/eslint-plugin-react-native#no-unused-styles-and-imports
Thank you for your contribution. 👍👍
On Sun 5. Dec 2021 at 15:26, David NRB @.***> wrote:
I created a PR #303 https://github.com/Intellicode/eslint-plugin-react-native/pull/303 to fix this issue:
Docs: https://github.com/retyui/eslint-plugin-react-native/blob/no-unused-styles-and-imports/docs/rules/no-unused-styles.md#options
If you want to test it you can install the version from Github:
yarn add -D retyui/eslint-plugin-react-native#no-unused-styles-and-imports
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Intellicode/eslint-plugin-react-native/issues/165#issuecomment-986239729, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD5O6O3DBBQF4W3E3CCY6K3UPNZCBANCNFSM4DSSPLRQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
latest version release
v4.0.0 …
on Dec 12, 2021
PR merged
xenokratos merged commit 804e3e1 into master on Feb 16
Waiting to be released
This is a super helpful feature, it would be great if we could make a release. @Intellicode
+1
Can we get a release @Intellicode?
I guess its about time for that, sorry for the inactivity
Actually, it's not merged in the main branch of this repo yet, the PR is still pending further review, but my time is too limited to wrap that up at the moment.