passsy / prefer-debuggable-coder3
Prefer Debuggable Code
PublicName intermediate values and declare them close to their use, so debuggers, logs and stack traces can show the state when code fails.
detector.tsisolate · reads files, writes none · no network · 100 ms · 32 MBEdit
import { mentioned, onPrompt } from "@wellactually/sdk/v3";
import { isDartProject } from "dart-kit";
/**
* Words only. Method chains and inline expressions are idiomatic Dart;
* whether an intermediate value deserves a name is exactly the judgment call
* the rule text teaches, not a shape a regex can convict.
*/
onPrompt({
*detect(event) {
if (isDartProject(event)) {
yield* mentioned(event, ["debuggable", "breakpoint", "breakpoints"]);
}
},
});
fixtures/dart_app/pubspec.yamlEdit
namedemo
package.jsonEdit
{
"name": "prefer-debuggable-code",
"private": true,
"dependencies": {
"dart-kit": "*"
}
}