Saturday, April 13, 2024
164
rated 0 times [  170] [ 6]  / answers: 1 / hits: 8504  / 4 Years ago, mon, april 6, 2020, 12:00:00

I am struggling to find a setting in my Prettier / ESLint config which allows me to wrap my code like this:


var [
first,
second,
third,
etc,
] = data();

When I hit save, it always turns the code to this automatically:


var [first, second, third, etc] = data();

This may not be such a big problem with this simple demonstration, but with more complex destructuring, this one liner will get hard to read.


Thank you for your help!


More From » destructuring

 Answers
2

In Eslint, you can enforce line breaks between array elements using option array-element-newline:



Incorrect code:



/*eslint array-element-newline: [error, always]*/
var d = [1, 2, 3];


Correct code:



/*eslint array-element-newline: [error, always]*/
var d = [1,
2,
3];


You can also check out:




[#4249] Friday, April 3, 2020, 4 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
makiyac

Total Points: 470
Total Questions: 100
Total Answers: 115

Location: Botswana
Member since Sat, Jan 7, 2023
1 Year ago
;