Sandbox
@dmmulroy/anti-slop

Oxlint plugin for anti-slop TypeScript rules

anti-slop adds an Oxlint plugin with rules that reject low-evidence patterns in TypeScript and JavaScript. You copy the vendored `src/` tree into your project, wire it into `oxlint.config.ts`, and then tune the rules to match your team’s standards.

4,276 stars94 forksTypeScriptUpdated 6d ago
Who it's for

Builders who want their agent-run TypeScript and JavaScript repos to enforce stricter local lint rules.

What it delivers

You can keep your agent from writing weak TypeScript and JavaScript patterns that need manual review later.

What it does

Generic anti-slop rules

Rules like `no-array-filter-map`, `no-known-value-widening`, `no-module-mocking`, `no-unknown-returns`, and `require-safety-comment-for-type-assertion` reject common low-signal patterns.

Effect-specific rules

An optional Effect plugin adds checks for manual tag handling, tagged construction, service constructor imports, and `Match` usage.

Vendored installation flow

The README treats the rules as code you copy into your repo, not as a fixed npm dependency, so you can edit and maintain them locally.

Agent skill setup

The bundled skill copies the plugin, installs compatible Oxlint dependencies, merges the config, enables rules, and validates the result.

Readable spacing autofix

`require-readable-spacing` adds blank lines between top-level and control-flow sections without changing the rest of the code.

Safety comment enforcement

`require-safety-comment-for-type-assertion` requires a nearby justification comment for non-const type assertions.

How to get it

  1. 1Run
    npx skills add dmmulroy/anti-slop --skill install-anti-slop
  2. 2To inspect available skills first
    npx skills add dmmulroy/anti-slop --list

README

anti-slop

skills.sh

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

Anti-slop is first and foremost the ruleset I use with my work, projects, and team. It reflects my preferences and taste rather than attempting to be a universal coding standard.

This project is meant to be vendored, not treated as a fixed npm dependency. There is no official npm package. 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. Community-maintained forks and packages are welcome, but their compatibility and release lifecycle belong to their maintainers.

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 compatible Oxlint dependencies—matching an existing Oxlint version when present—merges the plugin into the existing lint configuration, enables every generic rule, and validates the result. In repositories that depend directly on Effect, it also enables the opt-in Effect rule group.

Update an existing installation

Ask your agent to update anti-slop while preserving local customizations, optionally naming an upstream revision or selected fixes. The same skill stages incoming source separately, uses a three-way merge when the original upstream snapshot is recoverable, and otherwise ports reviewed changes conservatively. It preserves local rules and configuration, asks about conflicting policy and enabling new rules, and records provenance for future updates. It does not force-replace the vendored directory.

For latest upstream, ask the agent to retrieve and identify that revision; an already-installed skill bundle may be older. The copy script itself does not fetch or merge updates.

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/. If the repository already uses oxlint, install @oxlint/plugins at exactly the resolved Oxlint version. Otherwise, install the same current version of both packages. Keep both versions exact so upgrades move them together.

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: {
    "oxc/no-accumulating-spread": "error",
    "anti-slop/no-array-filter-map": "error",
    "anti-slop/no-reduce-accumulator-copy": "error",
    "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-readable-spacing": "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-manual-effect-error-tag": "error",
    "anti-slop-effect/no-manual-tag-comparison": "error",
    "anti-slop-effect/no-manual-tagged-construction": "error",
    "anti-slop-effect/no-service-constructor-imports": "error",
    "anti-slop-effect/prefer-effect-match": "error"
  }
});

Rules

Generic rules

  • no-array-filter-map — rejects adjacent eager array filter/map passes while allowing lazy iterator pipelines.
  • no-reduce-accumulator-copy — rejects non-spread accumulator copies inside reducers; complements native oxc/no-accumulating-spread.
  • no-chained-type-assertions — rejects nested as and angle-bracket assertions that fabricate evidence; chains made only of as const remain valid.
  • no-conditional-empty-object-spread — reports object spreads that use a conditional {} branch to omit fields. It intentionally has no autofix because omission is not equivalent to assigning undefined.
  • no-known-value-widening — rejects known expressions flowing into explicit unknown, object, anonymous-object, or open-dictionary targets, including known arguments passed to local unknown type predicates. Empty dictionary accumulators and finite-key Record targets remain valid.
  • no-module-mocking — rejects Vitest and Jest mock, doMock, and unstable_mockModule calls in favor of real dependency seams.
  • no-object-parameters — rejects object, unions containing it, and scoped or transparent generic aliases that resolve to it on function inputs.
  • no-reflect-apply — rejects global Reflect.apply in favor of typed function calls.
  • no-reflect-get — rejects global Reflect.get in favor of typed property access or boundary parsing.
  • no-runtime-typeof — requires boundary parsing instead of ad hoc typeof narrowing. Existence probes against the string "undefined" are allowed, and type predicates can be enabled explicitly.
  • no-shape-in-symbol-names — rejects the case-insensitive substring shape in locally owned symbol names while allowing static member names such as Zod's schema.shape that cannot be renamed locally.
  • no-unknown-parameters — rejects unknown and unions containing it on function inputs except the explicit cause convention and the exact subject of a type predicate.
  • no-unknown-returns — rejects explicit function contracts that resolve to unknown, Promise<unknown>, or PromiseLike<unknown>, including scoped and transparent generic aliases.
  • no-unknown-type-aliases — rejects scoped and transparent generic aliases whose resolved type is unknown.
  • no-unsafe-dictionary-type — rejects dictionary value contracts based on unknown, any, object, {}, and semantic equivalents. Generic constraints such as T extends Record<string, unknown> are allowed.
  • no-widen-then-assert — rejects immutable local flows that widen known evidence to unknown, any, object, or a broad record and later assert it back to a narrower type.
  • require-readable-spacing — autofixes missing blank lines between top-level declarations, around multiline bindings, before control flow/returns, and after blocks; preserves compact local bindings, imports, and overload groups.
  • require-safety-comment-for-type-assertion — requires each non-const assertion to have a nearby, non-empty invariant justification. Marker prefixes are configurable and default to SAFETY.

Effect rules

  • no-manual-effect-error-tag — rejects manual _tag comparisons and switches inside broad Effect.catch, Effect.catchAll, and Effect.catchIf handlers in favor of tagged error handlers.
  • no-manual-tag-comparison — rejects direct _tag comparisons and _tag switches in favor of Match, Predicate.isTagged, or tagged-enum matching.
  • no-manual-tagged-construction — rejects literal _tag object construction in favor of Schema, tagged class/error, or Data.taggedEnum constructors. Match.when and Match.not patterns remain allowed.
  • no-service-constructor-imports — rejects named make<CapabilityName> imports from relative project modules outside *.test.* and *.spec.* files. Runtime callers should import the owning Layer and yield the contextual service instead. Package and path-alias imports, default imports, and static constructors such as WorkspaceName.make are outside the rule.
  • prefer-effect-match — rejects chained literal ternaries over the same value in favor of Effect's Match API.

Analysis boundaries

The rules use Oxlint's ESTree and lexical-scope APIs rather than a TypeScript type checker. They resolve same-file aliases—including block-scoped aliases, forward references, and transparent generic aliases—but do not infer imported type definitions or cross-file call signatures. Rules that inspect calls therefore document when enforcement is intentionally local.

Violation examples

Each snippet below is rejected by the named rule.

no-array-filter-map

const users: User[] = loadUsers();
const emails = users.filter(user => user.active).map(user => user.email);
const found = users.map(lookup).filter(value => value !== undefined);

Prefer lazy iterator helpers where the target runtime supports them:

const emails = users.values()
  .filter(user => user.active)
  .map(user => user.email)
  .toArray();

A single flatMap(user => user.active ? [user.email] : []) or a reducer that pushes into a fresh local array is also allowed. Iterator helpers avoid intermediate arrays and per-item wrapper arrays, but are not guaranteed to be faster. Check runtime support; TypeScript library declarations do not polyfill them.

This AST/scope rule recognizes array literals, direct array/tuple annotations, immutable local aliases, and supported array-preserving method chains. Unknown receivers (including imported factory results and unannotated parameters), type aliases, and property-based array types are not inferred. Iterator pipelines are not flagged. Both filter().map() and map().filter() are covered, regardless of predicate. There is no autofix: callback ordering, indexes, thisArg, sparse arrays, and truthiness filtering must be reviewed before changing APIs.

no-reduce-accumulator-copy

items.reduce((acc, item) => Object.assign({}, acc, { [item.id]: item }), {});
items.reduce((acc, item) => acc.concat([item]), []);
items.reduce((acc, item) => {
  const next = acc.slice();
  next.push(item);
  return next;
}, []);

Instead, mutate a fresh, locally owned accumulator and return it:

items.reduce((acc, item) => {
  acc.push(item);
  return acc;
}, []);

Object.assign(acc, item) is also allowed. Copying individual input items is not copying accumulated state.

The rule covers inline reduce/reduceRight callbacks, including index parameters, and immutable local accumulator aliases. It detects global Object.assign with an object-literal target and the accumulator as a source, global Array.from(acc), and array accumulator calls to concat, slice, toSpliced, toSorted, toReversed, and with. Array copy methods require local array evidence for the initial value so string concatenation and unknown custom collections are not flagged. Like the native rule, reducer method names are syntactic evidence, not proof of the receiver's runtime type. Named callbacks, nested functions, indirect copy helpers, nested accumulator properties, and reassigned aliases are outside its scope. Copying a bounded accumulator is not necessarily quadratic, but these patterns are rejected because growing accumulators can be.

