AgentSkillsCN

antfu

Anthony Fu为JavaScript/TypeScript项目提供的独到工具与约定。适用于新建项目、配置ESLint/Prettier替代方案、Monorepo架构、库发布,或当用户提及Anthony Fu的偏好时使用。

SKILL.md
--- frontmatter
name: antfu
description: Anthony Fu's opinionated tooling and conventions for JavaScript/TypeScript projects. Use when setting up new projects, configuring ESLint/Prettier alternatives, monorepos, library publishing, or when the user mentions Anthony Fu's preferences.
metadata:
  author: Anthony Fu
  version: "2026.1.28"

Anthony Fu's Preferences

CategoryPreference
Package Managerpnpm (with @antfu/ni for unified commands)
LanguageTypeScript (strict mode, ESM only)
Linting & Formatting@antfu/eslint-config (no Prettier)
TestingVitest
Git Hookssimple-git-hooks + lint-staged
Bundler (Libraries)tsdown
DocumentationVitePress

Core Conventions

@antfu/ni Commands

CommandDescription
niInstall dependencies
ni <pkg> / ni -D <pkg>Add dependency / dev dependency
nr <script>Run script
nuUpgrade dependencies
nun <pkg>Uninstall dependency
nciClean install (pnpm i --frozen-lockfile)
nlx <pkg>Execute package (npx)

TypeScript Config

json
{
  "compilerOptions": {
    "target": "ESNext",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true
  }
}

ESLint Setup

js
// eslint.config.mjs
import antfu from '@antfu/eslint-config'

export default antfu()

Fix linting errors with nr lint --fix. Do NOT add a separate lint:fix script.

For detailed configuration options: antfu-eslint-config

Git Hooks

json
{
  "simple-git-hooks": {
    "pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
  },
  "lint-staged": { "*": "eslint --fix" },
  "scripts": { "prepare": "npx simple-git-hooks" }
}

Vitest Conventions

  • Test files: foo.tsfoo.test.ts (same directory)
  • Use describe/it API (not test)
  • Use toMatchSnapshot for complex outputs
  • Use toMatchFileSnapshot with explicit path for language-specific snapshots

pnpm Catalogs

Use named catalogs in pnpm-workspace.yaml for version management:

CatalogPurpose
prodProduction dependencies
inlinedBundler-inlined dependencies
devDev tools (linter, bundler, testing)
frontendFrontend libraries

Avoid the default catalog. Catalog names can be adjusted per project needs.


References

TopicDescriptionReference
ESLint ConfigFramework support, formatters, rule overrides, VS Code settingsantfu-eslint-config
Project Setup.gitignore, GitHub Actions, VS Code extensionssetting-up
App DevelopmentVue/Nuxt/UnoCSS conventions and patternsapp-development
Library Developmenttsdown bundling, pure ESM publishinglibrary-development
Monorepopnpm workspaces, centralized alias, Turborepomonorepo