landmines README

README проекта с github.com/interfere-inc/landmines. Одним файлом markdown: README.md.

landmines

Oxlint rules that keep AI-written code honest.

Coding agents are fast, and they optimise for green checks. Left alone, they mock the thing under test, sleep until a race usually goes their way, retry the flake, raise the timeout, and narrate the diff in comments. Every one of those passes CI. None of them is true.

landmines makes the honest path the only one that lints. Each rule fails with a message that tells the agent (or the human) what to do instead, so the fix lands in the same loop that tripped it.

Built and used in production at Interfere.

Install

bun add -d oxlint @interfere/landmines

Extend the recommended configuration in .oxlintrc.json:

{
  "extends": ["./node_modules/@interfere/landmines/configs/recommended.json"]
}

Or register only the plugins you want:

{
  "jsPlugins": [
    { "name": "landmines-testing", "specifier": "@interfere/landmines/testing" }
  ],
  "rules": {
    "landmines-testing/no-test-doubles": "error"
  }
}

Requires Oxlint 1.81 or later and Node 22.18 or later.

Rules

landmines-testing

Tests that can't lie.

Rule What it stops
no-test-doubles Replacing dependency behaviour in tests: module mocks, vi.fn(impl), stubbed globals, patched prototypes, hand-written bindings and fake responses. Use the real implementation and MSW for the network. Observation-only spies are allowed.
strict-msw Starting MSW without onUnhandledFrame: "error" (msw 3) or onUnhandledRequest: "error" (msw 2), so unmocked requests reach the network.
no-fixed-sleep Awaiting a fixed real-time delay in a test or hook. Await the operation or a signal it emits.
no-unsignaled-poll expect.poll and vi.waitFor on request recorders and spy state, which race a deadline instead of awaiting an event.
no-flake-masking Test retries and raised timeouts, per test or in Vitest config. A test that passes on rerun is a flake to fix.

no-fixed-sleep, strict-msw and no-flake-masking accept a per-file allowlist with an exact count, so you can adopt them in an existing codebase and ratchet down:

{
  "landmines-testing/no-flake-masking": [
    "error",
    { "allow": { "src/legacy/slow.test.ts": 2 } }
  ]
}

The rule reports when a file has fewer violations than its allowance, so the list only shrinks.

no-fixed-sleep also reports sleeps in callbacks that run while the test waits, such as act(async () => …) or .then(async () => …). Callbacks passed to other calls, like page.route handlers, are left alone. Pass runNow to replace the default callee names (act, waitFor, then, catch, finally, step), matched against a call's function or method name:

{
  "landmines-testing/no-fixed-sleep": [
    "error",
    {
      "runNow": ["act", "waitFor", "then", "catch", "finally", "step", "within"]
    }
  ]
}

landmines-style

Rule What it stops
no-comments Prose comments. Allowed: functional directives (oxlint-disable, @ts-expect-error, /* @__PURE__ */, licence headers…), single-line // WARNING: comments for dangerous recurring footguns (configurable with allow), and TSDoc on exported public API. Rationale belongs in the PR.

Pass publicApi (regular expressions matched against the file path) to allow TSDoc only in your published packages:

{
  "landmines-style/no-comments": ["error", { "publicApi": ["/packages/sdk/"] }]
}

Pass allow to choose which single-line comment prefixes are kept. It defaults to ["WARNING"]; add "SAFETY" to keep the // SAFETY: comments that anti-slop's require-safety-comment-for-type-assertion requires:

{
  "landmines-style/no-comments": ["error", { "allow": ["WARNING", "SAFETY"] }]
}

landmines-structure

Rule What it stops
colocated-tests Tests detached from the implementation they import. Tests live beside their subject or in its local tests/ directory.
test-file-names .spec.ts, .tests.ts, helpers.ts, mocks.ts and friends. Use .test.ts, .fixture.ts and .test-utils.ts.
package-exports Unrestricted source exports such as "./*": "./src/*.ts". Declare explicit entrypoints or named public namespaces in package.json.

landmines-types

Rule What it stops
no-explicit-return-types Annotated return types on implementations. Let them be inferred; pin a contract with satisfies where it matters.

Pairs well with

Contributing

bun install
bun run lint && bun run typecheck && bun run test

Add a changeset with bun changeset for any user-facing change.

License

MIT

landmines (interfere-inc/landmines)

Ищем в базе…

Что это?Набор правил для Oxlint (плагин для линтера), который не даёт ИИ-агентам подделывать зелёные проверки: моки в тестах, фиксированные паузы, повторные запуски нестабильных тестов, увеличенные таймауты и комментарии, которые пересказывают изменения в коде.
Это тест-раннер или линтер?Ни то, ни другое само по себе. Это плагин для Oxlint, поэтому Oxlint запускает его правила в вашем существующем шаге линтинга. Правила сгруппированы по тестированию, стилю, структуре и типам.
Как включить это в моём проекте?Расширьте рекомендованную конфигурацию в .oxlintrc.json или подключите только нужные плагины, а затем запускайте Oxlint как обычно.
Какие версии нужны в первую очередь?Oxlint 1.81 или новее и Node 22.18 или новее.
Зачем ИИ-агентам эти правила?Агенты оптимизируют под зелёные проверки, поэтому без присмотра они мокают тестируемый код, ставят паузы, пока гонки состояний обычно не пойдут в нужную им сторону, повторно запускают нестабильные тесты и увеличивают таймауты. Всё это проходит CI, но реальной корректности за этим не стоит.
Что происходит, если правило нарушено?Сообщение об ошибке подсказывает, что сделать вместо этого, поэтому агент или человек исправляет проблему в том же цикле, а не обходит её.
Можно ли ограничить TSDoc опубликованными пакетами?Да. Опция publicApi принимает регулярные выражения, которые проверяются по путям к файлам, поэтому TSDoc разрешён только в ваших опубликованных пакетах.
Автор
interfere-inc
Размер
0.1 MB
Звёзды
593
Возраст
21 д
Коммиты · 90 дней