eslint-plugin-unicorn
Version:
More than 300 powerful ESLint rules
11 lines (9 loc) • 337 B
JavaScript
/**
Check if an `if` statement is the `else` branch of another `if` statement, for example the second `if` in `if (a) {} else if (b) {}`.
@param {import('estree').IfStatement} node
@returns {boolean}
*/
export default function isElseIfStatement(node) {
return node.parent?.type === 'IfStatement'
&& node.parent.alternate === node;
}