Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'MemberExpression, JSXMemberExpression, MetaProperty'(node) {
const object = node.type === experimental_utils_1.AST_NODE_TYPES.MetaProperty ? node.meta : node.object;
const isComputed = 'computed' in node && node.computed;
const firstNonObjectToken = sourceCode.getFirstTokenBetween(object, node.property, eslint_utils_1.isNotClosingParenToken);
const secondNonObjectToken = sourceCode.getTokenAfter(firstNonObjectToken);
const objectParenCount = sourceCode.getTokensBetween(object, node.property, { filter: eslint_utils_1.isClosingParenToken }).length;
const firstObjectToken = objectParenCount
? sourceCode.getTokenBefore(object, { skip: objectParenCount - 1 })
: sourceCode.getFirstToken(object);
const lastObjectToken = sourceCode.getTokenBefore(firstNonObjectToken);
const firstPropertyToken = isComputed
? firstNonObjectToken
: secondNonObjectToken;
if (isComputed) {
// For computed MemberExpressions, match the closing bracket with the opening bracket.
offsets.setDesiredOffset(sourceCode.getLastToken(node), firstNonObjectToken, 0);
offsets.setDesiredOffsets(node.property.range, firstNonObjectToken, 1);
}
/*
* If the object ends on the same line that the property starts, match against the last token
function getPropertyRange(node) {
const dotOrOpenBracket = sourceCode.getTokenAfter(node.object, eslint_utils_1.isNotClosingParenToken);
return [dotOrOpenBracket.range[0], node.range[1]];
}
/**