@thethracian/oxlint-config 0.7.0 → 0.8.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.
- package/CHANGELOG.md +39 -1
- package/README.md +76 -54
- package/dist/index.d.ts +1 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -116
- package/dist/index.js.map +1 -1
- package/dist/rules/effect-canonical-patterns.d.ts +3 -0
- package/dist/rules/effect-canonical-patterns.d.ts.map +1 -0
- package/dist/rules/effect-canonical-patterns.js +254 -0
- package/dist/rules/effect-canonical-patterns.js.map +1 -0
- package/dist/rules/effect-canonical-scope.d.ts +5 -0
- package/dist/rules/effect-canonical-scope.d.ts.map +1 -0
- package/dist/rules/effect-canonical-scope.js +46 -0
- package/dist/rules/effect-canonical-scope.js.map +1 -0
- package/dist/rules/effect-default-compat-rules.d.ts +0 -10
- package/dist/rules/effect-default-compat-rules.d.ts.map +1 -1
- package/dist/rules/effect-default-compat-rules.js +0 -21
- package/dist/rules/effect-default-compat-rules.js.map +1 -1
- package/dist/rules/effect-default-env-rules.d.ts +8 -8
- package/dist/rules/effect-default-env-rules.d.ts.map +1 -1
- package/dist/rules/effect-default-env-rules.js +1 -60
- package/dist/rules/effect-default-env-rules.js.map +1 -1
- package/dist/rules/effect-default-helpers.d.ts +1 -5
- package/dist/rules/effect-default-helpers.d.ts.map +1 -1
- package/dist/rules/effect-default-helpers.js +1 -5
- package/dist/rules/effect-default-helpers.js.map +1 -1
- package/dist/rules/effect-default-scan-helpers.d.ts +0 -1
- package/dist/rules/effect-default-scan-helpers.d.ts.map +1 -1
- package/dist/rules/effect-default-scan-helpers.js +1 -1
- package/dist/rules/effect-default-scan-helpers.js.map +1 -1
- package/dist/rules/effect-default-workflow-helpers.d.ts +0 -1
- package/dist/rules/effect-default-workflow-helpers.d.ts.map +1 -1
- package/dist/rules/effect-default-workflow-helpers.js +1 -55
- package/dist/rules/effect-default-workflow-helpers.js.map +1 -1
- package/dist/rules/effect-default.d.ts +1 -1
- package/dist/rules/effect-default.d.ts.map +1 -1
- package/dist/rules/effect-default.js +2 -16
- package/dist/rules/effect-default.js.map +1 -1
- package/dist/rules/effect-path-options.d.ts +1 -55
- package/dist/rules/effect-path-options.d.ts.map +1 -1
- package/dist/rules/effect-path-options.js +1 -126
- package/dist/rules/effect-path-options.js.map +1 -1
- package/dist/rules/effect-rule-names.d.ts +2 -3
- package/dist/rules/effect-rule-names.d.ts.map +1 -1
- package/dist/rules/effect-rule-names.js +9 -72
- package/dist/rules/effect-rule-names.js.map +1 -1
- package/dist/rules/effect-strict-core-specs.d.ts.map +1 -1
- package/dist/rules/effect-strict-core-specs.js +3 -310
- package/dist/rules/effect-strict-core-specs.js.map +1 -1
- package/dist/rules/effect-strict-internals.d.ts +1 -3
- package/dist/rules/effect-strict-internals.d.ts.map +1 -1
- package/dist/rules/effect-strict-internals.js +1 -3
- package/dist/rules/effect-strict-internals.js.map +1 -1
- package/dist/rules/effect-strict-source-predicates.d.ts +1 -20
- package/dist/rules/effect-strict-source-predicates.d.ts.map +1 -1
- package/dist/rules/effect-strict-source-predicates.js +1 -118
- package/dist/rules/effect-strict-source-predicates.js.map +1 -1
- package/dist/rules/effect-strict.d.ts.map +1 -1
- package/dist/rules/effect-strict.js +1 -6
- package/dist/rules/effect-strict.js.map +1 -1
- package/dist/rules/no-module-mocking.d.ts.map +1 -1
- package/dist/rules/no-module-mocking.js +15 -22
- package/dist/rules/no-module-mocking.js.map +1 -1
- package/dist/rules/no-widen-then-assert.d.ts.map +1 -1
- package/dist/rules/no-widen-then-assert.js +79 -52
- package/dist/rules/no-widen-then-assert.js.map +1 -1
- package/dist/rules/plugin.d.ts.map +1 -1
- package/dist/rules/plugin.js +0 -2
- package/dist/rules/plugin.js.map +1 -1
- package/dist/rules/shared/dictionary-types.d.ts.map +1 -1
- package/dist/rules/shared/dictionary-types.js +48 -25
- package/dist/rules/shared/dictionary-types.js.map +1 -1
- package/dist/rules/shared/lexical-type-parameters.d.ts.map +1 -1
- package/dist/rules/shared/lexical-type-parameters.js +8 -5
- package/dist/rules/shared/lexical-type-parameters.js.map +1 -1
- package/package.json +1 -1
- package/dist/rules/effect-default-schema-helpers.d.ts +0 -5
- package/dist/rules/effect-default-schema-helpers.d.ts.map +0 -1
- package/dist/rules/effect-default-schema-helpers.js +0 -191
- package/dist/rules/effect-default-schema-helpers.js.map +0 -1
- package/dist/rules/effect-default-test-helpers.d.ts +0 -4
- package/dist/rules/effect-default-test-helpers.d.ts.map +0 -1
- package/dist/rules/effect-default-test-helpers.js +0 -81
- package/dist/rules/effect-default-test-helpers.js.map +0 -1
- package/dist/rules/effect-global-fetch-ast-traversal.d.ts +0 -4
- package/dist/rules/effect-global-fetch-ast-traversal.d.ts.map +0 -1
- package/dist/rules/effect-global-fetch-ast-traversal.js +0 -92
- package/dist/rules/effect-global-fetch-ast-traversal.js.map +0 -1
- package/dist/rules/effect-global-fetch-ast.d.ts +0 -3
- package/dist/rules/effect-global-fetch-ast.d.ts.map +0 -1
- package/dist/rules/effect-global-fetch-ast.js +0 -304
- package/dist/rules/effect-global-fetch-ast.js.map +0 -1
- package/dist/rules/effect-global-fetch-imports.d.ts +0 -10
- package/dist/rules/effect-global-fetch-imports.d.ts.map +0 -1
- package/dist/rules/effect-global-fetch-imports.js +0 -75
- package/dist/rules/effect-global-fetch-imports.js.map +0 -1
- package/dist/rules/effect-schema-no-redundant-tag-identifier.d.ts +0 -4
- package/dist/rules/effect-schema-no-redundant-tag-identifier.d.ts.map +0 -1
- package/dist/rules/effect-schema-no-redundant-tag-identifier.js +0 -109
- package/dist/rules/effect-schema-no-redundant-tag-identifier.js.map +0 -1
- package/dist/rules/effect-strict-ast-helpers.d.ts +0 -28
- package/dist/rules/effect-strict-ast-helpers.d.ts.map +0 -1
- package/dist/rules/effect-strict-ast-helpers.js +0 -132
- package/dist/rules/effect-strict-ast-helpers.js.map +0 -1
- package/dist/rules/effect-strict-ast-specs.d.ts +0 -3
- package/dist/rules/effect-strict-ast-specs.d.ts.map +0 -1
- package/dist/rules/effect-strict-ast-specs.js +0 -157
- package/dist/rules/effect-strict-ast-specs.js.map +0 -1
- package/dist/rules/effect-strict-boundary-helpers.d.ts +0 -5
- package/dist/rules/effect-strict-boundary-helpers.d.ts.map +0 -1
- package/dist/rules/effect-strict-boundary-helpers.js +0 -68
- package/dist/rules/effect-strict-boundary-helpers.js.map +0 -1
- package/dist/rules/effect-strict-external-helpers.d.ts +0 -10
- package/dist/rules/effect-strict-external-helpers.d.ts.map +0 -1
- package/dist/rules/effect-strict-external-helpers.js +0 -50
- package/dist/rules/effect-strict-external-helpers.js.map +0 -1
- package/dist/rules/effect-strict-helpers.d.ts +0 -16
- package/dist/rules/effect-strict-helpers.d.ts.map +0 -1
- package/dist/rules/effect-strict-helpers.js +0 -121
- package/dist/rules/effect-strict-helpers.js.map +0 -1
- package/dist/rules/effect-strict-segment-helpers.d.ts +0 -14
- package/dist/rules/effect-strict-segment-helpers.d.ts.map +0 -1
- package/dist/rules/effect-strict-segment-helpers.js +0 -201
- package/dist/rules/effect-strict-segment-helpers.js.map +0 -1
- package/dist/rules/effect-strict-wrapper-index.d.ts +0 -6
- package/dist/rules/effect-strict-wrapper-index.d.ts.map +0 -1
- package/dist/rules/effect-strict-wrapper-index.js +0 -147
- package/dist/rules/effect-strict-wrapper-index.js.map +0 -1
- package/dist/rules/no-comments.d.ts +0 -2
- package/dist/rules/no-comments.d.ts.map +0 -1
- package/dist/rules/no-comments.js +0 -22
- package/dist/rules/no-comments.js.map +0 -1
|
@@ -1,28 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { exportedDeclarationTexts, stripCommentsAndStrings } from './effect-source-helpers.js';
|
|
3
|
-
import { hasAsyncPushWithoutBuffer, hasBoundaryDataWithoutSchema, hasCommandHandlerWithoutSchema, hasDuplicateLayerInstance, hasEnsuringCleanupWithoutOnExit, hasExternalEffectWithoutSpan, hasExternalEffectWithoutTimeout, hasHTTPClientResponseWithoutSchema, hasHTTPServerRequestWithoutSchema, hasIdempotentExternalEffectWithoutRetry, hasLayerFactory, hasLiveTestService, hasNPlusOneWithoutBatchedResolver, hasOutputBoundaryWithoutSchema, hasPersistenceReadWithoutSchema, hasRealTestService, hasSharedMutableStateWithoutRef, hasSharedResourceForEachWithoutSemaphore, hasTimeCodeWithoutTestClock, hasUnbatchedResolver, hasUnprovidedServiceInEffectTest, hasUnsafeResourceStream, hasUnscopedResourceLayer, hasUnscopedResourceLoop, hasUnterminatedLongRunningStream, } from './effect-strict-helpers.js';
|
|
4
|
-
import { hasDirectPlatformAccess, hasEffectSignal, hasExportedRunPromiseAPI, hasPromiseReturningPublicAPI, hasRetryScheduleWithoutJitter, hasRunSyncInServerRequestHandler, hasRuntimeCall, publicAPIDeclarationSignature, } from './effect-strict-internals.js';
|
|
5
|
-
import { isConfiguredPath, isEffectTestPath, isUnitTestPath } from './effect-path-options.js';
|
|
6
|
-
import { hasRunForkWithoutObserver } from './effect-default-helpers.js';
|
|
1
|
+
import { hasRunSyncInServerRequestHandler } from './effect-strict-internals.js';
|
|
7
2
|
import { runSyncServerHandlerAST } from './effect-strict-server-handler-ast.js';
|
|
8
|
-
export const effectStrictCoreSpecs =
|
|
9
|
-
{
|
|
10
|
-
check: (source, context) => hasRuntimeCall(source) &&
|
|
11
|
-
!hasExportedRunPromiseAPI(source) &&
|
|
12
|
-
!hasRunForkWithoutObserver(source) &&
|
|
13
|
-
!isEffectTestPath(context) &&
|
|
14
|
-
!isConfiguredPath(context, 'entrypoints'),
|
|
15
|
-
message: 'Run Effect programs only from configured entrypoints.',
|
|
16
|
-
name: 'effect-no-run-outside-entrypoints',
|
|
17
|
-
tokens: ['Effect', 'effect', 'runMain'],
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
check: (source, context) => isConfiguredPath(context, 'entrypoints') &&
|
|
21
|
-
/Effect\.run(?:Promise|Sync|Fork)/.test(stripCommentsAndStrings(source)),
|
|
22
|
-
message: 'Entrypoints should use the platform runMain boundary instead of raw Effect runners.',
|
|
23
|
-
name: 'effect-require-platform-runmain-at-entrypoints',
|
|
24
|
-
tokens: ['Effect.run', 'effect/Effect', 'runPromise', 'runSync', 'runFork'],
|
|
25
|
-
},
|
|
3
|
+
export const effectStrictCoreSpecs = [
|
|
26
4
|
{
|
|
27
5
|
ast: runSyncServerHandlerAST,
|
|
28
6
|
check: hasRunSyncInServerRequestHandler,
|
|
@@ -30,290 +8,5 @@ export const effectStrictCoreSpecs = pipe([
|
|
|
30
8
|
name: 'effect-no-runSync-in-server-request-handlers',
|
|
31
9
|
tokens: ['runSync'],
|
|
32
10
|
},
|
|
33
|
-
|
|
34
|
-
check: hasPromiseReturningPublicAPI,
|
|
35
|
-
message: 'Public APIs should expose Effect return types instead of Promise.',
|
|
36
|
-
name: 'effect-no-promise-returning-public-api',
|
|
37
|
-
tokens: ['Promise', 'async'],
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
check: (source, context) => /\bprocess\s*\.\s*env\b/.test(stripCommentsAndStrings(source)) &&
|
|
41
|
-
!hasEffectSignal(source) &&
|
|
42
|
-
!isConfiguredPath(context, 'configLayers'),
|
|
43
|
-
message: 'Read process.env only inside the configured Effect Config layer.',
|
|
44
|
-
name: 'effect-no-direct-process-env-outside-config-layer',
|
|
45
|
-
tokens: ['process'],
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
check: (source, context) => /\b(?:Date\s*\.\s*now|Math\s*\.\s*random)\s*\(/.test(stripCommentsAndStrings(source)) &&
|
|
49
|
-
!hasEffectSignal(source) &&
|
|
50
|
-
!isConfiguredPath(context, 'adapterLayers'),
|
|
51
|
-
message: 'Use Clock and Random services outside configured adapter modules.',
|
|
52
|
-
name: 'effect-no-direct-clock-random-outside-adapters',
|
|
53
|
-
tokens: ['Date', 'Math'],
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
check: hasDirectPlatformAccess,
|
|
57
|
-
message: 'Use Effect platform services for HTTP and filesystem access outside adapters.',
|
|
58
|
-
name: 'effect-no-direct-http-fs-outside-platform-services',
|
|
59
|
-
tokens: ['fetch', 'readFileSync', 'writeFileSync', 'createReadStream'],
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
message: 'Services must use the configured class-based Effect service pattern.',
|
|
63
|
-
name: 'effect-require-service-class-pattern',
|
|
64
|
-
patterns: [/Context\.GenericTag(?:<[^>]+>)?\s*\(\s*['"`]/],
|
|
65
|
-
tokens: ['Context.GenericTag'],
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
message: 'Service tags require stable identifiers.',
|
|
69
|
-
name: 'effect-require-tag-identifier',
|
|
70
|
-
patterns: [
|
|
71
|
-
/Context\.Tag(?:<[^>]+>)?\s*\(\s*\)/,
|
|
72
|
-
/Context\.GenericTag(?:<[^>]+>)?\s*\(\s*\)/,
|
|
73
|
-
/class\s+[A-Z][\w$]*\s+extends\s+Context\.Tag\s*\(\s*\)/,
|
|
74
|
-
],
|
|
75
|
-
tokens: ['Context.Tag', 'Context.GenericTag'],
|
|
76
|
-
},
|
|
77
|
-
{
|
|
78
|
-
check: (source, context) => isConfiguredPath(context, 'domain') &&
|
|
79
|
-
/Layer\.|Live\b/.test(stripCommentsAndStrings(source)),
|
|
80
|
-
message: 'Domain exports must not leak raw service implementation dependencies.',
|
|
81
|
-
name: 'effect-no-leaked-service-dependencies',
|
|
82
|
-
tokens: ['Layer', 'Live'],
|
|
83
|
-
},
|
|
84
|
-
{
|
|
85
|
-
check: hasDuplicateLayerInstance,
|
|
86
|
-
message: 'Do not construct the same Layer multiple times in one module.',
|
|
87
|
-
name: 'effect-no-duplicate-layer-instances',
|
|
88
|
-
tokens: ['Layer'],
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
check: (source, context) => /Effect\.provide|Layer\.provide/.test(stripCommentsAndStrings(source)) &&
|
|
92
|
-
!isConfiguredPath(context, 'compositionRoots'),
|
|
93
|
-
message: 'Provide layers only from configured composition roots.',
|
|
94
|
-
name: 'effect-require-centralized-provision',
|
|
95
|
-
tokens: ['Effect.provide', 'Layer.provide'],
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
check: (source, context) => isConfiguredPath(context, 'domain') &&
|
|
99
|
-
/Effect\.provide|Layer\.provide/.test(stripCommentsAndStrings(source)),
|
|
100
|
-
message: 'Domain modules should declare requirements, not provide concrete layers.',
|
|
101
|
-
name: 'effect-no-provide-in-domain-modules',
|
|
102
|
-
tokens: ['Effect.provide', 'Layer.provide'],
|
|
103
|
-
},
|
|
104
|
-
{
|
|
105
|
-
check: hasLayerFactory,
|
|
106
|
-
message: 'Shared layers should be memoized constants instead of functions that recreate resources.',
|
|
107
|
-
name: 'effect-require-layer-memoization-constant',
|
|
108
|
-
tokens: ['Layer'],
|
|
109
|
-
},
|
|
110
|
-
{
|
|
111
|
-
message: 'Circular layer dependencies must be suspended.',
|
|
112
|
-
name: 'effect-require-suspend-for-circular-deps',
|
|
113
|
-
patterns: [
|
|
114
|
-
/Layer\.(?:effect|scoped)\s*\([\s\S]*?Layer\.(?:effect|scoped)\s*\((?![\s\S]*Effect\.suspend)/,
|
|
115
|
-
],
|
|
116
|
-
tokens: ['Layer'],
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
message: 'Avoid tiny one-off Layer declarations that fragment dependency wiring.',
|
|
120
|
-
name: 'effect-avoid-layer-explosion',
|
|
121
|
-
patterns: [
|
|
122
|
-
/const\s+[A-Za-z_$][\w$]*Layer\s*=\s*Layer\.[\s\S]*const\s+[A-Za-z_$][\w$]*Layer\s*=\s*Layer\./,
|
|
123
|
-
],
|
|
124
|
-
tokens: ['Layer'],
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
message: 'Use Layer.succeed for static pure services.',
|
|
128
|
-
name: 'effect-prefer-succeed-for-static-layers',
|
|
129
|
-
patterns: [/Layer\.effect\s*\([^,]+,\s*Effect\.succeed\s*\(/],
|
|
130
|
-
tokens: ['Layer.effect', 'Effect.succeed'],
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
check: hasUnscopedResourceLayer,
|
|
134
|
-
message: 'Layers that allocate resources must be scoped.',
|
|
135
|
-
name: 'effect-require-scoped-for-resource-layers',
|
|
136
|
-
tokens: ['Layer'],
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
check: (source, context) => !isConfiguredPath(context, 'adapterLayers') &&
|
|
140
|
-
!isConfiguredPath(context, 'configLayers') &&
|
|
141
|
-
!/Layer\./.test(stripCommentsAndStrings(source)) &&
|
|
142
|
-
/new\s+[A-Z][\w$]*(?:Service|Repo|Client)\s*\(/.test(stripCommentsAndStrings(source)),
|
|
143
|
-
message: 'Construct services inside Layers, not directly in domain or application logic.',
|
|
144
|
-
name: 'effect-no-service-construction-outside-layer',
|
|
145
|
-
tokens: ['Service', 'Repo', 'Client'],
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
check: hasBoundaryDataWithoutSchema,
|
|
149
|
-
message: 'Input boundaries must decode request, command, or message data with Schema.',
|
|
150
|
-
name: 'effect-schema-require-validation-at-input-boundaries',
|
|
151
|
-
tokens: ['.body', '.params', '.query', '.payload'],
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
check: hasOutputBoundaryWithoutSchema,
|
|
155
|
-
message: 'Output boundaries should encode or validate public response data.',
|
|
156
|
-
name: 'effect-schema-require-validation-at-output-boundaries',
|
|
157
|
-
tokens: ['Response.json', 'return json'],
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
check: hasHTTPClientResponseWithoutSchema,
|
|
161
|
-
message: 'HTTP client responses must be decoded with Schema.',
|
|
162
|
-
name: 'effect-schema-require-http-client-response-schema',
|
|
163
|
-
tokens: ['HttpClient.', 'response.json'],
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
check: hasHTTPServerRequestWithoutSchema,
|
|
167
|
-
message: 'HTTP server requests must be decoded with Schema.',
|
|
168
|
-
name: 'effect-schema-require-http-server-request-schema',
|
|
169
|
-
tokens: ['HttpRouter.', 'HttpServerRequest'],
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
check: (source, context) => isConfiguredPath(context, 'configLayers') &&
|
|
173
|
-
/Config\./.test(stripCommentsAndStrings(source)) &&
|
|
174
|
-
!/Schema\./.test(stripCommentsAndStrings(source)),
|
|
175
|
-
message: 'Configuration modules must decode configuration with Schema.',
|
|
176
|
-
name: 'effect-schema-require-config-schema',
|
|
177
|
-
tokens: ['Config'],
|
|
178
|
-
},
|
|
179
|
-
{
|
|
180
|
-
check: hasPersistenceReadWithoutSchema,
|
|
181
|
-
message: 'Persistence boundaries must validate loaded records with Schema.',
|
|
182
|
-
name: 'effect-schema-require-persistence-schema',
|
|
183
|
-
tokens: ['db.', 'database.', 'collection.', 'repository.'],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
check: hasCommandHandlerWithoutSchema,
|
|
187
|
-
message: 'Public command handlers must declare and use input schemas.',
|
|
188
|
-
name: 'effect-schema-require-public-command-schema',
|
|
189
|
-
tokens: ['handler'],
|
|
190
|
-
},
|
|
191
|
-
{
|
|
192
|
-
check: (source) => pipe(exportedDeclarationTexts(source), Array.some((declaration) => /\bunknown\b/.test(stripCommentsAndStrings(publicAPIDeclarationSignature(declaration))))),
|
|
193
|
-
message: 'unknown values must be decoded before crossing configured boundaries.',
|
|
194
|
-
name: 'effect-schema-no-unknown-crossing-boundary',
|
|
195
|
-
tokens: ['unknown'],
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
check: (source) => hasExternalEffectWithoutTimeout(source),
|
|
199
|
-
message: 'External effects must declare a timeout.',
|
|
200
|
-
name: 'effect-require-timeout-on-external-effects',
|
|
201
|
-
tokens: ['HttpClient.', 'fetch', 'FileSystem.', 'SqlClient.'],
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
check: (source) => hasIdempotentExternalEffectWithoutRetry(source),
|
|
205
|
-
message: 'Idempotent external effects must declare retry policy deliberately.',
|
|
206
|
-
name: 'effect-require-retry-policy-for-idempotent-external-effects',
|
|
207
|
-
tokens: ['HttpClient.', 'fetch', 'find', 'lookup', 'read'],
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
check: hasRetryScheduleWithoutJitter,
|
|
211
|
-
message: 'Retry schedules must include jitter.',
|
|
212
|
-
name: 'effect-require-schedule-jitter-for-retries',
|
|
213
|
-
tokenGroups: [['Effect.retry'], ['Schedule.']],
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
check: (source) => hasExternalEffectWithoutSpan(source),
|
|
217
|
-
message: 'External effects must declare an observability span.',
|
|
218
|
-
name: 'effect-require-span-external',
|
|
219
|
-
tokens: ['HttpClient.', 'fetch', 'FileSystem.', 'SqlClient.'],
|
|
220
|
-
},
|
|
221
|
-
{
|
|
222
|
-
check: hasSharedResourceForEachWithoutSemaphore,
|
|
223
|
-
message: 'Shared scarce resources must be guarded by Semaphore.',
|
|
224
|
-
name: 'effect-require-semaphore-for-shared-resources',
|
|
225
|
-
tokens: ['Effect.forEach'],
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
check: hasSharedMutableStateWithoutRef,
|
|
229
|
-
message: 'Shared mutable state must use Ref, SynchronizedRef, or scoped services.',
|
|
230
|
-
name: 'effect-require-ref-for-shared-mutable-state',
|
|
231
|
-
tokens: ['let '],
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
check: hasUnscopedResourceLoop,
|
|
235
|
-
message: 'Loops that acquire resources must scope each acquisition.',
|
|
236
|
-
name: 'effect-require-scoped-in-loops',
|
|
237
|
-
tokens: ['open', 'connect', 'subscribe', 'listen'],
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
check: hasEnsuringCleanupWithoutOnExit,
|
|
241
|
-
message: 'Cleanup logic should use onExit so success, failure, and interruption are handled.',
|
|
242
|
-
name: 'effect-require-onExit-for-cleanup',
|
|
243
|
-
tokens: ['Effect.ensuring', 'cleanup'],
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
check: hasUnsafeResourceStream,
|
|
247
|
-
message: 'Streams over resources must be scoped or bracketed.',
|
|
248
|
-
name: 'effect-require-stream-resource-safety',
|
|
249
|
-
tokens: ['Stream'],
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
check: hasUnterminatedLongRunningStream,
|
|
253
|
-
message: 'Long-running streams must declare termination or shutdown behavior.',
|
|
254
|
-
name: 'effect-require-stream-termination',
|
|
255
|
-
tokens: ['Stream'],
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
check: hasAsyncPushWithoutBuffer,
|
|
259
|
-
message: 'Stream.asyncPush must declare an explicit buffer/backpressure policy.',
|
|
260
|
-
name: 'effect-require-explicit-asyncPush-buffer',
|
|
261
|
-
tokens: ['Stream.asyncPush'],
|
|
262
|
-
},
|
|
263
|
-
{
|
|
264
|
-
check: hasUnbatchedResolver,
|
|
265
|
-
message: 'RequestResolver implementations should batch requests.',
|
|
266
|
-
name: 'effect-require-batching-for-resolver',
|
|
267
|
-
tokens: ['RequestResolver'],
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
check: hasNPlusOneWithoutBatchedResolver,
|
|
271
|
-
message: 'Potential N+1 data access should use a batched RequestResolver.',
|
|
272
|
-
name: 'effect-use-batched-resolver-for-n-plus-one',
|
|
273
|
-
tokens: ['Effect.forEach'],
|
|
274
|
-
},
|
|
275
|
-
{
|
|
276
|
-
message: 'Use PubSub for broadcast semantics instead of manually fanning out queues.',
|
|
277
|
-
name: 'effect-prefer-pubsub-for-broadcast',
|
|
278
|
-
patterns: [/Queue\.[\s\S]*?\bsubscribers\b|broadcast\s*\([\s\S]*?Queue\./],
|
|
279
|
-
tokens: ['Queue', 'broadcast', 'subscribers'],
|
|
280
|
-
},
|
|
281
|
-
{
|
|
282
|
-
check: (source, context) => isEffectTestPath(context) && hasUnprovidedServiceInEffectTest(source),
|
|
283
|
-
message: 'Effect tests must provide required services explicitly.',
|
|
284
|
-
name: 'effect-require-provided-services-in-tests',
|
|
285
|
-
tokens: ['Service', 'Repo', 'Client'],
|
|
286
|
-
},
|
|
287
|
-
{
|
|
288
|
-
check: (source, context) => isUnitTestPath(context) && hasRealTestService(source),
|
|
289
|
-
message: 'Unit tests should use in-memory service implementations.',
|
|
290
|
-
name: 'effect-prefer-in-memory-implementations',
|
|
291
|
-
tokens: ['real'],
|
|
292
|
-
},
|
|
293
|
-
{
|
|
294
|
-
check: (source, context) => isUnitTestPath(context) && hasLiveTestService(source),
|
|
295
|
-
message: 'Live services belong in integration tests, not unit tests.',
|
|
296
|
-
name: 'effect-no-live-services-in-unit-tests',
|
|
297
|
-
tokens: ['Live', 'Layer.live'],
|
|
298
|
-
},
|
|
299
|
-
{
|
|
300
|
-
check: (source, context) => isEffectTestPath(context) && hasTimeCodeWithoutTestClock(source),
|
|
301
|
-
message: 'Tests for time-dependent Effect code should use TestClock.',
|
|
302
|
-
name: 'effect-require-testclock-for-time-code',
|
|
303
|
-
tokens: ['Effect.timeout', 'Effect.delay', 'Clock.'],
|
|
304
|
-
},
|
|
305
|
-
{
|
|
306
|
-
check: (source, context) => isEffectTestPath(context) &&
|
|
307
|
-
/const\s+[A-Za-z_$][\w$]*(?:Runtime|Layer|Service)\s*=/.test(source),
|
|
308
|
-
message: 'Do not share mutable runtime, layer, or service state across Effect tests.',
|
|
309
|
-
name: 'effect-no-test-runtime-leakage',
|
|
310
|
-
tokens: ['Runtime', 'Layer', 'Service'],
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
message: 'Do not hide Effect semantics behind local wrapper DSLs.',
|
|
314
|
-
name: 'effect-no-ad-hoc-effect-wrapper-abstractions',
|
|
315
|
-
patterns: [/function\s+(?:runEffect|makeEffect|effectify|toEffect)\s*\(/],
|
|
316
|
-
tokens: ['runEffect', 'makeEffect', 'effectify', 'toEffect'],
|
|
317
|
-
},
|
|
318
|
-
], Array.map((spec) => spec));
|
|
11
|
+
];
|
|
319
12
|
//# sourceMappingURL=effect-strict-core-specs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-strict-core-specs.js","sourceRoot":"","sources":["../../src/rules/effect-strict-core-specs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effect-strict-core-specs.js","sourceRoot":"","sources":["../../src/rules/effect-strict-core-specs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gCAAgC,EAAE,MAAM,2BAA2B,CAAC;AAC7E,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAE7E,MAAM,CAAC,MAAM,qBAAqB,GAAwB;IACxD;QACE,GAAG,EAAE,uBAAuB;QAC5B,KAAK,EAAE,gCAAgC;QACvC,OAAO,EAAE,qDAAqD;QAC9D,IAAI,EAAE,8CAA8C;QACpD,MAAM,EAAE,CAAC,SAAS,CAAC;KACpB;CACF,CAAC"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { hasEffectSignal, hasRuntimeCall } from './effect-rule-core';
|
|
3
|
-
export { effectWrapperStatement, hasCryptoRandomUUID, hasDirectPlatformAccess, hasEffectSucceedWithVoid, hasExportedRunPromiseAPI, hasGlobalFetch, hasLayerEffectWithScope, hasMapFlatten, hasMapToVoid, hasMultipleProvideChain, hasNodeBuiltinImport, hasNonDeterministicServiceKey, hasPromiseReturningPublicAPI, hasRetryScheduleWithoutJitter, hasRunSyncInServerRequestHandler, hasSchemaInstanceof, hasSchemaStructWithTag, hasSchemaUnionOfLiterals, publicAPIDeclarationSignature, } from './effect-strict-source-predicates';
|
|
1
|
+
export { hasRunSyncInServerRequestHandlerSource as hasRunSyncInServerRequestHandler } from './effect-strict-server-handler-source';
|
|
4
2
|
//# sourceMappingURL=effect-strict-internals.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-strict-internals.d.ts","sourceRoot":"","sources":["../../src/rules/effect-strict-internals.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"effect-strict-internals.d.ts","sourceRoot":"","sources":["../../src/rules/effect-strict-internals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,IAAI,gCAAgC,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export { hasEffectSignal, hasRuntimeCall } from './effect-rule-core.js';
|
|
3
|
-
export { effectWrapperStatement, hasCryptoRandomUUID, hasDirectPlatformAccess, hasEffectSucceedWithVoid, hasExportedRunPromiseAPI, hasGlobalFetch, hasLayerEffectWithScope, hasMapFlatten, hasMapToVoid, hasMultipleProvideChain, hasNodeBuiltinImport, hasNonDeterministicServiceKey, hasPromiseReturningPublicAPI, hasRetryScheduleWithoutJitter, hasRunSyncInServerRequestHandler, hasSchemaInstanceof, hasSchemaStructWithTag, hasSchemaUnionOfLiterals, publicAPIDeclarationSignature, } from './effect-strict-source-predicates.js';
|
|
1
|
+
export { hasRunSyncInServerRequestHandlerSource as hasRunSyncInServerRequestHandler } from './effect-strict-server-handler-source.js';
|
|
4
2
|
//# sourceMappingURL=effect-strict-internals.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-strict-internals.js","sourceRoot":"","sources":["../../src/rules/effect-strict-internals.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"effect-strict-internals.js","sourceRoot":"","sources":["../../src/rules/effect-strict-internals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,IAAI,gCAAgC,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const hasRetryScheduleWithoutJitter: (source: string) => boolean;
|
|
3
|
-
export declare const publicAPIDeclarationSignature: (declaration: string) => string;
|
|
4
|
-
export declare const hasPromiseReturningPublicAPI: (source: string) => boolean;
|
|
5
|
-
export declare const hasExportedRunPromiseAPI: (source: string) => boolean;
|
|
6
|
-
export declare const hasRunSyncInServerRequestHandler: (source: string) => boolean;
|
|
7
|
-
export declare const hasCryptoRandomUUID: (source: string) => number | false;
|
|
8
|
-
export declare const hasSchemaInstanceof: (source: string) => number | false;
|
|
9
|
-
export declare const hasSchemaStructWithTag: (source: string) => number | false;
|
|
10
|
-
export declare const hasSchemaUnionOfLiterals: (source: string) => number | false;
|
|
11
|
-
export declare const hasNonDeterministicServiceKey: (source: string) => number | false;
|
|
12
|
-
export declare const hasMultipleProvideChain: (source: string) => number | false;
|
|
13
|
-
export declare const hasLayerEffectWithScope: (source: string) => number | false;
|
|
14
|
-
export declare const hasNodeBuiltinImport: (source: string) => number | false;
|
|
15
|
-
export declare const hasGlobalFetch: (source: string, context: RuleContext) => number | false;
|
|
16
|
-
export declare const hasEffectSucceedWithVoid: (source: string) => number | false;
|
|
17
|
-
export declare const hasMapToVoid: (source: string) => number | false;
|
|
18
|
-
export declare const hasMapFlatten: (source: string) => number | false;
|
|
19
|
-
export declare const effectWrapperStatement: (source: string, targetIndex: number) => string | undefined;
|
|
20
|
-
export declare const hasDirectPlatformAccess: (source: string, context: RuleContext) => boolean;
|
|
1
|
+
export { hasRunSyncInServerRequestHandlerSource as hasRunSyncInServerRequestHandler } from './effect-strict-server-handler-source';
|
|
21
2
|
//# sourceMappingURL=effect-strict-source-predicates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-strict-source-predicates.d.ts","sourceRoot":"","sources":["../../src/rules/effect-strict-source-predicates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effect-strict-source-predicates.d.ts","sourceRoot":"","sources":["../../src/rules/effect-strict-source-predicates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,IAAI,gCAAgC,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -1,119 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { exportedDeclarationTexts, findBalancedCallEnd, findStatementEnd, stripComments, stripCommentsAndStrings, } from './effect-source-helpers.js';
|
|
3
|
-
import { hasRunSyncInServerRequestHandlerSource } from './effect-strict-server-handler-source.js';
|
|
4
|
-
import { isConfiguredPath } from './effect-path-options.js';
|
|
5
|
-
const matchesIn = (source, pattern) => pipe(source.matchAll(pattern), Array.fromIterable);
|
|
6
|
-
const matchIndexOrFalse = (match) => pipe(Option.fromNullable(match), Option.map((value) => value.index), Option.getOrElse(() => false));
|
|
7
|
-
const codeMatchIndexOrFalse = (commentFreeSource, codeOnlySource, pattern, predicate = () => true) => pipe(matchesIn(commentFreeSource, pattern), Array.findFirst((match) => codeOnlySource[match.index] !== ' ' && predicate(match)), Option.map((match) => match.index), Option.getOrElse(() => false));
|
|
8
|
-
export const hasRetryScheduleWithoutJitter = (source) => pipe(matchesIn(source, /\bEffect\.retry\s*\(/g), Array.some((match) => {
|
|
9
|
-
const openParenIndex = source.indexOf('(', match.index);
|
|
10
|
-
const callBody = source.slice(openParenIndex + 1, findBalancedCallEnd(source, openParenIndex));
|
|
11
|
-
return /\bSchedule\./.test(callBody) && !/\bjitter(?:ed)?\b/.test(callBody);
|
|
12
|
-
}));
|
|
13
|
-
const declarationBeforeBody = (declaration) => {
|
|
14
|
-
const bodyStart = declaration.indexOf('{');
|
|
15
|
-
if (bodyStart === -1) {
|
|
16
|
-
return declaration;
|
|
17
|
-
}
|
|
18
|
-
return declaration.slice(0, bodyStart);
|
|
19
|
-
};
|
|
20
|
-
export const publicAPIDeclarationSignature = (declaration) => {
|
|
21
|
-
if (/^\s*(?:export\s+)?(?:async\s+)?function\b/.test(declaration)) {
|
|
22
|
-
return declarationBeforeBody(declaration);
|
|
23
|
-
}
|
|
24
|
-
if (/^\s*(?:export\s+)?(?:const|let|var)\b/.test(declaration)) {
|
|
25
|
-
return declarationBeforeBody(declaration);
|
|
26
|
-
}
|
|
27
|
-
return declaration;
|
|
28
|
-
};
|
|
29
|
-
const hasClassPromiseReturningPublicMember = (declaration) => {
|
|
30
|
-
if (!/^\s*(?:export\s+)?(?:default\s+)?(?:abstract\s+)?class\b/.test(declaration)) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
const signatureSource = stripCommentsAndStrings(declaration);
|
|
34
|
-
const publicMemberPrefix = String.raw `(?!private\b|protected\b)(?:(?:public|static|abstract|override|declare|readonly)\s+)*`;
|
|
35
|
-
const memberName = String.raw `[A-Za-z_$][\w$]*`;
|
|
36
|
-
const memberStart = `(?:^|[{\\n;]\\s*)${publicMemberPrefix}${memberName}`;
|
|
37
|
-
const accessorStart = `(?:^|[{\\n;]\\s*)${publicMemberPrefix}`;
|
|
38
|
-
return (new RegExp(`${memberStart}\\s*\\([^)]*\\)\\s*:\\s*Promise\\s*<`).test(signatureSource) ||
|
|
39
|
-
new RegExp(`(?:^|[{\\n;]\\s*)${publicMemberPrefix}async\\s+${memberName}\\s*\\([^)]*\\)`).test(signatureSource) ||
|
|
40
|
-
new RegExp(`${memberStart}\\s*=\\s*async\\b`).test(signatureSource) ||
|
|
41
|
-
new RegExp(`${memberStart}\\s*=\\s*\\([^)]*\\)\\s*:\\s*Promise\\s*<`).test(signatureSource) ||
|
|
42
|
-
new RegExp(`${memberStart}\\s*:\\s*[^;\\n=]*Promise\\s*<`).test(signatureSource) ||
|
|
43
|
-
new RegExp(`${accessorStart}get\\s+${memberName}\\s*\\([^)]*\\)\\s*:\\s*Promise\\s*<`).test(signatureSource) ||
|
|
44
|
-
new RegExp(`${accessorStart}accessor\\s+${memberName}\\s*:\\s*[^;\\n=]*Promise\\s*<`).test(signatureSource));
|
|
45
|
-
};
|
|
46
|
-
export const hasPromiseReturningPublicAPI = (source) => pipe(exportedDeclarationTexts(source), Array.some((declaration) => {
|
|
47
|
-
if (/^\s*(?:export\s+)?(?:default\s+)?(?:abstract\s+)?class\b/.test(declaration)) {
|
|
48
|
-
return hasClassPromiseReturningPublicMember(declaration);
|
|
49
|
-
}
|
|
50
|
-
const signature = stripCommentsAndStrings(publicAPIDeclarationSignature(declaration));
|
|
51
|
-
return (/\bPromise\s*</.test(signature) ||
|
|
52
|
-
/^\s*(?:export\s+)?async\s+function\b/.test(signature) ||
|
|
53
|
-
/=\s*async\b/.test(signature));
|
|
54
|
-
}));
|
|
55
|
-
export const hasExportedRunPromiseAPI = (source) => pipe(exportedDeclarationTexts(source), Array.some((declaration) => /\bEffect\.runPromise\s*\(/.test(stripCommentsAndStrings(declaration))));
|
|
56
|
-
export const hasRunSyncInServerRequestHandler = hasRunSyncInServerRequestHandlerSource;
|
|
57
|
-
export const hasCryptoRandomUUID = (source) => matchIndexOrFalse(/\bcrypto\.randomUUID\s*\(/.exec(stripCommentsAndStrings(source)));
|
|
58
|
-
export const hasSchemaInstanceof = (source) => {
|
|
59
|
-
const code = stripCommentsAndStrings(source);
|
|
60
|
-
return matchIndexOrFalse(/\binstanceof\s+[A-Z][\w$]*(?:Schema|Request)\b/.exec(code));
|
|
61
|
-
};
|
|
62
|
-
export const hasSchemaStructWithTag = (source) => matchIndexOrFalse(/\bSchema\.Struct\s*\(\s*{[\s\S]*?_tag\s*:\s*Schema\.Literal\s*\(/.exec(stripCommentsAndStrings(source)));
|
|
63
|
-
export const hasSchemaUnionOfLiterals = (source) => matchIndexOrFalse(/\bSchema\.Union\s*\(\s*Schema\.Literal\s*\([^)]*\)\s*,\s*Schema\.Literal\s*\(/.exec(stripCommentsAndStrings(source)));
|
|
64
|
-
const nonDeterministicServiceKeyIndex = (code, codeOnly, pattern) => codeMatchIndexOrFalse(code, codeOnly, pattern, (match) => {
|
|
65
|
-
const [, className, key] = match;
|
|
66
|
-
return className !== key && !key.endsWith(`/${className}`);
|
|
67
|
-
});
|
|
68
|
-
export const hasNonDeterministicServiceKey = (source) => {
|
|
69
|
-
const code = stripComments(source);
|
|
70
|
-
const codeOnly = stripCommentsAndStrings(source);
|
|
71
|
-
const legacyPattern = /\bclass\s+([A-Z][\w$]*)\s+extends\s+(?:Context\.Tag|Effect\.Service|Effect\.Tag)\s*\(\s*['"`]([^'"`]+)['"`]\s*\)/g;
|
|
72
|
-
const legacyIndex = nonDeterministicServiceKeyIndex(code, codeOnly, legacyPattern);
|
|
73
|
-
if (legacyIndex !== false) {
|
|
74
|
-
return legacyIndex;
|
|
75
|
-
}
|
|
76
|
-
const servicePattern = /\bclass\s+([A-Z][\w$]*)\s+extends\s+Effect\.Service\s*<\s*[A-Z][\w$]*\s*>\s*\(\s*\)\s*\(\s*['"`]([^'"`]+)['"`]/g;
|
|
77
|
-
return nonDeterministicServiceKeyIndex(code, codeOnly, servicePattern);
|
|
78
|
-
};
|
|
79
|
-
export const hasMultipleProvideChain = (source) => {
|
|
80
|
-
const code = stripCommentsAndStrings(source);
|
|
81
|
-
return matchIndexOrFalse(/\.pipe\s*\([\s\S]*?Effect\.provide\s*\([\s\S]*?Effect\.provide\s*\(/.exec(code));
|
|
82
|
-
};
|
|
83
|
-
export const hasLayerEffectWithScope = (source) => {
|
|
84
|
-
const code = stripCommentsAndStrings(source);
|
|
85
|
-
return matchIndexOrFalse(/\bLayer\.effect\s*\([\s\S]*?\b(?:Scope\.Scope|Scope)\b/.exec(code));
|
|
86
|
-
};
|
|
87
|
-
export const hasNodeBuiltinImport = (source) => codeMatchIndexOrFalse(stripComments(source), stripCommentsAndStrings(source), /\bfrom\s+['"]node:(?:fs|fs\/promises|path|child_process|crypto|stream|http|https)['"]/g);
|
|
88
|
-
export const hasGlobalFetch = (source, context) => {
|
|
89
|
-
const code = stripCommentsAndStrings(source);
|
|
90
|
-
if (isConfiguredPath(context, 'adapterLayers')) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
return pipe(matchesIn(code, /\bfetch\s*\(/g), Array.findFirst((match) => Boolean(effectWrapperStatement(code, match.index))), Option.map((match) => match.index), Option.getOrElse(() => false));
|
|
94
|
-
};
|
|
95
|
-
export const hasEffectSucceedWithVoid = (source) => matchIndexOrFalse(/\bEffect\.succeed\s*\(\s*(?:undefined|void\s+0)?\s*\)/.exec(stripCommentsAndStrings(source)));
|
|
96
|
-
export const hasMapToVoid = (source) => matchIndexOrFalse(/\bEffect\.map\s*\(\s*\(\s*\)\s*=>\s*(?:undefined|void\s+0|\{\s*\})\s*\)/.exec(stripCommentsAndStrings(source)));
|
|
97
|
-
export const hasMapFlatten = (source) => matchIndexOrFalse(/\bEffect\.map\s*\([\s\S]*?\)\s*,\s*Effect\.flatten\b|\bEffect\.map\s*\([\s\S]*?\)\.pipe\s*\(\s*Effect\.flatten\b/.exec(stripCommentsAndStrings(source)));
|
|
98
|
-
export const effectWrapperStatement = (source, targetIndex) => {
|
|
99
|
-
const statementStart = Math.max(source.lastIndexOf(';', targetIndex) + 1, source.lastIndexOf('\n', targetIndex) + 1);
|
|
100
|
-
const statementEnd = findStatementEnd(source, statementStart);
|
|
101
|
-
const statement = source.slice(statementStart, statementEnd + 1);
|
|
102
|
-
if (/\bEffect\.(?:promise|tryPromise)\s*\(/.test(statement)) {
|
|
103
|
-
return statement;
|
|
104
|
-
}
|
|
105
|
-
return undefined;
|
|
106
|
-
};
|
|
107
|
-
export const hasDirectPlatformAccess = (source, context) => {
|
|
108
|
-
if (isConfiguredPath(context, 'adapterLayers')) {
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
const code = stripCommentsAndStrings(source);
|
|
112
|
-
return pipe(matchesIn(code, /\b(?:fetch|readFileSync|writeFileSync|createReadStream)\s*\(/g), Array.some((match) => {
|
|
113
|
-
if (!match[0].startsWith('fetch')) {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
return !effectWrapperStatement(code, match.index);
|
|
117
|
-
}));
|
|
118
|
-
};
|
|
1
|
+
export { hasRunSyncInServerRequestHandlerSource as hasRunSyncInServerRequestHandler } from './effect-strict-server-handler-source.js';
|
|
119
2
|
//# sourceMappingURL=effect-strict-source-predicates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-strict-source-predicates.js","sourceRoot":"","sources":["../../src/rules/effect-strict-source-predicates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"effect-strict-source-predicates.js","sourceRoot":"","sources":["../../src/rules/effect-strict-source-predicates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sCAAsC,IAAI,gCAAgC,EAAE,MAAM,uCAAuC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-strict.d.ts","sourceRoot":"","sources":["../../src/rules/effect-strict.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"effect-strict.d.ts","sourceRoot":"","sources":["../../src/rules/effect-strict.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,iBAAiB,yDAAmC,CAAC;AAE3D,eAAe,iBAAiB,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import { Array, pipe } from 'effect';
|
|
2
|
-
import { effectStrictASTSpecs } from './effect-strict-ast-specs.js';
|
|
3
1
|
import { effectStrictCoreSpecs } from './effect-strict-core-specs.js';
|
|
4
2
|
import { makeRules } from './effect-rule-core.js';
|
|
5
|
-
|
|
6
|
-
const effectStrictRules = pipe(effectStrictCoreSpecs, Array.appendAll(effectStrictASTSpecs), (strictSpecs) => makeRules(strictSpecs, {
|
|
7
|
-
schema: strictPathOptionsSchema,
|
|
8
|
-
}));
|
|
3
|
+
const effectStrictRules = makeRules(effectStrictCoreSpecs);
|
|
9
4
|
export default effectStrictRules;
|
|
10
5
|
//# sourceMappingURL=effect-strict.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effect-strict.js","sourceRoot":"","sources":["../../src/rules/effect-strict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"effect-strict.js","sourceRoot":"","sources":["../../src/rules/effect-strict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C,MAAM,iBAAiB,GAAG,SAAS,CAAC,qBAAqB,CAAC,CAAC;AAE3D,eAAe,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-module-mocking.d.ts","sourceRoot":"","sources":["../../src/rules/no-module-mocking.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"no-module-mocking.d.ts","sourceRoot":"","sources":["../../src/rules/no-module-mocking.ts"],"names":[],"mappings":"AA8FA,eAAO,MAAM,mBAAmB,gCAsB9B,CAAC"}
|
|
@@ -18,18 +18,21 @@ function importedName(node) {
|
|
|
18
18
|
return null;
|
|
19
19
|
return node.imported.type === 'Identifier' ? node.imported.name : node.imported.value;
|
|
20
20
|
}
|
|
21
|
+
function isTestFrameworkNamespaceMember(sourceCode, expression) {
|
|
22
|
+
const member = staticMemberName(expression);
|
|
23
|
+
if (expression.object.type !== 'Identifier')
|
|
24
|
+
return false;
|
|
25
|
+
const variable = resolveVariable(sourceCode, expression.object);
|
|
26
|
+
return (variable?.defs.some((definition) => definition.type === 'ImportBinding' &&
|
|
27
|
+
definition.node.type === 'ImportNamespaceSpecifier' &&
|
|
28
|
+
definition.parent?.type === 'ImportDeclaration' &&
|
|
29
|
+
definition.parent.importKind !== 'type' &&
|
|
30
|
+
((definition.parent.source.value === 'vitest' && member === 'vi') ||
|
|
31
|
+
(definition.parent.source.value === '@jest/globals' && member === 'jest'))) ?? false);
|
|
32
|
+
}
|
|
21
33
|
function isTestFrameworkObject(sourceCode, expression) {
|
|
22
34
|
if (expression.type === 'MemberExpression') {
|
|
23
|
-
|
|
24
|
-
if (expression.object.type !== 'Identifier')
|
|
25
|
-
return false;
|
|
26
|
-
const variable = resolveVariable(sourceCode, expression.object);
|
|
27
|
-
return (variable?.defs.some((definition) => definition.type === 'ImportBinding' &&
|
|
28
|
-
definition.node.type === 'ImportNamespaceSpecifier' &&
|
|
29
|
-
definition.parent?.type === 'ImportDeclaration' &&
|
|
30
|
-
definition.parent.importKind !== 'type' &&
|
|
31
|
-
((definition.parent.source.value === 'vitest' && member === 'vi') ||
|
|
32
|
-
(definition.parent.source.value === '@jest/globals' && member === 'jest'))) ?? false);
|
|
35
|
+
return isTestFrameworkNamespaceMember(sourceCode, expression);
|
|
33
36
|
}
|
|
34
37
|
if (expression.type !== 'Identifier')
|
|
35
38
|
return false;
|
|
@@ -62,21 +65,11 @@ function staticMemberName(node) {
|
|
|
62
65
|
: null;
|
|
63
66
|
}
|
|
64
67
|
function moduleMockCall(sourceCode, callee) {
|
|
65
|
-
if (
|
|
68
|
+
if (callee.type !== 'MemberExpression')
|
|
66
69
|
return false;
|
|
67
70
|
if (!isTestFrameworkObject(sourceCode, callee.object))
|
|
68
71
|
return false;
|
|
69
|
-
const
|
|
70
|
-
const method = callee.computed
|
|
71
|
-
? property.type === 'Literal' &&
|
|
72
|
-
(property.value === 'doMock' ||
|
|
73
|
-
property.value === 'mock' ||
|
|
74
|
-
property.value === 'unstable_mockModule')
|
|
75
|
-
? property.value
|
|
76
|
-
: null
|
|
77
|
-
: property.type === 'Identifier'
|
|
78
|
-
? property.name
|
|
79
|
-
: null;
|
|
72
|
+
const method = staticMemberName(callee);
|
|
80
73
|
return method !== null && moduleMockMethods.has(method);
|
|
81
74
|
}
|
|
82
75
|
export const noModuleMockingRule = defineRule({
|