Contributing to Plasmo
November 1, 2024 ยท View on GitHub
To contribute to our examples, please see Adding examples below.
Contributing
-
Fork this repository to your own GitHub account and then clone it:
git clone git@github.com:<org>/plasmo.git --recurse-submodulesNOTE: Replace
<org>with your GitHub username or organization. -
Work on your fork's
mainbranch, then open a PR. Please ensure the PR name follows the naming convention:feat: some new featureReplacing
featwithfix,bugordocaccordingly
Adding examples
When you add an example to the examples repository:
- Use
pnpm create plasmo --expto create the example. - The name of the example should have a
with-*prefix. - To add additional notes, add a
## Notessection at the start of the generated readme. - Your PR should be pointed to the examples project.
Developing
The development branch is main, and this is the branch that all pull
requests should be made against.
To develop locally:
-
Install pnpm
- DO NOT install pnpm as a global npm dependency, we need pnpm to be linked directly to your $PATH.
- Recommended installation method is with corepack or with brew (on macOS)
- If installed with brew, you might need to include the pnpm $PATH to your debugger
-
Install the dependencies with:
pnpm i -
Start developing and watch for code changes:
pnpm dev:cli
Developing with your local version of Plasmo
As global link
-
Link
plasmoto your local registry:cd plasmo/cli/plasmo pnpm link --global -
Invoke plasmo directly:
plasmo init plasmo dev plasmo build -
To revert the linking later on:
pnpm rm -g plasmo
Note: The create-plasmo CLI tool is not meant to be run locally.
If you have already linked it, please run
pnpm -g unlink create-plasmo
to unlink it.
Building
You can build the project, including all type definitions, with:
pnpm build
Naming convention
Files and directories
Any files that require attention for reading should be UPPER_CASE. Examples:
- README.md
- LICENSE
- SECURITY.md
- CONTRIBUTING.md
Directory and source file should use kebab-case, unless required by tooling. Examples:
- cli/plasmo/src/features/extension-devtools/plasmo-extension-manifest.ts
Code
| Concept | Naming convention |
|---|---|
| Local constants | UPPER_CASE |
| Enum namespace | PascalCase |
| Enum values | PascalCase |
| TS types | PascalCase |
| TS fields | camelCase |
| React component | PascalCase |
| React hook | camelCase |
| Local variable | camelCase |
| Unused argument | _paddedCamelCase |
| Template Placeholder | __snake_case_padded__ |
| Functions | camelCase |
| API Routes | kebab-case |
For Core Maintainers / Admin
Plasmo has 2 deployed environments:
| env name | purpose | requirement |
|---|---|---|
| lab | For WIP test | Admin deploy directly |
| latest | Stable release | Merge to stable |
Reviewer approves and merges PRs to main branch -> deploys to latest
NOTE: Please make sure to use the
Squash and Mergestrategy
For hotfix, the workflow is:
-
Creates a
hotfix-FFFFbranch off ofstableand a PR tostablegit checkout stable git checkout -b hotfix-FFFFPR name:
hotfix: some quick patchFFFFis an issue number -
Admin reviews, approves and merges
hotfix-FFFFtomain-> deploys tolatest
Merge strategy
- Admin review PR
- If the rough idea is good, code owner season the PR or guide the author to make it better
- Merge and deploy following the table below:
| From | To | Strategy | Deploy to |
|---|---|---|---|
feat-* | main | Squash and Merge | latest |
hotfix-* | main | Squash and Merge | latest |