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

Add an option to configure ComposePreviewPublic to flag all previews #102

Merged
merged 1 commit into from
Oct 11, 2022

Conversation

mrmans0n
Copy link
Contributor

By default, ComposePreviewPublic will only flag public previews if they use a @PreviewParameter, because we know for sure that they are only going to be used for previews. This will continue to be the default behavior, but if people want to flag ALL public previews, they can use previewPublicOnlyIfParams to do that now.

Closes #95.

By default, `ComposePreviewPublic` will only flag public previews if they use a `@PreviewParameter`, because we know for sure that they are only going to be used for previews. This will continue to be the default behavior, but if people want to flag ALL public previews, they can use `previewPublicOnlyIfParams` to do that now.

Closes #95.
visitClass(klass, autoCorrect, emitter)
}

override fun visitKtElement(element: KtElement) {
super.visitKtElement(element)
element.attach(config)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found an issue in which visitKtElement was being called while visitFile wasn't 🤷 so I am attaching the config in all entrypoints, and made attach to be fine with that.

@@ -37,7 +37,7 @@ internal class KtlintComposeKtConfig(
getValueAsOrPut(key) { getList(key, default.toList()).toSet() } ?: default

override fun getBoolean(key: String, default: Boolean): Boolean =
getValueAsOrPut(key) { properties[ktlintKey(key)]?.getValueAs<String>()?.toBooleanStrictOrNull() } ?: default
getValueAsOrPut(key) { properties[ktlintKey(key)]?.getValueAs<Boolean>() } ?: default
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This stores a boolean for realsies now

@@ -83,4 +86,15 @@ class KtlintComposeKtConfigTest {

private val String.prop: Property
get() = Property.builder().value(this).build()

private val Boolean.prop: Property
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

massive yuck but works

@mrmans0n mrmans0n merged commit b66bf1c into main Oct 11, 2022
@mrmans0n mrmans0n deleted the nacho/preview-configurable branch October 11, 2022 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow reporting PreviewPublic for @Preview Composables without any param
2 participants