Skip to content

Code Quality: Use strict equality for boolean comparison in store.ts #3078

@maniktyagi04

Description

@maniktyagi04

Description

While reviewing the codebase, I noticed that line 253 in packages/pinia/src/store.ts uses loose equality (==) instead of strict equality (===) for a boolean comparison.

Current code:

} else if (isListening == false && !store._hotUpdating) {

Proposed fix:

} else if (isListening === false && !store._hotUpdating) {

Rationale

  • Using === instead of == is a JavaScript best practice
  • Prevents potential type coercion issues
  • Aligns with modern linting standards (ESLint, Prettier)
  • Makes the code more explicit and maintainable

Context

This code is in the onTrigger callback within the createSetupStore function, which handles debugger events during development mode. The isListening variable is declared as boolean type, so strict equality should be used.

Impact

  • Risk Level: Very Low
  • Breaking Changes: None
  • Behavior Change: None (strict equality produces the same result for boolean comparisons)
  • Code Quality: Improved

Testing

I have verified that all existing tests pass with this change:

  • ✅ 243 tests passed
  • ✅ Prettier formatting check passed

I will submit a pull request with this fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions