Subject: bug#68054: [PATCH] Add tree-sitter indent rule for lexical decls in js/typescript

From: Dmitry Gutov <[email-masked]>
Date: Wed, 24 Apr 2024 03:15:08 +0300

On 23/04/2024 08:07, Yuan Fu wrote:
>> 1) indent the dangling values with respect to start of the declaration
>>
>>      const a =
>>          (x: string): string => {
>>              return x + x;
>>          },
>>            bbb =
>>          {
>>              "x": 0
>>          },
>>            cccc =
>>          1,
>>            ddddd = 0;
>>    
>> 2) indent them with respect to the start of the variable_declarator
>>
>>      const a =
>>                (x: string): string => {
>>                    return x + x;
>>                },
>>            bbb =
>>                {
>>                    "x": 0
>>                },
>>            cccc =
>>                1,
>>            ddddd = 0;
>>
>> 3) align with the variable declarators (this is the same as js-mode)
>>
>>      const a =
>>            (x: string): string => {
>>                return x + x;
>>            },
>>            bbb =
>>            {
>>                "x": 0
>>            },
>>            cccc =
>>            1,
>>            ddddd = 0;
>>
>> I've attached a patch with with the rules for the 3 options here.
> I don’t really know what’s the convention, if there is one. Maybe Dmitry has better idea. Personally I like option 1.

What js-mode does (looks like 3) shouldn't be too bad, but I wouldn't 
mind an extra indentation level for such cases, too (example 2).

This seems like a rare enough case, so it probably doesn't matter too 
much, so I'd suggest picking one style and implementing it, and then 
adjusting based on user feedback later.