agentleFS
hiromailyhiromaily/go-crypto-wallet/.cursor/rules/typescript.mdc

go-crypto-wallet / rules

Cursor rule128 starsChanged 6 months agoMITView on GitHub

TypeScript/JavaScript File Rules

  • Installs packages

We split this typescript.mdc into the rules it gives an agent

6 rules. About 0 are common, 5 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈5

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Never use nullish coalescing (??) with empty string for critical values like secrets or keys.

    line 87
  2. Distinctive:

    Instead, throw an error to fail fast and prevent silent failures.

    line 88
  3. Distinctive:

    Prefer named exports over default exports for consistency and better tooling support.

    line 103
  4. Distinctive:

    No hardcoded secrets or API keys

    line 152
  5. Distinctive:

    No sensitive data in logs

    line 153
  6. Distinctive:

    Use environment variables for configuration

    line 155

≈ “Common” is an estimate: at least 1 in 5 of the 6,350 Cursor rule files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
typescript.mdc
---
description: TypeScript/JavaScript File Rules
globs: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx"]
alwaysApply: false
---


# TypeScript/JavaScript File Rules

## Overview

Rules for modifying TypeScript (`*.ts`, `*.tsx`) and JavaScript (`*.js`, `*.jsx`) files in go-crypto-wallet.

## Applicable Directories

| App              | Language              | Runtime | Path                     | Status                     |
| ---------------- | --------------------- | ------- | ------------------------ | -------------------------- |
| xrpl-grpc-server | TypeScript            | **Bun** | `apps/xrpl-grpc-server/` | **READ-ONLY** (deprecated) |
| eth-contracts    | JavaScript/TypeScript | Node.js | `apps/eth-contracts/`      | Active                     |

## Verification Commands

**Navigate to app directory first:**

### xrpl-grpc-server (TypeScript + Bun) - Active Development

```bash
cd apps/xrpl-grpc-server
bun install           # Install dependencies (if needed)
bun run lint          # Lint with Biome
bun run format        # Format with Biome
bun run typecheck     # TypeScript type checking
bun run dev           # Run dev server with hot reload
bun run build         # Build for production
bun run proto         # Generate protobuf code
```

> **Important**: See @.claude/rules/apps/bun.md for Bun runtime rules.
> **DO NOT** use `npm`/`npx` commands - always use `bun`/`bunx` instead.

### eth-contracts (JavaScript/Solidity)

```bash
cd apps/eth-contracts
npm install           # Install dependencies (if needed)
npm run lint          # Lint Solidity files
npm run lint-js       # Lint JavaScript/TypeScript files
npm run fmt           # Format all files with Prettier
npm run build         # Compile contracts with Truffle
npm run test-all      # Run all tests
```

## Command Summary

| App              | Lint              | Format           | Build           | Test                |
| ---------------- | ----------------- | ---------------- | --------------- | ------------------- |
| xrpl-grpc-server | `bun run lint`    | `bun run format` | `bun run build` | `bun run typecheck` |
| eth-contracts    | `npm run lint-js` | `npm run fmt`    | `npm run build` | `npm run test-all`  |

## Code Style

### TypeScript Best Practices

```typescript
// Good: Explicit types
function getBalance(address: string): Promise<number> {
  // ...
}

// Good: Async/await with error handling
async function fetchData(): Promise<Data> {
  try {
    const result = await api.call();
    return result;
  } catch (error) {
    throw new Error(`Failed to fetch data: ${error.message}`);
  }
}

// Avoid: any type (unless absolutely necessary)
// Bad: function process(data: any)
// Good: function process(data: TransactionData)
```

### Critical Value Handling

Never use nullish coalescing (`??`) with empty string for critical values like secrets or keys.
Instead, throw an error to fail fast and prevent silent failures.

```typescript
// Bad: Silently returns empty string if seed is undefined
const secret = wallet.seed ?? "";

// Good: Fail fast with explicit error
if (!wallet.seed) {
  throw new Error("Failed to generate a wallet seed.");
}
const secret = wallet.seed;
```

### Module Exports

Prefer named exports over default exports for consistency and better tooling support.

```typescript
// Bad: Mixed exports cause inconsistent import styles
export const myService = { ... };
export default myService;

// Good: Named exports only
export const myService = { ... };
```

### Import Order

1. Node.js built-ins
2. External packages
3. Internal modules

#### xrpl-grpc-server (xrpl.js 4.5.0)

```typescript
import * as path from "path";

import { Client, Wallet, xrpToDrops, dropsToXrp } from "xrpl";
import { createConnectRouter } from "@connectrpc/connect";

import { AccountService } from "./services/account";
```

#### eth-contracts

```typescript
import * as path from "path";

import { ethers } from "ethers";

import { TokenService } from "./services/token";
```

## Auto-Generated Files

**DO NOT EDIT:**

| App              | Generated Files                                                  |
| ---------------- | ---------------------------------------------------------------- |
| xrpl-grpc-server | `apps/xrpl-grpc-server/src/protogen/` (Buf/ConnectRPC generated) |
| eth-contracts    | `apps/eth-contracts/build/` (Truffle build artifacts)              |

## Security

- No hardcoded secrets or API keys
- No sensitive data in logs
- Input validation at boundaries
- Use environment variables for configuration

## Quick Checklist

### xrpl-grpc-server (Active)

- [ ] `bun run lint` passes
- [ ] `bun run format` applied
- [ ] `bun run typecheck` passes
- [ ] `bun run build` passes
- [ ] No `any` types (unless documented reason)
- [ ] Async errors properly handled

### eth-contracts

- [ ] `npm run lint-js` passes
- [ ] `npm run fmt` applied
- [ ] `npm run build` passes
- [ ] `npm run test-all` passes

## Related Documentation

- @apps/xrpl-grpc-server/README.md - xrpl-grpc-server documentation
- @apps/xrpl-grpc-server/docs/MIGRATION-GUIDE.md - Migration guide from ripple-lib
- @apps/xrpl-grpc-server/package.json - xrpl-grpc-server scripts
- @apps/eth-contracts/package.json - eth-contracts scripts

## Related Skills

- `typescript-development` - Full TypeScript workflow
- `solidity-development` - For Solidity contracts in eth-contracts

## Related Rules

- @.claude/rules/apps/bun.md - Bun runtime rules (use bun/bunx instead of npm/npx)
- @.claude/rules/apps/xrp-server.md - XRP server directory rules

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.