Skip to content

Commit

Permalink
Docs: correction in prefer-reflect docs (fixes #7069).
Browse files Browse the repository at this point in the history
  • Loading branch information
sstern6 committed Sep 27, 2016
1 parent 3b8069d commit 53b0d42
Showing 1 changed file with 43 additions and 43 deletions.
86 changes: 43 additions & 43 deletions docs/rules/prefer-reflect.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,30 @@ Examples of **incorrect** code for this rule when used without exceptions:
```js
/*eslint prefer-reflect: "error"*/

foo.apply(undefined, args);
foo.apply(null, args);
obj.foo.apply(obj, args);
obj.foo.apply(other, args);

foo.call(undefined, arg);
foo.call(null, arg);
obj.foo.call(obj, arg);
obj.foo.call(other, arg);
myFunction.apply(undefined, args);
myFunction.apply(null, args);
obj.myMethod.apply(obj, args);
obj.myMethod.apply(other, args);

myFunction.call(undefined, arg);
myFunction.call(null, arg);
obj.myMethod.call(obj, arg);
obj.myMethod.call(other, arg);
```

Examples of **correct** code for this rule when used without exceptions:

```js
/*eslint prefer-reflect: "error"*/

Reflect.apply(undefined, args);
Reflect.apply(null, args);
Reflect.apply(obj.foo, obj, args);
Reflect.apply(obj.foo, other, args);
Reflect.apply(undefined, [arg]);
Reflect.apply(null, [arg]);
Reflect.apply(obj.foo, obj, [arg]);
Reflect.apply(obj.foo, other, [arg]);
Reflect.apply(myFunction, undefined, args);
Reflect.apply(myFunction, null, args);
Reflect.apply(obj.myMethod, obj, args);
Reflect.apply(obj.myMethod, other, args);
Reflect.apply(myFunction, undefined, [arg]);
Reflect.apply(myFunction, null, [arg]);
Reflect.apply(obj.myMethod, obj, [arg]);
Reflect.apply(obj.myMethod, other, [arg]);
```

Examples of **correct** code for this rule with the `{ "exceptions": ["apply"] }` option:
Expand All @@ -70,10 +70,10 @@ Examples of **correct** code for this rule with the `{ "exceptions": ["apply"] }
/*eslint prefer-reflect: ["error", { "exceptions": ["apply"] }]*/

// in addition to Reflect.apply(...):
foo.apply(undefined, args);
foo.apply(null, args);
obj.foo.apply(obj, args);
obj.foo.apply(other, args);
myFunction.apply(undefined, args);
myFunction.apply(null, args);
obj.myMethod.apply(obj, args);
obj.myMethod.apply(other, args);
```

Examples of **correct** code for this rule with the `{ "exceptions": ["call"] }` option:
Expand All @@ -82,10 +82,10 @@ Examples of **correct** code for this rule with the `{ "exceptions": ["call"] }`
/*eslint prefer-reflect: ["error", { "exceptions": ["call"] }]*/

// in addition to Reflect.apply(...):
foo.call(undefined, arg);
foo.call(null, arg);
obj.foo.call(obj, arg);
obj.foo.call(other, arg);
myFunction.call(undefined, arg);
myFunction.call(null, arg);
ob.myMethod.call(obj, arg);
obj.myMethod.call(other, arg);
```

### Reflect.defineProperty
Expand All @@ -97,24 +97,24 @@ Examples of **incorrect** code for this rule when used without exceptions:
```js
/*eslint prefer-reflect: "error"*/

Object.defineProperty({}, 'foo', {value: 1})
Object.defineProperty({}, 'myProp', {value: 1})
```

Examples of **correct** code for this rule when used without exceptions:

```js
/*eslint prefer-reflect: "error"*/

Reflect.defineProperty({}, 'foo', {value: 1})
Reflect.defineProperty({}, 'myProp', {value: 1})
```

Examples of **correct** code for this rule with the `{ "exceptions": ["defineProperty"] }` option:

```js
/*eslint prefer-reflect: ["error", { "exceptions": ["defineProperty"] }]*/

Object.defineProperty({}, 'foo', {value: 1})
Reflect.defineProperty({}, 'foo', {value: 1})
Object.defineProperty({}, 'myProp', {value: 1})
Reflect.defineProperty({}, 'myProp', {value: 1})
```

### Reflect.getOwnPropertyDescriptor
Expand All @@ -126,24 +126,24 @@ Examples of **incorrect** code for this rule when used without exceptions:
```js
/*eslint prefer-reflect: "error"*/

Object.getOwnPropertyDescriptor({}, 'foo')
Object.getOwnPropertyDescriptor({}, 'myProp')
```

Examples of **correct** code for this rule when used without exceptions:

```js
/*eslint prefer-reflect: "error"*/

Reflect.getOwnPropertyDescriptor({}, 'foo')
Reflect.getOwnPropertyDescriptor({}, 'myProp')
```

Examples of **correct** code for this rule with the `{ "exceptions": ["getOwnPropertyDescriptor"] }` option:

```js
/*eslint prefer-reflect: ["error", { "exceptions": ["getOwnPropertyDescriptor"] }]*/

Object.getOwnPropertyDescriptor({}, 'foo')
Reflect.getOwnPropertyDescriptor({}, 'foo')
Object.getOwnPropertyDescriptor({}, 'myProp')
Reflect.getOwnPropertyDescriptor({}, 'myProp')
```

### Reflect.getPrototypeOf
Expand All @@ -155,27 +155,27 @@ Examples of **incorrect** code for this rule when used without exceptions:
```js
/*eslint prefer-reflect: "error"*/

Object.getPrototypeOf({}, 'foo')
Object.getPrototypeOf({}, 'myProp')
```

Examples of **correct** code for this rule when used without exceptions:

```js
/*eslint prefer-reflect: "error"*/

Reflect.getPrototypeOf({}, 'foo')
Reflect.getPrototypeOf({}, 'myProp')
```

Examples of **correct** code for this rule with the `{ "exceptions": ["getPrototypeOf"] }` option:

```js
/*eslint prefer-reflect: ["error", { "exceptions": ["getPrototypeOf"] }]*/

Object.getPrototypeOf({}, 'foo')
Reflect.getPrototypeOf({}, 'foo')
Object.getPrototypeOf({}, 'myProp')
Reflect.getPrototypeOf({}, 'myProp')
```

### Reflect.setPrototypeOf
### <Reflect class="setPrototypeOf"></Reflect>

Deprecates `Object.setPrototypeOf()`

Expand Down Expand Up @@ -300,7 +300,7 @@ Examples of **incorrect** code for this rule when used without exceptions:
```js
/*eslint prefer-reflect: "error"*/

delete foo.bar; // deleting object property
delete obj.myProp; // deleting object property
```

Examples of **correct** code for this rule when used without exceptions:
Expand All @@ -309,7 +309,7 @@ Examples of **correct** code for this rule when used without exceptions:
/*eslint prefer-reflect: "error"*/

delete bar; // deleting variable
Reflect.deleteProperty(foo, 'bar');
Reflect.deleteProperty(obj, 'myProp');
```

Note: For a rule preventing deletion of variables, see [no-delete-var instead](no-delete-var.md)
Expand All @@ -319,9 +319,9 @@ Examples of **correct** code for this rule with the `{ "exceptions": ["delete"]
```js
/*eslint prefer-reflect: ["error", { "exceptions": ["delete"] }]*/

delete bar
delete foo.bar
Reflect.deleteProperty(foo, 'bar');
delete bar // deleting variable
delete obj.myProp
Reflect.deleteProperty(obj, 'myProp');
```

## When Not To Use It
Expand Down

0 comments on commit 53b0d42

Please sign in to comment.