Skip to content

Commit 25b1936

Browse files
toshi-tomaljharb
authored andcommitted
[Fix] jsx-curly-spacing, jsx-no-bind, usedPropTypes util: avoid node.start and node.end
1 parent db4e471 commit 25b1936

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

lib/rules/jsx-curly-spacing.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ module.exports = {
244244

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

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

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

285285
return fixByTrimmingWhitespace(fixer, previousToken.range[1], token.range[0], 'end');

lib/rules/jsx-no-bind.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,13 @@ module.exports = {
132132

133133
function findVariableViolation(node, name) {
134134
getBlockStatementAncestors(node).find(
135-
block => reportVariableViolation(node, name, block.start)
135+
block => reportVariableViolation(node, name, block.range[0])
136136
);
137137
}
138138

139139
return {
140140
BlockStatement(node) {
141-
setBlockVariableNameSet(node.start);
141+
setBlockVariableNameSet(node.range[0]);
142142
},
143143

144144
VariableDeclarator(node) {
@@ -154,7 +154,7 @@ module.exports = {
154154
node.parent.kind === 'const' // only support const right now
155155
) {
156156
addVariableNameToSet(
157-
variableViolationType, node.id.name, blockAncestors[0].start
157+
variableViolationType, node.id.name, blockAncestors[0].range[0]
158158
);
159159
}
160160
},

lib/util/usedPropTypes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function isPropArgumentInSetStateUpdater(context, name) {
170170
unwrappedParentCalleeNode.property &&
171171
unwrappedParentCalleeNode.property.name === 'setState' &&
172172
// Make sure we are in the updater not the callback
173-
scope.block.parent.arguments[0].start === scope.block.start &&
173+
scope.block.parent.arguments[0].range[0] === scope.block.range[0] &&
174174
scope.block.parent.arguments[0].params &&
175175
scope.block.parent.arguments[0].params.length > 1
176176
) {

0 commit comments

Comments
 (0)