@atlaskit/eslint-plugin-design-system
Version:
The essential plugin for use with the Atlassian Design System.
12 lines • 428 B
JavaScript
// Get raw source code string for a given node
export function getNodeSource(fileContents, node) {
var _node$loc;
if ((_node$loc = node.loc) !== null && _node$loc !== void 0 && _node$loc.source) {
var _node$loc2;
return (_node$loc2 = node.loc) === null || _node$loc2 === void 0 ? void 0 : _node$loc2.source;
}
if (node.range) {
return fileContents.text.slice(node.range[0], node.range[1]);
}
return '';
}