Skip to content

Commit 5408682

Browse files
authored
update documentation (#234)
1 parent 802aede commit 5408682

2 files changed

Lines changed: 78 additions & 35 deletions

File tree

CONTRIBUTING.md

Lines changed: 57 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,67 @@
22

33
This is a guide for contributors.
44

5-
## How to dev
5+
## Design
6+
7+
Please read the slides about css-modules-kit (in Japanese).
8+
9+
- https://speakerdeck.com/mizdra/css-modules-kit
10+
11+
## Repo Setup
12+
13+
```console
14+
npm install
15+
npm run test
16+
```
17+
18+
## npm-scripts
619

720
- `npm run build`: Build for production
8-
- `npm run dev`: Run for development
921
- `npm run lint`: Run static-checking
1022
- `npm run test`: Run tests
1123

24+
## How to debug
25+
26+
You can run code in debug mode from the "Run and Debug" panel in VS Code. To start debugging, select one of the following configurations.
27+
28+
- `codegen (...)`: Debug for `codegen` package
29+
- `eslint-plugin (...)`: Debug for `eslint-plugin` package
30+
- `stylelint (...)`: Debug for `stylelint` package
31+
- `vscode (...)`: Debug for `vscode` and `ts-plugin` package
32+
- `vscode-test`: Debug for `npm run test:vscode`
33+
34+
Good to know:
35+
36+
- You can set breakpoints in `*.ts` files.
37+
- In VS Code, you can view the tsserver log with `F1 > TypeScript: Open TS Server log`.
38+
- Runtime errors from `ts-plugin` are output there.
39+
- In VS Code, you can view the Extension Host log with `F1 > Output: Show Output Channels... > Extension Host`.
40+
- If the extension fails to load, the log will be output there.
41+
42+
## Pull Request Guidelines
43+
44+
1. Write your code
45+
1. Add tests if necessary
46+
1. Update documentation if necessary
47+
1. Pass `npm run lint` and `npm run test`
48+
1. Run `npx @changesets/cli add` to create a changeset if the change affects users
49+
- The summary should be in the following format:
50+
- For bug fixes: `fix: ...`
51+
- For new features: `feat: ...`
52+
- For dependency updates: `deps: ...`
53+
- For everything else: `chore: ...`
54+
1. Create a pull request
55+
56+
Good to know:
57+
58+
- There are no rules for commit messages. Write whatever you like!
59+
1260
## How to release
1361

14-
- Wait for passing CI...
15-
- ```bash
16-
git switch main && git pull
17-
```
18-
- ```bash
19-
npm run build -- --clean && npm run build
20-
```
21-
- ```bash
22-
npx @changesets/cli version
23-
```
24-
- ```bash
25-
npx @changesets/cli publish
26-
```
27-
- ```bash
28-
git push --follow-tags
29-
```
62+
css-modules-kit is released using [changesets](https://github.com/changesets/changesets) on CI. Please read the following workflow file.
63+
64+
- https://github.com/mizdra/css-modules-kit/blob/main/.github/workflows/release.yml
65+
66+
Merging a pull request titled "Version Packages" will trigger a release.
67+
68+
- https://github.com/mizdra/css-modules-kit/pulls?q=is%3Apr+Version+Packages+in%3Atitle

README.md

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ A toolkit for making CSS Modules useful.
66

77
By default, CSS Modules have limited language features in editors. For example:
88

9-
- Clicking on `styles.button` does not jump to its definition in `Button.module.css`.
10-
- When renaming `styles.button`, the corresponding `.button {...}` in `Button.module.css` is not renamed.
11-
- Performing "Find All References" on `styles.button` does not find its definition in `Button.module.css`.
9+
- Clicking on `styles.button` does not go to its definition in `Button.module.css`.
10+
- Renaming `styles.button` does not rename the corresponding `.button {...}` in `Button.module.css`.
11+
- Find all references of `styles.button` does not include its definition in `Button.module.css`.
1212

13-
It has been difficult to solve these issues because the TypeScript Language Server (tsserver) does not handle CSS files. Since tsserver does not hold information about CSS files, it cannot calculate jump destinations or determine which code should be renamed.
13+
It has been difficult to solve these issues because the TypeScript Language Server (tsserver) does not handle CSS files. Since tsserver does not load CSS files, it cannot determine which definitions to go to or which code to rename.
1414

15-
css-modules-kit addresses this by using a TypeScript Language Service Plugin. With this plugin, css-modules-kit extends tsserver to handle `*.module.css` files. As a result, many language features like code navigation and rename refactoring become available.
15+
css-modules-kit solves this problem by using the [TypeScript Language Service Plugin](https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin). With this plugin, css-modules-kit extends tsserver to handle `*.module.css` files. As a result, rich language features like code navigation and rename refactoring become available.
1616

17-
Additionally, css-modules-kit provides various development tools for CSS Modules, such as a stylelint plugin and a utility for generating `*.d.ts` files.
17+
Another method that provides rich language features is to use the VS Code Extension API (see: https://github.com/Viijay-Kr/react-ts-css). However, it only supports VS Code. On the other hand, css-modules-kit is based on the TypeScript Language Service Plugin, so it supports other editors as well.
18+
19+
Additionally, css-modules-kit provides various development tools for CSS Modules. For example, stylelint plugins and the tool that generates `*.d.ts` files.
1820

1921
## Supported Language Features
2022

@@ -56,7 +58,7 @@ https://github.com/user-attachments/assets/4af168fa-357d-44e1-b010-3053802bf1a2
5658
</details>
5759

5860
<details>
59-
<summary>Create CSS Module file for current file.</summary>
61+
<summary>Create CSS Module file for current file</summary>
6062

6163
If there is no CSS Module file corresponding to `xxx.tsx`, create one.
6264

@@ -194,13 +196,21 @@ When this option is `true`, `import { button } from '...'` will be added. When t
194196
}
195197
```
196198

199+
## Supported CSS Modules features
200+
201+
- `:local(...)` and `:global(...)`
202+
- `@keyframes <name> { ... }`
203+
- `@value <name>: <value>;`
204+
- `@value <name>[, <value>]+ from <module-specifier>;`
205+
- `@import <module-specifier>;`
206+
197207
## Limitations
198208

199209
To simplify the implementation, some features are not supported.
200210

201-
- Sass/Less are not supported.
202-
- If you want to use Sass/Less, please use [happy-css-modules](https://github.com/mizdra/happy-css-modules). Although it does not offer as rich language features as css-modules-kit, it provides basic features such as code completion and Go to Definition.
203-
- The name of classes, @value, and @keyframes must be valid JavaScript identifiers.
211+
- Sass and Less are not supported.
212+
- If you want to use Sass and Less, please use [happy-css-modules](https://github.com/mizdra/happy-css-modules). Although it does not offer as rich language features as css-modules-kit, it provides basic features such as code completion and Go to Definition.
213+
- The name of classes, `@value`, and `@keyframes` must be valid JavaScript identifiers.
204214
- For example, `.fooBar` and `.foo_bar` are supported, but `.foo-bar` is not supported.
205215
- See [#176](https://github.com/mizdra/css-modules-kit/issues/176) for more details.
206216
- `:local .foo {...}` is not supported.
@@ -210,10 +220,4 @@ To simplify the implementation, some features are not supported.
210220
- `@keyframes :local(foo) {...}` is not supported.
211221
- Use `@keyframes foo {...}` instead.
212222
- Meanwhile, `@keyframes :global(foo) { ... }` is supported.
213-
- css-modules-kit does not work on VS Code for Web.
214-
215-
## History of this project
216-
217-
This project was created as a next-generation tool to replace [happy-css-modules](https://github.com/mizdra/happy-css-modules).
218-
219-
happy-css-modules was also a tool that provided language functionality for `*.module.css`. However, the tool was limited in the type of language features it could provide. To solve this limitation, css-modules-kit was created.
223+
- VS Code for Web is not supported.

0 commit comments

Comments
 (0)