@autotelic/plumb 0.6.1 → 0.6.3

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 (210) hide show
  1. package/dist/rules/require-deprecated-tag-for-legacy-comments.js +1 -1
  2. package/package.json +18 -18
  3. package/dist/src/configs/recommended-rules.d.ts +0 -20
  4. package/dist/src/configs/recommended-rules.js +0 -22
  5. package/dist/src/effect/index.d.ts +0 -3
  6. package/dist/src/effect/index.js +0 -60
  7. package/dist/src/effect/rules/guarded-op-must-return-effect.d.ts +0 -6
  8. package/dist/src/effect/rules/guarded-op-must-return-effect.js +0 -235
  9. package/dist/src/effect/rules/guarded-op-must-return-option.d.ts +0 -2
  10. package/dist/src/effect/rules/guarded-op-must-return-option.js +0 -88
  11. package/dist/src/effect/rules/no-cascading-layer-provide.d.ts +0 -6
  12. package/dist/src/effect/rules/no-cascading-layer-provide.js +0 -73
  13. package/dist/src/effect/rules/no-decode-unknown-option.d.ts +0 -7
  14. package/dist/src/effect/rules/no-decode-unknown-option.js +0 -34
  15. package/dist/src/effect/rules/no-direct-browser-storage.d.ts +0 -2
  16. package/dist/src/effect/rules/no-direct-browser-storage.js +0 -88
  17. package/dist/src/effect/rules/no-direct-fetch.d.ts +0 -2
  18. package/dist/src/effect/rules/no-direct-fetch.js +0 -37
  19. package/dist/src/effect/rules/no-manual-field-guards.d.ts +0 -6
  20. package/dist/src/effect/rules/no-manual-field-guards.js +0 -129
  21. package/dist/src/effect/rules/no-nested-layer-provide.d.ts +0 -2
  22. package/dist/src/effect/rules/no-nested-layer-provide.js +0 -50
  23. package/dist/src/effect/rules/no-nullish-default-on-partial-input.d.ts +0 -13
  24. package/dist/src/effect/rules/no-nullish-default-on-partial-input.js +0 -109
  25. package/dist/src/effect/rules/no-raw-error-forwarding.d.ts +0 -12
  26. package/dist/src/effect/rules/no-raw-error-forwarding.js +0 -103
  27. package/dist/src/effect/rules/no-schema-class-modeling.d.ts +0 -2
  28. package/dist/src/effect/rules/no-schema-class-modeling.js +0 -52
  29. package/dist/src/effect/rules/no-service-constructor-imports.d.ts +0 -2
  30. package/dist/src/effect/rules/no-service-constructor-imports.js +0 -42
  31. package/dist/src/effect/rules/no-silent-error-swallow.d.ts +0 -2
  32. package/dist/src/effect/rules/no-silent-error-swallow.js +0 -95
  33. package/dist/src/effect/rules/no-static-effect-service-forwarders.d.ts +0 -6
  34. package/dist/src/effect/rules/no-static-effect-service-forwarders.js +0 -222
  35. package/dist/src/effect/rules/no-try-catch.d.ts +0 -2
  36. package/dist/src/effect/rules/no-try-catch.js +0 -30
  37. package/dist/src/effect/rules/no-unguarded-json-parse.d.ts +0 -5
  38. package/dist/src/effect/rules/no-unguarded-json-parse.js +0 -200
  39. package/dist/src/effect/rules/option-core-needs-effect-public.d.ts +0 -5
  40. package/dist/src/effect/rules/option-core-needs-effect-public.js +0 -76
  41. package/dist/src/effect/rules/prefer-die-for-precondition-defects.d.ts +0 -5
  42. package/dist/src/effect/rules/prefer-die-for-precondition-defects.js +0 -112
  43. package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.d.ts +0 -5
  44. package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.js +0 -72
  45. package/dist/src/effect/rules/prefer-effect-match.d.ts +0 -2
  46. package/dist/src/effect/rules/prefer-effect-match.js +0 -74
  47. package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.d.ts +0 -2
  48. package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.js +0 -75
  49. package/dist/src/effect/rules/prefer-named-guard-predicate.d.ts +0 -2
  50. package/dist/src/effect/rules/prefer-named-guard-predicate.js +0 -93
  51. package/dist/src/effect/rules/prefer-option-pipeline.d.ts +0 -2
  52. package/dist/src/effect/rules/prefer-option-pipeline.js +0 -87
  53. package/dist/src/effect/rules/prefer-ordering-match.d.ts +0 -2
  54. package/dist/src/effect/rules/prefer-ordering-match.js +0 -135
  55. package/dist/src/effect/rules/prefer-tagged-enum.d.ts +0 -2
  56. package/dist/src/effect/rules/prefer-tagged-enum.js +0 -66
  57. package/dist/src/effect/rules/require-schema-type-derivation.d.ts +0 -7
  58. package/dist/src/effect/rules/require-schema-type-derivation.js +0 -80
  59. package/dist/src/index.d.ts +0 -3
  60. package/dist/src/index.js +0 -106
  61. package/dist/src/meta/index.d.ts +0 -7
  62. package/dist/src/meta/index.js +0 -22
  63. package/dist/src/meta/rules/no-disable-directives.d.ts +0 -6
  64. package/dist/src/meta/rules/no-disable-directives.js +0 -35
  65. package/dist/src/meta/rules/no-manual-ancestor-walks.d.ts +0 -2
  66. package/dist/src/meta/rules/no-manual-ancestor-walks.js +0 -26
  67. package/dist/src/meta/rules/prefer-before-file-scope.d.ts +0 -2
  68. package/dist/src/meta/rules/prefer-before-file-scope.js +0 -57
  69. package/dist/src/meta/rules/require-create-once.d.ts +0 -2
  70. package/dist/src/meta/rules/require-create-once.js +0 -51
  71. package/dist/src/meta/rules/require-rule-tester.d.ts +0 -2
  72. package/dist/src/meta/rules/require-rule-tester.js +0 -50
  73. package/dist/src/react/index.d.ts +0 -3
  74. package/dist/src/react/index.js +0 -16
  75. package/dist/src/react/role.d.ts +0 -23
  76. package/dist/src/react/role.js +0 -30
  77. package/dist/src/react/rules/require-dot-notation-exports.d.ts +0 -27
  78. package/dist/src/react/rules/require-dot-notation-exports.js +0 -144
  79. package/dist/src/react/rules/require-guarded-context-hook.d.ts +0 -19
  80. package/dist/src/react/rules/require-guarded-context-hook.js +0 -167
  81. package/dist/src/react/rules/require-tripartite-context.d.ts +0 -17
  82. package/dist/src/react/rules/require-tripartite-context.js +0 -160
  83. package/dist/src/react/rules/use-encapsulation.d.ts +0 -22
  84. package/dist/src/react/rules/use-encapsulation.js +0 -97
  85. package/dist/src/rules/no-anonymous-wide-tuples.d.ts +0 -7
  86. package/dist/src/rules/no-anonymous-wide-tuples.js +0 -34
  87. package/dist/src/rules/no-barrel-export-star.d.ts +0 -2
  88. package/dist/src/rules/no-barrel-export-star.js +0 -26
  89. package/dist/src/rules/no-boolean-field-signals.d.ts +0 -2
  90. package/dist/src/rules/no-boolean-field-signals.js +0 -279
  91. package/dist/src/rules/no-builtin-throws.d.ts +0 -6
  92. package/dist/src/rules/no-builtin-throws.js +0 -74
  93. package/dist/src/rules/no-chained-type-assertions.d.ts +0 -2
  94. package/dist/src/rules/no-chained-type-assertions.js +0 -54
  95. package/dist/src/rules/no-conditional-empty-object-spread.d.ts +0 -2
  96. package/dist/src/rules/no-conditional-empty-object-spread.js +0 -36
  97. package/dist/src/rules/no-duplicated-literal-union.d.ts +0 -6
  98. package/dist/src/rules/no-duplicated-literal-union.js +0 -66
  99. package/dist/src/rules/no-exported-mutable-state.d.ts +0 -7
  100. package/dist/src/rules/no-exported-mutable-state.js +0 -104
  101. package/dist/src/rules/no-generic-export-names.d.ts +0 -2
  102. package/dist/src/rules/no-generic-export-names.js +0 -141
  103. package/dist/src/rules/no-impossible-branch-throw.d.ts +0 -2
  104. package/dist/src/rules/no-impossible-branch-throw.js +0 -51
  105. package/dist/src/rules/no-known-value-widening.d.ts +0 -2
  106. package/dist/src/rules/no-known-value-widening.js +0 -176
  107. package/dist/src/rules/no-module-mocking.d.ts +0 -2
  108. package/dist/src/rules/no-module-mocking.js +0 -90
  109. package/dist/src/rules/no-multiple-function-params.d.ts +0 -2
  110. package/dist/src/rules/no-multiple-function-params.js +0 -155
  111. package/dist/src/rules/no-mutable-environment-capture.d.ts +0 -7
  112. package/dist/src/rules/no-mutable-environment-capture.js +0 -134
  113. package/dist/src/rules/no-nondeterministic-core.d.ts +0 -6
  114. package/dist/src/rules/no-nondeterministic-core.js +0 -63
  115. package/dist/src/rules/no-object-parameters.d.ts +0 -2
  116. package/dist/src/rules/no-object-parameters.js +0 -95
  117. package/dist/src/rules/no-optional-function-parameters.d.ts +0 -7
  118. package/dist/src/rules/no-optional-function-parameters.js +0 -44
  119. package/dist/src/rules/no-product-of-state-booleans.d.ts +0 -2
  120. package/dist/src/rules/no-product-of-state-booleans.js +0 -79
  121. package/dist/src/rules/no-redundant-derived-field.d.ts +0 -6
  122. package/dist/src/rules/no-redundant-derived-field.js +0 -194
  123. package/dist/src/rules/no-reflect-apply.d.ts +0 -2
  124. package/dist/src/rules/no-reflect-apply.js +0 -29
  125. package/dist/src/rules/no-reflect-get.d.ts +0 -2
  126. package/dist/src/rules/no-reflect-get.js +0 -29
  127. package/dist/src/rules/no-reinterpret-cast.d.ts +0 -2
  128. package/dist/src/rules/no-reinterpret-cast.js +0 -68
  129. package/dist/src/rules/no-runtime-typeof.d.ts +0 -2
  130. package/dist/src/rules/no-runtime-typeof.js +0 -54
  131. package/dist/src/rules/no-sentinel-comparison-union.d.ts +0 -2
  132. package/dist/src/rules/no-sentinel-comparison-union.js +0 -139
  133. package/dist/src/rules/no-shape-in-symbol-names.d.ts +0 -2
  134. package/dist/src/rules/no-shape-in-symbol-names.js +0 -39
  135. package/dist/src/rules/no-single-use-private-functions.d.ts +0 -17
  136. package/dist/src/rules/no-single-use-private-functions.js +0 -419
  137. package/dist/src/rules/no-sql-string-interpolation.d.ts +0 -7
  138. package/dist/src/rules/no-sql-string-interpolation.js +0 -62
  139. package/dist/src/rules/no-stacked-jsdoc-blocks.d.ts +0 -2
  140. package/dist/src/rules/no-stacked-jsdoc-blocks.js +0 -50
  141. package/dist/src/rules/no-stray-inline-comments.d.ts +0 -2
  142. package/dist/src/rules/no-stray-inline-comments.js +0 -74
  143. package/dist/src/rules/no-swappable-primitive-params.d.ts +0 -2
  144. package/dist/src/rules/no-swappable-primitive-params.js +0 -96
  145. package/dist/src/rules/no-tag-ladder-assertions.d.ts +0 -6
  146. package/dist/src/rules/no-tag-ladder-assertions.js +0 -63
  147. package/dist/src/rules/no-transposed-field-reads.d.ts +0 -8
  148. package/dist/src/rules/no-transposed-field-reads.js +0 -101
  149. package/dist/src/rules/no-unit-return-validators.d.ts +0 -2
  150. package/dist/src/rules/no-unit-return-validators.js +0 -64
  151. package/dist/src/rules/no-unknown-parameters.d.ts +0 -2
  152. package/dist/src/rules/no-unknown-parameters.js +0 -82
  153. package/dist/src/rules/no-unknown-returns.d.ts +0 -2
  154. package/dist/src/rules/no-unknown-returns.js +0 -86
  155. package/dist/src/rules/no-unknown-type-aliases.d.ts +0 -2
  156. package/dist/src/rules/no-unknown-type-aliases.js +0 -64
  157. package/dist/src/rules/no-unsafe-dictionary-type.d.ts +0 -2
  158. package/dist/src/rules/no-unsafe-dictionary-type.js +0 -116
  159. package/dist/src/rules/no-vague-test-filenames.d.ts +0 -2
  160. package/dist/src/rules/no-vague-test-filenames.js +0 -61
  161. package/dist/src/rules/no-widen-then-assert.d.ts +0 -2
  162. package/dist/src/rules/no-widen-then-assert.js +0 -268
  163. package/dist/src/rules/prefer-payload-brand.d.ts +0 -2
  164. package/dist/src/rules/prefer-payload-brand.js +0 -57
  165. package/dist/src/rules/prefer-property-tests.d.ts +0 -5
  166. package/dist/src/rules/prefer-property-tests.js +0 -39
  167. package/dist/src/rules/require-canonical-stringify-for-identity.d.ts +0 -8
  168. package/dist/src/rules/require-canonical-stringify-for-identity.js +0 -72
  169. package/dist/src/rules/require-deprecated-tag-for-legacy-comments.d.ts +0 -2
  170. package/dist/src/rules/require-deprecated-tag-for-legacy-comments.js +0 -34
  171. package/dist/src/rules/require-exhaustive-tag-switch.d.ts +0 -7
  172. package/dist/src/rules/require-exhaustive-tag-switch.js +0 -34
  173. package/dist/src/rules/require-fc-block-predicate.d.ts +0 -2
  174. package/dist/src/rules/require-fc-block-predicate.js +0 -37
  175. package/dist/src/rules/require-jsdoc-on-exported.d.ts +0 -2
  176. package/dist/src/rules/require-jsdoc-on-exported.js +0 -66
  177. package/dist/src/rules/require-published-order.d.ts +0 -2
  178. package/dist/src/rules/require-published-order.js +0 -102
  179. package/dist/src/rules/require-safety-comment-for-type-assertion.d.ts +0 -2
  180. package/dist/src/rules/require-safety-comment-for-type-assertion.js +0 -53
  181. package/dist/src/rules/require-sort-comparator.d.ts +0 -7
  182. package/dist/src/rules/require-sort-comparator.js +0 -34
  183. package/dist/src/rules/test-utils.d.ts +0 -35
  184. package/dist/src/rules/test-utils.js +0 -53
  185. package/dist/src/shared/ancestors.d.ts +0 -18
  186. package/dist/src/shared/ancestors.js +0 -19
  187. package/dist/src/shared/child-nodes.d.ts +0 -12
  188. package/dist/src/shared/child-nodes.js +0 -26
  189. package/dist/src/shared/dictionary-types.d.ts +0 -55
  190. package/dist/src/shared/dictionary-types.js +0 -413
  191. package/dist/src/shared/is-node.d.ts +0 -9
  192. package/dist/src/shared/is-node.js +0 -10
  193. package/dist/src/shared/lexical-type-parameters.d.ts +0 -12
  194. package/dist/src/shared/lexical-type-parameters.js +0 -50
  195. package/dist/src/shared/reflect-method.d.ts +0 -15
  196. package/dist/src/shared/reflect-method.js +0 -32
  197. package/dist/src/shared/rule-options.d.ts +0 -18
  198. package/dist/src/shared/rule-options.js +0 -12
  199. package/dist/src/shared/structural.d.ts +0 -54
  200. package/dist/src/shared/structural.js +0 -40
  201. package/dist/src/testing/index.d.ts +0 -2
  202. package/dist/src/testing/index.js +0 -1
  203. package/dist/src/testing/testable-rule.d.ts +0 -39
  204. package/dist/src/testing/testable-rule.js +0 -84
  205. package/dist/src/ui/index.d.ts +0 -12
  206. package/dist/src/ui/index.js +0 -18
  207. package/dist/src/ui/manifest.d.ts +0 -34
  208. package/dist/src/ui/manifest.js +0 -75
  209. package/dist/src/ui/rules/no-deprecated-parts.d.ts +0 -3
  210. package/dist/src/ui/rules/no-deprecated-parts.js +0 -131
