diff --git a/ktlint-rule-engine/src/main/kotlin/com/pinterest/ktlint/rule/engine/internal/SuppressionLocator.kt b/ktlint-rule-engine/src/main/kotlin/com/pinterest/ktlint/rule/engine/internal/SuppressionLocator.kt index 85c5e66231..06be443451 100644 --- a/ktlint-rule-engine/src/main/kotlin/com/pinterest/ktlint/rule/engine/internal/SuppressionLocator.kt +++ b/ktlint-rule-engine/src/main/kotlin/com/pinterest/ktlint/rule/engine/internal/SuppressionLocator.kt @@ -261,6 +261,7 @@ internal class SuppressionLocator( "RemoveCurlyBracesFromTemplate" to listOf("standard:string-template"), "ClassName" to listOf("standard:class-naming"), "FunctionName" to listOf("standard:function-naming"), + "LocalVariableName" to listOf("standard:backing-property-naming"), "PackageName" to listOf("standard:package-name"), "PropertyName" to listOf("standard:property-naming", "standard:backing-property-naming"), "ConstPropertyName" to listOf("standard:property-naming"), diff --git a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt index 6d33a7cdcf..ce3d3a1ebf 100644 --- a/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt +++ b/ktlint-ruleset-standard/src/test/kotlin/com/pinterest/ktlint/ruleset/standard/rules/BackingPropertyNamingRuleTest.kt @@ -359,4 +359,17 @@ class BackingPropertyNamingRuleTest { """.trimIndent() backingPropertyNamingRuleAssertThat(code).hasNoLintViolations() } + + @Test + fun `Issue 2779 - Given a property name suppressed via 'LocalVariableName' then also suppress the ktlint violation`() { + val code = + """ + @Suppress("LocalVariableName") + fun test() { + val _test = "test" + println(_test) + } + """.trimIndent() + backingPropertyNamingRuleAssertThat(code).hasNoLintViolations() + } }