-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. This stores a boolean for realsies now |
||
|
||
private fun ktlintKey(key: String): String = "twitter_compose_${key.toSnakeCase()}" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ package com.twitter.rules.core.ktlint | |
import com.pinterest.ktlint.core.api.EditorConfigProperties | ||
import org.assertj.core.api.AssertionsForInterfaceTypes.assertThat | ||
import org.ec4j.core.model.Property | ||
import org.ec4j.core.model.PropertyType | ||
import org.ec4j.core.model.PropertyType.LowerCasingPropertyType | ||
import org.ec4j.core.model.PropertyType.PropertyValueParser.BOOLEAN_VALUE_PARSER | ||
import org.junit.jupiter.api.Test | ||
|
||
class KtlintComposeKtConfigTest { | ||
|
@@ -15,7 +18,7 @@ class KtlintComposeKtConfigTest { | |
put("twitter_compose_my_list2", "a , b , c,a".prop) | ||
put("twitter_compose_my_set", "a,b,c,a,b,c".prop) | ||
put("twitter_compose_my_set2", " a, b,c ,a , b , c ".prop) | ||
put("twitter_compose_my_bool", "true".prop) | ||
put("twitter_compose_my_bool", true.prop) | ||
} | ||
|
||
private val properties: EditorConfigProperties = mapping | ||
|
@@ -70,7 +73,7 @@ class KtlintComposeKtConfigTest { | |
mapping["my_list2"] = "z,y".prop | ||
mapping["my_set"] = "a".prop | ||
mapping["my_set2"] = "a, b".prop | ||
mapping["my_bool"] = "false".prop | ||
mapping["my_bool"] = false.prop | ||
|
||
assertThat(config.getInt("myInt", 0)).isEqualTo(10) | ||
assertThat(config.getString("myString", null)).isEqualTo("abcd") | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. massive yuck but works |
||
get() = Property.builder() | ||
.type(LowerCasingPropertyType("", "", BOOLEAN_VALUE_PARSER, "true", "false")) | ||
.value( | ||
when (this) { | ||
true -> PropertyType.PropertyValue.valid("true", true) | ||
false -> PropertyType.PropertyValue.valid("false", false) | ||
} | ||
) | ||
.build() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.