Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Add examples to better show rule coverage. #9548

Merged
merged 1 commit into from Nov 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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