Skip to content

Commit

Permalink
Merge pull request #361 from kiwicom/lint-checks
Browse files Browse the repository at this point in the history
Add Slack's compose lint rules
  • Loading branch information
hrach authored Mar 2, 2023
2 parents c51dece + 64b261a commit 6f442f4
Show file tree
Hide file tree
Showing 25 changed files with 105 additions and 94 deletions.
1 change: 1 addition & 0 deletions catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -159,5 +159,6 @@ dependencies {
debugImplementation(libs.androidx.customView)
debugImplementation(libs.androidx.customViewPoolingContainer)

lintChecks(libs.slack.composeLintChecks)
lintChecks(project(":lint"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ internal fun DialogMaterialTimePicker(navController: NavController) {
val state = rememberTimePickerState()

TimePickerDialog(
title = "Select Time",
onCancel = { navController.popBackStack() },
onConfirm = {
navController.setResult(
Expand All @@ -59,7 +58,6 @@ internal fun DialogMaterialTimePicker(navController: NavController) {
@Suppress("Dependency")
@Composable
private fun TimePickerDialog(
title: String = "Select Time",
onCancel: () -> Unit,
onConfirm: () -> Unit,
toggle: @Composable RowScope.() -> Unit = {},
Expand Down Expand Up @@ -87,7 +85,7 @@ private fun TimePickerDialog(
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 20.dp),
text = title,
text = "Select Time",
style = MaterialTheme.typography.labelMedium,
)
content()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal fun IconsScreen(onNavigateUp: () -> Unit) {
}

@Composable
fun IconsScreenInner(contentPadding: PaddingValues) {
private fun IconsScreenInner(contentPadding: PaddingValues) {
val icons: List<Pair<String, Painter>> = Icons::class.memberProperties.map {
it.name to (it.getter.call(Icons, currentComposer, 0) as Painter)
}
Expand Down
1 change: 1 addition & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ javaJq = { module = "net.thisptr:jackson-jq", version="1.0.0-preview.20220705" }
junit = { module = "junit:junit", version = "4.13.2" }
kiwi-navigationComposeTyped = { module = "com.kiwi.navigation-compose.typed:core", version = "0.6.1" }
robolectric = { module = "org.robolectric:robolectric", version = "4.9.2" }
slack-composeLintChecks = { module = "com.slack.lint.compose:compose-lint-checks", version = "1.0.1" }
square-kotlinPoet = { module = "com.squareup:kotlinpoet", version.ref = "square-kotlinPoet" }

[bundles]
Expand Down
4 changes: 4 additions & 0 deletions ui/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ android {

lint {
disable.add("ObsoleteLintCustomCheck")
disable.add("ComposeUnstableCollections") // not suitable requirement for library, for now
disable.add("ComposeCompositionLocalUsage") // theming uses this a lot
abortOnError = true
warningsAsErrors = true
}
Expand Down Expand Up @@ -93,5 +95,7 @@ dependencies {
testImplementation(libs.compose.uiTestManifest)
testImplementation(libs.hamcrest) // ui test fails if not added

lintChecks(libs.slack.composeLintChecks)

lintPublish(projects.lint)
}
12 changes: 6 additions & 6 deletions ui/src/main/java/kiwi/orbit/compose/ui/controls/Alert.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ public fun AlertInfo(
Alert(
icon = icon,
title = title,
modifier = modifier,
actions = actions,
content = content,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -74,10 +74,10 @@ public fun AlertSuccess(
Alert(
icon = icon,
title = title,
modifier = modifier,
actions = actions,
content = content,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -97,10 +97,10 @@ public fun AlertWarning(
Alert(
icon = icon,
title = title,
modifier = modifier,
actions = actions,
content = content,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -120,10 +120,10 @@ public fun AlertCritical(
Alert(
icon = icon,
title = title,
modifier = modifier,
actions = actions,
content = content,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -132,10 +132,10 @@ public fun AlertCritical(
private fun Alert(
icon: Painter?,
title: @Composable ColumnScope.() -> Unit,
modifier: Modifier = Modifier,
actions: @Composable () -> Unit = {},
actions: @Composable () -> Unit,
content: @Composable ColumnScope.() -> Unit,
suppressed: Boolean,
modifier: Modifier = Modifier,
) {
val bgColor = when (suppressed) {
true -> OrbitTheme.colors.surface.subtle
Expand Down
10 changes: 5 additions & 5 deletions ui/src/main/java/kiwi/orbit/compose/ui/controls/AlertInline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public fun AlertInlineInfo(
title = title,
action = action,
onActionClick = onActionClick,
modifier = modifier,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -69,8 +69,8 @@ public fun AlertInlineSuccess(
title = title,
action = action,
onActionClick = onActionClick,
modifier = modifier,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -92,8 +92,8 @@ public fun AlertInlineWarning(
title = title,
action = action,
onActionClick = onActionClick,
modifier = modifier,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -115,8 +115,8 @@ public fun AlertInlineCritical(
title = title,
action = action,
onActionClick = onActionClick,
modifier = modifier,
suppressed = suppressed,
modifier = modifier,
)
}
}
Expand All @@ -127,8 +127,8 @@ private fun AlertInline(
title: @Composable () -> Unit,
action: @Composable RowScope.() -> Unit,
onActionClick: () -> Unit,
modifier: Modifier = Modifier,
suppressed: Boolean,
modifier: Modifier = Modifier,
) {
val bgColor = when (suppressed) {
true -> OrbitTheme.colors.surface.subtle
Expand Down
24 changes: 12 additions & 12 deletions ui/src/main/java/kiwi/orbit/compose/ui/controls/Badge.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public fun BadgeNeutral(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asNeutralTheme(), subtle = true, modifier, icon, content)
Badge(LocalColors.current.asNeutralTheme(), subtle = true, icon, content, modifier)
}

/**
Expand All @@ -42,7 +42,7 @@ public fun BadgeNeutralSubtle(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asNeutralSubtleStrongTheme(), subtle = true, modifier, icon, content)
Badge(LocalColors.current.asNeutralSubtleStrongTheme(), subtle = true, icon, content, modifier)
}

/**
Expand All @@ -54,7 +54,7 @@ public fun BadgeNeutralStrong(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asNeutralSubtleStrongTheme(), subtle = false, modifier, icon, content)
Badge(LocalColors.current.asNeutralSubtleStrongTheme(), subtle = false, icon, content, modifier)
}

/**
Expand All @@ -66,7 +66,7 @@ public fun BadgeInfo(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asInfoTheme(), subtle = false, modifier, icon, content)
Badge(LocalColors.current.asInfoTheme(), subtle = false, icon, content, modifier)
}

/**
Expand All @@ -78,7 +78,7 @@ public fun BadgeInfoSubtle(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asInfoTheme(), subtle = true, modifier, icon, content)
Badge(LocalColors.current.asInfoTheme(), subtle = true, icon, content, modifier)
}

/**
Expand All @@ -90,7 +90,7 @@ public fun BadgeSuccess(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asSuccessTheme(), subtle = false, modifier, icon, content)
Badge(LocalColors.current.asSuccessTheme(), subtle = false, icon, content, modifier)
}

/**
Expand All @@ -102,7 +102,7 @@ public fun BadgeSuccessSubtle(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asSuccessTheme(), subtle = true, modifier, icon, content)
Badge(LocalColors.current.asSuccessTheme(), subtle = true, icon, content, modifier)
}

/**
Expand All @@ -114,7 +114,7 @@ public fun BadgeWarning(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asWarningTheme(), subtle = false, modifier, icon, content)
Badge(LocalColors.current.asWarningTheme(), subtle = false, icon, content, modifier)
}

/**
Expand All @@ -126,7 +126,7 @@ public fun BadgeWarningSubtle(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asWarningTheme(), subtle = true, modifier, icon, content)
Badge(LocalColors.current.asWarningTheme(), subtle = true, icon, content, modifier)
}

/**
Expand All @@ -138,7 +138,7 @@ public fun BadgeCritical(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asCriticalTheme(), subtle = false, modifier, icon, content)
Badge(LocalColors.current.asCriticalTheme(), subtle = false, icon, content, modifier)
}

/**
Expand All @@ -150,7 +150,7 @@ public fun BadgeCriticalSubtle(
icon: @Composable RowScope.() -> Unit = {},
content: @Composable RowScope.() -> Unit,
) {
Badge(LocalColors.current.asCriticalTheme(), subtle = true, modifier, icon, content)
Badge(LocalColors.current.asCriticalTheme(), subtle = true, icon, content, modifier)
}

@Composable
Expand Down Expand Up @@ -205,9 +205,9 @@ public fun BadgeBundleTop(
private fun Badge(
colors: Colors,
subtle: Boolean,
modifier: Modifier,
icon: @Composable RowScope.() -> Unit,
content: @Composable RowScope.() -> Unit,
modifier: Modifier = Modifier,
) {
CompositionLocalProvider(LocalColors provides colors) {
ThemedSurface(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private fun BadgeCircle(
colors: Colors,
subtle: Boolean,
value: Int,
modifier: Modifier,
modifier: Modifier = Modifier,
) {
val height = with(LocalDensity.current) {
OrbitTheme.typography.bodySmallMedium.lineHeight.toDp() +
Expand Down
24 changes: 12 additions & 12 deletions ui/src/main/java/kiwi/orbit/compose/ui/controls/Button.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public fun ButtonPrimary(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = OrbitTheme.colors.primary.normal,
modifier = modifier,
interactionSource = interactionSource,
modifier = modifier,
content = content,
)
}
Expand All @@ -59,8 +59,8 @@ public fun ButtonPrimarySubtle(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = OrbitTheme.colors.primary.subtle,
modifier = modifier,
interactionSource = interactionSource,
modifier = modifier,
content = content,
)
}
Expand All @@ -84,8 +84,8 @@ public fun ButtonSecondary(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = OrbitTheme.colors.surface.normal,
modifier = modifier,
interactionSource = interactionSource,
modifier = modifier,
content = content,
)
}
Expand All @@ -109,8 +109,8 @@ public fun ButtonCritical(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = OrbitTheme.colors.critical.normal,
modifier = modifier,
interactionSource = interactionSource,
modifier = modifier,
content = content,
)
}
Expand All @@ -134,8 +134,8 @@ public fun ButtonCriticalSubtle(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = OrbitTheme.colors.critical.subtle,
modifier = modifier,
interactionSource = interactionSource,
modifier = modifier,
content = content,
)
}
Expand All @@ -159,10 +159,10 @@ public fun ButtonBundleBasic(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = Color.Unspecified,
interactionSource = interactionSource,
modifier = modifier,
backgroundBrush = OrbitTheme.colors.bundle.basicGradient,
contentColor = OrbitTheme.colors.bundle.onBasic,
modifier = modifier,
interactionSource = interactionSource,
content = content,
)
}
Expand All @@ -186,10 +186,10 @@ public fun ButtonBundleMedium(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = Color.Unspecified,
interactionSource = interactionSource,
modifier = modifier,
backgroundBrush = OrbitTheme.colors.bundle.mediumGradient,
contentColor = OrbitTheme.colors.bundle.onMedium,
modifier = modifier,
interactionSource = interactionSource,
content = content,
)
}
Expand All @@ -213,10 +213,10 @@ public fun ButtonBundleTop(
ButtonLargePrimitive(
onClick = onClick,
backgroundColor = Color.Unspecified,
interactionSource = interactionSource,
modifier = modifier,
backgroundBrush = OrbitTheme.colors.bundle.topGradient,
contentColor = OrbitTheme.colors.bundle.onTop,
modifier = modifier,
interactionSource = interactionSource,
content = content,
)
}
Expand All @@ -225,9 +225,9 @@ public fun ButtonBundleTop(
internal fun ButtonLargePrimitive(
onClick: () -> Unit,
backgroundColor: Color,
interactionSource: MutableInteractionSource,
modifier: Modifier = Modifier,
backgroundBrush: Brush? = null,
interactionSource: MutableInteractionSource,
contentColor: Color = contentColorFor(backgroundColor),
content: @Composable RowScope.() -> Unit,
) {
Expand Down
Loading

0 comments on commit 6f442f4

Please sign in to comment.