passsy / pure-functionsr3
Keep Functions Pure
PublicKeep functions free of side effects unless one is explicitly necessary, so they stay easy to reason about and test.
detector.tsisolate · reads files, writes none · no network · 100 ms · 32 MBEdit
import { mentioned, onPrompt } from "@wellactually/sdk/v3";
import { isDartProject } from "dart-kit";
/**
* Purity is a property of a whole function, not of any one line, so there is
* no file heuristic. The rule speaks up when the topic does.
*/
onPrompt({
*detect(event) {
if (isDartProject(event)) {
yield* mentioned(event, ["side effect", "side effects", "pure function", "pure functions"]);
}
},
});
fixtures/dart_app/pubspec.yamlEdit
namedemo
package.jsonEdit
{
"name": "pure-functions",
"private": true,
"dependencies": {
"dart-kit": "*"
}
}