bicep icon indicating copy to clipboard operation
bicep copied to clipboard

Add bicep linter rule to suggest use of empty() vs null or ''

Open marcosikkens opened this issue 5 months ago • 1 comments

Is your feature request related to a problem? Please describe. When writing bicep and having parameters with required and optional strings it would be nice for the linting to suggest the use of empty().

For example:

param a string = '' // or omit the default or pass null whatever


resource certificate 'Microsoft.ApiManagement/service/certificates@2024-05-01' existing = if ( a!= '') {
  parent: apim
  name: backendCertificateName
}

It would be nice if it gives a warning/error that the checks can be better done with empty() because it also fixed null or spaces in string compares. I could not find if this was possible in the documentation.

marcosikkens avatar Nov 20 '25 08:11 marcosikkens

Unfortunately, we don't like to give strong recommendations to users about coding styles. We're happy to take a contribution if this linter rule is off by default, but we have no plans to create this linter rule as on by default

stephaniezyen avatar Dec 03 '25 21:12 stephaniezyen