@ox0/guards 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -0
- package/bin/ox0-guards.js +22 -0
- package/dist/index.js +1023 -0
- package/package.json +33 -0
- package/src/ast-helpers.ts +168 -0
- package/src/check.ts +429 -0
- package/src/cli.ts +160 -0
- package/src/guards/index.ts +24 -0
- package/src/guards/missing-label.ts +79 -0
- package/src/guards/no-async-react-component.ts +42 -0
- package/src/guards/no-bare-intl.ts +54 -0
- package/src/guards/no-css-import.ts +102 -0
- package/src/guards/no-effect-set-state-chain.ts +189 -0
- package/src/guards/no-set-state-in-render.ts +91 -0
- package/src/guards/no-unsafe-type-assertion.ts +50 -0
- package/src/guards/no-web-storage.ts +55 -0
- package/src/guards/require-effect-cleanup.ts +234 -0
- package/src/guards/stable-provider-values.ts +66 -0
- package/src/guards.ts +1 -0
- package/src/index.ts +30 -0
- package/src/types.ts +73 -0
package/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# @ox0/guards
|
|
2
|
+
|
|
3
|
+
`@ox0/guards` is a deterministic syntax-level guard runner for React and TypeScript projects.
|
|
4
|
+
|
|
5
|
+
## Primary Usage
|
|
6
|
+
|
|
7
|
+
Inside `ox0`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pnpm run check:guards
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Inside another project where this package is installed:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm exec ox0-guards --project .
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## LLM Notes
|
|
20
|
+
|
|
21
|
+
- Treat this tool like a fast project-specific linter.
|
|
22
|
+
- Rules should reuse the parsed AST for a file instead of reparsing.
|
|
23
|
+
- Prefer high-signal syntax checks over broad heuristic rules.
|
|
24
|
+
- Keep suppressions explicit and narrow.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawnSync } from "node:child_process"
|
|
4
|
+
import { createRequire } from "node:module"
|
|
5
|
+
import { dirname, join } from "node:path"
|
|
6
|
+
import { fileURLToPath } from "node:url"
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url)
|
|
9
|
+
const cliPath = fileURLToPath(new URL("../src/cli.ts", import.meta.url))
|
|
10
|
+
const tsxDir = dirname(require.resolve("tsx/package.json"))
|
|
11
|
+
const tsxPath = join(tsxDir, "dist/cli.mjs")
|
|
12
|
+
const result = spawnSync(process.execPath, [tsxPath, cliPath, ...process.argv.slice(2)], {
|
|
13
|
+
stdio: "inherit",
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
if (typeof result.status === "number") {
|
|
17
|
+
process.exit(result.status)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (result.error) {
|
|
21
|
+
throw result.error
|
|
22
|
+
}
|