Skip to content

Commit c4b6e2e

Browse files
authored
Change test command and add config for Coding Agent (#331)
* chore: change test script name Claude Code often uses `npm run test` to run unit tests. However, it should be using `npm run test:vitest` instead. It seems the model is overfitted and prefers using `npm run test`. Therefore, we will change `npm run test` to the command for running unit tests. * chore: remove copilot-instructions.md * chore: add AGENTS.md * chore: `ln -s AGENTS.md CLAUDE.md`
1 parent d89f583 commit c4b6e2e

7 files changed

Lines changed: 136 additions & 73 deletions

File tree

.github/copilot-instructions.md

Lines changed: 0 additions & 59 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
with:
3939
node-version: 22
4040
- run: npm run build
41-
test-vitest:
41+
test:
4242
strategy:
4343
fail-fast: false
4444
matrix:
@@ -57,10 +57,10 @@ jobs:
5757
packages/*/dist
5858
packages/*/tsconfig.build.tsbuildinfo
5959
tsconfig.tsbuildinfo
60-
key: test-vitest-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}-${{ github.sha }}
61-
restore-keys: test-vitest-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}
62-
- run: npm run test:vitest
63-
test-vscode:
60+
key: test-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}-${{ github.sha }}
61+
restore-keys: test-tools-${{ runner.arch }}-${{ runner.os }}-node-${{ matrix.node }}
62+
- run: npm run test
63+
vscode-test:
6464
strategy:
6565
fail-fast: false
6666
matrix:
@@ -85,7 +85,7 @@ jobs:
8585
path: .vscode-test
8686
key: vscode-test-${{ runner.arch }}-${{ runner.os }}-vscode-${{ env.VSCODE_VERSION }}
8787

88-
- run: xvfb-run -a npm run test:vscode
88+
- run: xvfb-run -a npm run vscode-test
8989
if: runner.os == 'Linux'
90-
- run: npm run test:vscode
90+
- run: npm run vscode-test
9191
if: runner.os != 'Linux'

