UNPKG

eslint-codemod-utils

Version:

A collection of AST helper functions for more complex ESLint rule fixes.

17 lines (16 loc) 409 B
/** * Given a valid node return true if the node is of the specified type. * * This function uses the `is` assertion to resolve the correct TS type for the consumer. * * @return boolean */ export function isNodeOfType(node, type) { if (typeof node !== 'object' || node === null) { return false; } if (!('type' in node)) { return false; } return node.type === type; }