# object-shorthand

Rule `eslint/object-shorthand`. Require or disallow method and property shorthand syntax for object literals

- Source: eslint
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 16.8M weekly downloads of presets that enable it
- Trend: +15.1% last quarter
- Rank: #652 by reach, #1407 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `object-shorthand` | no | safe | package `eslint` | [docs](https://eslint.org/docs/latest/rules/object-shorthand) |
| Oxlint | `object-shorthand` | no | safe | plugin `eslint`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/eslint/object-shorthand.html) |
| Biome | `style/useConsistentObjectDefinitions` | no | safe | group style, since 2.0.0 | [docs](https://biomejs.dev/linter/rules/use-consistent-object-definitions/) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = {
    w: function() {},
    x: function *() {},
    [y]: function() {},
    z: z
};
```

```js
const foo = {
    w() {},
    *x() {},
    [y]() {},
    z
};
```

```js
const foo = {
    x: (y) => y
};
```

### Correct: the rule accepts this

```js
const foo = {
    "bar-baz": function() {},
    "qux": qux
};
```

```js
const foo = {
    ConstructorFunction: function() {}
};
```

```js
const foo = {
  "ConstructorFunction"() {}
};
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "object-shorthand": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "object-shorthand": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "useConsistentObjectDefinitions": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Airbnb base](https://lintradar.dev/presets/airbnb-base.md) | ESLint | `eslint-config-airbnb-base` | 241 | 6.5M | +2.1% |
| [Airbnb](https://lintradar.dev/presets/airbnb.md) | ESLint | `eslint-config-airbnb` | 346 | 3.4M | +2.3% |
| [JavaScript Standard Style](https://lintradar.dev/presets/standard.md) | ESLint | `eslint-config-standard` | 161 | 3.1M | +12.9% |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |
| [Ultracite for Oxlint](https://lintradar.dev/presets/ultracite-oxlint.md) | Oxlint | `ultracite` | 475 | 2.1M | +151.7% |
| [Anthony Fu's config](https://lintradar.dev/presets/antfu.md) | ESLint | `@antfu/eslint-config` | 294 | 758.7K | +49.9% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |
| [neostandard](https://lintradar.dev/presets/neostandard.md) | ESLint | `neostandard` | 95 | 317.6K | +50.2% |
| [eslint-config-love](https://lintradar.dev/presets/love.md) | ESLint | `eslint-config-love` | 258 | 171.7K | +39.3% |

## Related rules

- [vue/object-shorthand](https://lintradar.dev/rules/vue/object-shorthand.md): Require or disallow method and property shorthand syntax for object literals in `<template>`
- [eslint/no-useless-return](https://lintradar.dev/rules/eslint/no-useless-return.md): Disallow redundant return statements
- [eslint/no-unreachable-loop](https://lintradar.dev/rules/eslint/no-unreachable-loop.md): Disallow loops with a body that allows only one iteration
- [eslint/symbol-description](https://lintradar.dev/rules/eslint/symbol-description.md): Require symbol descriptions
- [eslint/prefer-promise-reject-errors](https://lintradar.dev/rules/eslint/prefer-promise-reject-errors.md): Require using Error objects as Promise rejection reasons
- [eslint/no-restricted-globals](https://lintradar.dev/rules/eslint/no-restricted-globals.md): Disallow specified global variables

---

Web page: https://lintradar.dev/rules/eslint/object-shorthand. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
