API ContractsHTTP contracts
api-contracts/no-misleading-http-status
Explicit HTTP status exits should agree with the route's visible result while allowing accepted work and deliberate protocol or privacy contracts.
01 Examples
TypeScript
app.post("/users", async (_req, res) => { await createUser(); res.sendStatus(404); });Finding
Disallow statuses that contradict visible outcomes.
02 Enable it
Setup
Install the package, register its plugin factory, then enable the rule.
Install the package
pnpm add -D @scruple/api-contractsRegister the plugin
In scruple.config.ts, register the factory under the api-contracts namespace used by the rule ID.
import { apiContracts } from "@scruple/api-contracts";
plugins: {
"api-contracts": apiContracts(),
},Enable the rule
"api-contracts/no-misleading-http-status": "warn"- Package
@scruple/api-contracts- Default threshold
- 0.9
- Minimum confidence
- 0.75