@atlaskit/eslint-plugin-ui-styling-standard
Version:
The eslint plugin to enforce and educate on Atlassian's UI Styling Standard
29 lines (28 loc) • 826 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getRangeFromNode = getRangeFromNode;
function getRangeFromNode(_ref) {
var node = _ref.node,
sourceNode = _ref.sourceNode;
/**
* The adjustment required to align the selector AST source position
* with the ESTree source position.
*/
var adjustment =
/**
* Using a non-null `!` is safe here because ESLint requires the parser to
* include a range value on nodes.
*
* https://eslint.org/docs/latest/extend/custom-parsers#all-nodes
*/
sourceNode.range[0] + (
/**
* We add +1 if it's a literal to account for the opening `'` or `"` character.
*/
sourceNode.type === 'Literal' ? 1 : 0);
var start = adjustment + node.sourceIndex;
var end = start + node.value.length;
return [start, end];
}