.vscode/launch.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,14 +191,14 @@
191191
}
192192
},
193193
{
194-
"name": "vscode:test",
194+
"name": "vscode-test",
195195
"type": "extensionHost",
196196
"request": "launch",
197197
"testConfiguration": "${workspaceFolder}/.vscode-test.cjs",
198198
"args": ["--profile-temp"],
199199
"outFiles": ["${workspaceFolder}/packages/vscode/dist/**/*"],
200200
"presentation": {
201-
"group": "vscode:test"
201+
"group": "vscode-test"
202202
}
203203
},
204204
{

AGENTS.md

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# AGENTS.md
2+
3+
## Project Overview
4+
5+
CSS Modules Kit is a toolkit that makes CSS Modules more convenient. It uses the TypeScript Language Service Plugin and Volar.js to provide rich editor language features for CSS Modules (Go to Definition, Rename, Find All References, etc.).
6+
7+
The provided language features and available settings are described in [README.md](./README.md).
8+
9+
## Architecture
10+
11+
This project is a monorepo and consists of the following packages:
12+
13+
- **packages/core**: Common package that provides core functionality such as parsing CSS Modules, generating type definitions, and validation
14+
- **packages/ts-plugin**: Implementation of the TypeScript Language Service Plugin (Volar.js-based)
15+
- Provides language features such as Go to Definition, Rename, Find All References
16+
- **packages/codegen**: CLI tool to generate CSS Modules type definition files (`.d.ts`)
17+
- **packages/vscode**: VS Code extension
18+
- Wrapper to run ts-plugin in VS Code
19+
- **packages/stylelint-plugin**: Stylelint plugin
20+
- **packages/eslint-plugin**: ESLint plugin
21+
- **crates/zed**: Zed editor extension (Rust implementation)
22+
- Wrapper to run ts-plugin in Zed
23+
24+
Package dependencies:
25+
26+
- ts-plugin, codegen, stylelint-plugin, and eslint-plugin all depend on the core package
27+
- Functionality is implemented via APIs provided by the core package (`parseCSSModule`, `generateDts`, `checkCSSModule`, etc.)
28+
29+
## Development Commands
30+
31+
```bash
32+
npm run build # Build all packages
33+
34+
npm run lint # Run all linting
35+
36+
npm run test # Run all tests except VS Code extension tests
37+
npx vitest --run --project unit # Run only unit tests
38+
npx vitest --run --project e2e # Run only E2E tests
39+
npx vitest --run packages/core/src/parser/css-module-parser.test.ts # Run a specific test file
40+
npm run vscode-test # Run VS Code extension tests
41+
```
42+
43+
### Updating generated files in examples
44+
45+
The examples directory contains generated type definition files produced by codegen as examples. If the generated type definition files change, these files must also be updated. You can update them with the following command:
46+
47+
```bash
48+
npm run update-generated-in-examples
49+
```
50+
51+
## Coding Conventions
52+
53+
### Error Handling
54+
55+
**Defining error classes**:
56+
57+
- Use classes that extend `Error` for errors to be thrown
58+
- Place error classes in `packages/*/src/error.ts`
59+
60+
```ts
61+
// packages/*/src/error.ts
62+
class AuthError extends Error {
63+
constructor(message: string) {
64+
super(message);
65+
this.name = 'AuthError';
66+
}
67+
}
68+
```
69+
70+
**Using @throws**:
71+
72+
- For functions that throw, describe exceptions with JSDoc `@throws`
73+
- Propagate `@throws` to calling functions (when not caught by try)
74+
75+
```ts
76+
/**
77+
* @throws {AuthError} When the user is not authorized
78+
*/
79+
function myFunction() {
80+
if (!user.isAuthorized()) {
81+
throw new AuthError('User is not authorized');
82+
}
83+
}
84+
```
85+
86+
## Glossary
87+
88+
- **Token**: A generic term for things exported by CSS Modules, such as class names and values defined with `@value`.
89+
- **Diagnostic**: An object representing errors or warnings
90+
- **Parse phase**: The phase that parses CSS Modules files and extracts token information
91+
- **Check phase**: The phase that validates CSS Modules files
92+
- **Emit phase**: The phase that generates `.d.ts` files
93+
- **cmkOptions**: Various option settings for CSS Modules Kit
94+
- **Mapping**: An object that maintains the positional relationship between a `.d.ts` file and its corresponding .css file
95+
- Mapping enables language features such as Go to Definition, Find All References, Rename
96+
97+
## Key Files
98+
99+
- `packages/core/src/type.ts`: Main type definitions used by CSS Modules Kit
100+
- `packages/core/src/parser/css-module-parser.ts`: CSS Modules parsing
101+
- Responsible for extracting tokens and generating diagnostics detectable during parsing
102+
- `packages/core/src/checker.ts`: CSS Modules validation
103+
- Responsible for generating diagnostics that cannot be detected in the parse phase
104+
- `packages/core/src/dts-generator.ts`: Generates type definition files (`.d.ts`) and mappings.
105+
106+
## Tech Stack
107+
108+
- TypeScript
109+
- Vitest
110+
- ESLint
111+
- Prettier
112+
- npm, npm workspaces
113+
- Changesets
114+
115+
## Other
116+
117+
- Commit messages follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
118+
- `<type>`: use one of feat, fix, docs, refactor, test, chore, deps
119+
- `[optional scope]`: choose one of core, ts-plugin, codegen, vscode, stylelint-plugin, eslint-plugin, zed
120+
- For changes spanning multiple packages, use comma-separated scopes like `feat(core, ts-plugin): ...`
121+
- If you make changes that affect users, add a changeset file under `.changeset`

CLAUDE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
AGENTS.md

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ npm run test
2020
- `npm run build`: Build for production
2121
- `npm run lint`: Run static-checking
2222
- `npm run test`: Run tests
23+
- `npm run vscode-test`: Run VS Code Extension tests
2324

2425
## How to debug
2526

@@ -29,7 +30,7 @@ You can run code in debug mode from the "Run and Debug" panel in VS Code. To sta
2930
- `eslint-plugin (...)`: Debug for `eslint-plugin` package
3031
- `stylelint (...)`: Debug for `stylelint` package
3132
- `vscode (...)`: Debug for `vscode` and `ts-plugin` package
32-
- `vscode-test`: Debug for `npm run test:vscode`
33+
- `vscode-test`: Debug for `npm run vscode-test`
3334

3435
Good to know:
3536

@@ -59,7 +60,7 @@ Good to know:
5960
1. Write your code
6061
1. Add tests if necessary
6162
1. Update documentation if necessary
62-
1. Pass `npm run lint` and `npm run test`
63+
1. Pass `npm run lint`, `npm run test`, and `npm run vscode-test`
6364
1. Run `npx @changesets/cli add` to create a changeset if the change affects users
6465
- The summary should be in the following format:
6566
- For bug fixes: `fix: ...`

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121
"lint:tsc": "tsc -b",
2222
"lint:eslint": "eslint .",
2323
"lint:prettier": "prettier --cache --check .",
24-
"test": "run-s -c test:*",
25-
"test:vitest": "vitest --run",
26-
"test:vscode": "vscode-test",
24+
"test": "vitest --run",
25+
"vscode-test": "vscode-test",
2726
"update-generated-in-examples": "./scripts/update-generated-in-examples.sh"
2827
},
2928
"prettier": "@mizdra/prettier-config-mizdra",

0 commit comments

Comments
 (0)