Skip to content

Instantly share code, notes, and snippets.

@TClark1011
TClark1011 / .lintstagedrc.cjs
Last active January 25, 2022 07:01
Bag of Holding V2 Configs
module.exports = {
"*.{js,ts,svelte}": "eslint --cache --fix",
"*.{js,css,md,ts,svelte}": "prettier --write",
};
@TClark1011
TClark1011 / instructions.md
Last active January 24, 2022 06:30
SvelteKit TS - Jest Setup

First run

yarn add --dev jest babel-jest @babel/preset-env svelte-jester jest-transform-stub @testing-library/svelte @testing-library/user-event babel-plugin-transform-vite-meta-env @testing-library/jest-dom ts-jest

Then copy over jest.config.json into project root.

Run with

@TClark1011
TClark1011 / Action.ts
Last active April 15, 2025 05:48
TS - Helpful Utilities
// branded types to allow for better type inference
// with default generic types
/* eslint-disable @typescript-eslint/naming-convention */
type NO_PAYLOAD = {
JgJES6BF8uyaOwF1: "FY7eBhPYJlqOxuVp";
};
type OPTIONAL_PAYLOAD = {
A7nWdXs0r5RLuHRf: "zPcrRNRIl4r5IHbA";
};
@TClark1011
TClark1011 / Event Functions In React.md
Last active October 22, 2024 05:12
React Utilities

Event Functions In React

When writing functions that can handle various different types of dom events in react, it's important to remember that react uses its own custom type of events which it calls "synthetic events". To best handle these, we create a custom type which can be either a native event or a react synthetic event.

Example code

import type { SyntheticEvent } from 'react';

type ReactCompatibleEvent = Event | SyntheticEvent;
@TClark1011
TClark1011 / theme.ts
Last active December 8, 2021 04:45
React - Personal Chakra UI Theme Setup
import { extendTheme } from '@chakra-ui/react';
export const theme = extendTheme({
layerStyles: {
noFocusOutline: {
'--chakra-shadows-outline': 'none',
},
},
config: {
useSystemColorMode: true,