rokucommunity / bslint

A linter for BrightScript and BrighterScript.
MIT License
27 stars 14 forks source link

Add new aa-comma-style all-except-single-line. #80

Closed justinMBullard closed 1 year ago

justinMBullard commented 1 year ago

The all-except-single-line option will enforce "always" for multiple line AA but for single line AA it will enforce "no-dangling".

The all-except-single-line option is here to help with creating more line independent when an AA is extended. For multiple line AA, always is preferred. Always will allow for the addition to AA at the end without requiring a change to the previous line.

However for a single line AA, always just adds an extra , and does not create line independence. For a single line AA it is better to use no-dangling. This will keep the AA smaller.

elsassph commented 1 year ago

Can you show an example where an extra , appears but you think should not?

Maybe it's a bug because single line AA should probably not have a dangling coma even with the dangling rule.

justinMBullard commented 1 year ago

@ elsassph I want to be able to support always but not require the last comma for a single line. The goal is to have a single style that supports both style2 and style4. Style2 for its ability to create more independent diff when changed, Style4 for its brevity.

sub syle2()
    a = {
        a1: 1,
        a2: 2, 'comment
        a3: 3,
    }
end sub

and

sub style4()
    a = { a1: 1, a2: 2, a3: 3 }
end sub
elsassph commented 1 year ago

style4 shouldn't have a dangling comma IMHO even with the option enabled. Let's just fix that without adding an option :D

justinMBullard commented 1 year ago

@elsassph Thanks. I made the change as you suggest.

justinMBullard commented 1 year ago

Thank you @elsassph. I think I have made all the required changes.

elsassph commented 1 year ago

Sorry @justinMBullard some tests seem to be failing...

justinMBullard commented 1 year ago

@elsassph Sorry there was a second test that I wasn't aware of that needed updating. I just fixed that. This is my first time working on this project and I am still learning how to navigate everything. Thank you for patients. I think everything should be good now.