UNPKG

@atlaskit/eslint-plugin-design-system

Version:

The essential plugin for use with the Atlassian Design System.

12 lines (11 loc) 680 B
import { isNodeOfType } from 'eslint-codemod-utils'; import { getSourceCode } from '@atlaskit/eslint-utils/context-compat'; export const getRawExpression = (node, context) => { if (!( // if not one of our recognized types or doesn't have a range prop, early return isNodeOfType(node, 'Literal') || isNodeOfType(node, 'Identifier') || isNodeOfType(node, 'BinaryExpression') || isNodeOfType(node, 'UnaryExpression') || isNodeOfType(node, 'TemplateLiteral') || isNodeOfType(node, 'CallExpression')) || !Array.isArray(node.range)) { return null; } const [start, end] = node.range; return getSourceCode(context).getText().substring(start, end).replaceAll('\n', ''); };