# no-optional-chaining

Rule `oxc/no-optional-chaining`. Disallow optional chaining.

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

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Oxlint | `oxc/no-optional-chaining` | no | no | plugin `oxc`, category restriction | [docs](https://oxc.rs/docs/guide/usage/linter/rules/oxc/no-optional-chaining.html) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = obj?.foo;
obj.fn?.();
```

Examples from the Oxlint documentation.

## Enable it

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "oxc/no-optional-chaining": "error"
  }
}
```

## Related rules

- [oxc/no-async-await](https://lintradar.dev/rules/oxc/no-async-await.md): Disallows the use of `async`/`await`.
- [oxc/no-rest-spread-properties](https://lintradar.dev/rules/oxc/no-rest-spread-properties.md): Disallow Object Rest/Spread Properties.
- [oxc/no-map-spread](https://lintradar.dev/rules/oxc/no-map-spread.md): Disallow the use of object or array spreads in `Array.prototype.map` and `Array.prototype.flatMap` to add properties/elements to array items.
- [oxc/no-this-in-exported-function](https://lintradar.dev/rules/oxc/no-this-in-exported-function.md): Disallows the use of `this` in exported functions.
- [oxc/no-const-enum](https://lintradar.dev/rules/oxc/no-const-enum.md): Disallow TypeScript `const enum`
- [oxc/no-barrel-file](https://lintradar.dev/rules/oxc/no-barrel-file.md): Disallow the use of barrel files where the file contains `export *` statements, and the total number of modules exceeds a threshold.

---

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