File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -26,18 +26,24 @@ This rule helps prevent the use of browser global variables that can cause error
2626
2727 /* ✓ GOOD */
2828 onMount(() => {
29- const a = window. localStorage.getItem('myCat');
29+ const a = localStorage.getItem('myCat');
3030 console.log(a);
3131 });
3232
3333 /* ✓ GOOD */
3434 if (browser) {
35- const a = window.localStorage.getItem('myCat');
35+ const a = localStorage.getItem('myCat');
36+ console.log(a);
37+ }
38+
39+ /* ✓ GOOD */
40+ if (typeof localStorage !== 'undefined') {
41+ const a = localStorage.getItem('myCat');
3642 console.log(a);
3743 }
3844
3945 /* ✗ BAD */
40- const a = window. localStorage.getItem('myCat');
46+ const a = localStorage.getItem('myCat');
4147 console.log(a);
4248</script>
4349```
You can’t perform that action at this time.
0 commit comments