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

Support --disabled_rules #267

Closed
dagguh opened this issue Aug 12, 2019 · 11 comments · Fixed by #280
Closed

Support --disabled_rules #267

dagguh opened this issue Aug 12, 2019 · 11 comments · Fixed by #280
Assignees

Comments

@dagguh
Copy link

dagguh commented Aug 12, 2019

Please support --disabled_rules.

I need it to disable no-wildcard-imports, because IntelliJ keeps adding in the dreaded java.util.* due to its misguided Packages to Use Import with '*' feature.

@Tapchicoma
Copy link
Collaborator

I suppose, using .editorconfig (even external to repo) is not an option for you?

@dagguh
Copy link
Author

dagguh commented Aug 12, 2019

.editorconfig is definitely an option, but I failed to find a working setting

@Tapchicoma
Copy link
Collaborator

If you put following .editorconfig file in your project root:

[*.{kt,kts}]
disabled_rules=no-wildcard-imports

then it should automatically picked up by ktlint. No additional configuration to ktlint-gradle plugin is required.

@dagguh
Copy link
Author

dagguh commented Aug 12, 2019

So disabled_rules=no-wildcard-imports works iff ktlint.enableExperimentalRules.set(true). Thanks for the pointer!
I believe this is functionally done, so I'll close it.

@dagguh dagguh closed this as completed Aug 12, 2019
@Tapchicoma
Copy link
Collaborator

Most probably in your previous attempts you've bumped into pinterest/ktlint#555

@dagguh
Copy link
Author

dagguh commented Aug 12, 2019

I didn't bump into that, but I simply didn't enable experimental features

@dagguh
Copy link
Author

dagguh commented Aug 13, 2019

Hah, I ran into pinterest/ktlint#555 right now 😆
And the ktlint.enableExperimentalRules.set(true) actually has no effect. I must have made a mistake yesterday.

@fpavageau
Copy link

As I have a Gradle plugin which configures ktlint-gradle (and some other plugins), I would definitely welcome the support of --disabled_rules to avoid repeating the same configuration via .editorconfig in each and every project (in my case, import-ordering).

@Tapchicoma
Copy link
Collaborator

@fpavageau this is valid reason to add such support for ktlint-gradle 👍

@Globegitter
Copy link

Very strange, I just switched to the latest version of the plugin and disabling "no-wildcard-import" does not work. I have the following config:

ktlint {
    enableExperimentalRules.set(true)
    disabledRules.set(setOf("experimental:package-name", "no-wildcard-import"))
}

It disables the package name rule just fine (I can see package name errors otherwise), but I am still seeing

> Task :app:ktlintMainSourceSetCheck FAILED
/.../app/src/main/kotlin/name/app/App.kt:29:1: Wildcard import (cannot be auto-corrected)

Putting disabled_rules = experimental:package-name,no-wildcard-imports into the .editorconfig file however is working just fine. It is working now, so ultimately it is fine but any idea what could be going on here?

@Tapchicoma
Copy link
Collaborator

@Globegitter you have a typo in rule id here:

    disabledRules.set(setOf("experimental:package-name", "no-wildcard-import"))

Correct id is "no-wildcard-imports".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants