javascript icon indicating copy to clipboard operation
javascript copied to clipboard

"#arrays--bracket-newline" which one is better ?

Open solidw opened this issue 6 years ago • 1 comments

In the guide (I mean README.md of airbnb/javascript), there is an example of arrays-bracket-newline.

  • 4.8 Use line breaks after open and before close array brackets if an array has multiple lines
// bad
const arr = [
  [0, 1], [2, 3], [4, 5],
];

const objectInArray = [{
  id: 1,
}, {
  id: 2,
}];

const numberInArray = [
  1, 2,
];

// good
const arr = [[0, 1], [2, 3], [4, 5]];

const objectInArray = [
  {
    id: 1,
  },
  {
    id: 2,
  },
];

const numberInArray = [
  1,
  2,
];

Here is an example for "arr".

// good
const arr = [[0, 1], [2, 3], [4, 5]];

But I think this is better.

const arr = [
  [0, 1],
  [2, 3],
  [4, 5]
];

I just wanna talk about with everyone who interest in convention. Let's discuss!

https://github.com/airbnb/javascript#arrays--bracket-newline

solidw avatar Jul 11 '20 06:07 solidw

This is good as it is.

solidw avatar Jul 14 '20 15:07 solidw