-
Notifications
You must be signed in to change notification settings - Fork 94
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
Conversation
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
massive yuck but works
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 usepreviewPublicOnlyIfParams
to do that now.Closes #95.