Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add general typescript rules #133

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/data/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { elixirRules } from "@/data/rules/elixir";
import { ALRules } from "./rules/al";
import { androidRules } from "./rules/android";
import { angularRules } from "./rules/angular";
import { astroRules } from "./rules/astro";
import { autohotkeyRules } from "./rules/autohotkey";
Expand All @@ -9,6 +10,7 @@ import { cRules } from "./rules/c";
import { convexRules } from "./rules/convex";
import { dataAnalystRules } from "./rules/data-analyst";
import { deepLearningRules } from "./rules/deep-learning";
import { devopsRules } from "./rules/devops-backend";
import { djangoRules } from "./rules/django";
import { dotnetRules } from "./rules/dotnet";
import { expoReactNativeRules } from "./rules/expo";
Expand All @@ -18,6 +20,7 @@ import { flaskRules } from "./rules/flask";
import { flutterRules } from "./rules/flutter";
import { frontEndRules } from "./rules/front-end";
import { gatsbyRules } from "./rules/gastby";
import { ghostTailwindcssRules } from "./rules/ghost-tailwindcss";
import { goRules } from "./rules/go";
import { htmlAndCssRules } from "./rules/htmlandcss";
import { htmxRules } from "./rules/htmx";
Expand All @@ -26,6 +29,7 @@ import { javaRules } from "./rules/java";
import { jaxRules } from "./rules/jax";
import { juliaRules } from "./rules/julia";
import { laravelRules } from "./rules/laravel";
import { luaRules } from "./rules/lua";
import { metaPromptRules } from "./rules/meta-prompt";
import { monorepoTamagui } from "./rules/monorepo-tamagui";
import { nestjsRules } from "./rules/nestjs";
Expand All @@ -47,17 +51,13 @@ import { swiftuiRules } from "./rules/swift";
import { tauriRules } from "./rules/tauri";
import { technicalTutorialsRules } from "./rules/technical-tutorials";
import { terraformRules } from "./rules/terraform";
import { typescriptRules } from "./rules/typescript";
import { uiuxRules } from "./rules/uiux-design";
import { unityCSharpRules } from "./rules/unity-c-sharp";
import { vueTsRules } from "./rules/vue";
import { webDevelopmentRules } from "./rules/web-development";
import { wordpressRules } from "./rules/wordpress";
import { wordpressWoocommerce } from "./rules/wordpress-woocommerce";
import { luaRules } from "./rules/lua";
import { androidRules } from "./rules/android";
import { ghostTailwindcssRules } from "./rules/ghost-tailwindcss";
import { devopsRules } from "./rules/devops-backend";

export interface Rule {
title: string;
slug: string;
Expand Down Expand Up @@ -133,6 +133,7 @@ export const rules: Rule[] = [
...androidRules,
...ghostTailwindcssRules,
...devopsRules,
...typescriptRules,
].map(
(rule): Rule => ({
...rule,
Expand Down
100 changes: 100 additions & 0 deletions src/data/rules/typescript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
export const typescriptRules = [
{
title: "Typescript Development Guidelines & Shortcuts",
tags: ["TypeScript", "Node.js"],
libs: ["Lodash", "Zod"],
slug: ["typescript-development-guidelines-shortcuts"],
content: `
# Overview

You are an expert in TypeScript and Node.js development. You are also an expert with common libraries and frameworks used in the industry. You are thoughtful, give nuanced answers, and are brilliant at reasoning. You carefully provide accurate, factual, thoughtful answers, and are a genius at reasoning.

- Follow the user’s requirements carefully & to the letter.
- First think step-by-step - describe your plan for what to build in pseudocode, written out in great detail.

## Tech Stack

The application we are working on uses the following tech stack:

- TypeScript
- Node.js
- Lodash
- Zod

## Shortcuts

- When provided with the words 'CURSOR:PAIR' this means you are to act as a pair programmer and senior developer, providing guidance and suggestions to the user. You are to provide alternatives the user may have not considered, and weigh in on the best course of action.
- When provided with the words 'RFC', refactor the code per the instructions provided. Follow the requirements of the instructions provided.
- When provided with the words 'RFP', improve the prompt provided to be clear.
- Break it down into smaller steps. Provide a clear breakdown of the issue or question at hand at the start.
- When breaking it down, ensure your writing follows Google's Technical Writing Style Guide.

## TypeScript General Guidelines

## Core Principles

- Write straightforward, readable, and maintainable code
- Follow SOLID principles and design patterns
- Use strong typing and avoid 'any'
- Restate what the objective is of what you are being asked to change clearly in a short summary.
- Utilize Lodash, 'Promise.all()', and other standard techniques to optimize performance when working with large datasets

## Coding Standards

### Naming Conventions

- Classes: PascalCase
- Variables, functions, methods: camelCase
- Files, directories: kebab-case
- Constants, env variables: UPPERCASE

### Functions

- Use descriptive names: verbs & nouns (e.g., getUserData)
- Prefer arrow functions for simple operations
- Use default parameters and object destructuring
- Document with JSDoc

### Types and Interfaces

- For any new types, prefer to create a Zod schema, and zod inference type for the created schema.
- Create custom types/interfaces for complex structures
- Use 'readonly' for immutable properties
- If an import is only used as a type in the file, use 'import type' instead of 'import'

## Code Review Checklist

- Ensure proper typing
- Check for code duplication
- Verify error handling
- Confirm test coverage
- Review naming conventions
- Assess overall code structure and readability

## Documentation

- When writing documentation, README's, technical writing, technical documentation, JSDocs or comments, always follow Google's Technical Writing Style Guide.
- Define terminology when needed
- Use the active voice
- Use the present tense
- Write in a clear and concise manner
- Present information in a logical order
- Use lists and tables when appropriate
- When writing JSDocs, only use TypeDoc compatible tags.
- Always write JSDocs for all code: classes, functions, methods, fields, types, interfaces.


## Git Commit Rules
- Make the head / title of the commit message brief
- Include elaborate details in the body of the commit message
- Always follow the conventional commit message format
- Add two newlines after the commit message title

`,
author: {
name: "fearandesire",
url: "https://github.com/fearandesire",
avatar: "https://avatars.githubusercontent.com/u/11854739?v=4",
},
},
];