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

From: Yuan Fu <[email-masked]>
Date: Mon, 22 Apr 2024 22:07:20 -0700

> On Apr 17, 2024, at 1:21 PM, Noah Peart <[email-masked]> wrote:
> 
> Sorry, I forgot about this. I've just added a rule to align the variable_declarators
> in let, var, and const declarations, but I need some feedback about the indentation
> for values in the variable_declarators following dangling '='.

Thanks!

> 
> For example, which of the following would be preferable?
> 
> 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.

Yuan