UNPKG

eslint-codemod-utils

Version:

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

16 lines (15 loc) 541 B
import type * as ESTree from 'estree-jsx'; /** * Adds a prop to a JSXElement. * * @author Sam Scheding * @example * ``` * const boxNode = jsxElement({ ...node }) * console.log(boxNode.toString()) // --> "<Box></Box>" * * const boxNodeWithProp = insertJSXAttribute(node, 'display', 'block') * console.log(boxNodeWithProp.toString()) // --> "<Box display='block'></Box>" * ``` */ export declare function insertJSXAttribute(node: ESTree.JSXElement, propName: string, propValue: ESTree.JSXAttribute['value']): ESTree.JSXElement;