Show HN:Deslop - 针对 AI 生成的 TypeScript 的 Oxlint 规则
Show HN: Deslop – Oxlint rules for AI-generated TypeScript

原始链接: https://github.com/maharshi365/deslop

`ai-deslop` 是一个 Oxlint 插件,提供有主见的规则,用于标记低信号、AI 生成的“slop”代码。它引入了来自 `dmmulroy/anti-slop`(MIT)的通用规则,并在 `deslop/*` 命名空间下添加了更多规则。使用 `npm install --save-dev ai-deslop` 安装;`@oxlint/plugins` 是运行时依赖。它提供面向 Bun、Deno 和 Node 的已编译 JS。在 Oxlint 中通过 `jsPlugins` 和 `deslopConfigs.recommended` 配置。推荐规则涵盖不安全类型模式(unknown 参数/返回值、断言、类型拓宽、对象参数/字典)、性能问题(filter/map、reduce 展开、Reflect)、测试反模式(模块模拟、仅模拟调用断言)以及标准 TypeScript 规则(已弃用、浮动 Promise、require 导入、不必要条件、不可达)。可选规则处理重复 const/类型、重命名导入和 Tailwind 类名。鸣谢 anti-slop(MIT)。

Hacker News 最新 | 过往 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 Show HN:Deslop – 面向 AI 生成的 TypeScript 的 Oxlint 规则 ( github.com/maharshi365 ) 6 分 由 maharshi365 1 小时前 | 隐藏 |
相关文章

原文

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.

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).

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
});
Rule Status Description
no-chained-type-assertions Recommended Rejects nested as / angle-bracket assertions that fabricate evidence.
no-conditional-empty-object-spread Recommended Reports object spreads using a conditional {} branch to omit fields.
no-known-value-widening Recommended Rejects known expressions flowing into explicit unknown, object, or open dictionaries.
no-object-parameters Recommended Rejects object on function inputs.
no-runtime-typeof Recommended Requires boundary parsing instead of ad hoc typeof narrowing.
no-unknown-parameters Recommended Rejects unknown on function inputs.
no-unknown-returns Recommended Rejects return contracts resolving to unknown.
no-unknown-type-aliases Recommended Rejects aliases whose resolved type is unknown.
no-unsafe-dictionary-type Recommended Rejects dictionary values based on unsafe escape hatches.
no-widen-then-assert Recommended Rejects widening known evidence before narrowing assertions.
require-safety-comment-for-type-assertion Recommended Requires an invariant justification for non-const assertions.
no-pass-through-type-alias Recommended Disallows aliases that only rename another type.
Rule Status Description
no-array-filter-map Recommended Rejects adjacent eager array filter/map passes; allows lazy iterator pipelines.
no-reduce-accumulator-copy Recommended Rejects non-spread accumulator copies inside reducers. Enable native oxc/no-accumulating-spread alongside it.
no-reflect-apply Recommended Rejects global Reflect.apply.
no-reflect-get Recommended Rejects global Reflect.get.
no-shape-in-symbol-names Recommended Rejects shape in locally owned symbol names.
Rule Status Description
no-call-only-assertions Recommended Flags tests whose assertions only check mock calls.
no-module-mocking Recommended Rejects Vitest and Jest module mocks.
no-poor-substring-tests Recommended Rejects testing that a constant string contains substrings.
no-repeated-expect-call Recommended Flags adjacent assertions that repeat the same call in test files. Reuse the result instead. No fixer.
Rule Status Description
no-duplicate-consts Opt-in Reports all-caps constants with the same static value in different files.
no-duplicate-types Opt-in Reports exact duplicate object contracts. No fixer.
no-renamed-imports Opt-in Fixes unnecessary named-import aliases when the original name has no module-level conflict.
canonical-class-names Opt-in Fixes non-canonical Tailwind CSS v4 class spellings.

Standard rules enabled by the recommended config

Standard rule Status Description
typescript/no-deprecated Recommended Disallows using code marked @deprecated. Requires type-aware linting.
typescript/no-require-imports Recommended Disallows CommonJS require() imports.
typescript/no-floating-promises Recommended Disallows floating promises. Requires type-aware linting.
typescript/no-unnecessary-condition Recommended Disallows always truthy/falsy/nullish conditions. Requires type-aware linting.
no-unreachable Recommended Disallows unreachable code.
  • Generic rules vendored verbatim from dmmulroy/anti-slop (MIT, © Dillon Mulroy), including src/shared/*.

MIT

联系我们 contact @ memedata.com