Skip to content

Commit 006e610

Browse files
committed
chore: add clarity
1 parent 40d7d74 commit 006e610

File tree

12 files changed

+592
-157
lines changed

12 files changed

+592
-157
lines changed

.cursor/rules/code-style.mdc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
description: Code Style & Structure specifics
3+
globs:
4+
---
5+
## Code Style & Structure
6+
7+
- Write concise, technical TypeScript code with accurate examples in the docblock
8+
- If Bun native modules are available, use them
9+
- Use functional and declarative programming patterns; avoid classes unless needed
10+
- Prefer iteration and modularization over code duplication
11+
- Use descriptive variable names with auxiliary verbs (e.g., `isLoading`, `hasError`)
12+
- Use proper jsdoc comments for functions, types, interfaces, and ensure examples are accurate

.cursor/rules/documentation.mdc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
description: Documentation specific rules
3+
globs: docs/**/*.md
4+
---
5+
## Documentation
6+
7+
- Write documentation for all functions, types, interfaces, and ensure examples are accurate
8+
- The `./docs` directory is where the vitepress markdown documentation is stored
9+
- Make sure to update the docs markdown files

.cursor/rules/error-handling.mdc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: Error Handling and Validation specifics
3+
globs:
4+
---
5+
## Error Handling and Validation
6+
7+
- Prioritize error handling: handle errors and edge cases early
8+
- Use early returns and guard clauses
9+
- Implement proper error logging and user-friendly messages
10+
- Use error boundaries for unexpected errors
11+
- when `neverthrow` is available, ensure errors are typed

.cursor/rules/key-conventions.mdc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: Key code conventions
3+
globs:
4+
---
5+
## Key Conventions
6+
7+
- If there are two equally valid implementations, the browser version should be preferred
8+
- Aim for 100% test coverage
9+
- Avoid usage of `any`
10+
- Reuse eslint-ignore comments where present, unless not needed
11+
- ensure we log everything properly, including for debug reasons
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
description: Project structure information
3+
globs:
4+
---
5+
## Project Structure
6+
7+
- the `./src` directory is the source code
8+
- the `./test` directory is the test code
9+
- the `./bin` directory is the command-line code
10+
- you can also call the CLI via `./clarity ...`
11+
- the `./docs` directory is the documentation

.cursor/rules/readme.mdc

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
description: General information based on the latest ./README.md content
3+
globs:
4+
---
5+
Update it if APIs change:
6+
7+
# TS-Inputs
8+
9+
A TypeScript library providing specialized input handling and formatting for various data types.
10+
11+
## Overview
12+
13+
TS-Inputs is a modular library that provides specialized input handling, formatting, and validation for different types of data. It's designed to be used in web applications where precise input control and formatting are required.
14+
15+
## Features
16+
17+
- **Credit Card Input**: Formatting and validation for credit card numbers
18+
- **Date Input**: Specialized date input handling
19+
- **Time Input**: Time format handling
20+
- **Numeral Input**: Number formatting and validation
21+
- **General Input**: Common input handling utilities
22+
- **Cursor Tracker**: Input cursor position tracking
23+
24+
## Project Structure
25+
26+
```
27+
src/
28+
├── common/ # Shared utilities and types
29+
│ ├── types.ts # Common type definitions
30+
│ └── utils.ts # Shared utility functions
31+
├── credit-card/ # Credit card input handling
32+
├── cursor-tracker/ # Cursor position tracking
33+
├── date/ # Date input handling
34+
├── general/ # General input utilities
35+
├── numeral/ # Number formatting
36+
└── time/ # Time input handling
37+
```
38+
39+
## Common Utilities
40+
41+
The library provides several common utilities and types:
42+
43+
- `RequireExactlyOne`: Type utility for requiring exactly one property from a set
44+
- `DelimiterType`: Type definition for input delimiters
45+
- `BlocksType`: Type for input block definitions
46+
- Various interfaces for input formatting and delimiter handling
47+
48+
## Usage
49+
50+
```typescript
51+
import { creditCard, date, numeral, time } from 'ts-inputs'
52+
53+
// Example usage with credit card input
54+
const formattedCard = creditCard.format('4111111111111111')
55+
// Result: '4111 1111 1111 1111'
56+
```
57+
58+
## Installation
59+
60+
```bash
61+
npm install ts-inputs
62+
# or
63+
yarn add ts-inputs
64+
```
65+
66+
## Contributing
67+
68+
Contributions are welcome! Please feel free to submit a Pull Request.
69+
70+
## Testing
71+
72+
```bash
73+
bun test
74+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
description: Syntax and Formatting specifics
3+
globs:
4+
---
5+
## Syntax and Formatting
6+
7+
- Use the "function" keyword for pure functions
8+
- Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements
9+
- Make sure everything is properly commented

.cursor/rules/testing.mdc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
description: Testing specifics
3+
globs:
4+
---
5+
## Testing
6+
7+
- Write tests for all functions, types, interfaces, and ensure examples are accurate
8+
- The `./test` directory is where the tests are stored
9+
- Use `bun test` to run the tests
10+
- Use bun native modules for testing from `import { x, y, z } from 'bun:test'`

.cursor/rules/typescript.mdc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
description: TypeScript Usage specifics
3+
globs: docs/**/*.md
4+
---
5+
## TypeScript Usage
6+
7+
- Use TypeScript for all code; prefer interfaces over types
8+
- Avoid enums; use `maps` instead, or `as const`
9+
- Use functional components with TypeScript interfaces

bun.lock

Lines changed: 428 additions & 157 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)