---
url: /docs/guide/usage/linter/rules/eslint/object-shorthand.md
---

### 它的作用

要求或禁止对象字面量使用方法和属性的简写语法

### 为什么这不好？

风格偏好

### 示例

以下是一些使用 ES5 语法的常见示例：

```javascript
var properties = { x: x, y: y, z: z };
var methods = { a: function () {}, b: function () {} };
```

下面是对应的 ES6 写法：

```javascript
var properties = { x, y, z };
var methods = { a() {}, b() {} };
```

## 配置

### 第 1 个选项

type: `"always" | "methods" | "properties" | "consistent" | "consistent-as-needed" | "never"`

### 第 2 个选项

此选项是一个包含以下属性的对象：

#### avoidExplicitReturnArrows

type: `boolean`

default: `false`

#### avoidQuotes

type: `boolean`

default: `false`

#### ignoreConstructors

type: `boolean`

default: `false`

#### methodsIgnorePattern

type: `string`

## 如何使用

## 版本

此规则于 v1.59.0 中添加。

## 参考资料
