You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: website/src/pages/en/subgraphs/guides/subgraph-linter.mdx
+4-5Lines changed: 4 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,15 +9,14 @@ It complements existing tools by helping you catch problems locally while writin
9
9
10
10
## When to use it
11
11
12
-
Run Subgraph Linter when you want to detect handler and mapping issues that don't often appear until indexing starts, such as:
12
+
Run Subgraph Linter when you want to detect handler and mapping issues that don't often appear until indexing starts, such as:
13
13
14
14
- Entities saved with missing required fields
15
15
- Entity overwrite issues from concurrent/stale instances
16
16
- Optional values force-unwrapped without checks
17
17
- Divisions without guaranteeing a non-zero denominator
18
18
-`@derivedFrom` fields mutated directly or left stale
19
-
- Contract calls are used without being declared in the manifest
20
-
These bugs usually compile fine, but crash at runtime or silently produce incorrect data. Subgraph Linter performs static analysis on your mapping code to detect these issues before deploying the subgraph.
19
+
- Contract calls are used without being declared in the manifest These bugs usually compile fine, but crash at runtime or silently produce incorrect data. Subgraph Linter performs static analysis on your mapping code to detect these issues before deploying the subgraph.
21
20
22
21
## How it works
23
22
@@ -38,7 +37,7 @@ Subgraph Linter currently detects the following categories of issues:
38
37
-`entity-overwrite`: Detects cases where a handler works with an entity instance that becomes stale after calling a helper (or other code path) that loads and saves the same entity, and then the handler saves its stale instance and overwrites those updates.
39
38
-`unexpected-null`: Detects when entities may be saved in an invalid state—either because required fields weren’t initialized before `save()`, or because code attempts to assign to `@derivedFrom` fields.
40
39
-`unchecked-load`: Detects risky patterns where `Entity.load(...)` is treated as always present (for example via `!`) instead of explicitly handling the case where the entity doesn’t exist yet.
41
-
-`unchecked-nonnull`: Detects risky non-null assertions on values that can be missing at runtime, and encourages explicit guards instead of assuming the value is always set.
40
+
-`uncheckednonnull-`: Detects risky non-null assertions on values that can be missing at runtime, and encourages explicit guards instead of assuming the value is always set.
42
41
-`division-guard`: Detects divisions where the denominator may be zero on some execution paths, and suggests guarding the value before dividing.
43
42
-`derived-field-guard`: Detects cases where code updates “base” fields that require derived recomputation, but then saves without the helper(s) that keep derived values consistent.
44
43
-`helper-return-contract`: Detects helper functions that can return entities without fully initializing required fields, and flags call sites where the returned entity is used/saved without completing initialization.
@@ -79,7 +78,7 @@ You can also provide an explicit config file:
79
78
npm run check -- --manifest ../your-subgraph/subgraph.yaml --config ./subgraph-linter.config.json
80
79
```
81
80
82
-
*Configuration note:* Subgraph Linter supports configurable severities per check. By default, checks have sensible severities, but you can override them to match your project’s tolerance. Only checks with effective severity `error` cause a non-zero exit code; warnings-only runs exit successfully.
81
+
_Configuration note:_ Subgraph Linter supports configurable severities per check. By default, checks have sensible severities, but you can override them to match your project’s tolerance. Only checks with effective severity `error` cause a non-zero exit code; warnings-only runs exit successfully.
83
82
84
83
#### Configuration (severity overrides and suppression)
0 commit comments