UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

42 lines (41 loc) 1.37 kB
/* eslint-disable @repo/internal/react/require-jsdoc */ import { isNodeOfType } from 'eslint-codemod-utils'; export var FunctionCall = { getName: function getName(node) { if (!isNodeOfType(node, 'CallExpression')) { return undefined; } if (!isNodeOfType(node.callee, 'Identifier')) { return undefined; } return node.callee.name; }, updateName: function updateName(node, newName, fixer) { return fixer.replaceText(node.callee, newName); }, /** * Function arguments can be many things: * `css(myStyles, () => {}, undefined, 'literal', ...rest) // etc` * They all need slightly different treatment. * * Currently 'getArgumentAtPos' only implements strategies for Literals and ObjectExpressions. * If you need to support another type of arg, add it, and update the type. */ getArgumentAtPos: function getArgumentAtPos(node, pos) { var argument = node.arguments[pos]; if (isNodeOfType(argument, 'Literal') && argument.value) { var _argument$value; return { type: 'Literal', value: (_argument$value = argument.value) === null || _argument$value === void 0 ? void 0 : _argument$value.toString() }; } if (isNodeOfType(argument, 'ObjectExpression')) { argument; return { type: 'ObjectExpression', value: argument }; } } };