Skip to content

Commit

Permalink
Docs: Cross-reference two rules (refs #11041) (#11042)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmelnikow authored and not-an-aardvark committed Nov 3, 2018
1 parent 5525eb6 commit 4fe3287
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
12 changes: 8 additions & 4 deletions docs/rules/no-useless-rename.md
Expand Up @@ -28,13 +28,17 @@ let { foo } = bar;

This rule disallows the renaming of import, export, and destructured assignments to the same name.

See Also:

- [`object-shorthand`](https://eslint.org/docs/rules/object-shorthand) which can enforce this behavior for properties in object literals.

## Options

This rule allows for more fine-grained control with the following options:

* `ignoreImport`: When set to `true`, this rule does not check imports
* `ignoreExport`: When set to `true`, this rule does not check exports
* `ignoreDestructuring`: When set to `true`, this rule does not check destructuring assignments
- `ignoreImport`: When set to `true`, this rule does not check imports
- `ignoreExport`: When set to `true`, this rule does not check exports
- `ignoreDestructuring`: When set to `true`, this rule does not check destructuring assignments

By default, all options are set to `false`:

Expand Down Expand Up @@ -117,4 +121,4 @@ You can safely disable this rule if you do not care about redundantly renaming i

## Compatibility

* **JSCS**: [disallowIdenticalDestructuringNames](https://jscs-dev.github.io/rule/disallowIdenticalDestructuringNames)
- **JSCS**: [disallowIdenticalDestructuringNames](https://jscs-dev.github.io/rule/disallowIdenticalDestructuringNames)
22 changes: 13 additions & 9 deletions docs/rules/object-shorthand.md
Expand Up @@ -82,16 +82,20 @@ var foo = {
};
```

See Also:

- [`no-useless-rename`](https://eslint.org/docs/rules/object-shorthand) which disallows renaming import, export, and destructured assignments to the same name.

## Options

The rule takes an option which specifies when it should be applied. It can be set to one of the following values:

* `"always"` (default) expects that the shorthand will be used whenever possible.
* `"methods"` ensures the method shorthand is used (also applies to generators).
* `"properties"` ensures the property shorthand is used (where the key and variable name match).
* `"never"` ensures that no property or method shorthand is used in any object literal.
* `"consistent"` ensures that either all shorthand or all long-form will be used in an object literal.
* `"consistent-as-needed"` ensures that either all shorthand or all long-form will be used in an object literal, but ensures all shorthand whenever possible.
- `"always"` (default) expects that the shorthand will be used whenever possible.
- `"methods"` ensures the method shorthand is used (also applies to generators).
- `"properties"` ensures the property shorthand is used (where the key and variable name match).
- `"never"` ensures that no property or method shorthand is used in any object literal.
- `"consistent"` ensures that either all shorthand or all long-form will be used in an object literal.
- `"consistent-as-needed"` ensures that either all shorthand or all long-form will be used in an object literal, but ensures all shorthand whenever possible.

You can set the option in configuration like this:

Expand All @@ -103,9 +107,9 @@ You can set the option in configuration like this:

Additionally, the rule takes an optional object configuration:

* `"avoidQuotes": true` indicates that long-form syntax is preferred whenever the object key is a string literal (default: `false`). Note that this option can only be enabled when the string option is set to `"always"`, `"methods"`, or `"properties"`.
* `"ignoreConstructors": true` can be used to prevent the rule from reporting errors for constructor functions. (By default, the rule treats constructors the same way as other functions.) Note that this option can only be enabled when the string option is set to `"always"` or `"methods"`.
* `"avoidExplicitReturnArrows": true` indicates that methods are preferred over explicit-return arrow functions for function properties. (By default, the rule allows either of these.) Note that this option can only be enabled when the string option is set to `"always"` or `"methods"`.
- `"avoidQuotes": true` indicates that long-form syntax is preferred whenever the object key is a string literal (default: `false`). Note that this option can only be enabled when the string option is set to `"always"`, `"methods"`, or `"properties"`.
- `"ignoreConstructors": true` can be used to prevent the rule from reporting errors for constructor functions. (By default, the rule treats constructors the same way as other functions.) Note that this option can only be enabled when the string option is set to `"always"` or `"methods"`.
- `"avoidExplicitReturnArrows": true` indicates that methods are preferred over explicit-return arrow functions for function properties. (By default, the rule allows either of these.) Note that this option can only be enabled when the string option is set to `"always"` or `"methods"`.

### `avoidQuotes`

Expand Down

0 comments on commit 4fe3287

Please sign in to comment.