| name | no-use-effect |
|---|---|
| description | Enforce the no-useEffect rule when writing or reviewing React code. ACTIVATE when writing React components, refactoring existing useEffect calls, reviewing PRs with useEffect, or when an agent adds useEffect "just in case." Provides the five replacement patterns and the useMountEffect escape hatch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import type { Prettify } from 'ts-essentials'; | |
| export type Result<T = unknown, E = unknown> = Success<T> | Failure<E>; | |
| export interface Success<T> { | |
| kind: 'success'; | |
| value: T; | |
| } | |
| export interface Failure<E> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * If argument is a string, try to parse as JSON. | |
| * Otherwise return null. | |
| */ | |
| export function parseOrNull(raw: unknown) { | |
| if (!raw) return null | |
| if (typeof raw === 'string') { | |
| try { | |
| return JSON.parse(raw) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const uuid = () => Date.now().toString(36) + Math.random().toString(36).substr(2); |
I’ve written a newer optimized 2026 version of this guide with a faster setup using Zinit + Starship and improved plugin loading.
This version avoids slow shell startups and works better with modern Zsh setups.
Updated guide: https://gist.github.com/n1snt/2cccc8aa5f7b645a7628d3512c70deb6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum LocalStorageExpired { | |
| INFINITE = 'INFINITE', | |
| LOGOUT = 'LOGOUT', | |
| } | |
| class LocalStorageService { | |
| prefix = 'GG_'; | |
| get<T extends unknown>(key: string, defaultValue: T): T { | |
| try { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Who needs eventemitter3, mitt, or some other library when you can use native DOM APIs? 😁 | |
| let eventEmitter = new EventTarget(); | |
| eventEmitter.addEventListener('test', console.log); // CustomEvent { type: 'test', detail: 123, ... } | |
| eventEmitter.dispatchEvent(new CustomEvent('test', { detail: 123 })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function createRoundedRectPath(x, y, width, height, radius) { | |
| return ( | |
| // Move to position, offset by radius in x direction | |
| "M" +(x + radius) + "," + y | |
| // Draw a horizontal line to the top right curve start | |
| + "h" + (width - 2 * radius) | |
| // Draw the top right corner curve | |
| + "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius | |
| // Draw a vertical line to the bottom right corner | |
| + "v" + (height - 2 * radius) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from 'axios'; | |
| import { LANGUAGE_NAME, REFRESH_TOKEN_IN_STORE, TOKEN_NAME_IN_STORE } from '../constants/api'; | |
| import { getBrowserLang, setTokens } from './GlobalHelper'; | |
| import { logoutDispatch } from './StoreHelper'; | |
| import LocalStorageHelper from './LocalStorageHelper'; | |
| import { BACKEND_ROUTES } from '../constants/routes'; | |
| export const API_REQUEST_AUTH_USER_LOGIN_URL = '/users/login'; | |
| export const API_REQUEST_AUTH_USER_LOGIN_SOCIAL_URL = '/login/social'; |
NewerOlder
