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
Initial implementation of IDE integration via editorconfig #874
Initial implementation of IDE integration via editorconfig #874
Conversation
ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/internal/EditorConfigGenerator.kt
Outdated
Show resolved
Hide resolved
ktlint-core/src/test/kotlin/com/pinterest/ktlint/core/internal/EditorConfigGeneratorTest.kt
Show resolved
Hide resolved
ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/api/UsesEditorConfigProperties.kt
Outdated
Show resolved
Hide resolved
LGTM 👍 looks way cleaner now (esp. on a calling side). What if we have a custom EC property (like ij_kotlin_something) - we'd need to create our own PropertyType, right? |
Yes, for that custom |
Two annotations: - feature in alpha state - this is highly experimental feature that will change in the future. - feature in beta state - experimental feature that may have some bugs. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
a3fbfe4
to
aa8f239
Compare
This interface should be used by rules to provide default editorconfig properties. This is used to generate missing properties for .editorconfig and enable better integration with IDE. Feature is set to be in alpha state. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Should simplify writing tests for rules implementing UsesEditorConfigProperty interface. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This will allow to load written by test case `.editorconfig` file. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Split into smaller test-cases, use EditorConfigTestRule. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
79c4bcb
to
13b9870
Compare
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
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.
Sorry I was reading the code and couldn't help but notice these. I mean we're using this awesome lib because we're all pedantic… right?
ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/api/UsesEditorConfigProperties.kt
Outdated
Show resolved
Hide resolved
ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt
Outdated
Show resolved
Hide resolved
ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/KtLint.kt
Outdated
Show resolved
Hide resolved
ktlint-core/src/test/kotlin/com/pinterest/ktlint/core/internal/EditorConfigGeneratorTest.kt
Outdated
Show resolved
Hide resolved
ktlint-core/src/test/kotlin/com/pinterest/ktlint/core/internal/EditorConfigGeneratorTest.kt
Outdated
Show resolved
Hide resolved
@gnawf thank you for noticing it, will fix nits 👍 |
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Make it follow common pattern '*EditorConfig*'. Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
This PR brings base implementation of IDE integration via
.editorconfig
file:UsesEditorConfigProperties
that rule should implement to provide default values to generated.editorconfig
file. Just as an example on how it will be - 'final-newline' rule was updated to support it. In followup PR all standard rules should be updated to support it.KtLint
object -generateKotlinEditorconfigSection(params)
that generates.editorconfig
Kotlin section based on existing.editorconfig
and default rules values. CLI support will be added in followup PR.Additionally I've introduced two annotations -
FeatureInAlphaState
andFeatureInBetaState
to indicate that this feature is experimental and api may change.Update:
EditorConfigTestRule
to simplify writing.editorconfig
file content for testsRule
extension methods for tests that additionally accepts linted file path, so KtLint will load located in the same folder.editorconfig
file.Part of #701 issue