@avi2dg/checks 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +43 -1
  2. package/dist/index.js +43 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -80,6 +80,48 @@ export default {
80
80
  The registry version is pinned by the consumer's lockfile; bump
81
81
  `@avi2dg/checks` to adopt a new release.
82
82
 
83
+ ## Effect rules
84
+
85
+ The base config loads the `effect-channel` plugin and turns on
86
+ `effect-channel/no-error-channel-escape`, which refuses `Effect.ignore`,
87
+ `Effect.ignoreCause`, the `Effect.catchCause` family, and an
88
+ `Effect.catch` whose handler takes no error or names it `_`.
89
+
90
+ Two more rules ship off, because a repository writes only some of its
91
+ paths in Effect: code a host loads without `node_modules`, such as a
92
+ hook bundle or this oxlint plugin, cannot import it.
93
+
94
+ - `effect-channel/no-throw` refuses a `throw` statement.
95
+ - `effect-channel/no-try-catch` refuses a `try` statement with a
96
+ `catch` clause. `try`/`finally` stays allowed.
97
+
98
+ Each refusal says what to write instead: a `Schema.TaggedError` failed
99
+ through `Effect.fail`, a throwing call wrapped in `Effect.try` or
100
+ `Effect.tryPromise`, and recovery by tag with `Effect.catchTag`.
101
+
102
+ A repository turns them on for the paths it writes in Effect through an
103
+ `overrides` entry in its root `.oxlintrc.json`:
104
+
105
+ ```json
106
+ {
107
+ "extends": ["./node_modules/@avi2dg/checks/oxlintrc.json"],
108
+ "plugins": ["typescript", "oxc", "eslint", "import"],
109
+ "overrides": [
110
+ {
111
+ "files": ["src/**"],
112
+ "rules": {
113
+ "effect-channel/no-throw": "error",
114
+ "effect-channel/no-try-catch": "error"
115
+ }
116
+ }
117
+ ]
118
+ }
119
+ ```
120
+
121
+ oxlint resolves `files` against the directory of the config that holds
122
+ the override, so a config passed with `-c` from outside the repository
123
+ matches nothing and reports nothing.
124
+
83
125
  ## Test layout
84
126
 
85
127
  `checks-test-layout` fails unless the repo holds this shape, and names the
@@ -527,7 +569,7 @@ a tag off `main` and reruns the build, `dist/` check, lint, typecheck
527
569
  and tests before it publishes:
528
570
 
529
571
  ```sh
530
- git tag v0.4.0 && git push origin v0.4.0
572
+ git tag v0.5.0 && git push origin v0.5.0
531
573
  ```
532
574
 
533
575
  The `release` workflow publishes the tagged version through npm
package/dist/index.js CHANGED
@@ -69,10 +69,52 @@ var rule = {
69
69
  };
70
70
  var no_error_channel_escape_default = rule;
71
71
 
72
+ // effect-channel/no-throw.ts
73
+ var rule2 = {
74
+ meta: {
75
+ type: "problem",
76
+ docs: { description: "Disallow throw, which fails outside Effect's error channel" }
77
+ },
78
+ create(context) {
79
+ return {
80
+ ThrowStatement(node) {
81
+ context.report({
82
+ node,
83
+ message: "throw escapes the error channel: no type records the failure, so no caller has to answer for it. Define the failure with Schema.TaggedError and fail with it through Effect.fail, so it stays in E for Effect.catchTag to handle"
84
+ });
85
+ }
86
+ };
87
+ }
88
+ };
89
+ var no_throw_default = rule2;
90
+
91
+ // effect-channel/no-try-catch.ts
92
+ var rule3 = {
93
+ meta: {
94
+ type: "problem",
95
+ docs: { description: "Disallow a try statement with a catch clause, which recovers outside Effect's error channel" }
96
+ },
97
+ create(context) {
98
+ return {
99
+ CatchClause(node) {
100
+ context.report({
101
+ node,
102
+ message: "catch recovers outside the error channel: it takes whatever was thrown as unknown, bugs included. Wrap the throwing call in Effect.try or Effect.tryPromise, whose catch maps the cause to a Schema.TaggedError, and recover by tag with Effect.catchTag"
103
+ });
104
+ }
105
+ };
106
+ }
107
+ };
108
+ var no_try_catch_default = rule3;
109
+
72
110
  // effect-channel/index.ts
73
111
  var plugin = {
74
112
  meta: { name: "effect-channel" },
75
- rules: { "no-error-channel-escape": no_error_channel_escape_default }
113
+ rules: {
114
+ "no-error-channel-escape": no_error_channel_escape_default,
115
+ "no-throw": no_throw_default,
116
+ "no-try-catch": no_try_catch_default
117
+ }
76
118
  };
77
119
  var effect_channel_default = plugin;
78
120
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avi2dg/checks",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Deterministic checks shared across the captain's TypeScript repos",
5
5
  "license": "MIT",
6
6
  "repository": {