• Stars
    star
    231
  • Rank 173,434 (Top 4 %)
  • Language
  • Created over 2 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Contribution guide for my projects

Contribution Guide

Hey there! We are really excited that you are interested in contributing. This is a general contribution guide for most of Anthony's projects. Before submitting your contribution, please make sure to take a moment and read through the following guide:

👨‍💻 Repository Setup

We use pnpm for most of the projects, and maybe a few with yarn, we highly recommend you install ni so you don't need to worry about the package manager when switching across different projects.

We will use ni's commands in the following code snippets. If you are not using it, you can do the conversion yourself: ni = pnpm install, nr = pnpm run.

To set the repository up:

Step Command
1. Install Node.js, using the latest LTS -
2. Enable Corepack corepack enable
3. Install @antfu/ni npm i -g @antfu/ni
4. Install dependencies under the project root ni

💡 Commands

nr dev

Start the development environment.

If it's a Node.js package, it will start the build process in watch mode, or stub the passive watcher when using unbuild.

If it's a frontend project, it usually starts the dev server. You can then develop and see the changes in real time.

nr play

If it's a Node.js package, it starts a dev server for the playground. The code is usually under playground/.

nr build

Build the project for production. The result is usually under dist/.

nr lint

We use ESLint for both linting and formatting. It also lints for JSON, YAML and Markdown files if exists.

You can run nr lint --fix to let ESLint formats and lints the code.

Learn more about the ESLint Setup.

We don't use Prettier.

nr test

Run the tests. We mostly using Vitest - a replacement of Jest.

You can filter the tests to be run by nr test [match], for example, nr test foo will only run test files that contain foo.

Config options are often under the test field of vitest.config.ts or vite.config.ts.

Vitest runs in watch mode by default, so you can modify the code and see the test result automatically, which is great for test-driven development. To run the test only once, you can do nr test --run.

For some projects, we might have multiple types of tests set up. For example nr test:unit for unit tests, nr test:e2e for end-to-end tests. nr test commonly run them together, you can run them separately as needed.

nr docs

If the project contains documentation, you can run nr docs to start the documentation dev server. Use nr docs:build to build the docs for production.

nr

For more, you can run bare nr, which will prompt a list of all available scripts.

🙌 Sending Pull Request

Discuss First

Before you start to work on a feature pull request, it's always better to open a feature request issue first to discuss with the maintainers whether the feature is desired and the design of those features. This would help save time for both the maintainers and the contributors and help features to be shipped faster.

For typo fixes, it's recommended to batch multiple typo fixes into one pull request to maintain a cleaner commit history.

Commit Convention

We use Conventional Commits for commit messages, which allows the changelog to be auto-generated based on the commits. Please read the guide through if you aren't familiar with it already.

Only fix: and feat: will be presented in the changelog.

Note that fix: and feat: are for actual code changes (that might affect logic). For typo or document changes, use docs: or chore: instead:

  • fix: typo -> docs: fix typo

Pull Request

If you don't know how to send a Pull Request, we recommend reading the guide.

When sending a pull request, make sure your PR's title also follows the Commit Convention.

If your PR fixes or resolves an existing issue, please add the following line in your PR description (replace 123 with a real issue number):

fix #123

This will let GitHub know the issues are linked, and automatically close them once the PR gets merged. Learn more at the guide.

It's ok to have multiple commits in a single PR, you don't need to rebase or force push for your changes as we will use Squash and Merge to squash the commits into one commit when merging.

🧑‍🔧 Maintenance

This section is for maintainers with write access, or if you want to maintain your own forks.

Update Dependencies

Keeping dependencies up-to-date is one of the important aspects to keep projects alive and getting latest bug fixes on time. We recommend to update dependencies in weekly or bi-weekly intervals.

We use taze to update the dependencies manually most of the time. As deps updating bots like Dependabot or Renovate could be a bit annoying when you have a lot projects.

With taze, you can run taze major -Ir to check and select the versions to update interactive. -I stands for --interactive, -r stands for --recursive for monorepo.

After bumpping, we install them, runing build and test to verify nothing breaks before pushing to main.

