General
PromptBeginner5 minmarkdown
<h1 align="center">
<a href="https://prompts.chat">
5
globs:
Sign in to like and favorite skills
const over let (never use var)import and export (never use CJS require)
.js, .ts or .tsx).import { Foo } from './foo'import { type Route } from './types/root'import zod from 'zod'import { logger } from '~/types'import { Foo } from './foo.js'import { type Route } from './types/root.js'import { Foo } from './foo.ts'All packages must follow these
package.json rules:
type must be set to modulePartial, Pick, Omit) to manipulate existing typesany/unknown or casting values like (value as any) in TypeScript outside of test files e.g. *.test.ts or test fixtures e.g. **/test-data.ts.typeof, ReturnType<>, Awaited<>, etc for complex type inference (it's ok for simple types)as const as needed for better type inferencefunction myFunction({ foo, bar }: { foo: boolean; bar: string }) {} function VideoPlayer({ sid }: { sid: string }) {}
function myFunction(foo: boolean, bar: string, baz: number) {}
function myFunction({ foo, bar }: { foo: boolean; bar: string }) {}
function myFunction(args: { foo: boolean; bar: string }) { const { foo, bar } = args }
z.union([ z.literal('youtube'), z.literal('spotify') ]) is better than this enum z.enum([ 'youtube', 'spotify' ])async functions which implicitly create Promises) must always be properly handled, either via:
await to wait for the Promise to resolve successfully.then or .catch to handle Promise resolutionnode: protocol when importing Node.js modules (e.g., import fs from 'node:fs/promises')Always prefer using standard web APIs like
fetch, WebSocket, and ReadableStream when possible. Avoid redundant libraries (like node-fetch).
fetch API for making HTTP requests instead of Node.js modules like http or https
fetch API instead of node-fetch or polyfilled cross-fetchky library for HTTP requests instead of axios or superagentURL and URLSearchParams classes instead of the Node.js url moduleRequest and Response objects from the Fetch API instead of Node.js-specific request and response objectsasync/await over .then() and .catch()try/catch or .catch())Comments should be used to document and explain code. They should complement the use of descriptive variable and function names and type declarations.
console for logging.[target].test.ts and placed in the same directory as the code they are testing (NOT a separate directory)
src/my-file.ts and src/my-file.test.tssrc/my-file.ts and src/test/my-file.test.ts or test/my-file.test.ts or src/__tests__/my-file.test.tspnpm test:unitany/unknown in test files (such as *.test.ts) or test fixtures (like **/test-data.ts) to facilitate mocking or stubbing external modules or partial function arguments, referencing the usage guidelines in the TypeScript section.git add and git commit commands into a single git commit -am command, to speed things up