Skip to content
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

New rule to check if @Preview (Jetpack Compose) functions end with 'Preview' suffix and are also private #1322

Closed
WebTiger89 opened this issue May 27, 2022 · 3 comments · Fixed by #1728
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@WebTiger89
Copy link

WebTiger89 commented May 27, 2022

This is a common issue with Jetpack Compose and would be really convenient. Actually, this should be a resposnibility for android lint I guess but maybe you see potential here.

Description:
In Jetpack Compose it is common to give your @Preview functions a 'Preview' suffix for example

@Preview
@Composable
private fun BannerPreview() {}

It's not so common to make them private but it should be. I had a discussion on slack, check https://kotlinlang.slack.com/archives/CJLTWPH7S/p1652276247920509

Sooner or later this will be adopted by android. If you think this is a good idea for 2 new rules, I'm glad to see it in a future version :)

@WebTiger89 WebTiger89 added the bug Something isn't working label May 27, 2022
@orchestr7 orchestr7 added enhancement New feature or request and removed bug Something isn't working labels May 27, 2022
@orchestr7
Copy link
Member

Good rules for the future. Will be added after 1.2.0

@orchestr7 orchestr7 added help wanted Extra attention is needed good first issue Good for newcomers labels May 30, 2022
@orchestr7 orchestr7 modified the milestones: 1.2.0, 2.0.0 May 30, 2022
@0x6675636b796f75676974687562 0x6675636b796f75676974687562 changed the title New rule to check if @Preview (Jetpack Compose) functions end with 'Preview' suffix and are also private New rule to check if @Preview (Jetpack Compose) functions end with 'Preview' suffix and are also private Mar 14, 2023
@mbalajee
Copy link

mbalajee commented Aug 30, 2023

It will be really useful to have a rule to check if Preview functions are called in the non preview functions.

@orchestr7 orchestr7 assigned kgevorkyan and unassigned icemachined Aug 30, 2023
@orchestr7
Copy link
Member

#1725

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants