mirror of
https://github.com/jlengrand/detekt.git
synced 2026-03-10 08:11:23 +00:00
Add two new config steps for Compose (#4322)
* Added two new configs for Compose * Added contributor entry to README * Clarify wording of FunctionNaming config
This commit is contained in:
@@ -236,6 +236,7 @@ If you contributed to detekt but your name is not in the list, please feel free
|
||||
- [Hans-Martin Schuller](https://github.com/hmSchuller) - Rule Improvement: ForbiddenComment
|
||||
- [Lukasz Osowicki](https://github.com/lukaszosowicki) - New rule: OutdatedDocumentation
|
||||
- [Luan Nico](https://github.com/luanpotter) - Bug fix for the UselessCallOnNotNull rule
|
||||
- [Tasha Ramesh](https://github.com/drinkthestars) - Docs around configuring for Compose
|
||||
|
||||
### Mentions
|
||||
|
||||
|
||||
@@ -11,6 +11,23 @@ Relevant rule sets and their configuration options for Compose styles & usage. T
|
||||
- [Compose API Guidelines](https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-api-guidelines.md)
|
||||
- [Compose source](https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:compose)
|
||||
|
||||
### FunctionNaming
|
||||
|
||||
See [FunctionNaming](https://detekt.github.io/detekt/naming.html#functionnaming).
|
||||
|
||||
``@Composable`` functions that return ``Unit`` are named using ``PascalCase``. Detekt may see this as a violation:
|
||||
|
||||
``` kotlin
|
||||
@Composable
|
||||
fun FooButton(text: String, onClick: () -> Unit) { // Violation for FooButton()
|
||||
```
|
||||
|
||||
#### Configurations:
|
||||
Choose _either_ of the following options:
|
||||
|
||||
* Augment default ``functionPattern`` to ``'([A-Za-z][a-zA-Z0-9]*)|(`.*`)'`` (default: ``'([a-z][a-zA-Z0-9]*)|(`.*`)'``)
|
||||
* Set ``ignoreAnnotated`` to ``['Composable']``
|
||||
|
||||
### TopLevelPropertyNaming
|
||||
|
||||
See [TopLevelPropertyNaming](https://detekt.github.io/detekt/naming.html#toplevelpropertynaming).
|
||||
@@ -65,4 +82,22 @@ class Foo {
|
||||
|
||||
#### Configurations:
|
||||
|
||||
* Set ``ignorePropertyDeclaration = true``, ``ignoreCompanionObjectPropertyDeclaration = true`` (default)
|
||||
* Set ``ignorePropertyDeclaration = true``, ``ignoreCompanionObjectPropertyDeclaration = true`` (default)
|
||||
|
||||
### UnusedPrivateMember
|
||||
|
||||
See [UnusedPrivateMember](https://detekt.github.io/detekt/style.html#unusedprivatemember).
|
||||
|
||||
Detekt may see composable preview functions, i.e. those marked with ``@Preview``, as unused.
|
||||
|
||||
``` kotlin
|
||||
@Preview
|
||||
@Composable
|
||||
private fun FooLazyColumnPreview() { // Violation for FooLazyColumnPreview()
|
||||
FooLazyColumn()
|
||||
}
|
||||
```
|
||||
|
||||
#### Configurations:
|
||||
|
||||
* Set ``ignoreAnnotated`` to ``['Preview']``
|
||||
|
||||
Reference in New Issue
Block a user