UNPKG

eslint-plugin-unicorn

Version:
18 lines (13 loc) 356 B
const isChainElement = node => node.type === 'MemberExpression' || node.type === 'CallExpression'; export default function hasOptionalChainElement(node) { if (!isChainElement(node)) { return false; } if (node.optional) { return true; } if (node.type === 'MemberExpression') { return hasOptionalChainElement(node.object); } return false; }