# @fisch0920/oxlint-plugin-anti-slop 中文文档

规范地址：https://npmcn.com/package/%40fisch0920/oxlint-plugin-anti-slop/

版本：0\.2\.1
npm 元数据更新时间：2026-08-21T10:25:22.988Z
中文译文更新时间：2026-11-14T20:25:25.722Z
软件包许可：MIT

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

原始 npm 页面：https://www.npmjs.com/package/%40fisch0920/oxlint-plugin-anti-slop
原文对照：https://npmcn.com/package/%40fisch0920/oxlint-plugin-anti-slop/?lang=original

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

- 包体积（解压后）：185 kB，6 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- 首次发布：2026-08-21T10:10:52.386Z
- 最新版本发布：2026-08-21T10:25:22.815Z
- 近 30 天下载量：4325（2026-10-15 至 2026-11-13，npm 官方下载统计）
- 已发布版本数：2（近 12 个月 2 个）

## 中文简介

有观点认为Oxlint规则拒绝低证据TypeScript和JavaScript模式.

## 安装

```sh
npm install @fisch0920/oxlint-plugin-anti-slop
```

也可以使用：`pnpm add @fisch0920/oxlint-plugin-anti-slop`、`yarn add @fisch0920/oxlint-plugin-anti-slop`、`bun add @fisch0920/oxlint-plugin-anti-slop`

## README

# 反斜体

[![skills.sh](https://skills.sh/b/dmmulroy/anti-slop)](https://skills.sh/dmmulroy/anti-slop)

有观点认为Oxlint规则拒绝低证据和低信号的TypeScript和JavaScript模式.

这个项目的用意是销售,而不是作为固定npm依赖。 将规则复制到您的寄存器中,读取,并修改,以符合您的团队标准. 捆绑的代理技能处理初始复制和配置;之后,卖出的文件由您维护并自行制作.

## 用代理技能安装

```bash
npx skills add dmmulroy/anti-slop --skill install-anti-slop
```

然后请您的编码代理在当前的寄存器中安装或配置反斜体 。 技能复制了插件,安装了当前Oxlint的依赖性,将插件合并到现有的林特配置中,使每个通用规则都能够实现,并验证结果. 在依赖于Effect的寄存器中,它也使选择生效规则组成为可能.

首先检查现有技能:

```bash
npx skills add dmmulroy/anti-slop --list
```

## 手动本地安装

复制 `src/` 输入目标存储器,例如 `tools/oxlint/anti-slop/`,并安装匹配当前版本的 `oxlint` 财务报告和审定财务报表 `@oxlint/plugins`。 。 。 .

注册在 `oxlint.config.ts`数字 :

```ts
import { defineConfig } from "oxlint";

export default defineConfig({
  ignorePatterns: [
    ".agent/**",
    ".agents/**",
    ".claude/**",
    ".codex/**",
    ".continue/**",
    ".cursor/**",
    ".gemini/**",
    ".opencode/**",
    ".pi/**",
    ".roo/**",
    ".windsurf/**",
    "tools/oxlint/anti-slop/**",
  ],
  jsPlugins: [
    { name: "anti-slop", specifier: "./tools/oxlint/anti-slop/index.ts" },
  ],
  rules: {
    "anti-slop/no-chained-type-assertions": "error",
    "anti-slop/no-conditional-empty-object-spread": "error",
    "anti-slop/no-known-value-widening": "error",
    "anti-slop/no-module-mocking": "error",
    "anti-slop/no-object-parameters": "error",
    "anti-slop/no-reflect-apply": "error",
    "anti-slop/no-reflect-get": "error",
    "anti-slop/no-runtime-typeof": "error",
    "anti-slop/no-shape-in-symbol-names": "error",
    "anti-slop/no-unknown-parameters": "error",
    "anti-slop/no-unknown-returns": "error",
    "anti-slop/no-unknown-type-aliases": "error",
    "anti-slop/no-unsafe-dictionary-type": "error",
    "anti-slop/no-widen-then-assert": "error",
    "anti-slop/require-safety-comment-for-type-assertion": "error"
  }
});
```

一样 `ignorePatterns`, (中文(简体) ), `jsPlugins`和规则 `lint` 在 Vite+ 配置中。 将忽略模式合并到 Vite+ 的 `fmt.ignorePatterns` 也一样 `vp check` 不重构已安装的代理资产或供应商插件。 保存已存在的已忽略并添加在寄存器中检测到的任何其他工程本地代理工具目录;不广泛忽略每个点目录.

### 可选效果规则

效果特定规则生活在单独的插件中,因此不使用效果的项目不会继承效果架构政策. 仅在使用效果的寄存器中注册效果切入点:

```ts
export default defineConfig({
  jsPlugins: [
    { name: "anti-slop", specifier: "./tools/oxlint/anti-slop/index.ts" },
    {
      name: "anti-slop-effect",
      specifier: "./tools/oxlint/anti-slop/effect/index.ts"
    }
  ],
  rules: {
    "anti-slop-effect/no-service-constructor-imports": "error"
  }
});
```

## 规则

### 通则

-   `no-chained-type-assertions` ——拒绝编造出证据的巢类断言.
-   `no-conditional-empty-object-spread` - 拒绝使用的条件差 `{}` 以略去字段.
-   `no-known-value-widening` ——拒绝明确而广泛的目标类型来抛弃已知的价值证据.
-   `no-module-mocking` ——拒绝Vitest和Jest模块为取而代之的是真正的依赖接合.
-   `no-object-parameters` - 拒绝广泛 `object` 键入函数输入.
-   `no-reflect-apply` - 拒绝 `Reflect.apply` 用于键入函数调用.
-   `no-reflect-get` - 拒绝 `Reflect.get` 倾向于打入财产或解析边界.
-   `no-runtime-typeof` - 需要解析边界而不是临时解析 `typeof` 缩小.
-   `no-shape-in-symbol-names` - 拒绝 `shape` 在符号名称中.
-   `no-unknown-parameters` - 拒绝 `unknown` 输入,但明确 `cause` 公约.
-   `no-unknown-returns` 拒绝返回的函数合同 `unknown` 或者说 `Promise<unknown>`。 。 。 .
-   `no-unknown-type-aliases` - 拒绝只是隐瞒的别名 `unknown`。 。 。 .
-   `no-unsafe-dictionary-type` - 拒绝基于 `unknown`, (中文(简体) ), `any`, (中文(简体) ), `object`, (中文(简体) ), `{}`,和语义等同.
-   `no-widen-then-assert` ——拒绝拓宽已知价值的本地流动,后又加以回溯.
-   `require-safety-comment-for-type-assertion` 要求每个非一致的断言记录其检查的无变化性.

### 效果规则

-   `no-service-constructor-imports` - 拒绝出口的相对项目进口 `make<CapabilityName>` 外部构造器 `*.test.*` 财务报告和审定财务报表 `*.spec.*` 文档。 运行时调用者应导入自有的图层并生成背景服务。 进口包和静态构造器,例如: `WorkspaceName.make` 不在规则范围内.

## 违规事例

下面的每个片段被命名规则所拒绝.

### `no-chained-type-assertions`

```ts
const user = input as object as User;
```

### `no-conditional-empty-object-spread`

```ts
const options = {
  ...(timeout !== undefined ? { timeout } : {}),
};
```

### `no-known-value-widening`

```ts
const handlers: Record<string, Handler> = {
  start: startHandler,
};
```

丢弃已知的 `start` 键。 保留推断或使用 `satisfies Record<string, Handler>` 换句话说.

### `no-module-mocking`

```ts
vi.mock("./user-store");
```

### `no-object-parameters`

```ts
function save(value: object) {}
```

### `no-reflect-apply`

```ts
const value = Reflect.apply(operation, owner, args);
```

### `no-reflect-get`

```ts
const value = Reflect.get(owner, key);
```

### `no-runtime-typeof`

```ts
if (typeof input === "string") {
  useName(input);
}
```

无项目可以允许 `typeof` 直接检查类型上游和 在继续拒绝在其他地方进行特别检查的同时,保留功能:

```json
{
  "anti-slop/no-runtime-typeof": [
    "error",
    { "allowInTypeGuards": true }
  ]
}
```

选项默认为 `false`。 。 。 .

### `no-shape-in-symbol-names`

```ts
interface UserShape {
  id: string;
}
```

### 效果 : `no-service-constructor-imports`

```ts
import { makeIssueService } from "./issue-service.ts";
```

导入自有图层并生成 `IssueService` 换句话说 重点 `*.test.*` 财务报告和审定财务报表 `*.spec.*` 文件可能直接导入构建器 .

### `no-unknown-parameters`

```ts
function handle(input: unknown) {}
```

### `no-unknown-returns`

```ts
function loadUser(): unknown {
  return input;
}
```

### `no-unknown-type-aliases`

```ts
type ExternalValue = unknown;
```

### `no-unsafe-dictionary-type`

```ts
type Metadata = Record<string, unknown>;
type OtherMetadata = { [key: string]: object };
```

### `no-widen-then-assert`

```ts
const loaded: User = loadUser();
const stored: unknown = loaded;
const user = stored as User;
```

### `require-safety-comment-for-type-assertion`

```ts
const userId = value as UserId;
```

在必要的断言之前增加具体理由:

```ts
// SAFETY: parseUserId validated the identifier before branding it.
const userId = value as UserId;
```

## 发展

```bash
pnpm install
pnpm check
```

`src/` 简直太夸张了 改变生产来源后运行 `pnpm sync:skill-assets`; CI 检查该技能捆绑的拷贝是否仍然相同.

## 许可证

麻省理工学院

## 常见问题

### @fisch0920/oxlint-plugin-anti-slop 是什么？

有观点认为Oxlint规则拒绝低证据TypeScript和JavaScript模式\.

### 如何安装 @fisch0920/oxlint-plugin-anti-slop？

在项目目录运行 npm install @fisch0920/oxlint-plugin-anti-slop，或使用 pnpm add / yarn add / bun add。

### @fisch0920/oxlint-plugin-anti-slop 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @fisch0920/oxlint-plugin-anti-slop 支持 ESM 还是 CommonJS？

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

### @fisch0920/oxlint-plugin-anti-slop 可以商用吗？

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

### @fisch0920/oxlint-plugin-anti-slop 的下载量有多少？

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

### @fisch0920/oxlint-plugin-anti-slop 还在维护吗？

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

