Skip to content

Support single-line objects/arrays #586

Closed
@alex-frankel

Description

@alex-frankel

This could be implemented by #498, but the other option is to somehow do this without ,

Activity

added this to the v0.3 milestone on Oct 1, 2020
benc-uk

benc-uk commented on Nov 5, 2020

@benc-uk

Please... especially when LoC and verbosity are some of the advantages of Bicep

By single line assume we mean allowing something like

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16' ]
    }
self-assigned this
on Dec 12, 2020
removed their assignment
on Jan 4, 2021
ChristopherGLewis

ChristopherGLewis commented on Jan 13, 2021

@ChristopherGLewis
Contributor

One comment I'd have is that as you start to think about single line objects, consider what would happen if you have a bicep linter and your linter converts from single-line to multi-line.

With single line, these would be the same in bicep:

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16', '10.1.0.0/16' ]
    }
...
    addressSpace: {
      addressPrefixes: [ 
        '10.0.0.0/16'
        '10.1.0.0/16'
      ]
    }

However, a simple code formatting tool may have issues converting between the two since there's not just a white space change.
The linting tool would have to know that the comma is needed in single-line, but not needed in multi-line.

Give that changing lines involved more than just white-space, my suggestion is that you either support just a white-space separator or support both white-space and comma.

This would mean that this would be valid syntax:

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16' '10.1.0.0/16' ]
    }
...
    addressSpace: {
      addressPrefixes: [ 
        '10.0.0.0/16'
        '10.1.0.0/16'
      ]
    }

Along with

    addressSpace: {
      addressPrefixes: [ '10.0.0.0/16', '10.1.0.0/16' ]
    }
...
    addressSpace: {
      addressPrefixes: [ 
        '10.0.0.0/16',
        '10.1.0.0/16'
      ]
    }

Personally, I support the second syntax (commas) because then each object is a (semi) valid JSON primitive. It would be super nice if it was a valid primitive, but that would require supporting real quote characters :-)

changed the title Support single-line objects arrays Support single-line objects/arrays on Feb 23, 2021

16 remaining items

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Support single-line objects/arrays · Issue #586 · Azure/bicep