Sunday, 26 March 2023

Object properties must be on a new line with ESLint

let's say I have the following variable:

const myObject = { property1: 'value1', property2: 'value2', property3: 'value3' };

I want to enforce an eslint rule so that if an object has a minimum of three properties, then each property must go on a new line, such as below:

const myObject = {
  property1: 'value1',
  property2: 'value2',
  property3: 'value3',
};

However, if I use the eslint rule object-curly-newline, it appears that the following is acceptable, and this is what get's automatically formatted when eslint --fix runs:

const myObject = {
  property1: 'value1', property2: 'value2', property3: 'value3',
};

How can I enforce an eslint rule that makes sure that each new property is on a new line? Thanks!



from Object properties must be on a new line with ESLint

No comments:

Post a Comment