Skip to content

Commit f73d3ee

Browse files
committed
chore: add clarity and cursor rules
1 parent d19fe7f commit f73d3ee

File tree

12 files changed

+476
-43
lines changed

12 files changed

+476
-43
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: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
---
2+
description: General information based on the latest ./README.md content
3+
globs:
4+
---
5+
Update it if APIs change:
6+
7+
# ts-datetime
8+
9+
A modern, immutable, and fully-typed TypeScript datetime library inspired by Carbon (PHP) and Day.js.
10+
11+
## Features
12+
13+
- 🔄 **Immutable API** _All operations return new instances_
14+
- ⛓️ **Fluent Interface** _Chainable, readable, and expressive_
15+
- 🌍 **Locale Support** _Global, per-instance, and per-call configuration_
16+
- 📅 **Robust Parsing** _ISO, timestamps, relative strings (e.g. "next week", "+2 days")_
17+
- ⏱️ **Intervals & Periods** _Built-in support for durations and date ranges_
18+
- 💪 **TypeScript First** _Fully typed, with great DX in modern editors_
19+
- ✅ **Tested** _Thoroughly tested for edge cases and correctness_
20+
21+
## Installation
22+
23+
```bash
24+
# npm
25+
npm install @stacksjs/ts-datetime
26+
27+
# pnpm
28+
pnpm add @stacksjs/ts-datetime
29+
30+
# yarn
31+
yarn add @stacksjs/ts-datetime
32+
33+
# bun
34+
bun add @stacksjs/ts-datetime
35+
```
36+
37+
## Quick Examples
38+
39+
```ts
40+
import { Datetime, DatetimeInterval, DatetimePeriod } from 'ts-datetime'
41+
42+
// Creating dates
43+
const now = Datetime.now()
44+
const tomorrow = Datetime.tomorrow()
45+
const specificDate = new Datetime('2024-01-01T12:00:00Z')
46+
47+
// Manipulation
48+
const nextWeek = now.addDays(7)
49+
const lastMonth = now.subMonths(1)
50+
51+
// Formatting
52+
console.log(specificDate.format('YYYY-MM-DD')) // "2024-01-01"
53+
console.log(now.diffForHumans()) // "just now"
54+
55+
// Intervals
56+
const interval = DatetimeInterval.days(5).add(DatetimeInterval.hours(12))
57+
console.log(interval.forHumans()) // "5 days 12 hours"
58+
59+
// Periods (date ranges)
60+
const period = new DatetimePeriod(
61+
new Datetime('2024-01-01'),
62+
new Datetime('2024-01-10'),
63+
DatetimeInterval.days(2)
64+
)
65+
66+
// Iterate over period
67+
for (const date of period) {
68+
console.log(date.format('YYYY-MM-DD'))
69+
}
70+
// 2024-01-01, 2024-01-03, 2024-01-05, 2024-01-07, 2024-01-09
71+
```
72+
73+
## Documentation
74+
75+
For full documentation, visit [ts-datetime.netlify.app](https://ts-datetime.netlify.app).
76+
77+
- [Introduction](https://ts-datetime.netlify.app/intro)
78+
- [Installation](https://ts-datetime.netlify.app/install)
79+
- [Usage](https://ts-datetime.netlify.app/usage)
80+
- [Configuration](https://ts-datetime.netlify.app/config)
81+
82+
### Feature Documentation
83+
84+
- [Immutable API](https://ts-datetime.netlify.app/features/immutable-api)
85+
- [Formatting](https://ts-datetime.netlify.app/features/formatting)
86+
- [Intervals](https://ts-datetime.netlify.app/features/intervals)
87+
- [Periods](https://ts-datetime.netlify.app/features/periods)
88+
- [Human Diffs](https://ts-datetime.netlify.app/features/human-diffs)
89+
- [Relative Strings](https://ts-datetime.netlify.app/features/relative-strings)
90+
91+
### Advanced Topics
92+
93+
- [Localization](https://ts-datetime.netlify.app/advanced/localization)
94+
- [Type Safety](https://ts-datetime.netlify.app/advanced/type-safety)
95+
- [Performance](https://ts-datetime.netlify.app/advanced/performance)
96+
- [Testing](https://ts-datetime.netlify.app/advanced/testing)
97+
98+
## Testing
99+
100+
```bash
101+
bun test
102+
```
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

0 commit comments

Comments
 (0)