install-anti-slop

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Install anti-slop

安装anti-slop插件

Install the bundled Oxlint plugin into the current repository and integrate it with the repository's existing lint setup. Preserve unrelated work and adapt to the project's package manager and configuration style.
将预打包的Oxlint插件安装到当前仓库,并与仓库现有的lint配置集成。保留无关工作内容,适配项目的包管理器和配置风格。

Procedure

操作步骤

  1. Inspect the repository before changing it:
    • Read its agent instructions.
    • Check
      git status
      and preserve unrelated changes.
    • Identify the package manager from
      packageManager
      and lockfiles.
    • Find Oxlint configuration (
      oxlint.config.*
      ,
      .oxlintrc*
      , or a Vite+ config).
    • Check whether anti-slop files or rules already exist. Do not overwrite them without reviewing the diff.
  2. Copy the bundled plugin from this skill. Run from the target repository:
    bash
    node <skill-directory>/scripts/install.mjs
    This creates
    tools/oxlint/anti-slop/
    . Pass another relative destination as the first argument when the repository has an established tooling layout. The script refuses to replace an existing destination; only use
    --force
    after backing up and reviewing existing files.
  3. Install current compatible dependencies rather than trusting versions remembered by the agent:
    • Query
      npm view oxlint version
      and
      npm view @oxlint/plugins version
      .
    • Install the same current version of both packages with the repository's package manager.
    • oxlint
      is a development dependency. The copied source imports
      @oxlint/plugins
      , so install it as a development dependency for a local-only plugin.
    • Do not replace the package manager or rewrite unrelated dependency ranges.
  4. Register the plugin and enable all rules. For
    oxlint.config.ts
    or
    .oxlintrc.json
    , add:
    ts
    jsPlugins: [
      { name: "anti-slop", specifier: "./tools/oxlint/anti-slop/index.ts" },
    ],
    For Vite+, add that same entry to
    lint.jsPlugins
    . Merge it with existing entries instead of replacing them.
    Enable these rules at
    "error"
    :
    json
    {
      "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-object-parameters": "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-type-aliases": "error",
      "anti-slop/no-unsafe-dictionary-type": "error",
      "anti-slop/no-widen-then-assert": "error"
    }
  5. Run the repository's lint command and typecheck. If findings appear, report them and fix them only when the user asked for migration/cleanup. Do not suppress rules, weaken rule severity, add unsafe casts, or mechanically launder types to make lint pass.
  6. Review the final diff and clearly report:
    • copied path,
    • dependency versions installed,
    • configuration changed,
    • checks run and any remaining findings.
  1. 在修改仓库前先进行检查:
    • 读取agent说明文档。
    • 执行
      git status
      命令,保留无关变更。
    • 通过
      packageManager
      字段和锁文件识别包管理器。
    • 查找Oxlint配置文件(
      oxlint.config.*
      .oxlintrc*
      或Vite+配置)。
    • 检查是否已存在anti-slop相关文件或规则。未查看差异前请勿覆盖现有内容。
  2. 从此skill中复制预打包的插件。在目标仓库中运行以下命令:
    bash
    node <skill-directory>/scripts/install.mjs
    此命令会创建
    tools/oxlint/anti-slop/
    目录。若仓库已有既定的工具布局,可将另一个相对路径作为第一个参数传入。脚本会拒绝替换已存在的目标目录;仅在备份并查看现有文件后,方可使用
    --force
    参数。
  3. 安装当前兼容的依赖,而非依赖agent记忆的版本:
    • 查询
      npm view oxlint version
      npm view @oxlint/plugins version
      获取最新版本。
    • 使用仓库的包管理器安装这两个包的当前相同版本。
    • oxlint
      是开发依赖。复制的源码会导入
      @oxlint/plugins
      ,因此需将其作为开发依赖安装,以支持本地插件。
    • 请勿替换包管理器或重写无关的依赖版本范围。
  4. 注册插件并启用所有规则。对于
    oxlint.config.ts
    .oxlintrc.json
    文件,添加以下内容:
    ts
    jsPlugins: [
      { name: "anti-slop", specifier: "./tools/oxlint/anti-slop/index.ts" },
    ],
    对于Vite+,将上述条目添加至
    lint.jsPlugins
    中。需与现有条目合并,而非替换。
    将以下规则设置为
    "error"
    级别:
    json
    {
      "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-object-parameters": "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-type-aliases": "error",
      "anti-slop/no-unsafe-dictionary-type": "error",
      "anti-slop/no-widen-then-assert": "error"
    }
  5. 运行仓库的lint命令和类型检查。若发现问题,需进行报告;仅当用户要求迁移/清理时,才修复这些问题。请勿禁用规则、降低规则严重程度、添加不安全类型断言,或通过机械方式修改类型以通过lint检查。
  6. 查看最终差异并清晰报告以下内容:
    • 复制的路径
    • 安装的依赖版本
    • 修改的配置
    • 执行的检查及剩余的问题

Migration guidance

迁移指南

When replacing an older local copy, compare its rules and diagnostics before overwriting. Keep project-specific rules in their own plugin; anti-slop is intentionally generic. Prefer inference,
as const
,
satisfies
, named owner contracts, and boundary parsing when resolving findings.
替换旧版本地副本时,需在覆盖前对比其规则和诊断信息。将项目特定规则保留在独立插件中;anti-slop规则设计为通用型。解决问题时,优先使用类型推断、
as const
satisfies
、命名所有者契约和边界解析。