目录

@hw-stylistic/object-property-newline

Enforce placing object properties on separate lines. This rule only checks .ets files.

When an object has no more than four properties, it is allowed to have them all on the same line, or each property can be on a new line. When an object has more than four properties, each property must be on a new line.

Rule Configuration

// code-linter.json5
{
  "rules": {
    "@hw-stylistic/object-property-newline": "error"
  }
}

Options

This rule is not configurable.

Example of Correct Code

export {a, b};

interface II {
  p1: string;
  p2: string;
  p3: string;
  p4: string;
  p5?: string;
}

const a: II = {
  p1: 'p1',
  p2: 'p2',
  p3: 'p3',
  p4: 'p4',
  p5: 'p5'
};

const b: II = { p1: 'p1', p2: 'p2', p3: 'p3', p4: 'p4' };

Example of Incorrect Code

export {a, b};

interface II {
  p1: string;
  p2: string;
  p3: string;
  p4: string;
  p5?: string;
}

// Object properties must go on a new line.
const a: II = { p1: 'p1', p2: 'p2',
  p3: 'p3', p4: 'p4' };

// Object properties must go on a new line.
const b: II = { p1: 'p1', p2: 'p2', p3: 'p3', p4: 'p4', p5: 'p5' };

Rule Set

"plugin:@hw-stylistic/recommended"
"plugin:@hw-stylistic/all"

For details about how to configure Code Linter check rules, see Code Linter.