# @coffeelint/cli 中文文档

规范地址：https://npmcn.com/package/%40coffeelint/cli/

版本：5\.2\.15
npm 元数据更新时间：2026-10-28T04:01:12.916Z
中文译文更新时间：2026-11-10T09:38:23.865Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40coffeelint/cli
原文对照：https://npmcn.com/package/%40coffeelint/cli/?lang=original
项目主页：https://coffeelint.github.io/
源码仓库：https://github.com/coffeelint/coffeelint

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：326 kB，67 个文件
- 模块格式：CommonJS
- TypeScript 类型：未声明
- Node.js 要求：^20\.19\.0 \|\| ^22\.12\.0 \|\| \>=23
- 运行依赖：6 个
- 首次发布：2020-01-13T19:24:02.280Z
- 最新版本发布：2026-10-28T04:01:12.566Z
- 近 30 天下载量：26696（2026-10-10 至 2026-11-08，npm 官方下载统计）
- 已发布版本数：53（近 12 个月 4 个）

## 中文简介

打开你的咖啡稿

## 安装

```sh
npm install @coffeelint/cli
```

也可以使用：`pnpm add @coffeelint/cli`、`yarn add @coffeelint/cli`、`bun add @coffeelint/cli`

## README

# 咖啡壶

CoffeeLint 是帮助保留 CoffeeScript 代码的样式检查器 干净而一致.

关于安装、使用和配置 CoffeeLint 的指南,头部 [这里](https://coffeelint.github.io/)。 。 。 .

建议一个功能,报告错误,或一般性讨论, 头朝前 [这里](https://github.com/coffeelint/coffeelint/issues/)。 。 。 .

## 团队

当前 :

-   [https://github.com/orgs/coffeelint/people (中文(简体) )](https://github.com/orgs/coffeelint/people)

过去 :

-   [王书](https://github.com/swang)
-   [阿萨·艾尔斯](https://github.com/AsaAyers)
-   [马特·佩皮克](https://github.com/clutchski)

## 捐款

-   新的规则应订为 `warn` 级别。 开发者会期望新的修改不会打破他们现有的工作流程, 因此除非您的修改非常有用, 默认为 `warn`。如果选择使用,则期待讨论 `error`。 。 。 .
    
-   在决定如何命名你的规则时,看看现有的规则和测试结构. `no_foo.coffee` 用于许多旨在捕捉特定错误的测试,而 `foo.coffee` 用于执行格式化和语法的测试.
    

### 步骤

1.  以地为叉取还.
2.  运行 `npm install` 获取依赖.
3.  在单个文件中创建规则为 `src/rules/your_rule_here.coffee`,使用现有的 规则作为指南。 您可以使用 [https://asaayers.github.io/clfiddle/ 页面存档备份,存于互联网档案馆](https://asaayers.github.io/clfiddle/)。 。 。 .
4.  添加您的测试文件 `my_test.coffee` 页:1 `test` 目录.
5.  登记您的规则 `src/coffeelint.coffee`。 。 。 .
6.  使用 `npm run testrule test/your_test_here.coffee`。 。 。 .
7.  使用 `npm test`。 。 。 .
8.  提交拉动请求 .

[![Github Actions](https://github.com/coffeelint/coffeelint/workflows/CI/badge.svg?branch=master)](https://github.com/coffeelint/coffeelint/actions)

### 新增规则时更新文件

添加新规则时,其文档通过设置 `description` 其内部财产 `rule` 属性 :

```coffeescript
module.exports = class NoComment

    rule:
        name: 'no_comment'
        level: 'ignore'
        message: 'No comment'
        description: '''
            Disallows any comment in the code
            '''

    tokens: ['#', '###']

    lintToken : (token, tokenApi) ->
        return {context: "Found '#{token[0]}'"}
```

描述属性是一个可以嵌入 HTML 代码的字符串 :

```html
description: '''
    Disallows any comment in the code. This code would not pass:
    <pre>
    <code>### Some code with comments
    foo = ->
        # some other comments
        bar()
    </code>
    </pre>
    '''
```

[咖啡林网站](https://coffeelint.github.io/) 生成每个 规则的文档基于此 `description` 属性.

## 常见问题

### @coffeelint/cli 是什么？

打开你的咖啡稿

### 如何安装 @coffeelint/cli？

在项目目录运行 npm install @coffeelint/cli，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 coffeelint，可以用 npx coffeelint 直接运行。

### @coffeelint/cli 支持 TypeScript 吗？

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

### @coffeelint/cli 支持 ESM 还是 CommonJS？

以 CommonJS 形式发布，可以直接 require\(\)；在 ES Module 项目中也可以用 import 引入（Node\.js 会把 module\.exports 作为默认导出）。

### @coffeelint/cli 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js ^20\.19\.0 \|\| ^22\.12\.0 \|\| \>=23。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @coffeelint/cli 可以商用吗？

@coffeelint/cli 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @coffeelint/cli 的下载量有多少？

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

### @coffeelint/cli 还在维护吗？

最新版本 5\.2\.15 发布于 2026/10/28（13 天前）；至今共发布 53 个版本，其中过去 12 个月发布了 4 个；首次发布于 2020/01/14。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

