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

test custom rule loading in ktlin 0.50.0 #699

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/kotlin-js/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.js.compiler=ir
1 change: 1 addition & 0 deletions samples/kotlin-mpp/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kotlin.js.compiler=ir
2 changes: 1 addition & 1 deletion samples/kotlin-rulesets-creating/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ plugins {
dependencies {
compileOnly(pluginLibs.kotlin.reflect)
compileOnly(pluginLibs.kotlin.script.runtime)
compileOnly(pluginLibs.ktlint.core)
compileOnly("com.pinterest.ktlint:ktlint-cli-ruleset-core:0.50.0")
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package org.jlleitschuh.gradle.ktlint.sample.kotlin

import com.pinterest.ktlint.core.RuleSet
import com.pinterest.ktlint.core.RuleSetProvider
import com.pinterest.ktlint.cli.ruleset.core.api.RuleSetProviderV3
import com.pinterest.ktlint.rule.engine.core.api.RuleProvider
import com.pinterest.ktlint.rule.engine.core.api.RuleSetId

class CustomRuleSetProvider : RuleSetProvider {
class CustomRuleSetProvider : RuleSetProviderV3(RuleSetId("custom")) {

override fun get(): RuleSet = RuleSet("custom", NoVarRule())
override fun getRuleProviders(): Set<RuleProvider> {
return setOf(RuleProvider { NoVarRule() })
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package org.jlleitschuh.gradle.ktlint.sample.kotlin

import com.pinterest.ktlint.core.Rule
import com.pinterest.ktlint.rule.engine.core.api.Rule
import com.pinterest.ktlint.rule.engine.core.api.RuleId
import org.jetbrains.kotlin.com.intellij.lang.ASTNode
import org.jetbrains.kotlin.com.intellij.psi.impl.source.tree.LeafPsiElement
import org.jetbrains.kotlin.com.intellij.psi.util.PsiTreeUtil.getNonStrictParentOfType
import org.jetbrains.kotlin.psi.KtStringTemplateEntry

class NoVarRule : Rule("no-var") {
override fun visit(
class NoVarRule : Rule(
RuleId("test:novar"),
About()
) {
override fun beforeVisitChildNodes(
node: ASTNode,
autoCorrect: Boolean,
emit: (offset: Int, errorMessage: String, canBeAutoCorrected: Boolean) -> Unit
Expand Down
1 change: 1 addition & 0 deletions samples/kotlin-rulesets-using/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ dependencies {
}

ktlint {
version.set("0.50.0")
verbose.set(true)
outputToConsole.set(true)
reporters {
Expand Down
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ pluginManagement {
includeBuild("./plugin")

plugins {
id("org.jetbrains.kotlin.jvm") version "1.5.31"
id("org.jetbrains.kotlin.js") version "1.5.31"
id("org.jetbrains.kotlin.jvm") version "1.8.22"
id("org.jetbrains.kotlin.js") version "1.8.22"
}

repositories {
Expand Down
Loading