react-doctor/client-localstorage-no-version
Bake a version into the storage key (e.g. "myKey:v1"); a future schema change can ignore old data instead of crashing on it
- Category: Correctness
- Severity: warn
- Source:
oxlint-plugin-react-doctor - Framework: global
- Enabled when: always
Validation prompt
Use this to decide whether a fired diagnostic is real or a false positive.
Confirm the call is localStorage.setItem or sessionStorage.setItem with a string-literal key that lacks a version suffix — the rule's regex /(?:[._:-]v\d+|@\d+|\bv\d+\b)/i already accepts keys like "prefs:v1", "cache@1", or "stateV2" — AND whose second argument is a literal JSON.stringify(...) call. False positive: the serialized payload itself already encodes a schema version field.
Fix prompt
Use this once validation confirms the diagnostic is real.
Append a version suffix to the storage key (e.g. "prefs" becomes "prefs:v1") and, on read, drop or migrate data from older keys so a future shape change skips stale entries instead of crashing JSON.parse. Bump the suffix anytime the stored shape changes. See https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API/Using_the_Web_Storage_API
Related rules
More Correctness rules from the rules reference:
react-doctor/exhaustive-deps: Match the deps array to what the hook callback actually captures, or stabilize/move recreated values instead of blindly adding them.react-doctor/html-no-invalid-paragraph-child: Replace the wrapping <p> with a <div>, or hoist the block-level child out of the paragraphreact-doctor/html-no-invalid-table-nesting: Author each table element under its required host parent: thead/tbody/tfoot in <table>, tr in a row group, td/th in <tr>react-doctor/html-no-nested-interactive: Hoist the inner interactive element out, or make the outer one a non-interactive wrapper: change <a><a/></a> to <a/> next to <a/>, or wrap with <div>/<span>react-doctor/jsx-no-comment-textnodes: Wrap JSX comments in `{/* … */}` so they're parsed as comments, not rendered as literal child text.