@sshkeda/check 3.0.0 → 4.0.1
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/README.md +5 -41
- package/docs/how-to-grant-a-permission.md +28 -0
- package/docs/how-to-make-check-pass.md +4 -31
- package/package.json +2 -2
- package/scripts/check.ts +2 -3
- package/src/internal/ban-fixed-values-in-recoveries.ts +1 -1
- package/src/lib/project-directory/index.ts +0 -1
- package/src/lib/project-directory/internal/read-the-project-directory.ts +1 -5
- package/src/lib/tasks/internal/declare-the-check-task.ts +6 -6
- package/src/lib/tasks/internal/declare-the-checker-queries-task.ts +4 -4
- package/src/lib/tasks/internal/declare-the-typed-checks-task.ts +4 -4
- package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/index.ts +4 -4
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/find-layer-provides-outside-program-starts.ts +15 -1
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/resolve-imported-package-apis.ts +1 -2
- package/src/lib/tasks/lib/detect-duplicate-functions/index.ts +4 -4
- package/src/lib/tasks/lib/enforce-file-layout/index.ts +4 -4
- package/src/lib/tasks/lib/enforce-file-layout/internal/file-layout-errors.ts +7 -29
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-file-layout-violations.ts +14 -181
- package/src/lib/tasks/lib/enforce-file-types/index.ts +4 -4
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/declare-the-formatting-task.ts +28 -17
- package/src/lib/tasks/lib/lint-with-oxlint/index.ts +4 -4
- package/src/lib/tasks/lib/refuse-disable-directives/index.ts +4 -4
- package/src/lib/tasks/lib/require-type-checking-every-linted-file/index.ts +4 -4
- package/src/lib/tasks/lib/type-check-with-bun-check/index.ts +4 -4
- package/src/lib/tasks/shared/check-each-nested-package.ts +2 -0
- package/src/lib/tasks/shared/declare-lint-config-task.ts +4 -4
- package/src/lib/tasks/shared/declare-start-directory-task.ts +40 -0
- package/src/lib/tasks/shared/declare-typescript-config-task.ts +4 -4
- package/src/lib/tasks/shared/project-config-and-tool-errors.ts +9 -0
- package/src/lib/tasks/shared/query-the-typescript-project.ts +10 -15
- package/src/lib/tasks/shared/watch-the-typescript-api-process.ts +177 -0
- package/src/shared/bans-each-permission-lifts.ts +0 -7
- package/src/shared/record-and-grant-permissions-by-path.ts +1 -3
- package/src/lib/tasks/internal/verify-where-check-was-started.ts +0 -50
- package/src/lib/tasks/lib/enforce-file-layout/internal/resolve-task-imports.ts +0 -178
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ Check sends your AI slop code back to the kitchen!
|
|
|
4
4
|
|
|
5
5
|
Check holds your TypeScript code to a strict standard built around Effect and Bun, so the code stays type-safe, observable and predictable.
|
|
6
6
|
|
|
7
|
-
It runs about 310 lint rules,
|
|
7
|
+
It runs about 310 lint rules, 65 of them its own, and about 80 checks on your project's layout, imports and config. It also runs oxfmt, Effect's diagnostics and `bun check`. Your agent keeps fixing what it reports until the slop is gone.
|
|
8
8
|
|
|
9
|
-
No comment or setting turns a rule off everywhere. A small set of rules was picked to allow an override, and you grant each one to a single file in `oxlint.config.ts`. See [Grant a
|
|
9
|
+
No comment or setting turns a rule off everywhere. A small set of rules was picked to allow an override, and you grant each one to a single file in `oxlint.config.ts`. See [How to Grant a Permission](docs/how-to-grant-a-permission.md).
|
|
10
10
|
|
|
11
11
|
Check is a command you run in your repo. It runs its checks with [Task](https://github.com/sshkeda/task), a task runner for Bun.
|
|
12
12
|
|
|
@@ -48,7 +48,8 @@ Here's what Check prints when it runs on that code:
|
|
|
48
48
|
[typed-checks] error SettledTasksFailed: 2 of 6 tasks failed: oxlint, effect-tsgo
|
|
49
49
|
[check] read node_modules/@sshkeda/check/docs/how-to-make-check-pass.md before you change the code
|
|
50
50
|
[check] error SettledTasksFailed: 1 of 7 tasks failed: typed-checks
|
|
51
|
-
failed: effect-tsgo, oxlint (2 of
|
|
51
|
+
failed: effect-tsgo, oxlint (2 of 18 tasks), 1.0s
|
|
52
|
+
...
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
Here's what each error catches:
|
|
@@ -150,44 +151,7 @@ Check needs Bun 1.4.4 or newer and a Git repository.
|
|
|
150
151
|
|
|
151
152
|
Check checks the package in the directory you start it in.
|
|
152
153
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
To run Check beside your own tasks, such as your tests, add Task and start the command from a task in `scripts/`.
|
|
156
|
-
|
|
157
|
-
```bash
|
|
158
|
-
bun add @sshkeda/task
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
`scripts/internal/start-check.ts` starts the command:
|
|
162
|
-
|
|
163
|
-
```ts
|
|
164
|
-
import { Task } from "@sshkeda/task";
|
|
165
|
-
|
|
166
|
-
export const check = Task.make("check", Task.exec("bunx", ["@sshkeda/check"]));
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
`scripts/ci.ts` runs it:
|
|
170
|
-
|
|
171
|
-
```ts
|
|
172
|
-
import { Task } from "@sshkeda/task";
|
|
173
|
-
|
|
174
|
-
import { check } from "./internal/start-check.ts";
|
|
175
|
-
|
|
176
|
-
if (import.meta.main) {
|
|
177
|
-
Task.main(check);
|
|
178
|
-
}
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
To run your tests too, make one task in `scripts/internal/run-checks-and-tests.ts` that runs both, and pass it to `Task.main` in `scripts/ci.ts`:
|
|
182
|
-
|
|
183
|
-
```ts
|
|
184
|
-
import { Task } from "@sshkeda/task";
|
|
185
|
-
|
|
186
|
-
import { tests } from "../../tests/index.ts";
|
|
187
|
-
import { check } from "./start-check.ts";
|
|
188
|
-
|
|
189
|
-
export const ci = Task.make("ci", Task.allSettled([check, tests]));
|
|
190
|
-
```
|
|
154
|
+
To run one check alone, name it, as in `bunx @sshkeda/check oxlint`.
|
|
191
155
|
|
|
192
156
|
## Make it yours
|
|
193
157
|
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# How to Grant a Permission
|
|
2
|
+
|
|
3
|
+
Grant a permission to one file or directory in `oxlint.config.ts`. The key is the path from the folder that holds `oxlint.config.ts`, with no glob. Each name in `allow` lifts one ban for that path only.
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
export default lintConfig({
|
|
7
|
+
"src/config.ts": { allow: ["readsConfig"] },
|
|
8
|
+
"src/internal/run-all-checks.ts": { allow: ["handlesEveryFailure"] },
|
|
9
|
+
});
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
- `readsConfig`: Allows Effect `Config`, `process.env` and `process.argv`.
|
|
13
|
+
- `spawnsCommands`: Allows Effect `ChildProcess`, `Bun.spawn` and `spawn` from `node:child_process`.
|
|
14
|
+
- `locksFiles`: Allows `open` from `node:fs/promises` and `constants` from `node:fs`.
|
|
15
|
+
- `importsDynamically`: Allows `import()` and `createRequire(…).resolve`.
|
|
16
|
+
- `exitsTheProcess`: Allows `process.exit`.
|
|
17
|
+
- `usesSqlDatabases`: Allows Effect SQL.
|
|
18
|
+
- `writesToTheTerminal`: Allows Effect `Stdio`.
|
|
19
|
+
- `usesAbbreviations`: Allows abbreviations in variable, function, type and other declared names.
|
|
20
|
+
- `pollsWithADeadline`: Allows `Effect.repeat` and `Effect.retry` with `Schedule.spaced` or `Schedule.exponential`, under a deadline. `Schedule.exponential` may be wrapped in or piped through `Schedule.jittered`.
|
|
21
|
+
- `waitsOnTimers`: Allows `Effect.sleep`, `Effect.delay`, `Clock.sleep` and the Stream operations that wait on a timer, such as `Stream.tick`.
|
|
22
|
+
- `hasAnUnlistedFileType`: Allows a file type Check doesn't list, such as Markdown.
|
|
23
|
+
- `isAnUnlistedDirectory`: Allows a directory Check doesn't list, such as `.github`. Check doesn't apply its directory-shape rules inside it, but files there still need their own `hasAnUnlistedFileType` grant.
|
|
24
|
+
- `patchesADependency`: Allows a patch file from `bun patch`.
|
|
25
|
+
- `trustsUnverifiedTypes`: Allows trusting a value's type without checking it, through `Schema.declare`.
|
|
26
|
+
- `handlesEveryFailure`: Allows catching every error, through `Effect.catch`, `Effect.exit`, a forked fiber or `Effect.runPromise`.
|
|
27
|
+
- `fallsBackToFixedValues`: Allows answering every failure, or a whole library error such as `PlatformError`, with a fixed value that never reads the failure.
|
|
28
|
+
- `isGeneratedByATool`: Check skips this path, so it can't have any other permission.
|
|
@@ -6,41 +6,13 @@ Check may not catch every violation of these principles. Review your code agains
|
|
|
6
6
|
|
|
7
7
|
## Meet the requirement behind the error
|
|
8
8
|
|
|
9
|
-
- Use a grant only for an unavoidable exception.
|
|
9
|
+
- Use a grant only for an unavoidable exception. [How to Grant a Permission](how-to-grant-a-permission.md) lists each grant and what it allows.
|
|
10
10
|
- Move the code that needs a grant into its own small file and grant that file. A grant covers the whole file, so Check stops reporting that ban for everything else in it.
|
|
11
11
|
- Design for the current requirement as if you were starting fresh. Delete code the new design doesn't need.
|
|
12
12
|
- Handle a forked effect's failure before the fork, or keep the fiber and join it.
|
|
13
|
+
- Return a fixed value only for the one failure you expect, such as a file that isn't there. Let every other failure fail.
|
|
13
14
|
- Grant `isGeneratedByATool` only to a file a tool generates.
|
|
14
15
|
|
|
15
|
-
## Grant a permission
|
|
16
|
-
|
|
17
|
-
Grant a permission to one file or directory in `oxlint.config.ts`. The key is the path from the folder that holds `oxlint.config.ts`, with no glob. Each name in `allow` lifts one ban for that path only.
|
|
18
|
-
|
|
19
|
-
```ts
|
|
20
|
-
export default lintConfig({
|
|
21
|
-
"src/config.ts": { allow: ["readsConfig"] },
|
|
22
|
-
"src/internal/run-all-checks.ts": { allow: ["handlesEveryFailure"] },
|
|
23
|
-
});
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
- `readsConfig`: Allows Effect `Config`, `process.env` and `process.argv`.
|
|
27
|
-
- `spawnsCommands`: Allows Effect `ChildProcess`, `Bun.spawn` and `spawn` from `node:child_process`.
|
|
28
|
-
- `locksFiles`: Allows `open` from `node:fs/promises` and `constants` from `node:fs`.
|
|
29
|
-
- `importsDynamically`: Allows `import()` and `createRequire(…).resolve`.
|
|
30
|
-
- `exitsTheProcess`: Allows `process.exit`.
|
|
31
|
-
- `usesSqlDatabases`: Allows Effect SQL.
|
|
32
|
-
- `writesToTheTerminal`: Allows Effect `Stdio`.
|
|
33
|
-
- `usesAbbreviations`: Allows abbreviations in variable, function, type and other declared names.
|
|
34
|
-
- `pollsWithADeadline`: Allows `Effect.repeat` and `Effect.retry` with `Schedule.spaced` or `Schedule.exponential`, under a deadline. `Schedule.exponential` may be wrapped in or piped through `Schedule.jittered`.
|
|
35
|
-
- `waitsOnTimers`: Allows `Effect.sleep`, `Effect.delay`, `Clock.sleep` and the Stream operations that wait on a timer, such as `Stream.tick`.
|
|
36
|
-
- `hasAnUnlistedFileType`: Allows a file type Check doesn't list, such as Markdown.
|
|
37
|
-
- `isAnUnlistedDirectory`: Allows a directory Check doesn't list, such as `.github`. Check doesn't apply its directory-shape rules inside it, but files there still need their own `hasAnUnlistedFileType` grant.
|
|
38
|
-
- `patchesADependency`: Allows a patch file from `bun patch`.
|
|
39
|
-
- `trustsUnverifiedTypes`: Allows trusting a value's type without checking it, through `Schema.declare`.
|
|
40
|
-
- `handlesEveryFailure`: Allows catching every error, through `Effect.catch`, `Effect.exit`, a forked fiber or `Effect.runPromise`.
|
|
41
|
-
- `fallsBackToFixedValues`: Allows answering every failure, or a whole library error such as `PlatformError`, with a fixed value that never reads the failure.
|
|
42
|
-
- `isGeneratedByATool`: Check skips this path, so it can't have any other permission.
|
|
43
|
-
|
|
44
16
|
## Make the code explain itself
|
|
45
17
|
|
|
46
18
|
- Use what Effect, Bun or a dependency already provides.
|
|
@@ -54,7 +26,8 @@ export default lintConfig({
|
|
|
54
26
|
## Make program output clear
|
|
55
27
|
|
|
56
28
|
- Follow Git and uv's style. Say what failed, name the affected file or value and explain the cause.
|
|
57
|
-
- Give the reader enough context to choose a fix.
|
|
29
|
+
- Give the reader enough context to choose a fix.
|
|
30
|
+
- Put a fix in the message only when it is concrete and takes no thought, such as a command to paste and run or the exact code to write. Leave out any fix that needs a decision.
|
|
58
31
|
- Report each cause once. Put the main failure first, supporting details below it and internal debugging details in the trace.
|
|
59
32
|
- Preserve useful messages from underlying tools, including error codes and exact names.
|
|
60
33
|
- Write short, full sentences. Use periods instead of semicolons between sentences.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sshkeda/check",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.1",
|
|
4
4
|
"homepage": "https://github.com/sshkeda/check#readme",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/sshkeda/check/issues"
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"@effect/platform-bun": "4.1.0",
|
|
31
31
|
"@effect/tsgo": "0.67.4",
|
|
32
32
|
"@oxlint/plugins": "1.88.0",
|
|
33
|
-
"@sshkeda/task": "
|
|
33
|
+
"@sshkeda/task": "2.0.0",
|
|
34
34
|
"oxc-parser": "0.153.0",
|
|
35
35
|
"oxc-resolver": "11.24.2",
|
|
36
36
|
"oxlint": "1.88.0",
|
package/scripts/check.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { Task } from "@sshkeda/task";
|
|
3
|
-
|
|
4
2
|
import { PROJECT_DIRECTORY_VARIABLE } from "../src/lib/project-directory/index.ts";
|
|
5
3
|
import { check } from "../src/lib/tasks/index.ts";
|
|
6
4
|
|
|
7
5
|
if (import.meta.main) {
|
|
8
6
|
process.env[PROJECT_DIRECTORY_VARIABLE] = process.cwd();
|
|
9
|
-
Task.main(check);
|
|
10
7
|
}
|
|
8
|
+
|
|
9
|
+
export default check;
|
|
@@ -242,7 +242,7 @@ export const noFixedFallbacks = defineRule({
|
|
|
242
242
|
type: "problem",
|
|
243
243
|
messages: {
|
|
244
244
|
fixed:
|
|
245
|
-
"{{operation}} answers {{failure}} with the fixed value {{value}} and never reads the failure
|
|
245
|
+
"{{operation}} answers {{failure}} with the fixed value {{value}} and never reads the failure",
|
|
246
246
|
unusedGrant: unusedGrantMessage(FIXED_FALLBACKS),
|
|
247
247
|
},
|
|
248
248
|
schema: ruleOptionsJsonSchema(FIXED_FALLBACK_OPTIONS),
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import { Config
|
|
1
|
+
import { Config } from "effect";
|
|
2
2
|
|
|
3
3
|
export const PROJECT_DIRECTORY_VARIABLE = "SSHKEDA_CHECK_PROJECT_DIRECTORY";
|
|
4
4
|
|
|
5
5
|
const THE_PACKAGE_THAT_RUNS_THE_TASK = ".";
|
|
6
6
|
|
|
7
|
-
const FIRST_SCRIPT_ARGUMENT = 2;
|
|
8
|
-
|
|
9
7
|
export const projectDirectory = Config.String(PROJECT_DIRECTORY_VARIABLE).pipe(
|
|
10
8
|
Config.withDefault(THE_PACKAGE_THAT_RUNS_THE_TASK),
|
|
11
9
|
);
|
|
12
|
-
|
|
13
|
-
export const givenArguments = Effect.sync(() => process.argv.slice(FIRST_SCRIPT_ARGUMENT));
|
|
@@ -7,9 +7,9 @@ import { layout } from "../lib/enforce-file-layout/index.ts";
|
|
|
7
7
|
import { fileTypes } from "../lib/enforce-file-types/index.ts";
|
|
8
8
|
import { formatting } from "../lib/format-with-bun-fmt/index.ts";
|
|
9
9
|
import { lintConfigFile } from "../shared/declare-lint-config-task.ts";
|
|
10
|
+
import { startDirectory } from "../shared/declare-start-directory-task.ts";
|
|
10
11
|
import { typeScriptConfig } from "../shared/declare-typescript-config-task.ts";
|
|
11
12
|
import { typedChecks } from "./declare-the-typed-checks-task.ts";
|
|
12
|
-
import { verifyWhereCheckWasStarted } from "./verify-where-check-was-started.ts";
|
|
13
13
|
|
|
14
14
|
const GUIDE_FILE = new URL("../../../../docs/how-to-make-check-pass.md", import.meta.url);
|
|
15
15
|
|
|
@@ -22,10 +22,10 @@ const pointAtTheGuide = Effect.gen(function* () {
|
|
|
22
22
|
yield* Effect.logError(`read ${guide} before you change the code`);
|
|
23
23
|
});
|
|
24
24
|
|
|
25
|
-
export const check: Task.Task<void> = Task.make(
|
|
26
|
-
"check",
|
|
27
|
-
Effect.andThen(
|
|
28
|
-
|
|
25
|
+
export const check: Task.Task<void> = Task.make({
|
|
26
|
+
name: "check",
|
|
27
|
+
run: Effect.andThen(
|
|
28
|
+
startDirectory,
|
|
29
29
|
Task.allSettled([
|
|
30
30
|
typeScriptConfig,
|
|
31
31
|
lintConfigFile,
|
|
@@ -36,4 +36,4 @@ export const check: Task.Task<void> = Task.make(
|
|
|
36
36
|
duplicateFunctions,
|
|
37
37
|
]).pipe(Effect.tapError(() => pointAtTheGuide)),
|
|
38
38
|
),
|
|
39
|
-
);
|
|
39
|
+
});
|
|
@@ -19,9 +19,9 @@ import { ProjectQueryCachesLive } from "../shared/provide-project-query-caches.t
|
|
|
19
19
|
import { TYPESCRIPT_PROJECT_FILE } from "../shared/query-the-typescript-project.ts";
|
|
20
20
|
import { runChecksOverOneTypeScriptProject } from "./run-checks-over-one-typescript-project.ts";
|
|
21
21
|
|
|
22
|
-
export const checkerQueries = Task.make(
|
|
23
|
-
"checker-queries",
|
|
24
|
-
Effect.andThen(
|
|
22
|
+
export const checkerQueries = Task.make({
|
|
23
|
+
name: "checker-queries",
|
|
24
|
+
run: Effect.andThen(
|
|
25
25
|
Task.all([typeScriptConfig, lintConfigFile]),
|
|
26
26
|
inEachPackage("checker-queries", (packageDirectory) =>
|
|
27
27
|
Path.Path.use((path) =>
|
|
@@ -41,4 +41,4 @@ export const checkerQueries = Task.make(
|
|
|
41
41
|
),
|
|
42
42
|
),
|
|
43
43
|
).pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
44
|
-
);
|
|
44
|
+
});
|
|
@@ -9,9 +9,9 @@ import { typeCheck } from "../lib/type-check-with-bun-check/index.ts";
|
|
|
9
9
|
import { typeScriptConfig } from "../shared/declare-typescript-config-task.ts";
|
|
10
10
|
import { checkerQueries } from "./declare-the-checker-queries-task.ts";
|
|
11
11
|
|
|
12
|
-
export const typedChecks: Task.Task<void> = Task.make(
|
|
13
|
-
"typed-checks",
|
|
14
|
-
Effect.andThen(
|
|
12
|
+
export const typedChecks: Task.Task<void> = Task.make({
|
|
13
|
+
name: "typed-checks",
|
|
14
|
+
run: Effect.andThen(
|
|
15
15
|
typeScriptConfig,
|
|
16
16
|
Task.allSettled([
|
|
17
17
|
typeCheck,
|
|
@@ -22,4 +22,4 @@ export const typedChecks: Task.Task<void> = Task.make(
|
|
|
22
22
|
lintedFilesTypeChecked,
|
|
23
23
|
]),
|
|
24
24
|
),
|
|
25
|
-
);
|
|
25
|
+
});
|
|
@@ -7,10 +7,10 @@ import { typeScriptConfig } from "../../shared/declare-typescript-config-task.ts
|
|
|
7
7
|
import { ProjectQueryCachesLive } from "../../shared/provide-project-query-caches.ts";
|
|
8
8
|
import { effectDiagnosticsIn } from "./internal/check-effect-diagnostics-with-effect-tsgo.ts";
|
|
9
9
|
|
|
10
|
-
export const effectStrict = Task.make(
|
|
11
|
-
"effect-tsgo",
|
|
12
|
-
Effect.andThen(
|
|
10
|
+
export const effectStrict = Task.make({
|
|
11
|
+
name: "effect-tsgo",
|
|
12
|
+
run: Effect.andThen(
|
|
13
13
|
Task.all([typeScriptConfig, lintConfigFile]),
|
|
14
14
|
inEachPackage("effect-tsgo", effectDiagnosticsIn),
|
|
15
15
|
).pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
16
|
-
);
|
|
16
|
+
});
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
isIdentifier,
|
|
14
14
|
isObjectLiteralExpression,
|
|
15
15
|
isParameterDeclaration,
|
|
16
|
+
isPropertyAssignment,
|
|
16
17
|
isReturnStatement,
|
|
17
18
|
isSpreadElement,
|
|
18
19
|
isVariableDeclaration,
|
|
@@ -409,6 +410,12 @@ const isRunnerArgument = (
|
|
|
409
410
|
return isArgument ? startsTheProgram(checker, apis, parent) : Effect.succeed(false);
|
|
410
411
|
};
|
|
411
412
|
|
|
413
|
+
const objectHoldingAPropertyValue = (node: Node) => {
|
|
414
|
+
const { parent } = node;
|
|
415
|
+
const isPropertyValue = isPropertyAssignment(parent) && isObjectLiteralExpression(parent.parent);
|
|
416
|
+
return isPropertyValue ? parent.parent : node;
|
|
417
|
+
};
|
|
418
|
+
|
|
412
419
|
const isExported = (declaration: Node) => {
|
|
413
420
|
const statement = declaration.parent.parent;
|
|
414
421
|
return (
|
|
@@ -448,7 +455,14 @@ const isConstOnlyRunByARunner = (
|
|
|
448
455
|
(read) => read !== undefined && read.pos !== declaration.name.pos,
|
|
449
456
|
);
|
|
450
457
|
const isReadOnce = onlyRead !== undefined && otherReads.length === 0;
|
|
451
|
-
return
|
|
458
|
+
return (
|
|
459
|
+
isReadOnce &&
|
|
460
|
+
(yield* isRunnerArgument(
|
|
461
|
+
checker,
|
|
462
|
+
apis,
|
|
463
|
+
objectHoldingAPropertyValue(outermostWrapperOf(onlyRead)),
|
|
464
|
+
))
|
|
465
|
+
);
|
|
452
466
|
});
|
|
453
467
|
|
|
454
468
|
const isWhereTheProgramStarts = (
|
|
@@ -11,7 +11,6 @@ import type { Checker, Symbol as TypeScriptSymbol } from "typescript/unstable/as
|
|
|
11
11
|
import {
|
|
12
12
|
TASK_NAMESPACE_EXPORT,
|
|
13
13
|
TASK_PACKAGE,
|
|
14
|
-
TASK_MAIN_MEMBER,
|
|
15
14
|
TASK_MAKE_MEMBER,
|
|
16
15
|
} from "../../../../../shared/bans-each-permission-lifts.ts";
|
|
17
16
|
import {
|
|
@@ -94,7 +93,7 @@ const PROGRAM_STARTS = [
|
|
|
94
93
|
isPackage: isTaskPackage,
|
|
95
94
|
module: PACKAGE_ROOT,
|
|
96
95
|
exports: [TASK_NAMESPACE_EXPORT],
|
|
97
|
-
members: [
|
|
96
|
+
members: [TASK_MAKE_MEMBER],
|
|
98
97
|
returnedBySignature: DIRECT_CALLS,
|
|
99
98
|
},
|
|
100
99
|
] as const;
|
|
@@ -4,7 +4,7 @@ import { Effect } from "effect";
|
|
|
4
4
|
import { ProjectQueryCachesLive } from "../../shared/provide-project-query-caches.ts";
|
|
5
5
|
import { duplicateFunctionsOfEachPackage } from "./internal/find-duplicate-functions.ts";
|
|
6
6
|
|
|
7
|
-
export const duplicateFunctions = Task.make(
|
|
8
|
-
"duplicate-functions",
|
|
9
|
-
duplicateFunctionsOfEachPackage.pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
10
|
-
);
|
|
7
|
+
export const duplicateFunctions = Task.make({
|
|
8
|
+
name: "duplicate-functions",
|
|
9
|
+
run: duplicateFunctionsOfEachPackage.pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
10
|
+
});
|
|
@@ -4,7 +4,7 @@ import { Effect } from "effect";
|
|
|
4
4
|
import { ProjectQueryCachesLive } from "../../shared/provide-project-query-caches.ts";
|
|
5
5
|
import { fileLayoutViolationsOfEachPackage } from "./internal/check-the-layout-of-each-package.ts";
|
|
6
6
|
|
|
7
|
-
export const layout = Task.make(
|
|
8
|
-
"layout",
|
|
9
|
-
fileLayoutViolationsOfEachPackage.pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
10
|
-
);
|
|
7
|
+
export const layout = Task.make({
|
|
8
|
+
name: "layout",
|
|
9
|
+
run: fileLayoutViolationsOfEachPackage.pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
10
|
+
});
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Effect, Schema } from "effect";
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
TASK_MAIN_MEMBER,
|
|
5
|
-
TASK_NAMESPACE_EXPORT,
|
|
6
|
-
TASK_PACKAGE,
|
|
7
|
-
} from "../../../../../shared/bans-each-permission-lifts.ts";
|
|
3
|
+
import { TASK_PACKAGE } from "../../../../../shared/bans-each-permission-lifts.ts";
|
|
8
4
|
import { LINT_CONFIG_FILE } from "../../../../../shared/config-file-names.ts";
|
|
9
5
|
import { listedViolations } from "../../../../../shared/format-reported-failures.ts";
|
|
10
6
|
import {
|
|
@@ -68,37 +64,21 @@ export class TopLevelNonScript extends Schema.TaggedError<TopLevelNonScript>()(
|
|
|
68
64
|
}
|
|
69
65
|
}
|
|
70
66
|
|
|
71
|
-
export class
|
|
72
|
-
"
|
|
67
|
+
export class TopLevelScriptWithoutDefaultExport extends Schema.TaggedError<TopLevelScriptWithoutDefaultExport>()(
|
|
68
|
+
"TopLevelScriptWithoutDefaultExport",
|
|
73
69
|
{ location: Schema.String },
|
|
74
70
|
) {
|
|
75
71
|
public override get message() {
|
|
76
|
-
return `sits directly in ${SCRIPTS_DIRECTORY}/ and
|
|
72
|
+
return `sits directly in ${SCRIPTS_DIRECTORY}/ and has no default export`;
|
|
77
73
|
}
|
|
78
74
|
}
|
|
79
75
|
|
|
80
|
-
const SCRIPT_ENTRY_POINTS = ["main-guard", "default-export"] as const;
|
|
81
|
-
|
|
82
|
-
const STATEMENTS_A_SCRIPT_MAY_HOLD = {
|
|
83
|
-
"main-guard": `an import and if (import.meta.main) { ${TASK_NAMESPACE_EXPORT}.${TASK_MAIN_MEMBER}(task); }`,
|
|
84
|
-
"default-export": "an import and export default task",
|
|
85
|
-
} satisfies Record<(typeof SCRIPT_ENTRY_POINTS)[number], string>;
|
|
86
|
-
|
|
87
76
|
export class TopLevelScriptHoldsOtherStatement extends Schema.TaggedError<TopLevelScriptHoldsOtherStatement>()(
|
|
88
77
|
"TopLevelScriptHoldsOtherStatement",
|
|
89
|
-
{ location: Schema.String, entryPoint: Schema.Literals(SCRIPT_ENTRY_POINTS) },
|
|
90
|
-
) {
|
|
91
|
-
public override get message() {
|
|
92
|
-
return `holds a statement other than ${STATEMENTS_A_SCRIPT_MAY_HOLD[this.entryPoint]}`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export class TopLevelScriptWithMainAndDefaultExport extends Schema.TaggedError<TopLevelScriptWithMainAndDefaultExport>()(
|
|
97
|
-
"TopLevelScriptWithMainAndDefaultExport",
|
|
98
78
|
{ location: Schema.String },
|
|
99
79
|
) {
|
|
100
80
|
public override get message() {
|
|
101
|
-
return
|
|
81
|
+
return "holds a statement other than an import and export default task";
|
|
102
82
|
}
|
|
103
83
|
}
|
|
104
84
|
|
|
@@ -376,10 +356,9 @@ export class DirectoryGrantedPermissions extends Schema.TaggedError<DirectoryGra
|
|
|
376
356
|
}
|
|
377
357
|
}
|
|
378
358
|
|
|
379
|
-
const MISPLACEMENT_PLACES = ["root-
|
|
359
|
+
const MISPLACEMENT_PLACES = ["root-code-file", "docs-non-markdown"] as const;
|
|
380
360
|
|
|
381
361
|
const MISPLACEMENTS = {
|
|
382
|
-
"root-task-script": "is a task script at the package root",
|
|
383
362
|
"root-code-file": "is code at the package root",
|
|
384
363
|
"docs-non-markdown": `is not markdown but sits in ${DOCS_DIRECTORY}/`,
|
|
385
364
|
} satisfies Record<(typeof MISPLACEMENT_PLACES)[number], string>;
|
|
@@ -402,9 +381,8 @@ export class FileLayoutViolations extends Schema.TaggedError<FileLayoutViolation
|
|
|
402
381
|
MisplacedToolFile,
|
|
403
382
|
BunTestFileName,
|
|
404
383
|
TopLevelNonScript,
|
|
405
|
-
|
|
384
|
+
TopLevelScriptWithoutDefaultExport,
|
|
406
385
|
TopLevelScriptHoldsOtherStatement,
|
|
407
|
-
TopLevelScriptWithMainAndDefaultExport,
|
|
408
386
|
LibraryDirectory,
|
|
409
387
|
DirectoryOutsideModuleLayout,
|
|
410
388
|
ModuleWithoutIndex,
|