eslint-codemod-utils
Version:
A collection of AST helper functions for more complex ESLint rule fixes.
21 lines (20 loc) • 763 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.node = void 0;
const constants_1 = require("../constants");
/**
* Internally focused function to help resolve / parse the AST. It hands off
* to the `typeToHelperLookup` map to apply the correct transformation.
*
* This function can be applied to any valid `espree`/`typescript-eslint` node
* — whether it was produced by a parser (with full `loc`/`range`) or
* synthesised by a consumer through one of the node-factory helpers (which
* return `StringableASTNode<T>` where `loc`/`range` are optional).
*
* @internal
*/
const node = (estNode) => {
const handler = constants_1.typeToHelperLookup[estNode.type];
return handler(estNode);
};
exports.node = node;