@fisch0920/oxlint-plugin-anti-slop

中文文档
0.2.1发布于 2026/08/21MITTypeScriptES Module近 30 天下载 4325

Opinionated Oxlint rules that reject low-evidence TypeScript and JavaScript patterns.

原始使用文档
文档目录25 节
  1. Install with an agent skill
  2. Manual local installation
  3. Optional Effect rules
  4. Rules
  5. Generic rules
  6. Effect rules
  7. Violation examples
  8. no-chained-type-assertions
  9. no-conditional-empty-object-spread
  10. no-known-value-widening
  11. no-module-mocking
  12. no-object-parameters
  13. no-reflect-apply
  14. no-reflect-get
  15. no-runtime-typeof
  16. no-shape-in-symbol-names
  17. Effect: no-service-constructor-imports
  18. no-unknown-parameters
  19. no-unknown-returns
  20. no-unknown-type-aliases
  21. no-unsafe-dictionary-type
  22. no-widen-then-assert
  23. require-safety-comment-for-type-assertion
  24. Development
  25. License

anti-slop

skills.sh

Opinionated Oxlint rules that reject low-evidence and low-signal TypeScript and JavaScript patterns.

This project is meant to be vendored, not treated as a fixed npm dependency. Copy the rules into your repository, read them, and change them to match your team's standards. The bundled agent skill handles the initial copy and configuration; after that, the vendored files are yours to maintain and make your own.

Install with an agent skill

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

Then ask your coding agent to install or configure anti-slop in the current repository. The skill copies the plugin, installs current Oxlint dependencies, merges the plugin into the existing lint configuration, enables every generic rule, and validates the result. In repositories that depend on Effect, it also enables the opt-in Effect rule group.

To inspect available skills first:

npx skills add dmmulroy/anti-slop --list

Manual local installation

Copy src/ into the target repository, for example at tools/oxlint/anti-slop/, and install matching current versions of oxlint and @oxlint/plugins.

Register the copied entry point in oxlint.config.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"
  }
});

The same ignorePatterns, jsPlugins, and rules work under lint in a Vite+ config. Merge the ignore patterns into Vite+'s fmt.ignorePatterns as well so vp check does not reformat installed agent assets or the vendored plugin. Preserve existing ignores and add any other project-local agent tooling directories detected in the repository; do not broadly ignore every dot-directory.

Optional Effect rules

Effect-specific rules live in a separate plugin so projects that do not use Effect do not inherit Effect architecture policy. Register the Effect entry point only in repositories that use Effect:

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"
  }
});

Rules

Generic rules

  • no-chained-type-assertions — rejects nested type assertions that fabricate evidence.
  • no-conditional-empty-object-spread — rejects conditional spreads that use {} to omit fields.
  • no-known-value-widening — rejects explicit broad target types that discard known value evidence.
  • no-module-mocking — rejects Vitest and Jest module mocks in favor of real dependency seams.
  • no-object-parameters — rejects the broad object type on function inputs.
  • no-reflect-apply — rejects Reflect.apply in favor of typed function calls.
  • no-reflect-get — rejects Reflect.get in favor of typed property access or boundary parsing.
  • no-runtime-typeof — requires boundary parsing instead of ad hoc typeof narrowing.
  • no-shape-in-symbol-names — rejects shape in symbol names.
  • no-unknown-parameters — rejects unknown inputs except the explicit cause convention.
  • no-unknown-returns — rejects function contracts that return unknown or Promise<unknown>.
  • no-unknown-type-aliases — rejects aliases that merely conceal unknown.
  • no-unsafe-dictionary-type — rejects dictionary value contracts based on unknown, any, object, {}, and semantic equivalents.
  • no-widen-then-assert — rejects local flows that widen known values and later assert them back.
  • require-safety-comment-for-type-assertion — requires each non-const assertion to document its checked invariant.

Effect rules

  • no-service-constructor-imports — rejects relative project imports of exported make<CapabilityName> constructors outside *.test.* and *.spec.* files. Runtime callers should import the owning Layer and yield the contextual service instead. Package imports and static constructors such as WorkspaceName.make are outside the rule.

Violation examples

Each snippet below is rejected by the named rule.

no-chained-type-assertions

const user = input as object as User;

no-conditional-empty-object-spread

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

no-known-value-widening

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

This discards the known start key. Preserve inference or use satisfies Record<string, Handler> instead.

no-module-mocking

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

no-object-parameters

function save(value: object) {}

no-reflect-apply

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

no-reflect-get

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

no-runtime-typeof

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

Schema-free projects can permit typeof checks directly inside type predicate and assertion functions while continuing to reject ad hoc checks elsewhere:

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

The option defaults to false.

no-shape-in-symbol-names

interface UserShape {
  id: string;
}

Effect: no-service-constructor-imports

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

Import the owning Layer and yield IssueService instead. Focused *.test.* and *.spec.* files may import the constructor directly.

no-unknown-parameters

function handle(input: unknown) {}

no-unknown-returns

function loadUser(): unknown {
  return input;
}

no-unknown-type-aliases

type ExternalValue = unknown;

no-unsafe-dictionary-type

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

no-widen-then-assert

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

require-safety-comment-for-type-assertion

const userId = value as UserId;

Add a specific justification immediately before a necessary assertion:

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

Development

pnpm install
pnpm check

src/ is canonical. After changing production source, run pnpm sync:skill-assets; CI checks that the skill's bundled copy remains identical.

License

MIT

版本与发布记录

@fisch0920/oxlint-plugin-anti-slop 共发布 2 个版本,首次发布于 2026/08/21;过去 12 个月发布了 2 个版本。

版本发布日期距今
0.2.1latest2026/08/212 个月前
0.2.02026/08/212 个月前

关于 @fisch0920/oxlint-plugin-anti-slop 的常见问题

@fisch0920/oxlint-plugin-anti-slop 是什么?

Opinionated Oxlint rules that reject low-evidence TypeScript and JavaScript patterns.

如何安装 @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 和提交记录判断。