Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Improve support of default editorconfig properties #1580

Merged

Conversation

paul-dingemans
Copy link
Collaborator

@paul-dingemans paul-dingemans commented Aug 13, 2022

Description

Deprecate ExperimentalParams.editorConfigPath in favor of new parameter ExperimentalParams.editorConfigDefaults. When used in the old implementation this resulted in ignoring all ".editorconfig" files on the path to the file. The new implementation uses properties from the "editorConfigDefaults" parameter only when no ".editorconfig" files on the path to the file supplies this property for the filepath.
Closes #1551

API consumers can easily create the EditConfigDefaults by calling "EditConfigDefaults.load(path)" or creating it programmatically.

The CLI still supports the "--editorconfig=" option but has improved support. The path given can be either be a path to file or directory. In case of a directory path, it is expected that the directory does contain a file with name ".editorconfig". In of a file path, any valid file name is accepted. The path can be relative or absolute. Depending on the OS, the "~" at the start of the path is accepted as well.

BaseCLITest no longer always waits 3 seconds for completion of the asynchronous process. Once the process is started, it checks every 100 ms whether the process is still alive (e.g. is running) and stops polling otherwise resulting in better performance (most notable on local machine). The maximum duration of the CLI test has been increased to 10 seconds.

Checklist

  • PR description added
  • tests are added
  • KtLint has been applied on source code itself and violations are fixed
  • documentation is updated
  • CHANGELOG.md is updated

In case of adding a new rule:

Deprecate ExperimentalParams.editorConfigDefaults in favor of new parameter
ExperimentalParams.editorConfigDefaults. When used in the old implementation
this resulted in ignoring all ".editorconfig" files on the path to the file.
The new implementation uses properties from the "editorConfigDefaults"
parameter only when no ".editorconfig" files on the path to the file supplies
this property for the filepath.
Closes pinterest#1551

API consumers can easily create the EditConfigDefaults by calling
 "EditConfigDefaults.load(path)" or creating it programmatically.

The CLI still supports the "--editorconfig=" option but has improved support.
The path given can be either be a path to file or directory. In case of a
directory path, it is expected that the directory does contain a file with
name ".editorconfig". In of a file path, any valid file name is accepted. The
path can be relative or absolute. Depending on the OS, the "~" at the start of
the path is accepted as well.

BaseCLITest no longer always waits 3 seconds for completion of the asynchronous
process. Once the process is started, it checks every 100 ms whether the process
is still alive (e.g. is running) and stops polling otherwise resulting in better
performance (most notable on local machine). The maximum duration of the CLI
test has been increased to 10 seconds.
CHANGELOG.md Outdated Show resolved Hide resolved
@paul-dingemans paul-dingemans added this to the 0.47.0 milestone Aug 16, 2022
# Conflicts:
#	CHANGELOG.md
#	ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/internal/EditorConfigLoader.kt
#	ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/internal/PreparedCode.kt
#	ktlint-core/src/main/kotlin/com/pinterest/ktlint/core/internal/ThreadSafeEditorConfigCache.kt
#	ktlint-core/src/test/kotlin/com/pinterest/ktlint/core/internal/EditorConfigLoaderTest.kt
#	ktlint/src/main/kotlin/com/pinterest/ktlint/internal/KtlintCommandLine.kt
@paul-dingemans paul-dingemans merged commit 3c6eaca into pinterest:master Aug 18, 2022
@paul-dingemans paul-dingemans deleted the 1551-editorconfig-path-cli branch August 18, 2022 15:29
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong file path resolved when using --editorconfig
2 participants