{
  "markdown": "# anti-slop\n\n[![skills.sh](https://skills.sh/b/dmmulroy/anti-slop)](https://skills.sh/dmmulroy/anti-slop)\n\nOpinionated Oxlint rules that reject low-evidence and low-signal TypeScript and JavaScript patterns.\n\nAnti-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.\n\n**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.\n\n## Install with an agent skill\n\n```bash\nnpx skills add dmmulroy/anti-slop --skill install-anti-slop\n```\n\nThen 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.\n\nTo inspect available skills first:\n\n```bash\nnpx skills add dmmulroy/anti-slop --list\n```\n\n## Manual local installation\n\nCopy `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.\n\nRegister the copied entry point in `oxlint.config.ts`:\n\n```ts\nimport { defineConfig } from \"oxlint\";\n\nexport default defineConfig({\n  ignorePatterns: [\n    \".agent/**\",\n    \".agents/**\",\n    \".claude/**\",\n    \".codex/**\",\n    \".continue/**\",\n    \".cursor/**\",\n    \".gemini/**\",\n    \".opencode/**\",\n    \".pi/**\",\n    \".roo/**\",\n    \".windsurf/**\",\n    \"tools/oxlint/anti-slop/**\",\n  ],\n  jsPlugins: [\n    { name: \"anti-slop\", specifier: \"./tools/oxlint/anti-slop/index.ts\" },\n  ],\n  rules: {\n    \"anti-slop/no-chained-type-assertions\": \"error\",\n    \"anti-slop/no-conditional-empty-object-spread\": \"error\",\n    \"anti-slop/no-known-value-widening\": \"error\",\n    \"anti-slop/no-module-mocking\": \"error\",\n    \"anti-slop/no-object-parameters\": \"error\",\n    \"anti-slop/no-reflect-apply\": \"error\",\n    \"anti-slop/no-reflect-get\": \"error\",\n    \"anti-slop/no-runtime-typeof\": \"error\",\n    \"anti-slop/no-shape-in-symbol-names\": \"error\",\n    \"anti-slop/no-unknown-parameters\": \"error\",\n    \"anti-slop/no-unknown-returns\": \"error\",\n    \"anti-slop/no-unknown-type-aliases\": \"error\",\n    \"anti-slop/no-unsafe-dictionary-type\": \"error\",\n    \"anti-slop/no-widen-then-assert\": \"error\",\n    \"anti-slop/require-safety-comment-for-type-assertion\": \"error\"\n  }\n});\n```\n\nThe 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.\n\n### Optional Effect rules\n\nEffect-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:\n\n```ts\nexport default defineConfig({\n  jsPlugins: [\n    { name: \"anti-slop\", specifier: \"./tools/oxlint/anti-slop/index.ts\" },\n    {\n      name: \"anti-slop-effect\",\n      specifier: \"./tools/oxlint/anti-slop/effect/index.ts\"\n    }\n  ],\n  rules: {\n    \"anti-slop-effect/no-service-constructor-imports\": \"error\"\n  }\n});\n```\n\n## Rules\n\n### Generic rules\n\n- `no-chained-type-assertions` — rejects nested `as` and angle-bracket assertions that fabricate evidence; chains made only of `as const` remain valid.\n- `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`.\n- `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.\n- `no-module-mocking` — rejects Vitest and Jest `mock`, `doMock`, and `unstable_mockModule` calls in favor of real dependency seams.\n- `no-object-parameters` — rejects `object`, unions containing it, and scoped or transparent generic aliases that resolve to it on function inputs.\n- `no-reflect-apply` — rejects global `Reflect.apply` in favor of typed function calls.\n- `no-reflect-get` — rejects global `Reflect.get` in favor of typed property access or boundary parsing.\n- `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.\n- `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.\n- `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.\n- `no-unknown-returns` — rejects explicit function contracts that resolve to `unknown`, `Promise<unknown>`, or `PromiseLike<unknown>`, including scoped and transparent generic aliases.\n- `no-unknown-type-aliases` — rejects scoped and transparent generic aliases whose resolved type is `unknown`.\n- `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.\n- `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.\n- `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`.\n\n### Effect rules\n\n- `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.\n\n### Analysis boundaries\n\nThe 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.\n\n## Violation examples\n\nEach snippet below is rejected by the named rule.\n\n### `no-chained-type-assertions`\n\n```ts\nconst user = input as object as User;\n```\n\n### `no-conditional-empty-object-spread`\n\n```ts\nconst options = {\n  ...(timeout !== undefined ? { timeout } : {}),\n};\n```\n\n### `no-known-value-widening`\n\n```ts\nconst handlers: Record<string, Handler> = {\n  start: startHandler,\n};\n```\n\nThis discards the known `start` key. Preserve inference or use `satisfies Record<string, Handler>` instead.\n\nKnown values must not be widened back to `unknown` through a local type predicate:\n\n```ts\nfunction isUser(value: unknown): value is User {\n  return UserSchema.safeParse(value).success;\n}\n\ndeclare const user: User;\nisUser(user);\n```\n\nCall the predicate at the unparsed boundary, while the argument is still `unknown`.\n\n### `no-module-mocking`\n\n```ts\nvi.mock(\"./user-store\");\n```\n\n### `no-object-parameters`\n\n```ts\nfunction save(value: object) {}\n```\n\n### `no-reflect-apply`\n\n```ts\nconst value = Reflect.apply(operation, owner, args);\n```\n\n### `no-reflect-get`\n\n```ts\nconst value = Reflect.get(owner, key);\n```\n\n### `no-runtime-typeof`\n\n```ts\nif (typeof input === \"string\") {\n  useName(input);\n}\n```\n\nSchema-free projects can permit `typeof` checks directly inside type predicate and\nassertion functions while continuing to reject ad hoc checks elsewhere:\n\n```json\n{\n  \"anti-slop/no-runtime-typeof\": [\n    \"error\",\n    { \"allowInTypeGuards\": true }\n  ]\n}\n```\n\nThe 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.\n\n### `no-shape-in-symbol-names`\n\n```ts\ninterface UserShape {\n  id: string;\n}\n```\n\nStatic member reads such as `schema.shape` are allowed because the member name belongs to the value's owner and cannot be renamed locally.\n\n### Effect: `no-service-constructor-imports`\n\n```ts\nimport { makeIssueService } from \"./issue-service.ts\";\n```\n\nImport the owning Layer and yield `IssueService` instead. Focused `*.test.*` and `*.spec.*` files may import the constructor directly.\n\n### `no-unknown-parameters`\n\n```ts\nfunction handle(input: unknown) {}\n```\n\nA type predicate may accept `unknown` for the parameter it narrows; other `unknown`\nparameters on the same function remain rejected.\n\n### `no-unknown-returns`\n\n```ts\nfunction loadUser(): unknown {\n  return input;\n}\n```\n\n### `no-unknown-type-aliases`\n\n```ts\ntype ExternalValue = unknown;\n```\n\n### `no-unsafe-dictionary-type`\n\n```ts\ntype Metadata = Record<string, unknown>;\ntype OtherMetadata = { [key: string]: object };\n```\n\n### `no-widen-then-assert`\n\n```ts\nconst loaded: User = loadUser();\nconst stored: unknown = loaded;\nconst user = stored as User;\n```\n\n### `require-safety-comment-for-type-assertion`\n\n```ts\nconst userId = value as UserId;\n```\n\nAdd a specific justification immediately before a necessary assertion:\n\n```ts\n// SAFETY: parseUserId validated the identifier before branding it.\nconst userId = value as UserId;\n```\n\n`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:\n\n```json\n{\n  \"anti-slop/require-safety-comment-for-type-assertion\": [\n    \"error\",\n    { \"markers\": [\"INVARIANT\", \"SAFETY\"] }\n  ]\n}\n```\n\n## Development\n\n```bash\npnpm install\npnpm check\n```\n\n`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.\n\n## License\n\nMIT\n",
  "bytes": 11138,
  "sha": "16b81f9c98b7aad6eaaca74aa3f2fba2b039b0323cf556793c876e62eb33d17d",
  "repo_slug": "dmmulroy/anti-slop",
  "fonte": "repo",
  "truncated": false,
  "api": "https://agentalog.com/api/listings/skl_dmmulroy_anti_slop_install_anti_slop_87179005/readme"
}