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

no-unused-styles doesn't work when imporing from file

Open gusgard opened this issue 6 years ago • 15 comments

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.

gusgard avatar Jul 11 '17 18:07 gusgard

Its only implemented for the same file at the moment

Intellicode avatar Jul 19 '17 20:07 Intellicode

I´m also interested on this feature. Do you have it on your roadmap?

oximer avatar Aug 22 '17 12:08 oximer

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 avatar Aug 24 '17 22:08 Intellicode

@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 avatar Jan 06 '18 11:01 skovhus

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

Intellicode avatar Jan 07 '18 12:01 Intellicode

Are there any updates on this?

KrisLau avatar Jun 15 '21 15:06 KrisLau

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

maestrolsj avatar Dec 01 '21 12:12 maestrolsj

I never got this wrapped up unfortunately. And I’m not working with React Native currently. :)

skovhus avatar Dec 01 '21 13:12 skovhus

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

retyui avatar Dec 05 '21 14:12 retyui

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.

maestrolsj avatar Dec 05 '21 19:12 maestrolsj

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

matart15 avatar Apr 13 '22 01:04 matart15

This is a super helpful feature, it would be great if we could make a release. @Intellicode

QSuraj avatar Apr 28 '22 12:04 QSuraj

+1

Can we get a release @Intellicode?

yonureker avatar Jul 11 '22 13:07 yonureker

I guess its about time for that, sorry for the inactivity

Intellicode avatar Jul 18 '22 19:07 Intellicode

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.

Intellicode avatar Jul 18 '22 20:07 Intellicode