`flarelint` audits Cloudflare Workers, Pages, and Astro edge applications at native Rust speed. Catches unsupported Node.js runtime built-ins, un-awaited promises, transaction hazards, and Pages routing quota limits before deployment.
Audits AST import and require specifiers. Flags strictly unsupported modules (`child_process`, `cluster`, `dgram`, `vm`, `v8`) and verifies `nodejs_compat` configuration.
// ❌ FAILS on Workers edge
import { spawn } from 'child_process';
import crypto from 'node:crypto'; // without nodejs_compat
// ✔️ PASSES with nodejs_compat
import { Buffer } from 'node:buffer';
Detects background async operations invoked inside request handlers that are neither awaited nor registered via `ctx.waitUntil(promise)`.
// ❌ Terminated prematurely when HTTP response sent
export default {
async fetch(req, env, ctx) {
sendTelemetry(req); // floating promise
return new Response("OK");
}
}
Enforces explicit `await` on storage methods, detects race hazards in `Promise.all` batch writes, and prohibits invalid nested transactions.
// ✔️ Atomically safe Durable Object batch write
await this.ctx.storage.transaction(async (txn) => {
await txn.put("keyA", 1);
await txn.put("keyB", 2);
});
Guarantees compliance with Cloudflare Pages 100-rule limit, verifies trailing wildcard placement, and detects shadowed or unneeded routing rules.
{
"version": 1,
"include": ["/*"],
"exclude": ["/static/*", "/favicon.ico"]
}
import { exec } from 'child_process';
import { Buffer } from 'buffer';
import crypto from 'node:crypto';
export default {
async fetch() { return new Response('OK'); }
};
ERROR node-compat/strictly-unsupported:1:1
'child_process' is strictly unsupported on edge.
WARN node-compat/prefer-node-protocol:2:1
Prefer explicit 'node:buffer' specifier.
| Command | Description | Example |
|---|---|---|
| flarelint check [PATH] | Runs all rules across JS, TS, Astro, and `_routes.json` files. | flarelint check . --strict |
| flarelint node-compat [PATH] | Scans for unsupported Node.js runtime built-in modules. | flarelint node-compat src/ |
| flarelint waituntil [PATH] | Detects floating promises inside request/queue handlers. | flarelint waituntil src/ |
| flarelint do-storage [PATH] | Lints Durable Object storage concurrency and transactions. | flarelint do-storage src/ |
| flarelint routes [PATH] | Lints Cloudflare Pages `_routes.json` quotas and globs. | flarelint routes public/_routes.json |
| flarelint completions <SHELL> | Generates shell completions (`zsh`, `bash`, `fish`, `powershell`). | flarelint completions zsh |