Skip to content

Commit

Permalink
Docs: Add examples to better show rule coverage. (#9548)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrpool authored and ilyavolodin committed Nov 1, 2017
1 parent 88d2303 commit ab0f66d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions docs/rules/object-property-newline.md
Expand Up @@ -92,7 +92,7 @@ This rule applies equally to all property specifications, regardless of notation

- `a: 1` (ES5)
- `a` (ES2015 shorthand property)
- ``[`prop${a}`]`` (computed property name)
- ``[`prop${a}`]`` (ES2015 computed property name)

Thus, the rule (without the object option) prohibits both of these:

Expand Down Expand Up @@ -200,19 +200,31 @@ const obj3 = {
const a = "antidisestablishmentarianistically";
const b = "yugoslavyalılaştırabildiklerimizdenmişsiniz";
const obj4 = {a, b};

const domain = process.argv[4];
const obj5 = {
foo: "foo", [
domain.includes(":") ? "complexdomain" : "simpledomain"
]: true};
```

Examples of **correct** code for this rule, with no object option or with `allowMultiplePropertiesPerLine` set to `false`:

```js
/*eslint object-property-newline: "error"*/

const obj = {
const obj1 = {
foo: "foo",
bar: "bar",
baz: "baz"
};

const obj2 = {
foo: "foo"
, bar: "bar"
, baz: "baz"
};

const user = process.argv[2];
const obj3 = {
user,
Expand All @@ -231,9 +243,9 @@ Examples of additional **correct** code for this rule with the `{ "allowMultiple
```js
/*eslint object-property-newline: ["error", { "allowMultiplePropertiesPerLine": true }]*/

var obj = { foo: "foo", bar: "bar", baz: "baz" };
const obj = { foo: "foo", bar: "bar", baz: "baz" };

var obj2 = {
const obj2 = {
foo: "foo", bar: "bar", baz: "baz"
};
const user = process.argv[2];
Expand Down

0 comments on commit ab0f66d

Please sign in to comment.