Skip to content

Commit 1d0d8da

Browse files
committed
update docs
1 parent 34cd85c commit 1d0d8da

1 file changed

Lines changed: 30 additions & 11 deletions

File tree

docs/rescript_ai.md

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,16 @@ Commands
2323
- `find-references`: Finds references from either a symbol path or a source location.
2424
2525
Initial rules
26-
- Lint: `forbidden-reference`, `single-use-function`, `alias-avoidance`, `forbidden-source-root-reference`, `preferred-type-syntax`
27-
- Rewrite: `prefer-switch`, `no-optional-some`, `preferred-type-syntax`
26+
- Lint:
27+
- `forbidden-reference`: Bans using configured module, value, and type references.
28+
- `single-use-function`: Reports local helper functions that are defined once and only used once.
29+
- `alias-avoidance`: Reports local aliases like `let f = Module.f`, `type t = Module.t`, and `module M = Long.Path`. Prefer the fully qualified reference instead.
30+
- `forbidden-source-root-reference`: Reports value and type references whose declarations come from configured source roots such as generated code folders.
31+
- `preferred-type-syntax`: Reports non-canonical type spellings like `Dict.t<_>` in favor of builtin syntax like `dict<_>`.
32+
- Rewrite:
33+
- `prefer-switch`: Rewrites eligible `if` / `else if` chains and ternaries into canonical `switch` forms.
34+
- `no-optional-some`: Rewrites redundant `~label=?Some(expr)` optional-argument wrapping into the direct labeled form.
35+
- `preferred-type-syntax`: Rewrites supported non-canonical type spellings like `Dict.t<_>` into builtin syntax like `dict<_>`.
2836
2937
Support
3038
- Add `.rescript-lint.json` config support, a shipped JSON schema, AI tooling docs, and golden tests for the new command surface
@@ -132,7 +140,14 @@ Proposed fields:
132140
Example JSON finding:
133141

134142
```json
135-
{"rule":"forbidden-reference","path":"src/A.res","range":[12,2,12,20],"severity":"error","symbol":"Belt.Array.forEach","message":"Forbidden reference"}
143+
{
144+
"rule": "forbidden-reference",
145+
"path": "src/A.res",
146+
"range": [12, 2, 12, 20],
147+
"severity": "error",
148+
"symbol": "Belt.Array.forEach",
149+
"message": "Forbidden reference"
150+
}
136151
```
137152

138153
## Lint Output Contract
@@ -198,8 +213,8 @@ Example shape:
198213
"severity": "error",
199214
"message": "Do not use Belt.Array helpers here.",
200215
"items": [
201-
{"kind": "module", "path": "Belt.Array"},
202-
{"kind": "value", "path": "Belt.Array.forEach"}
216+
{ "kind": "module", "path": "Belt.Array" },
217+
{ "kind": "value", "path": "Belt.Array.forEach" }
203218
]
204219
},
205220
{
@@ -329,6 +344,10 @@ This section is intentionally a scratchpad for future rules.
329344
- disallow plain functions that return JSX; require them to be defined as React components instead
330345
- goal: keep file shape predictable and preserve HMR-friendly module boundaries
331346

347+
### FFI shape
348+
349+
- disallow `@obj external`
350+
332351
### Size limits
333352

334353
- file length limits
@@ -408,9 +427,9 @@ Lint and rewrite config should each live under their own namespace in `.rescript
408427
"forbidden-reference": {
409428
"severity": "error",
410429
"items": [
411-
{"kind": "value", "path": "Belt.Array.forEach"},
412-
{"kind": "value", "path": "Belt.Array.map"},
413-
{"kind": "type", "path": "Js.Json.t"}
430+
{ "kind": "value", "path": "Belt.Array.forEach" },
431+
{ "kind": "value", "path": "Belt.Array.map" },
432+
{ "kind": "type", "path": "Js.Json.t" }
414433
]
415434
},
416435
"single-use-function": {
@@ -424,9 +443,9 @@ Lint and rewrite config should each live under their own namespace in `.rescript
424443
},
425444
"rewrite": {
426445
"rules": {
427-
"prefer-switch": {"enabled": true, "if": true, "ternary": true},
428-
"no-optional-some": {"enabled": true},
429-
"preferred-type-syntax": {"enabled": true, "dict": true}
446+
"prefer-switch": { "enabled": true, "if": true, "ternary": true },
447+
"no-optional-some": { "enabled": true },
448+
"preferred-type-syntax": { "enabled": true, "dict": true }
430449
}
431450
}
432451
}

0 commit comments

Comments
 (0)