Hacker News AI · 2026/10/14 01:52:57

ai-deslop 发布 Oxlint 规则集:拦截 AI 生成 TypeScript 中的低证据代码与类型断言滥用

原标题:Show HN: Deslop – Oxlint rules for AI-generated TypeScript
68AI 研判分
核心综述

开发者推出 ai-deslop,这是一套基于 Oxlint 的静态分析规则插件,专门用于识别和拒绝 AI 生成的“垃圾代码”(AI Slop)。该工具通过检测链式类型断言、条件空对象展开等缺乏实际证据支撑的模式,强制提升 AI 辅助编程的代码质量。它支持 Bun、Deno 和 Node.js 环境,旨在从工程层面遏制大模型在编码任务中常见的幻觉与低效模式。

报道全文原始报道全文

本文目录9 个章节

ai-deslop

Opinionated Oxlint rules that reject low-evidence, low-signal, AI-slop code patterns.

Rules are vendored from dmmulroy/anti-slop (generic rules) alongside additional deslop rules, all renamed under the deslop/* namespace. The vendored source is MIT licensed; see Credits below.

Install

BASH
npm install --save-dev ai-deslop
# @oxlint/plugins comes along as a runtime dependency — keep it in sync with your oxlint version

Ships compiled JavaScript — works with any oxlint JS-plugin runtime (Bun, Deno, or Node.js).

Usage

TS
import { defineConfig } from "oxlint";
import { configs as deslopConfigs } from "ai-deslop";

export default defineConfig({
  jsPlugins: ["ai-deslop"],
  options: deslopConfigs.recommended.options,
  rules: deslopConfigs.recommended.rules
});

Rules

Type safety and evidence

RuleStatusDescription
no-chained-type-assertionsRecommendedRejects nested as / angle-bracket assertions that fabricate evidence.
no-conditional-empty-object-spreadRecommendedReports object spreads using a conditional {} branch to omit fields.
no-known-value-wideningRecommendedRejects known expressions flowing into explicit unknown, object, or open dictionaries.
no-object-parametersRecommendedRejects object on function inputs.
no-runtime-typeofRecommendedRequires boundary parsing instead of ad hoc typeof narrowing.
no-unknown-parametersRecommendedRejects unknown on function inputs.
no-unknown-returnsRecommendedRejects return contracts resolving to unknown.
no-unknown-type-aliasesRecommendedRejects aliases whose resolved type is unknown.
no-unsafe-dictionary-typeRecommendedRejects dictionary values based on unsafe escape hatches.
no-widen-then-assertRecommendedRejects widening known evidence before narrowing assertions.
require-safety-comment-for-type-assertionRecommendedRequires an invariant justification for non-const assertions.
no-pass-through-type-aliasRecommendedDisallows aliases that only rename another type.

Code quality and APIs

RuleStatusDescription
no-array-filter-mapRecommendedRejects adjacent eager array filter/map passes; allows lazy iterator pipelines.
no-reduce-accumulator-copyRecommendedRejects non-spread accumulator copies inside reducers. Enable native oxc/no-accumulating-spread alongside it.
no-reflect-applyRecommendedRejects global Reflect.apply.
no-reflect-getRecommendedRejects global Reflect.get.
no-shape-in-symbol-namesRecommendedRejects shape in locally owned symbol names.

Tests

RuleStatusDescription
no-call-only-assertionsRecommendedFlags tests whose assertions only check mock calls.
no-module-mockingRecommendedRejects Vitest and Jest module mocks.
no-poor-substring-testsRecommendedRejects testing that a constant string contains substrings.
no-repeated-expect-callRecommendedFlags adjacent assertions that repeat the same call in test files. Reuse the result instead. No fixer.

Opt-in rules

RuleStatusDescription
no-duplicate-constsOpt-inReports all-caps constants with the same static value in different files.
no-duplicate-typesOpt-inReports exact duplicate object contracts. No fixer.
no-renamed-importsOpt-inFixes unnecessary named-import aliases when the original name has no module-level conflict.
canonical-class-namesOpt-inFixes non-canonical Tailwind CSS v4 class spellings.
Standard ruleStatusDescription
typescript/no-deprecatedRecommendedDisallows using code marked @deprecated. Requires type-aware linting.
typescript/no-require-importsRecommendedDisallows CommonJS require() imports.
typescript/no-floating-promisesRecommendedDisallows floating promises. Requires type-aware linting.
typescript/no-unnecessary-conditionRecommendedDisallows always truthy/falsy/nullish conditions. Requires type-aware linting.
no-unreachableRecommendedDisallows unreachable code.

Guides

GuideContents
No duplicate constsConfiguration and exact static-value comparison behavior.
No duplicate typesExact comparison behavior, worker scope, complete TypeScript/JSON examples, and every supported option.
No renamed importsWhen named-import aliases are fixed and how conflicts are handled.
Tailwind canonical class namesTailwind v4 setup, complete TypeScript/JSON examples, and every supported option.

作者发帖说明(HN):

Catches unsafe types, duplicate code, and low-value tests.