# shorthand-property-grouping

Rule `sonarjs/shorthand-property-grouping`. Shorthand object properties should be grouped at the beginning or end of an object declaration

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #2175 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/shorthand-property-grouping` | no | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-3499/) |

## Code examples

### Incorrect: the rule reports this

```js
let obj1 = {
  foo,
  a: 1,
  color,  // Noncompliant
  b: 2,
  judyGarland  // Noncompliant
}
```

### Correct: the rule accepts this

```js
let obj1 = {
  foo,
  color,
  judyGarland,
  a: 1,
  b: 2
}
```

```js
let obj1 = {
  a: 1,
  b: 2,
  foo,
  color,
  judyGarland
}
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/shorthand-property-grouping": "error",
    },
  },
];
```

## Related rules

- [sonarjs/prefer-object-literal](https://lintradar.dev/rules/sonarjs/prefer-object-literal.md): Object literal syntax should be used
- [sonarjs/strings-comparison](https://lintradar.dev/rules/sonarjs/strings-comparison.md): Comparison operators should not be used with strings
- [sonarjs/prefer-immediate-return](https://lintradar.dev/rules/sonarjs/prefer-immediate-return.md): Local variables should not be declared and then immediately returned or thrown
- [sonarjs/too-many-break-or-continue-in-loop](https://lintradar.dev/rules/sonarjs/too-many-break-or-continue-in-loop.md): Loops should not contain more than a single "break" or "continue" statement
- [sonarjs/unicode-aware-regex](https://lintradar.dev/rules/sonarjs/unicode-aware-regex.md): Regular expressions using Unicode character classes or property escapes should enable the unicode flag
- [sonarjs/operation-returning-nan](https://lintradar.dev/rules/sonarjs/operation-returning-nan.md): Arithmetic operations should not result in "NaN"

---

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