@harperfast/code-guidelines

中文文档
0.1.2发布于 2026/07/29Apache-2.0ES Module近 30 天下载 6.4万

Coding Guidelines for Harper repositories. Includes types, linting, and formatting.

原始使用文档
文档目录6 节
  1. Quick Start
  2. Formatting
  3. Linting
  4. Using the Harper ESLint Configuration
  5. Type Checking
  6. Adding new configurations

@harperfast/code-guidelines

This repository contains code guideline tools and configurations for the Harper organization.

Currently exports shared configurations for Prettier, ESLint, and TS Node Type Checking. More tools will be added soon.

Quick Start

  1. npm i --save-dev @harperfast/code-guidelines

  2. Add "prettier": "@harperfast/code-guidelines/prettier" to package.json.

  3. Run npx prettier .

Formatting

We use Prettier for formatting. The default config is exported under the /prettier path (i.e. @harperfast/code-guidelines/prettier).

Review the Sharing Configurations documentation for more information how to use or extend the base config.

Linting

We use ESLint to enforce code quality and integrate Prettier formatting. The default config is exported under the /eslint path (i.e. @harperfast/code-guidelines/eslint).

Using the Harper ESLint Configuration

You must create a local ESLint configuration that imports Harper's ESLint configuration, then you can extend or override the base configuration by adding your own rules.

For more detailed information about extending configurations, see the ESLint Configuration Files documentation.

  1. Install the required dependencies:
npm i --save-dev @harperfast/code-guidelines eslint prettier
  1. Create an eslint.config.mjs file in your project root:
import harperConfig from '@harperfast/code-guidelines/eslint';
import { defineConfig } from 'eslint/config';

export default defineConfig([
    ...harperConfig,
    // Your custom configuration here
    {
        rules: {
            // Override or add custom rules
        },
    },
]);
  1. Run ESLint:
npx eslint .

Type Checking

TypeScript configuration files are available under the /tsconfig export path and can be used with the extends property in your own tsconfig.json files.

For example, to use the base Node.js configuration (supporting Node.js v20 or later):

  1. Start by installing necessary dev dependencies:
   npm i --save-dev typescript @types/node@20 @harperfast/code-guidelines
  1. Then create a tsconfig.json file in your project with the following content:
{
    "extends": "@harperfast/code-guidelines/tsconfig.node.json",
    "compilerOptions": {
        // Your custom options here
    }
}
  1. Finally, use TypeScript or Node.js Type Stripping!
   npx tsc
   # or
   node src/index.ts

Configurations are based off of the popular tsconfig bases project.

The following list outlines the available configurations:

  • tsconfig.node.json - Node.js v20 or later with Node.js Type Stripping support
  • More coming soon!

Adding new configurations

To add a new TypeScript configuration:

  1. Create a new file in this repository starting with tsconfig. and ending with .json. The name in between should be descriptive of the environment or relevant version (e.g. tsconfig.react.json or tsconfig.node-24.json).
  2. Update the exports field in package.json to include the new configuration file using the same name as the file.
  3. Add it to the list above with a brief description.
  4. Ship it 🚀

版本与发布记录

@harperfast/code-guidelines 共发布 3 个版本,首次发布于 2026/07/29;过去 12 个月发布了 3 个版本。

版本发布日期距今
0.1.2latest2026/07/293 个月前
0.1.12026/07/293 个月前
0.1.02026/07/293 个月前

关于 @harperfast/code-guidelines 的常见问题

@harperfast/code-guidelines 是什么?

Coding Guidelines for Harper repositories. Includes types, linting, and formatting.

如何安装 @harperfast/code-guidelines?

在项目目录运行 npm install @harperfast/code-guidelines,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:eslint(>= 9)、prettier(>= 3)、typescript(>= 5.9)、@types/node(>= 20)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@harperfast/code-guidelines 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/harperfast__code-guidelines 是否存在。

@harperfast/code-guidelines 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@harperfast/code-guidelines 可以商用吗?

@harperfast/code-guidelines 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@harperfast/code-guidelines 的下载量有多少?

根据 npm 官方下载统计,@harperfast/code-guidelines 在 2026/10/18 – 2026/11/16 这 30 天内被下载 63,710 次,日均约 2,124 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@harperfast/code-guidelines 还在维护吗?

最新版本 0.1.2 发布于 2026/07/29(3 个月前);至今共发布 3 个版本,其中过去 12 个月发布了 3 个;首次发布于 2026/07/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。