Skip to content

Commit

Permalink
ESLint Plugin: Destructure references immediatley prior to use
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Jul 29, 2019
1 parent d45c8ea commit 44a4ac9
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions packages/eslint-plugin/rules/react-no-unsafe-timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ module.exports = {
create( context ) {
return {
'CallExpression[callee.name="setTimeout"]'( node ) {
const { references } = context.getScope();

// If the result of a `setTimeout` call is assigned to a
// variable, assume the timer ID is handled by a cancellation.
const hasAssignment = (
Expand Down Expand Up @@ -74,6 +72,7 @@ module.exports = {
// Consider whether `setTimeout` is a reference to the global
// by checking references to see if `setTimeout` resolves to a
// variable in scope.
const { references } = context.getScope();
const hasResolvedReference = references.some( ( reference ) => (
reference.identifier.name === 'setTimeout' &&
!! reference.resolved &&
Expand Down

0 comments on commit 44a4ac9

Please sign in to comment.