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

Initial implementation of IDE integration via editorconfig #874

Merged

Conversation

Tapchicoma
Copy link
Collaborator

@Tapchicoma Tapchicoma commented Aug 29, 2020

This PR brings base implementation of IDE integration via .editorconfig file:

  • adds new interface 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.
  • Adds new method in 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 and FeatureInBetaState to indicate that this feature is experimental and api may change.

Update:

  • Added EditorConfigTestRule to simplify writing .editorconfig file content for tests
  • Two new Rule 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

@romtsn
Copy link
Collaborator

romtsn commented Sep 8, 2020

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?

@Tapchicoma
Copy link
Collaborator Author

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 PropertyType needs to be created.

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>
@Tapchicoma Tapchicoma force-pushed the 701/initial-editorconfig-integration branch from a3fbfe4 to aa8f239 Compare September 8, 2020 19:59
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>
@Tapchicoma Tapchicoma force-pushed the 701/initial-editorconfig-integration branch 2 times, most recently from 79c4bcb to 13b9870 Compare September 17, 2020 13:18
Signed-off-by: Yahor Berdnikau <egorr.berd@gmail.com>
Copy link

@gnawf gnawf left a 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?

@Tapchicoma
Copy link
Collaborator Author

@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>
@Tapchicoma
Copy link
Collaborator Author

@gnawf should be fixed via 30cfe18

@Tapchicoma Tapchicoma merged commit f305e2e into pinterest:master Sep 18, 2020
@Tapchicoma Tapchicoma deleted the 701/initial-editorconfig-integration branch September 18, 2020 19:35
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.

None yet

4 participants