Releasing

Before you do, make sure you have lastest git commit from upstream and all CI passes.

For most of the time, we do nr release. It will prompts a list for the target version you want to release. After select, it will bump your package.json and commit the changes with git tag, powered by bumpp.

There are two kinds of publishing setup, either of them are done by nr release already.

Build Locally

For this type of setup, the building and publishing process is done on your local machine. Make sure you have your local npm logged in before doing that.

In package.json, we usually have:

{
  "scripts": {
    "prepublishOnly": "nr build"
  }
}

So whenever you run npm publish, it will make sure you have the latest change in the distribution.

Build on CI

For complex projects that take long time to build, we might move the building and publishing process to CI. So it doesn't block your local workflow.

They will be triggered by the v prefixed git tag added by bumpp. The action is usually defined under .github/workflows/release.yml

When maintaining your own fork, you might need to see NPM_TOKEN secret to your repository for it to publish the packages.

Changelogs are always generated by GitHub Actions.

📖 References

Corepack

TL;DR

To enable it, run

corepack enable

You only need to do it once after Node.js is installed.

What's Corepack

Corepack makes sure you are using the correct version for package manager when you run corresponding commands. Projects might have packageManager field in their package.json.

Under projects with configuration as shown on the right, corepack will install v7.1.5 of pnpm (if you don't have it already) and use it to run your commands. This makes sure everyone working on this project have the same behavior for the dependencies and the lockfile.


package.json

{
  "packageManager": "[email protected]"
}

ESLint

We use ESLint for both linting and formatting with @antfu/eslint-config.

IDE Setup

We recommend using VS Code along with the ESLint extension.

With the settings on the right, you can have auto fix and formatting when you save the code you are editing.


VS Code's settings.json

{
  "editor.codeActionsOnSave": {
    "source.fixAll": false,
    "source.fixAll.eslint": true
  }
}

No Prettier

Since ESLint is already configured to format the code, there is no need to duplicate the functionality with Prettier (Why I don't Use Prettier). To format the code, you can run nr lint --fix or referring the ESLint section for IDE Setup.

If you have Prettier installed in your editor, we recommend you disable it when working on the project to avoid conflict.

🗒 Additional Info

In case you are interested in, here is Anthony's personal configrations and setups:

CLI Tools

  • ni - package manager alias
  • esno - TypeScript runner
  • taze - dependency updater
  • bumpp - version bumpper

In addition of ni, here is a few shell aliases to be even lazier:

alias d="nr dev"
alias b="nr build"
alias t="nr test"
alias tu="nr test -u"
alias p="nr play"
alias c="nr typecheck"
alias lint="nr lint"
alias lintf="nr lint --fix"
alias release="nr release"

More Repositories

1

vitesse

🏕 Opinionated Vite + Vue Starter Template
TypeScript
8,522
star
2

ni

💡 Use the right package manager
TypeScript
4,527
star
3

icones

⚡️ Icon Explorer with Instant searching, powered by Iconify
Vue
4,525
star
4

unplugin-vue-components

📲 On-demand components auto importing for Vue
TypeScript
3,011
star
5

unocss

The instant on-demand atomic CSS engine.
TypeScript
2,990
star
6

unplugin-icons

🤹 Access thousands of icons as components on-demand universally.
TypeScript
2,793
star
7

vitesse-webext

⚡️ WebExtension Vite Starter Template
TypeScript
2,581
star
8

unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
TypeScript
2,307
star
9

vscode-file-nesting-config

Config of File Nesting for VS Code
JavaScript
2,132
star
10

vue-starport

🛰 Shared component across routes with animations
TypeScript
1,744
star
11

vscode-settings

My VS Code settings and extensions
1,739
star
12

eslint-config

Anthony's ESLint config presets
JavaScript
1,605
star
13

vitesse-nuxt3

Vitesse for Nuxt 3 🏔💚⚡️
TypeScript
1,510
star
14

shikiji

A syntax highlighter based on TextMate grammars. ESM rewrite of shiki, with more features and capabilities.
TypeScript
1,465
star
15

reactivue

🙊 Use Vue Composition API in React components
TypeScript
1,415
star
16

taze

🥦 A modern cli tool that keeps your deps fresh
TypeScript
1,233
star
17

vite-ssg

Static site generation for Vue 3 on Vite
TypeScript
1,198
star
18

handle

A Chinese Hanzi variation of Wordle - 汉字 Wordle
TypeScript
1,194
star
19

qrcode-toolkit

Anthony's QR Code Toolkit for AI generated QR Codes
Vue
1,111
star
20

case-police

🚨 Make the case correct, PLEASE!
TypeScript
1,098
star
21

vite-plugin-inspect

Inspect the intermediate state of Vite plugins
Vue
1,009
star
22

use

Things I am using
991
star
23

vitesse-lite

⛺️ Lightweight version of Vitesse
TypeScript
901
star
24

drauu

Headless SVG-based drawboard in browser.
TypeScript
817
star
25

broz

A simple, frameless browser for screenshots
JavaScript
745
star
26

iroiro

Beautiful Colors Lookup in CLI
TypeScript
735
star
27

retypewriter

Replay the steps of your changes at ease.
TypeScript
715
star
28

live-draw

A tool allows you to draw on screen real-time.
C#
706
star
29

sd-webui-qrcode-toolkit

Anthony's QR Toolkit for Stable Diffusion WebUI
JavaScript
640
star
30

changelogithub

Generate changelog for GitHub
TypeScript
613
star
31

vite-plugin-md

Markdown with Vue for Vite
TypeScript
602
star
32

vscode-smart-clicks

Smart selection with double clicks for VS Code.
TypeScript
601
star
33

unplugin-vue2-script-setup

💡 Bring `<script setup>` to Vue 2.
TypeScript
567
star
34

sponsorkit

💖 Toolkit for generating sponsors images 😄
TypeScript
550
star
35

eslint-flat-config-viewer

A visual tool to help you view and understand your ESLint Flat config.
Vue
549
star
36

unconfig

A universal solution for loading configurations.
TypeScript
524
star
37

utils

Collection of common JavaScript / TypeScript utils
TypeScript
493
star
38

100

My 100-day project of exploring design, compform, and new things.
Vue
491
star
39

v-lazy-show

Compile-time directive to lazy initialize v-show for Vue
TypeScript
487
star
40

antfu.me

My personal website
Markdown
463
star
41

raycast-multi-translate

A Raycast extension that translates text to multiple languages at once
TypeScript
454
star
42

vue-reuse-template

Define and reuse Vue template inside the component scope.
TypeScript
440
star
43

vite-node

Vite as Node.js runtime
JavaScript
428
star
44

vscode-browse-lite

🚀 An embedded browser in VS Code
TypeScript
425
star
45

vscode-vite

One step faster for Vite in VS Code ⚡️
TypeScript
404
star
46

vscode-theme-vitesse

🏕 Vitesse theme for VS Code
TypeScript
395
star
47

starter-ts

Starter template for TypeScript library
TypeScript
386
star
48

vue-template-promise

Template as Promise in Vue
TypeScript
373
star
49

vue-global-api

Use Vue Composition API globally
TypeScript
331
star
50

vue-router-better-scroller

Enhanced scroll behavior for Vue Router
TypeScript
327
star
51

qr-scanner-wechat

QR Code scanner in JS with Open CV and WeChat's Algorithm
JavaScript
322
star
52

starter-vscode

Starter template for VS Code Extension
TypeScript
299
star
53

vscode-iconify

🙂 Iconify IntelliSense for VS Code
TypeScript
294
star
54

1990-script

Make your GitHub history back to 1990
Shell
293
star
55

p

Toolkit for managing multiple promises
TypeScript
284
star
56

wenyan-lang-vscode

文言 Wenyan Lang for VS Code
TypeScript
277
star
57

pnpm-patch-i

A better and interactive pnpm patch
TypeScript
265
star
58

fsxx

File system in zx style
JavaScript
262
star
59

birpc

Message-based two-way remote procedure call.
TypeScript
245
star
60

vue-minesweeper

A tiny minesweeper clone in Vue 3
TypeScript
242
star
61

purge-icons

🎐 Bundles icons on demand
TypeScript
229
star
62

vscode-open-in-github-button

Add a button to go to the GitHub on the status bar.
TypeScript
224
star
63

github-doorcat

😼 Supercharges GitHub navbar for fast navigation [WIP]
TypeScript
214
star
64

vscode-goto-alias

Go to Definition following alias redirections.
TypeScript
211
star
65

refined-github-notifications

UserScript that enhances the GitHub Notifications
JavaScript
208
star
66

eslint-plugin-command

Comment-as-command for one-off codemod with ESLint.
TypeScript
195
star
67

nuxt-server-fn

Server functions in client for Nuxt 3
TypeScript
194
star
68

magic-string-stack

magic-string with the capability of committing changes.
TypeScript
190
star
69

vscode-array-index-inlay

Show array index inlay hints for large arrays for VS Code
TypeScript
185
star
70

eslint-typegen

Generate types from ESLint rule schemas, with auto-completion and type-checking for rule options.
TypeScript
185
star
71

prism-theme-vars

A customizable Prism.js theme using CSS variables
CSS
178
star
72

what-time

What time works for you?
Vue
177
star
73

esbuild-node-loader

Transpile TypeScript to ESM with Node.js loader.
JavaScript
175
star
74

userscript-clean-twitter

Bring back the peace on Twitter
JavaScript
174
star
75

vitesse-nuxt-bridge

🏕 Vitesse experience for Nuxt 2 and Vue 2
Vue
174
star
76

vscode-icons-carbon

Carbon Visual Studio Code product icon theme
TypeScript
170
star
77

talks

Slides & code for my talks
Vue
170
star
78

fs-spy

Monitoring fs accessing for Node process
TypeScript
166
star
79

vite-plugin-glob

The design experiment for import.meta.glob from Vite.
TypeScript
164
star
80

diff-match-patch-es

ESM and TypeScript rewrite of Google's diff-match-patch for JavaScript
TypeScript
159
star
81

vite-plugin-optimize-persist

Persist dynamically analyzed dependencies optimization
TypeScript
155
star
82

eslint-ts-patch

Support loading eslint.config.mjs and eslint.config.ts as flat config files for ESLint.
JavaScript
155
star
83

markdown-it-github-alerts

Support GitHub-style alerts for markdown-it
TypeScript
153
star
84

regex-doctor

Monitor your RegExp consumption and provide suggestions to improve performance.
TypeScript
152
star
85

v-dollar

jQuery-like Vue Reactivity API
TypeScript
146
star
86

.github

The default community health files for all my repos on GitHub
146
star
87

p5i

p5.js, but with more friendly instance mode APIs
TypeScript
139
star
88

vscode-pnpm-catalog-lens

Show versions inline for PNPM catalog: field
TypeScript
136
star
89

magic-string-extra

Extended magic-string with extra utilities
TypeScript
131
star
90

export-size

Analysis bundle cost for each export of a package
TypeScript
130
star
91

eslint-plugin-format

Format various languages with formatters in ESLint
TypeScript
129
star
92

local-pkg

Get information on local packages.
TypeScript
126
star
93

vite-plugin-restart

Custom files/globs to restart Vite server
TypeScript
124
star
94

pkg-exports

Get exports of an local npm package.
TypeScript
118
star
95

qr-verify

A CLI to verify scannable QR Code in batch
TypeScript
114
star
96

eslint-plugin-antfu

Anthony extended ESLint rules.
TypeScript
114
star
97

install-pkg

Install package programmatically.
TypeScript
114
star
98

deploy-check

WIP, Prevent runtime errors earlier in CI
TypeScript
113
star
99

fast-npm-meta

A lightweight API server to get npm package metadata, resolve the latest versions on server, and batch multiple package resolutions in one request.
TypeScript
110
star
100

markdown-it-mdc

MDC (Markdown Components) syntax for markdown-it.
TypeScript
106
star