跳至內容

oxc/no-optional-chaining 限制

作用

禁用可選鏈結

範例

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

選項

json
{
  "rules": {
    "no-optional-chaining": [
        "error",
        {
            "message": "Our output target is ES2016, and optional chaining results in verbose
            helpers and should be avoided.",
        }
    ]
  }
}
  • message: 發現可選鏈結時顯示的自訂協助訊息。

參考

根據 MIT 許可發布。