UNPKG

@atlaskit/eslint-plugin-ui-styling-standard

Version:

The eslint plugin to enforce and educate on Atlassian's UI Styling Standard

24 lines • 676 B
export function getRangeFromNode({ node, sourceNode }) { /** * The adjustment required to align the selector AST source position * with the ESTree source position. */ const 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); const start = adjustment + node.sourceIndex; const end = start + node.value.length; return [start, end]; }