Skip to content

oxc/no-optional-chaining Restriction

What it does

Disallow optional chaining.

Example

javascript
const foo = obj?.foo;
obj.fn?.();

Options

json
{
  "rules": {
    "no-optional-chaining": [
        "error",
        {
            "message": "Our output target is ES2016, and optional chaining results in verbose
            helpers and should be avoided.",
        }
    ]
  }
}
  • message: A custom help message to display when optional chaining is found.

References

Released under the MIT License.