RegExp Query:
([\(\)\._a-zA-Z]*)\s\?\?=\s([\._a-zA-Z\(\)]*)
RegExp Substitue With:
$1 = ($1 === null || $1 === undefined) ? $2 : $1
Example:
| import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; | |
| import { render, act } from '#tests/utils'; | |
| import { FormProvider, useForm } from 'react-hook-form'; | |
| import { useResetFormAsync } from './useResetFormAsync'; | |
| import React, { useEffect } from 'react'; | |
| vi.useFakeTimers(); | |
| // Mock requestAnimationFrame to work with fake timers | |
| vi.spyOn(global, 'requestAnimationFrame').mockImplementation((cb) => { |
| function gitacp() { | |
| if git diff --quiet && git diff --cached --quiet; then | |
| echo "✅ No changes to commit. Exiting." | |
| return 0 | |
| fi | |
| if [ -z "$1" ]; then | |
| echo "Usage: gitac \"commit message\"" | |
| return 1 | |
| fi |
| //https://www.youtube.com/watch?v=AdmGHwvgaVs&t=414s | |
| const catchErrorTyped = <T, E extends new (message?: string) => | |
| Error>( | |
| p: Promise<T>, | |
| customErrors?: E[] | |
| ):Promise<(undefined| T)[] | [E]> => { | |
| return p.then((data:T) => { | |
| return [undefined, data]; |
| import mockRouter from "next-router-mock"; | |
| jest.mock("next/router", () => jest.requireActual("next-router-mock")); | |
| describe("Page useRouter hook", () => { | |
| it("renders", () => { | |
| mockRouter.push("/home?with=query"); | |
| //... | |
| }); |
| import useSWRInfinite from "swr/infinite"; | |
| jest.mock("swr/infinite"); | |
| describe("Page with SWRInfinite", () => { | |
| it("renders", () => { | |
| (useSWRInfinite as jest.Mock).mockResolvedValue({ | |
| data: [{ data: [] }], | |
| error: null, | |
| }); |
| /** | |
| * Based on this article | |
| * https://medium.com/geekculture/using-zoho-api-for-leads-in-node-js-ea204e98d41b | |
| */ | |
| /** | |
| * IMPORTANT: pay attention to the super-domain ("com", "eu", etc). | |
| * Must be the same you used for the client registration. | |
| * Otherwise will cause: `{ "error": "invalid_client" }` | |
| */ |
| import enumToArray from "./enumToArray"; | |
| enum Numbers { | |
| One = 'One', | |
| Two = 'Two', | |
| Three = 'Three' | |
| }; | |
| enum Empty {} |
RegExp Query:
([\(\)\._a-zA-Z]*)\s\?\?=\s([\._a-zA-Z\(\)]*)
RegExp Substitue With:
$1 = ($1 === null || $1 === undefined) ? $2 : $1
Example:
| /** @type {import('next').NextConfig} */ | |
| const nextConfig = { | |
| reactStrictMode: true, | |
| pageExtensions: [ | |
| 'mdx', | |
| 'md', | |
| 'jsx', | |
| 'tsx', | |
| 'ts' |