GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — chore(lint): the effect lint error walks the alternatives before the … · pingdotgg/t3code@34ca613

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • oxlint-plugin-t3code/rules
    • no-unreasoned-state-sync.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎oxlint-plugin-t3code/rules/no-unreasoned-state-sync.ts‎

Copy file name to clipboardExpand all lines: oxlint-plugin-t3code/rules/no-unreasoned-state-sync.ts
+18-4Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ const isEffectHookCall = (node: ESTree.CallExpression): boolean => {
1818
return false;
1919
};
2020

21+
// Agents read this message and act on it, so it walks the alternatives before it shows the way out.
22+
const MESSAGE =
23+
"Stop and reconsider before keeping this effect. " +
24+
"Is it computable from props or state? Compute it during render; the compiler memoizes it. " +
25+
"Does it respond to a user action? Do it in that handler. " +
26+
"Does it reset state when a prop changes? Key the component on that prop. " +
27+
"Does it tell a parent or store that a value changed? Do it where the change happens. " +
28+
"Does it load app data? Read it from an atom. " +
29+
"Does it read a value from outside React? Use an atom or useSyncExternalStore. " +
30+
"An effect that sets state another effect reads is one handler or one derivation. " +
31+
"An effect is right only when it keeps something outside React in step with this component while mounted: " +
32+
"a DOM node, listener, timer, native module, connection, router, imperative toast, " +
33+
"or a registry entry or resource held until unmount. " +
34+
"Moving the same logic into a ref or store to dodge this rule is not a fix. " +
35+
"If the effect does that, name what it keeps in step on the line above: " +
36+
"`// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- <what it syncs with and why>`.";
37+
2138
// Every kept effect carries its reason in the suppression above it; t3code/require-suppression-reason
2239
// rejects a suppression that does not say why.
2340
export default defineRule({
@@ -37,10 +54,7 @@ export default defineRule({
3754
if (!isEffectHookCall(node)) return;
3855
context.report({
3956
node,
40-
message:
41-
"First ask whether this is synchronization that belongs in render or in the handler that causes it. " +
42-
"If an effect is the honest model, say why on the line above it: " +
43-
"`// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- <why>`.",
57+
message: MESSAGE,
4458
});
4559
},
4660
};

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.