# conditional-indentation

Rule `sonarjs/conditional-indentation`. A conditionally executed single line should be denoted by indentation

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

## Linters

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

## Code examples

### Incorrect: the rule reports this

```js
if (condition)  // Noncompliant
doTheThing();

doTheOtherThing();
somethingElseEntirely();

foo();
```

### Correct: the rule accepts this

```js
if (condition)
  doTheThing();

doTheOtherThing();
somethingElseEntirely();

foo();
```

Examples from the ESLint documentation.

## Enable it

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

```js
export default [
  {
    rules: {
      "sonarjs/conditional-indentation": "error",
    },
  },
];
```

## Related rules

- [sonarjs/composite-assertions](https://lintradar.dev/rules/sonarjs/composite-assertions.md): Composite assertions should be split
- [sonarjs/comment-regex](https://lintradar.dev/rules/sonarjs/comment-regex.md): Track comments matching a regular expression
- [sonarjs/cyclomatic-complexity](https://lintradar.dev/rules/sonarjs/cyclomatic-complexity.md): Cyclomatic Complexity of functions should not be too high
- [sonarjs/class-prototype](https://lintradar.dev/rules/sonarjs/class-prototype.md): Class methods should be used instead of "prototype" assignments
- [sonarjs/declarations-in-global-scope](https://lintradar.dev/rules/sonarjs/declarations-in-global-scope.md): Variables and functions should not be declared in the global scope
- [sonarjs/bool-param-default](https://lintradar.dev/rules/sonarjs/bool-param-default.md): Optional boolean parameters should have default value

---

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