@@ -1,88 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- import { ancestorsOf } from "../../shared/ancestors.js";
3
- import { isString } from "../../shared/structural.js";
4
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
- const BANNED_STORAGE = new Set(["indexedDB", "localStorage", "sessionStorage"]);
6
- /**
7
- * The banned-storage global named by an identifier, if any.
8
- *
9
- * @param {ESTree.Node} node - The identifier node to test.
10
- * @returns {string | null} The banned storage name, or null.
11
- */
12
- function storageName(node) {
13
- if (node.type !== "Identifier")
14
- return null;
15
- return BANNED_STORAGE.has(node.name) ? node.name : null;
16
- }
17
- /** Browser storage globals hide I/O from the Effect runtime; persist through KeyValueStore or an injected store. */
18
- export const noDirectBrowserStorageRule = defineRule({
19
- meta: {
20
- type: "problem",
21
- docs: {
22
- description: "Disallow direct browser storage globals (indexedDB, localStorage, sessionStorage); persist through Effect's KeyValueStore/IndexedDb modules or an injected storage service.",
23
- },
24
- messages: {
25
- directStorage: "`{{name}}` is reached directly, hiding I/O from the Effect runtime. Persist through Effect's KeyValueStore/IndexedDb layer or an injected storage service so access stays testable and swappable.",
26
- },
27
- },
28
- createOnce(context) {
29
- const reportStorage = (node, name) => {
30
- context.report({ node, messageId: "directStorage", data: { name } });
31
- };
32
- return {
33
- before() {
34
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
35
- return false;
36
- },
37
- Identifier(node) {
38
- const name = storageName(node);
39
- if (name === null)
40
- return;
41
- const chain = ancestorsOf(context.sourceCode, node);
42
- const parent = chain[0];
43
- const grandparent = chain[1];
44
- if (parent === undefined)
45
- return;
46
- if (parent.type === "MemberExpression") {
47
- return;
48
- }
49
- if (parent.type === "Property") {
50
- const containerType = grandparent === undefined ? "" : grandparent.type;
51
- if (parent.key === node && parent.value !== node && containerType !== "ObjectPattern") {
52
- return;
53
- }
54
- }
55
- if (parent.type === "ImportSpecifier") {
56
- if (parent.imported === node && parent.local !== node) {
57
- return;
58
- }
59
- }
60
- reportStorage(node, name);
61
- },
62
- MemberExpression(node) {
63
- const direct = storageName(node.object);
64
- if (direct !== null) {
65
- reportStorage(node, direct);
66
- return;
67
- }
68
- if (node.object.type !== "Identifier")
69
- return;
70
- const objectName = node.object.name;
71
- if (objectName !== "globalThis" && objectName !== "window")
72
- return;
73
- let propertyName;
74
- if (node.computed) {
75
- if (node.property.type === "Literal" && isString(node.property.value)) {
76
- propertyName = node.property.value;
77
- }
78
- }
79
- else if (node.property.type === "Identifier") {
80
- propertyName = node.property.name;
81
- }
82
- if (propertyName !== undefined && BANNED_STORAGE.has(propertyName)) {
83
- reportStorage(node, propertyName);
84
- }
85
- },
86
- };
87
- },
88
- });
@@ -1,2 +0,0 @@
1
- /** Bare `fetch` reaches past the application boundary un-injected; require a client service. */
2
- export declare const noDirectFetchRule: import("@oxlint/plugins").Rule;
@@ -1,37 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
3
- /** Bare `fetch` reaches past the application boundary un-injected; require a client service. */
4
- export const noDirectFetchRule = defineRule({
5
- meta: {
6
- type: "problem",
7
- docs: {
8
- description: "Disallow direct fetch calls; acquire an HTTP client service (e.g. Effect's HttpClient) so requests are injectable, cancellable, and testable.",
9
- },
10
- messages: {
11
- directFetch: "Bare `fetch` bypasses the injected HTTP client service. Route the request through a client dependency so calls are injectable, cancellable, and testable.",
12
- },
13
- },
14
- createOnce(context) {
15
- return {
16
- before() {
17
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
18
- return false;
19
- },
20
- CallExpression(node) {
21
- const callee = node.callee;
22
- if (callee.type === "Identifier" && callee.name === "fetch") {
23
- context.report({ node, messageId: "directFetch" });
24
- return;
25
- }
26
- if (callee.type === "MemberExpression" &&
27
- callee.computed !== true &&
28
- callee.property.type === "Identifier" &&
29
- callee.property.name === "fetch" &&
30
- callee.object.type === "Identifier" &&
31
- (callee.object.name === "window" || callee.object.name === "globalThis")) {
32
- context.report({ node, messageId: "directFetch" });
33
- }
34
- },
35
- };
36
- },
37
- });
@@ -1,6 +0,0 @@
1
- /**
2
- * Once a module decodes payloads through SchemaParser, per-field validation
3
- * belongs in Schema refinements (checks/filters) so evidence flows through the
4
- * schema issue channel instead of hand-rolled ladders beside the decoder.
5
- */
6
- export declare const noManualFieldGuardsRule: import("@oxlint/plugins").Rule;
@@ -1,129 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- import { ancestorsOf } from "../../shared/ancestors.js";
3
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
4
- function calleeName(node) {
5
- const callee = node.callee;
6
- if (callee.type === "MemberExpression" && callee.property.type === "Identifier") {
7
- return callee.property.name;
8
- }
9
- return null;
10
- }
11
- /** Whether this node sits inside a `Schema.makeFilter` predicate, where ad-hoc checks are the point.
12
- *
13
- * @param {ESTree.Node} node - The visited node.
14
- * @param {ReadonlyArray<ESTree.Node>} ancestors - Nearest-first ancestor chain of `node`.
15
- * @returns {boolean} True when enclosed by a makeFilter call.
16
- */
17
- function insideMakeFilter(node, ancestors) {
18
- for (let index = ancestors.length - 1; index >= 0; index--) {
19
- const current = ancestors[index];
20
- if (current.type === "Program")
21
- break;
22
- if (current.type === "CallExpression" && calleeName(current) === "makeFilter") {
23
- return true;
24
- }
25
- }
26
- return false;
27
- }
28
- /**
29
- * Once a module decodes payloads through SchemaParser, per-field validation
30
- * belongs in Schema refinements (checks/filters) so evidence flows through the
31
- * schema issue channel instead of hand-rolled ladders beside the decoder.
32
- */
33
- export const noManualFieldGuardsRule = defineRule({
34
- meta: {
35
- type: "suggestion",
36
- docs: {
37
- description: "In modules that decode via SchemaParser, require field validation to live in Schema refinements rather than hand-rolled regex tests and Option-tag guards.",
38
- },
39
- messages: {
40
- regexTest: "Hand-rolled lexical check beside a SchemaParser decode. Move this predicate into a Schema refinement (`.check(Schema.makeFilter(...))`) so failures surface as schema issue evidence.",
41
- optionGuard: "Hand-rolled Option-tag guard beside a SchemaParser decode. Validate the field with a Schema refinement (or decode into the domain value via `SchemaGetter.transformOrFail`) so the ladder branch disappears.",
42
- },
43
- },
44
- createOnce(context) {
45
- let hasDecode = false;
46
- const pending = [];
47
- const optionVars = new Set();
48
- const queue = (node, messageId) => {
49
- if (insideMakeFilter(node, ancestorsOf(context.sourceCode, node)))
50
- return;
51
- pending.push({ node, messageId });
52
- };
53
- return {
54
- before() {
55
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
56
- return false;
57
- hasDecode = false;
58
- pending.length = 0;
59
- optionVars.clear();
60
- },
61
- CallExpression(node) {
62
- const name = calleeName(node);
63
- if (name !== null && name.startsWith("decodeUnknown"))
64
- hasDecode = true;
65
- {
66
- const callee = node.callee;
67
- if (callee.type === "MemberExpression" &&
68
- !callee.computed &&
69
- callee.property.type === "Identifier" &&
70
- callee.property.name === "test") {
71
- queue(node, "regexTest");
72
- return;
73
- }
74
- }
75
- if (name === "isNone" || name === "isSome") {
76
- const argument = node.arguments[0];
77
- if (argument !== undefined &&
78
- argument.type === "Identifier" &&
79
- optionVars.has(argument.name)) {
80
- queue(node, "optionGuard");
81
- }
82
- }
83
- },
84
- IfStatement(node) {
85
- const binaryTest = node.test;
86
- if (binaryTest.type !== "BinaryExpression")
87
- return;
88
- if (binaryTest.operator !== "===" && binaryTest.operator !== "!==")
89
- return;
90
- const sides = [binaryTest.left, binaryTest.right];
91
- const hasTagSide = sides.some((side) => side.type === "MemberExpression" &&
92
- side.property.type === "Identifier" &&
93
- side.property.name === "_tag");
94
- const literal = sides.find((side) => side.type === "Literal");
95
- if (!hasTagSide ||
96
- literal === undefined ||
97
- literal.type !== "Literal" ||
98
- (literal.value !== "None" && literal.value !== "Some"))
99
- return;
100
- const tagMember = sides.find((side) => {
101
- return side.type === "MemberExpression" && side.object.type === "Identifier";
102
- });
103
- if (tagMember !== undefined &&
104
- tagMember.object.type === "Identifier" &&
105
- optionVars.has(tagMember.object.name)) {
106
- queue(node.test, "optionGuard");
107
- }
108
- },
109
- "Program:exit"() {
110
- if (!hasDecode)
111
- return;
112
- for (const { node, messageId } of pending) {
113
- context.report({ node, messageId });
114
- }
115
- },
116
- VariableDeclarator(node) {
117
- if (node.init !== null && node.init !== undefined && node.init.type === "CallExpression") {
118
- const name = calleeName(node.init);
119
- if (name !== null &&
120
- name.startsWith("from") &&
121
- name.endsWith("Option") &&
122
- node.id.type === "Identifier") {
123
- optionVars.add(node.id.name);
124
- }
125
- }
126
- },
127
- };
128
- },
129
- });
@@ -1,2 +0,0 @@
1
- /** Nested Layer.provide calls hide the dependency stage; extract the inner layer or use provideMerge. */
2
- export declare const noNestedLayerProvideRule: import("@oxlint/plugins").Rule;
@@ -1,50 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
3
- /**
4
- * Whether a call targets `Layer.provide`.
5
- *
6
- * @param {ESTree.Node} node - The candidate call expression.
7
- * @returns {boolean} True when the call is a Layer.provide invocation.
8
- */
9
- function isLayerProvide(node) {
10
- if (node.type !== "CallExpression")
11
- return false;
12
- const callee = node.callee;
13
- if (callee.type !== "MemberExpression" || callee.computed)
14
- return false;
15
- if (callee.object.type !== "Identifier")
16
- return false;
17
- return callee.object.name === "Layer" && callee.property.type === "Identifier" && callee.property.name === "provide";
18
- }
19
- /** Nested Layer.provide calls hide the dependency stage; extract the inner layer or use provideMerge. */
20
- export const noNestedLayerProvideRule = defineRule({
21
- meta: {
22
- type: "problem",
23
- docs: {
24
- description: "Disallow Layer.provide nested inside Layer.provide; extract the inner layer to a named value or use Layer.provideMerge so each dependency stage is visible.",
25
- },
26
- messages: {
27
- nestedProvide: "`Layer.provide` inside `Layer.provide` hides this dependency stage. Extract the inner layer into a named value, or use `Layer.provideMerge` when the layers are independent.",
28
- },
29
- },
30
- createOnce(context) {
31
- return {
32
- before() {
33
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
34
- return false;
35
- },
36
- CallExpression(node) {
37
- if (!isLayerProvide(node))
38
- return;
39
- for (const argument of node.arguments) {
40
- if (isLayerProvide(argument)) {
41
- context.report({
42
- node: argument,
43
- messageId: "nestedProvide",
44
- });
45
- }
46
- }
47
- },
48
- };
49
- },
50
- });
@@ -1,13 +0,0 @@
1
- /**
2
- * Disallow using nullish coalescing (`??`) with a literal default on a
3
- * member expression of an external input object. In partial updates
4
- * (PATCH/PUT), a field might be intentionally absent; `?? false` conflates
5
- * "absent" with "explicitly false", so you can't distinguish "don't change
6
- * this field" from "set it to false".
7
- *
8
- * This pattern re-invent's Effect's Schema: it manually detects absence where
9
- * `Schema.optional` / `Schema.nullable` would distinguish absent from falsy
10
- * with full type safety. The schema also centralizes the rule so it can't
11
- * drift between the API and the UI.
12
- */
13
- export declare const noNullishDefaultOnPartialInputRule: import("@oxlint/plugins").Rule;
@@ -1,109 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- import { firstOptionRecord } from "../../shared/rule-options.js";
3
- import { isString } from "../../shared/structural.js";
4
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
- /** Object names that suggest external input: request bodies, params, etc. */
6
- const DEFAULT_INPUT_NAMES = new Set([
7
- "body",
8
- "params",
9
- "query",
10
- "data",
11
- "input",
12
- "payload",
13
- ]);
14
- /**
15
- * Whether a node is a literal value (boolean, string, number, null).
16
- * @param {ESTree.Node} node - The node to test.
17
- * @returns {boolean} True when the node is a literal.
18
- */
19
- function isLiteral(node) {
20
- return node.type === "Literal";
21
- }
22
- /**
23
- * The display string for a literal value.
24
- * @param {ESTree.Expression} node - The literal node.
25
- * @returns {string} The display string.
26
- */
27
- function literalDisplay(node) {
28
- if (node.type === "Literal" && node.value === null)
29
- return "null";
30
- if (node.type === "Literal")
31
- return String(node.value);
32
- if (node.type === "UnaryExpression" && node.argument.type === "Literal")
33
- return String(node.argument.value);
34
- return "unknown";
35
- }
36
- /**
37
- * Disallow using nullish coalescing (`??`) with a literal default on a
38
- * member expression of an external input object. In partial updates
39
- * (PATCH/PUT), a field might be intentionally absent; `?? false` conflates
40
- * "absent" with "explicitly false", so you can't distinguish "don't change
41
- * this field" from "set it to false".
42
- *
43
- * This pattern re-invent's Effect's Schema: it manually detects absence where
44
- * `Schema.optional` / `Schema.nullable` would distinguish absent from falsy
45
- * with full type safety. The schema also centralizes the rule so it can't
46
- * drift between the API and the UI.
47
- */
48
- export const noNullishDefaultOnPartialInputRule = defineRule({
49
- meta: {
50
- type: "problem",
51
- docs: {
52
- description: "Disallow nullish coalescing (??) with literal defaults on member expressions of external input objects; this conflates 'absent' with 'falsy' in partial updates and re-invent's Effect's Schema. Use Schema.optional / Schema.nullable to distinguish absent from falsy.",
53
- },
54
- messages: {
55
- nullishDefaultOnPartialInput: "`?? {{default}}` on `{{object}}.{{property}}` conflates 'absent' with '{{default}}' in partial updates and re-invent's Effect's Schema. Use `Schema.optional` / `Schema.nullable` to distinguish absent from falsy with full type safety.",
56
- },
57
- schema: [
58
- {
59
- type: "object",
60
- properties: {
61
- allow: { type: "array", items: { type: "string" } },
62
- },
63
- additionalProperties: false,
64
- },
65
- ],
66
- defaultOptions: [{ allow: [] }],
67
- },
68
- createOnce(context) {
69
- const option = firstOptionRecord(context.options);
70
- const allowed = new Set(Array.isArray(option.allow) ? option.allow.filter(isString) : []);
71
- const inputNames = new Set(DEFAULT_INPUT_NAMES);
72
- for (const name of allowed)
73
- inputNames.delete(name);
74
- return {
75
- before() {
76
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
77
- return false;
78
- },
79
- LogicalExpression(node) {
80
- if (node.operator !== "??")
81
- return;
82
- if (node.left.type !== "MemberExpression")
83
- return;
84
- if (!isLiteral(node.right))
85
- return;
86
- const member = node.left;
87
- if (member.object.type !== "Identifier")
88
- return;
89
- const objectName = member.object.name;
90
- if (!inputNames.has(objectName))
91
- return;
92
- const propertyName = !member.computed && member.property.type === "Identifier"
93
- ? member.property.name
94
- : undefined;
95
- if (propertyName === undefined)
96
- return;
97
- context.report({
98
- node,
99
- messageId: "nullishDefaultOnPartialInput",
100
- data: {
101
- default: literalDisplay(node.right),
102
- object: objectName,
103
- property: propertyName,
104
- },
105
- });
106
- },
107
- };
108
- },
109
- });
@@ -1,12 +0,0 @@
1
- /**
2
- * Disallow forwarding raw error messages from caught exceptions. This pattern
3
- * re-invent's Effect's typed error channel: raw strings leak internal details
4
- * (stack traces, file paths, database errors) and lose structure so callers
5
- * can't match on the failure kind.
6
- *
7
- * Use Effect's `TaggedError`: a tagged class per failure kind carrying
8
- * structured evidence as fields, rendering its message from those fields. The
9
- * error then flows through Effect's typed error channel instead of being
10
- * stringified at every boundary.
11
- */
12
- export declare const noRawErrorForwardingRule: import("@oxlint/plugins").Rule;
@@ -1,103 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- import { ancestorsOf } from "../../shared/ancestors.js";
3
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
4
- /** Error properties that carry internal details and must not be forwarded raw. */
5
- const ERROR_PROPS = new Set(["message", "stack"]);
6
- /**
7
- * Whether a member expression accesses an error property on a catch parameter.
8
- * @param {ESTree.MemberExpression} member - The member expression to test.
9
- * @param {ReadonlySet<string>} catchParams - Names of catch parameters in scope.
10
- * @returns {boolean} True when the member accesses an error property on a catch param.
11
- */
12
- function isErrorPropAccess(member, catchParams) {
13
- if (member.object.type !== "Identifier")
14
- return false;
15
- if (!catchParams.has(member.object.name))
16
- return false;
17
- if (member.computed)
18
- return false;
19
- return member.property.type === "Identifier" && ERROR_PROPS.has(member.property.name);
20
- }
21
- /**
22
- * Whether the error property access is inside a console.* call (logging, not forwarding).
23
- * @param {SourceCode} sourceCode - The rule's source-code accessor.
24
- * @param {ESTree.Node} node - The node to test.
25
- * @returns {boolean} True when the access is inside a console.* call.
26
- */
27
- function isLoggingCall(sourceCode, node) {
28
- const chain = ancestorsOf(sourceCode, node);
29
- for (let i = chain.length - 1; i >= 0; i--) {
30
- const ancestor = chain[i];
31
- if (ancestor === undefined)
32
- continue;
33
- if (ancestor.type === "CallExpression" && ancestor.callee.type === "MemberExpression") {
34
- const obj = ancestor.callee.object;
35
- if (obj.type === "Identifier" && obj.name === "console")
36
- return true;
37
- }
38
- if (ancestor.type === "Program" || ancestor.type === "BlockStatement")
39
- return false;
40
- }
41
- return false;
42
- }
43
- /**
44
- * Disallow forwarding raw error messages from caught exceptions. This pattern
45
- * re-invent's Effect's typed error channel: raw strings leak internal details
46
- * (stack traces, file paths, database errors) and lose structure so callers
47
- * can't match on the failure kind.
48
- *
49
- * Use Effect's `TaggedError`: a tagged class per failure kind carrying
50
- * structured evidence as fields, rendering its message from those fields. The
51
- * error then flows through Effect's typed error channel instead of being
52
- * stringified at every boundary.
53
- */
54
- export const noRawErrorForwardingRule = defineRule({
55
- meta: {
56
- type: "problem",
57
- docs: {
58
- description: "Disallow forwarding raw error messages (e.message, e.stack) from caught exceptions; this pattern re-invent's Effect's typed error channel. Use Effect's TaggedError so failures carry structured evidence and flow through the typed channel.",
59
- },
60
- messages: {
61
- rawErrorForwarding: "Forwarding the raw error '{{prop}}' re-invent's Effect's typed error channel: it leaks internal details and loses structure so callers can't match on the failure kind. Use Effect's TaggedError (a tagged class per failure kind carrying structured evidence as fields) so the error flows through the typed channel.",
62
- },
63
- },
64
- createOnce(context) {
65
- const catchParamStack = [];
66
- return {
67
- before() {
68
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
69
- return false;
70
- },
71
- CatchClause(node) {
72
- const param = node.param;
73
- if (param !== null && param !== undefined && param.type === "Identifier") {
74
- catchParamStack.push(new Set([param.name]));
75
- }
76
- else {
77
- catchParamStack.push(new Set());
78
- }
79
- },
80
- "CatchClause:exit"() {
81
- catchParamStack.pop();
82
- },
83
- MemberExpression(node) {
84
- if (catchParamStack.length === 0)
85
- return;
86
- const allParams = new Set();
87
- for (const params of catchParamStack) {
88
- for (const name of params)
89
- allParams.add(name);
90
- }
91
- if (!isErrorPropAccess(node, allParams))
92
- return;
93
- if (isLoggingCall(context.sourceCode, node))
94
- return;
95
- context.report({
96
- node,
97
- messageId: "rawErrorForwarding",
98
- data: { prop: node.property.type === "Identifier" ? node.property.name : "message" },
99
- });
100
- },
101
- };
102
- },
103
- });
@@ -1,2 +0,0 @@
1
- /** Schema.Class/TaggedClass must not be the default data-modeling pattern. */
2
- export declare const noSchemaClassModelingRule: import("@oxlint/plugins").Rule;
@@ -1,52 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- const BANNED = new Set(["Class", "TaggedClass"]);
3
- function isBannedSchemaStatic(expression) {
4
- return (expression?.type === "MemberExpression" &&
5
- expression.object.type === "Identifier" &&
6
- expression.object.name === "Schema" &&
7
- expression.property.type === "Identifier" &&
8
- BANNED.has(expression.property.name));
9
- }
10
- /** Schema.Class/TaggedClass must not be the default data-modeling pattern. */
11
- export const noSchemaClassModelingRule = defineRule({
12
- meta: {
13
- type: "problem",
14
- docs: {
15
- description: "Disallow Schema.Class and Schema.TaggedClass as default data-modeling patterns; model records with Schema.Struct plus a same-name interface, variants with Schema.TaggedUnion/TaggedStruct, and typed errors with Schema.TaggedError.",
16
- },
17
- messages: {
18
- schemaClass: "Do not introduce `Schema.{{name}}` as a data-modeling pattern. Model records with `Schema.Struct(...)` plus a same-name interface, tagged variants with `Schema.TaggedStruct`/`Schema.TaggedUnion`, and typed errors with `Schema.TaggedError`.",
19
- },
20
- },
21
- createOnce(context) {
22
- const checkExpression = (callee) => {
23
- if (!isBannedSchemaStatic(callee))
24
- return;
25
- const property = callee.property;
26
- if (property.type !== "Identifier")
27
- return;
28
- context.report({
29
- node: callee,
30
- messageId: "schemaClass",
31
- data: { name: property.name },
32
- });
33
- };
34
- return {
35
- CallExpression(node) {
36
- checkExpression(node.callee);
37
- },
38
- ClassDeclaration(node) {
39
- if (!isBannedSchemaStatic(node.superClass))
40
- return;
41
- const property = node.superClass.property;
42
- if (property.type !== "Identifier")
43
- return;
44
- context.report({
45
- node: node.superClass,
46
- messageId: "schemaClass",
47
- data: { name: property.name },
48
- });
49
- },
50
- };
51
- },
52
- });
@@ -1,2 +0,0 @@
1
- /** Keep dependency-bearing Effect service constructors local to their owning capability modules. */
2
- export declare const noServiceConstructorImportsRule: import("@oxlint/plugins").Rule;
@@ -1,42 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
- const SERVICE_CONSTRUCTOR_NAME = /^make[A-Z]/u;
3
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
4
- /** Keep dependency-bearing Effect service constructors local to their owning capability modules. */
5
- export const noServiceConstructorImportsRule = defineRule({
6
- meta: {
7
- type: "problem",
8
- docs: {
9
- description: "Disallow project-local make<CapabilityName> imports outside test and spec files.",
10
- },
11
- messages: {
12
- serviceConstructorImport: 'Do not import Effect service constructor "{{name}}" into runtime code. Import the owning Layer, yield the contextual service, and allow its requirements to propagate to the composition root.',
13
- },
14
- },
15
- createOnce(context) {
16
- let isTestFile = false;
17
- return {
18
- before() {
19
- isTestFile = TEST_FILE.test(context.filename.replaceAll("\\", "/"));
20
- },
21
- ImportDeclaration(node) {
22
- const source = node.source.value;
23
- if (isTestFile || !(source.startsWith("./") || source.startsWith("../")))
24
- return;
25
- for (const specifier of node.specifiers) {
26
- if (specifier.type !== "ImportSpecifier")
27
- continue;
28
- const importedName = specifier.imported.type === "Identifier"
29
- ? specifier.imported.name
30
- : specifier.imported.value;
31
- if (!SERVICE_CONSTRUCTOR_NAME.test(importedName))
32
- continue;
33
- context.report({
34
- node: specifier,
35
- messageId: "serviceConstructorImport",
36
- data: { name: importedName },
37
- });
38
- }
39
- },
40
- };
41
- },
42
- });