Skip to content

Commit a116c1f

Browse files
authored
Merge pull request #6 from opentoolsteam/jelkins/fix-tests
this PR is to fix tests & linters
2 parents 5bc7e55 + 3977a1c commit a116c1f

File tree

16 files changed

+1030
-739
lines changed

16 files changed

+1030
-739
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
description: Cursor rules derived by SpecStory from the project AI interaction history
3+
globs: *
4+
---
5+
6+
## PROJECT OVERVIEW
7+
This project is a Node.js based CLI tool. The source code is written in TypeScript.
8+
9+
## CODE STYLE
10+
Adhere to standard TypeScript coding conventions. Use Prettier for formatting.
11+
12+
## FOLDER ORGANIZATION
13+
The project follows a standard structure:
14+
- `src`: Source code.
15+
- `test`: Unit tests.
16+
- `cli`: Contains the CLI application's entry point and related files.
17+
18+
19+
## TECH STACK
20+
- Node.js
21+
- TypeScript
22+
- npm
23+
- shx (used in build script)
24+
- OCLIF (used for CLI framework)
25+
- zod (added 2025-03-12)
26+
27+
28+
## PROJECT-SPECIFIC STANDARDS
29+
- All commands should be defined in the `src/commands` directory.
30+
- Unit tests should be written for every command. Tests should accurately reflect command functionality. Avoid simple string matching in tests; instead verify behavior.
31+
- The `package.json` file should clearly define the entry point for the CLI.
32+
- Avoid using `any` type; explicitly define types for all variables to prevent runtime errors. (Added 2025-03-12)
33+
- Interface properties should be sorted alphabetically to satisfy `perfectionist/sort-object-types` linting rule. (Added 2025-03-12)
34+
35+
36+
## WORKFLOW & RELEASE RULES
37+
- Before running the CLI, build the TypeScript code using `npm run build`.
38+
- Version updates will be managed using semantic versioning. (Further details on versioning strategy needed)
39+
- To resolve TypeScript errors and missing modules, follow the steps outlined in `2025-03-12_14-21-fixing-typescript-errors-and-missing-modules.md`. This includes installing `zod` and correctly typing variables to avoid `'value' is of type 'unknown'` errors. The `npm install zod` command will install the necessary dependency. Type assertions like `as [string, EnvVariable][]` may be necessary to resolve type errors related to 'unknown' types.
40+
- To run tests, use `npm run test`. Tests should be updated to reflect actual command behavior, not simple string matching. Remove tests for commands that do not exist. Use `npm run lint -- --fix` to automatically fix many linting errors. To run tests without linting, use `npm test --no-posttest`.
41+
- Address deprecation warnings related to `fs.Stats` constructor.
42+
43+
44+
## REFERENCE EXAMPLES
45+
- Running the CLI from source: See instructions in `2025-03-11_12-54-running-a-package-from-source-instructions.md`
46+
- Fixing TypeScript errors and missing modules: See `2025-03-12_14-21-fixing-typescript-errors-and-missing-modules.md`
47+
- Fixing type issues in `uninstall.ts`: See `2025-03-12_15-33-fixing-type-issues-in-uninstall-ts.md`
48+
49+
50+
## PROJECT DOCUMENTATION & CONTEXT SYSTEM
51+
Documentation will be maintained using markdown files and integrated into the repository.
52+
53+
## DEBUGGING
54+
- Ensure the TypeScript code is built (`npm run build`) before running the CLI.
55+
- The error "command i not found" indicates that the TypeScript code needs to be compiled.
56+
- `'value' is of type 'unknown'` errors in TypeScript indicate improperly typed variables. Refer to `2025-03-12_14-21-fixing-typescript-errors-and-missing-modules.md` for solutions.
57+
- Missing module errors (e.g., "Cannot find module 'zod'") indicate missing dependencies. Use `npm install` to install required packages.
58+
- Test failures often indicate a mismatch between test expectations and actual command output. Refactor tests to reflect actual command behavior.
59+
- Deprecation warnings related to `fs.Stats` constructor indicate outdated code. Update the relevant code sections.
60+
- Use `npm run lint -- --fix` to automatically fix many linting errors.
61+
- `any` type errors indicate a need for explicit type definitions. Properly type variables to resolve these errors. (Added 2025-03-12)
62+
- `perfectionist/sort-object-types` linting errors indicate improperly ordered object properties. Ensure properties are alphabetically ordered. (Added 2025-03-12)
63+
64+
65+
## FINAL DOs AND DON'Ts
66+
- **DO** use TypeScript.
67+
- **DO** write unit tests that accurately reflect command functionality.
68+
- **DO** build the project using `npm run build` before running.
69+
- **DO** follow the folder organization guidelines.
70+
- **DO** install all necessary dependencies using `npm install`.
71+
- **DO** explicitly define types for all variables to avoid runtime errors. (Added 2025-03-12)
72+
- **DO** sort object properties alphabetically to satisfy linting rules. (Added 2025-03-12)
73+
- **DON'T** run the CLI without building the TypeScript code first.
74+
- **DON'T** leave variables untyped; ensure proper type declarations to avoid runtime errors.
75+
- **DON'T** write tests that rely on simple string matching of command output. Focus on verifying actual command behavior.
76+
- **DON'T** ignore deprecation warnings; address them promptly to maintain code quality and avoid future compatibility issues.
77+
- **DON'T** ignore linting errors; address them using `npm run lint -- --fix` or manually.
78+
- **DON'T** use `any` type unless absolutely necessary and with clear justification. (Added 2025-03-12)
79+
- **DON'T** leave object properties unsorted; maintain alphabetical order for consistency and to satisfy linting rules. (Added 2025-03-12)

.cursorignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ignore SpecStory derived-cursor-rules.mdc backup files
2+
.specstory/cursor_rules_backups/*

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ yarn.lock
1010
pnpm-lock.yaml
1111
*.tsbuildinfo
1212
.vscode/
13+
.specstory

package-lock.json

Lines changed: 152 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@
1010
"dependencies": {
1111
"@inquirer/prompts": "^7.2.1",
1212
"@oclif/core": "^4",
13-
"@oclif/plugin-help": "^6"
13+
"@oclif/plugin-help": "^6",
14+
"sinon": "^19.0.2",
15+
"zod": "^3.24.2"
1416
},
1517
"devDependencies": {
1618
"@oclif/prettier-config": "^0.2.1",
1719
"@oclif/test": "^4",
1820
"@types/chai": "^4",
1921
"@types/mocha": "^10",
2022
"@types/node": "^18",
23+
"@types/sinon": "^17.0.4",
2124
"chai": "^4",
2225
"eslint": "^8",
2326
"eslint-config-oclif": "^5",
@@ -27,7 +30,7 @@
2730
"oclif": "^4",
2831
"shx": "^0.3.3",
2932
"ts-node": "^10",
30-
"typescript": "^5"
33+
"typescript": "~5.3.3"
3134
},
3235
"engines": {
3336
"node": ">=18.0.0"

0 commit comments

Comments
 (0)