Enable native oxc/no-accumulating-spread alongside it for array/object spreads in reducers and supported loops. Neither rule proves that every possible quadratic reduction is absent. No automatic mutation rewrite is provided because accumulator ownership cannot be established syntactically.

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.

Known values must not be widened back to unknown through a local type predicate:

function isUser(value: unknown): value is User {
  return UserSchema.safeParse(value).success;
}

declare const user: User;
isUser(user);

Call the predicate at the unparsed boundary, while the argument is still unknown.

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. Existence probes such as typeof document === "undefined" are always allowed because they establish whether a binding exists rather than narrow its representation.

no-shape-in-symbol-names

interface UserShape {
  id: string;
}

Static member reads such as schema.shape are allowed because the member name belongs to the value's owner and cannot be renamed locally.

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.

Effect: tagged values and matching

Direct tag checks are rejected by no-manual-tag-comparison:

if (result._tag === "Ready") useReady(result);

Use Predicate.isTagged for a predicate or Match for branching:

if (Predicate.isTagged("Ready")(result)) useReady(result);

Literal tag objects are rejected by no-manual-tagged-construction:

const result = { _tag: "Ready", value };

Use the existing Schema, tagged class/error, or Data.taggedEnum constructor instead, such as Ready.make({ value }). Object patterns passed directly to Match.when and Match.not remain allowed.

Manual tag branching in broad catch handlers is rejected by no-manual-effect-error-tag:

program.pipe(
  Effect.catch((error) =>
    error._tag === "NotFound" ? recover : Effect.fail(error)
  )
);

Use the selective error operator:

program.pipe(Effect.catchTag("NotFound", () => recover));

For a tagged error.reason, use Effect.catchReason or Effect.catchReasons.

Repeated literal ternaries over the same value are rejected by prefer-effect-match:

const label = kind === "a" ? "A" : kind === "b" ? "B" : "Other";

Use Match:

const label = Match.value(kind).pipe(
  Match.when("a", () => "A"),
  Match.when("b", () => "B"),
  Match.orElse(() => "Other")
);

These rules are syntactic. They recognize direct Effect.catch* and Match.when/Match.not calls under those exact identifiers and do not resolve import aliases or verify that similarly named objects came from Effect. prefer-effect-match compares the source text of the repeatedly tested expression; it does not infer its type or prove exhaustiveness.

no-unknown-parameters

function handle(input: unknown) {}

A type predicate may accept unknown for the parameter it narrows; other unknown parameters on the same function remain rejected.

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-readable-spacing

export const first = 1;
/** Documentation stays attached to second. */
export const second = 2;

Autofix inserts a blank line before the documentation. Inside functions, adjacent short variable declarations stay grouped, while multiline bindings and control-flow boundaries receive spacing. Adjacent function overload signatures and their implementation remain grouped. Existing blank lines are never removed. The rule takes no options; edit the vendored policy if your team's preferences differ.

Run oxlint --fix (or vp lint --fix), then your formatter, then lint again. The rule inserts whitespace only; it does not add braces, wrap expressions, sort imports, or infer every logical group. Keep indentation and wrapping with the formatter rather than enabling a competing stylistic preset.

The comment-aware engine is vendored from ESLint Stylistic under MIT. Copy its LICENSE and provenance along with the code; no third-party plugin dependency is needed.

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;

SAFETY remains the default marker. Comments immediately above exported declarations are recognized. Repositories with an established convention can configure one or more alternatives; every marker must still be followed by a colon and a non-empty justification:

{
  "anti-slop/require-safety-comment-for-type-assertion": [
    "error",
    { "markers": ["INVARIANT", "SAFETY"] }
  ]
}

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. pnpm check runs Oxlint, every RuleTester suite, TypeScript typechecking, and the skill-asset drift check.

License

MIT

Files in the repo

Repository payload12 top-level entries
  • .github
  • scripts
  • skills
  • src
  • .gitignore
  • .oxlintrc.json
  • AGENTS.md
  • LICENSE
  • package.json
  • pnpm-lock.yaml
  • README.md
  • tsconfig.json

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More plugins

Makes your AI agent think like the laziest senior dev in the room. The best code is the code you never wrote.

138k
1 add

Graphs that teach > graphs that impress. Turn any code into an interactive knowledge graph you can explore, search, and ask questions about. Works with Claude Code, Codex, Cursor, Copilot, Gemini CLI, and more.

82k
code-yeongyu/
oh-my-openagent

OmO: Just type "mass ulw" keyword with your prompt. Now you are the master of graph engineering.

69k

Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More

94k
cbrock84/
headcount

An agent organization for Claude Code, structured as a company — 15+ departments, 125+ skills, each independently installable.

1.4k