Skip to content

Commit

Permalink
[Fix] jsx-curly-spacing, jsx-no-bind, usedPropTypes util: avoid…
Browse files Browse the repository at this point in the history
… node.start and node.end
  • Loading branch information
toshi-toma authored and ljharb committed May 9, 2020
1 parent db4e471 commit 25b1936
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/rules/jsx-curly-spacing.js
Expand Up @@ -244,7 +244,7 @@ module.exports = {

// Take comments into consideration to narrow the fix range to what is actually affected. (See #1414)
if (nextComment.length > 0) {
return fixByTrimmingWhitespace(fixer, token.range[1], Math.min(nextToken.range[0], nextComment[0].start), 'start');
return fixByTrimmingWhitespace(fixer, token.range[1], Math.min(nextToken.range[0], nextComment[0].range[0]), 'start');
}

return fixByTrimmingWhitespace(fixer, token.range[1], nextToken.range[0], 'start');
Expand Down Expand Up @@ -279,7 +279,7 @@ module.exports = {

// Take comments into consideration to narrow the fix range to what is actually affected. (See #1414)
if (previousComment.length > 0) {
return fixByTrimmingWhitespace(fixer, Math.max(previousToken.range[1], previousComment[0].end), token.range[0], 'end');
return fixByTrimmingWhitespace(fixer, Math.max(previousToken.range[1], previousComment[0].range[1]), token.range[0], 'end');
}

return fixByTrimmingWhitespace(fixer, previousToken.range[1], token.range[0], 'end');
Expand Down
6 changes: 3 additions & 3 deletions lib/rules/jsx-no-bind.js
Expand Up @@ -132,13 +132,13 @@ module.exports = {

function findVariableViolation(node, name) {
getBlockStatementAncestors(node).find(
block => reportVariableViolation(node, name, block.start)
block => reportVariableViolation(node, name, block.range[0])
);
}

return {
BlockStatement(node) {
setBlockVariableNameSet(node.start);
setBlockVariableNameSet(node.range[0]);
},

VariableDeclarator(node) {
Expand All @@ -154,7 +154,7 @@ module.exports = {
node.parent.kind === 'const' // only support const right now
) {
addVariableNameToSet(
variableViolationType, node.id.name, blockAncestors[0].start
variableViolationType, node.id.name, blockAncestors[0].range[0]
);
}
},
Expand Down
2 changes: 1 addition & 1 deletion lib/util/usedPropTypes.js
Expand Up @@ -170,7 +170,7 @@ function isPropArgumentInSetStateUpdater(context, name) {
unwrappedParentCalleeNode.property &&
unwrappedParentCalleeNode.property.name === 'setState' &&
// Make sure we are in the updater not the callback
scope.block.parent.arguments[0].start === scope.block.start &&
scope.block.parent.arguments[0].range[0] === scope.block.range[0] &&
scope.block.parent.arguments[0].params &&
scope.block.parent.arguments[0].params.length > 1
) {
Expand Down

0 comments on commit 25b1936

Please sign in to comment.