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

Feature Request: Allow specifying an optional pattern for ComposableNaming #104

Closed
ZacSweers opened this issue Oct 16, 2022 · 2 comments · Fixed by #105
Closed

Feature Request: Allow specifying an optional pattern for ComposableNaming #104

ZacSweers opened this issue Oct 16, 2022 · 2 comments · Fixed by #105
Labels
enhancement New feature or request

Comments

@ZacSweers
Copy link
Contributor

Is your feature request related to a problem? Please describe.
In our architecture we can define presenter functions that return State objects. These tend to be define similarly to how Molecule does it, where the function acts as business logic. This fails the naming check however.

@Composable
fun ProfilePresenter(
  userFlow: Flow<User>,
  balanceFlow: Flow<Long>,
): ProfileModel {
  val user by userFlow.collectAsState(null)
  val balance by balanceFlow.collectAsState(0L)

  return if (user == null) {
    Loading
  } else {
    Data(user.name, balance)
  }
}

Describe the solution you'd like
It would be convenient if we could have a matcher config to ignore these types.

TwitterCompose:
  ComposableNaming:
    active: false
    functionNameExcludes: ['**Presenter']

Describe alternatives you've considered
The only option right now is to suppress or disable the rule entirely.

Additional context
Happy to send a PR if you're open to it 👍

@mrmans0n mrmans0n added the enhancement New feature or request label Oct 16, 2022
@mrmans0n
Copy link
Contributor

Yup, sounds like a great idea 😄
You'll need to modify ComposableNaming.kt and make sure that detekt/ComposableNamingCheck.kt and ktlint/ComposableNamingCheck.kt support the change (via tests).

ZacSweers added a commit to ZacSweers/compose-rules that referenced this issue Oct 17, 2022
Wasn't sure what to call the editorconfig property, let me know!

Resolves twitter#104
mrmans0n pushed a commit that referenced this issue Oct 19, 2022
@ZacSweers
Copy link
Contributor Author

Hmm, I'm trying this now in the latest release but it doesn't appear to be working. Am I missing something about its configuration?

slackhq/circuit#225

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

Successfully merging a pull request may close this issue.

2 participants