@sshkeda/check 0.0.0-stage → 1.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/LICENSE +21 -0
- package/README.md +156 -2
- package/docs/how-to-make-check-pass.md +71 -0
- package/package.json +51 -4
- package/src/index.ts +8 -0
- package/src/internal/ban-abbreviated-words-in-declared-names.ts +165 -0
- package/src/internal/ban-checked-members-outside-calls.ts +151 -0
- package/src/internal/ban-comments.ts +23 -0
- package/src/internal/ban-comparing-or-switching-on-tag.ts +114 -0
- package/src/internal/ban-deadlines-inside-tests.ts +41 -0
- package/src/internal/ban-declared-values.ts +70 -0
- package/src/internal/ban-dropped-failures-detached-fibers-sleeps-and-untraced-functions.ts +67 -0
- package/src/internal/ban-failures-collected-as-results.ts +57 -0
- package/src/internal/ban-fallbacks-of-named-recoveries.ts +118 -0
- package/src/internal/ban-function-overloads.ts +107 -0
- package/src/internal/ban-global-error-in-failure-types.ts +146 -0
- package/src/internal/ban-instanceof-in-effect-recovery-callbacks.ts +63 -0
- package/src/internal/ban-let-and-effect-mutable-ref.ts +79 -0
- package/src/internal/ban-logic-in-index-files.ts +178 -0
- package/src/internal/ban-namespaces-used-without-a-member.ts +176 -0
- package/src/internal/ban-node-builtins-that-effect-replaces.ts +42 -0
- package/src/internal/ban-parsing-outside-data-without-a-schema.ts +299 -0
- package/src/internal/ban-re-exports.ts +172 -0
- package/src/internal/ban-reading-the-clock-and-sleeping-outside-effect.ts +239 -0
- package/src/internal/ban-retired-words-in-names.ts +49 -0
- package/src/internal/ban-scanning-directories-with-bun-glob.ts +79 -0
- package/src/internal/ban-shebang-lines.ts +26 -0
- package/src/internal/ban-timer-globals-and-the-global-object.ts +34 -0
- package/src/internal/ban-timer-schedules-without-deadlines.ts +240 -0
- package/src/internal/ban-type-and-interface-declarations.ts +48 -0
- package/src/internal/ban-type-predicates.ts +82 -0
- package/src/internal/ban-unknown-in-function-signatures.ts +143 -0
- package/src/internal/ban-vague-error-class-names.ts +28 -0
- package/src/internal/ban-vague-file-names.ts +51 -0
- package/src/internal/ban-what-a-file-is-not-granted.ts +512 -0
- package/src/internal/ban-while-do-while-and-for-loops.ts +27 -0
- package/src/internal/confine-service-declarations-to-granted-files.ts +116 -0
- package/src/internal/confine-the-stdio-service-to-terminal-output.ts +190 -0
- package/src/internal/define-the-lint-plugin-and-configs.ts +361 -0
- package/src/internal/describe-and-decode-rule-options.ts +22 -0
- package/src/internal/keep-assertions-in-the-test-home-and-ban-test-runners.ts +128 -0
- package/src/internal/keep-effect-testing-helpers-in-test-files.ts +157 -0
- package/src/internal/match-banned-modules-and-globals.ts +71 -0
- package/src/internal/match-effect-service-factories.ts +20 -0
- package/src/internal/require-a-named-const-for-compound-conditions.ts +44 -0
- package/src/internal/require-capital-snake-case-and-as-const-on-literal-constants.ts +141 -0
- package/src/internal/require-service-keys-to-end-with-their-class-name.ts +64 -0
- package/src/internal/resolve-what-an-expression-imports.ts +295 -0
- package/src/internal/sort-type-constituents.ts +82 -0
- package/src/internal/split-names-into-words.ts +12 -0
- package/src/internal/visit-every-declared-name.ts +264 -0
- package/src/lib/tasks/index.ts +1 -0
- package/src/lib/tasks/internal/declare-the-check-task.ts +29 -0
- package/src/lib/tasks/internal/declare-the-checker-queries-task.ts +41 -0
- package/src/lib/tasks/internal/declare-the-typed-checks-task.ts +25 -0
- package/src/lib/tasks/internal/run-checks-over-one-typescript-project.ts +68 -0
- package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/index.ts +15 -0
- package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/internal/check-effect-diagnostics-with-effect-tsgo.ts +211 -0
- package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/internal/read-effect-tsgo-json-report.ts +39 -0
- package/src/lib/tasks/lib/check-import-boundaries/index.ts +1 -0
- package/src/lib/tasks/lib/check-import-boundaries/internal/find-import-boundary-violations.ts +415 -0
- package/src/lib/tasks/lib/check-import-boundaries/internal/find-subpath-import-targets.ts +117 -0
- package/src/lib/tasks/lib/check-import-boundaries/internal/find-what-hides-an-import.ts +65 -0
- package/src/lib/tasks/lib/check-import-boundaries/internal/import-boundary-errors.ts +176 -0
- package/src/lib/tasks/lib/check-uses-by-their-declarations/index.ts +1 -0
- package/src/lib/tasks/lib/check-uses-by-their-declarations/internal/declared-use-errors.ts +32 -0
- package/src/lib/tasks/lib/check-uses-by-their-declarations/internal/find-declared-use-violations.ts +38 -0
- package/src/lib/tasks/lib/check-uses-by-their-declarations/internal/find-sync-calls.ts +23 -0
- package/src/lib/tasks/lib/check-uses-by-their-declarations/internal/find-type-only-schemas.ts +375 -0
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/index.ts +1 -0
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/find-layer-provides-outside-program-starts.ts +648 -0
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/layer-provide-errors.ts +27 -0
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/resolve-imported-package-apis.ts +262 -0
- package/src/lib/tasks/lib/confine-stdio-to-granted-files/index.ts +1 -0
- package/src/lib/tasks/lib/confine-stdio-to-granted-files/internal/find-ungranted-stdio-uses.ts +219 -0
- package/src/lib/tasks/lib/confine-stdio-to-granted-files/internal/stdio-use-errors.ts +31 -0
- package/src/lib/tasks/lib/detect-inferrable-annotations/index.ts +1 -0
- package/src/lib/tasks/lib/detect-inferrable-annotations/internal/find-inferrable-annotations.ts +357 -0
- package/src/lib/tasks/lib/detect-inferrable-annotations/internal/inferrable-annotation-errors.ts +33 -0
- package/src/lib/tasks/lib/detect-repeated-service-yields/index.ts +1 -0
- package/src/lib/tasks/lib/detect-repeated-service-yields/internal/find-repeated-service-yields.ts +162 -0
- package/src/lib/tasks/lib/detect-repeated-service-yields/internal/repeated-service-yield-errors.ts +25 -0
- package/src/lib/tasks/lib/enforce-file-layout/index.ts +5 -0
- package/src/lib/tasks/lib/enforce-file-layout/internal/check-the-layout-of-each-package.ts +9 -0
- package/src/lib/tasks/lib/enforce-file-layout/internal/file-layout-errors.ts +417 -0
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-export-path-mismatches.ts +83 -0
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-file-layout-violations.ts +848 -0
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-module-layout-violations.ts +82 -0
- package/src/lib/tasks/lib/enforce-file-layout/internal/resolve-task-imports.ts +178 -0
- package/src/lib/tasks/lib/enforce-file-types/index.ts +5 -0
- package/src/lib/tasks/lib/enforce-file-types/internal/file-type-errors.ts +21 -0
- package/src/lib/tasks/lib/enforce-file-types/internal/find-file-type-violations.ts +78 -0
- package/src/lib/tasks/lib/format-with-bun-fmt/index.ts +1 -0
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/check-formatting-with-bun-fmt.ts +157 -0
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/declare-the-formatting-task.ts +66 -0
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/find-format-config-violations.ts +16 -0
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/find-format-input-violations.ts +74 -0
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/find-symbolic-links.ts +14 -0
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/unformatted-file-errors.ts +12 -0
- package/src/lib/tasks/lib/judge-index-re-exports/index.ts +1 -0
- package/src/lib/tasks/lib/judge-index-re-exports/internal/find-index-re-export-violations.ts +353 -0
- package/src/lib/tasks/lib/judge-index-re-exports/internal/index-re-export-errors.ts +21 -0
- package/src/lib/tasks/lib/lint-with-oxlint/index.ts +15 -0
- package/src/lib/tasks/lib/lint-with-oxlint/internal/check-lint-rules-with-oxlint.ts +123 -0
- package/src/lib/tasks/lib/lint-with-oxlint/internal/check-unsafe-enum-assignments.ts +152 -0
- package/src/lib/tasks/lib/lint-with-oxlint/internal/find-tsgolint-executable.ts +21 -0
- package/src/lib/tasks/lib/lint-with-oxlint/internal/read-oxlint-json-report.ts +82 -0
- package/src/lib/tasks/lib/lint-with-oxlint/internal/read-tsgolint-rule-messages.ts +68 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/index.ts +1 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/export-placement-errors.ts +135 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-export-placement-violations.ts +507 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-misplaced-files.ts +116 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-subdivided-directories.ts +29 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-the-importer-graph.ts +451 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/list-binding-names.ts +49 -0
- package/src/lib/tasks/lib/refuse-disable-directives/index.ts +15 -0
- package/src/lib/tasks/lib/refuse-disable-directives/internal/disable-directive-errors.ts +45 -0
- package/src/lib/tasks/lib/refuse-disable-directives/internal/find-disable-directives.ts +66 -0
- package/src/lib/tasks/lib/refuse-error-mappings-that-end-streams/index.ts +1 -0
- package/src/lib/tasks/lib/refuse-error-mappings-that-end-streams/internal/error-mapping-errors.ts +21 -0
- package/src/lib/tasks/lib/refuse-error-mappings-that-end-streams/internal/find-error-mappings-to-done.ts +135 -0
- package/src/lib/tasks/lib/require-separate-service-layers/index.ts +1 -0
- package/src/lib/tasks/lib/require-separate-service-layers/internal/find-service-layer-violations.ts +170 -0
- package/src/lib/tasks/lib/require-separate-service-layers/internal/service-layer-errors.ts +21 -0
- package/src/lib/tasks/lib/require-type-checking-every-linted-file/index.ts +14 -0
- package/src/lib/tasks/lib/require-type-checking-every-linted-file/internal/find-linted-files-not-type-checked.ts +117 -0
- package/src/lib/tasks/lib/require-type-checking-every-linted-file/internal/linted-file-errors.ts +51 -0
- package/src/lib/tasks/lib/type-check-with-bun-check/index.ts +11 -0
- package/src/lib/tasks/lib/type-check-with-bun-check/internal/check-types-with-bun-check.ts +54 -0
- package/src/lib/tasks/lib/type-check-with-bun-check/internal/read-bun-check-output.ts +73 -0
- package/src/lib/tasks/lib/type-check-with-bun-check/internal/type-check-errors.ts +10 -0
- package/src/lib/tasks/shared/check-each-nested-package.ts +79 -0
- package/src/lib/tasks/shared/classify-files-by-role.ts +115 -0
- package/src/lib/tasks/shared/count-the-line-of-an-offset.ts +2 -0
- package/src/lib/tasks/shared/create-the-module-resolver.ts +38 -0
- package/src/lib/tasks/shared/declare-lint-config-task.ts +13 -0
- package/src/lib/tasks/shared/declare-typescript-config-task.ts +18 -0
- package/src/lib/tasks/shared/encode-compact-json.ts +5 -0
- package/src/lib/tasks/shared/find-installed-package-binaries.ts +62 -0
- package/src/lib/tasks/shared/find-module-requests.ts +482 -0
- package/src/lib/tasks/shared/find-named-package-manifests.ts +94 -0
- package/src/lib/tasks/shared/find-unmet-typescript-config-requirements.ts +60 -0
- package/src/lib/tasks/shared/list-ignored-files-imported-by-source.ts +79 -0
- package/src/lib/tasks/shared/list-linted-files.ts +28 -0
- package/src/lib/tasks/shared/list-owned-files.ts +13 -0
- package/src/lib/tasks/shared/list-package-files.ts +66 -0
- package/src/lib/tasks/shared/load-the-lint-config.ts +176 -0
- package/src/lib/tasks/shared/match-granted-patch-files.ts +88 -0
- package/src/lib/tasks/shared/parse-config-files-that-import-from-check.ts +310 -0
- package/src/lib/tasks/shared/print-failures-and-keep-detail-in-the-trace.ts +99 -0
- package/src/lib/tasks/shared/project-config-and-tool-errors.ts +485 -0
- package/src/lib/tasks/shared/query-the-typescript-project.ts +635 -0
- package/src/lib/tasks/shared/read-named-package-manifests.ts +53 -0
- package/src/lib/tasks/shared/read-package-manifest-object.ts +28 -0
- package/src/lib/tasks/shared/resolve-absolute-paths.ts +4 -0
- package/src/lib/tasks/shared/resolve-module-requests.ts +121 -0
- package/src/lib/tasks/shared/run-tools-and-decode-their-reports.ts +98 -0
- package/src/lib/tasks/shared/tool-file-locations.ts +38 -0
- package/src/shared/bans-each-permission-lifts.ts +454 -0
- package/src/shared/config-file-names.ts +3 -0
- package/src/shared/find-retired-words.ts +17 -0
- package/src/shared/format-reported-failures.ts +31 -0
- package/src/shared/lint-rule-messages-and-patterns.ts +104 -0
- package/src/shared/match-file-names-and-path-prefixes.ts +18 -0
- package/src/shared/permission-grant-errors.ts +42 -0
- package/src/shared/record-and-grant-permissions-by-path.ts +419 -0
- package/src/shared/test-home-directories.ts +4 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Task } from "@sshkeda/task";
|
|
2
|
+
import { Effect, Path } from "effect";
|
|
3
|
+
|
|
4
|
+
import { findImportBoundaryViolations } from "../lib/check-import-boundaries/index.ts";
|
|
5
|
+
import { findDeclaredUseViolations } from "../lib/check-uses-by-their-declarations/index.ts";
|
|
6
|
+
import { findLayerProvidesOutsideProgramStarts } from "../lib/confine-layer-provides-to-program-starts/index.ts";
|
|
7
|
+
import { findUngrantedStdioUses } from "../lib/confine-stdio-to-granted-files/index.ts";
|
|
8
|
+
import { findInferrableAnnotations } from "../lib/detect-inferrable-annotations/index.ts";
|
|
9
|
+
import { findRepeatedServiceYields } from "../lib/detect-repeated-service-yields/index.ts";
|
|
10
|
+
import { findIndexReExportViolations } from "../lib/judge-index-re-exports/index.ts";
|
|
11
|
+
import { findExportPlacementViolations } from "../lib/place-exports-in-the-narrowest-directory/index.ts";
|
|
12
|
+
import { findErrorMappingsToDone } from "../lib/refuse-error-mappings-that-end-streams/index.ts";
|
|
13
|
+
import { findServiceLayerViolations } from "../lib/require-separate-service-layers/index.ts";
|
|
14
|
+
import { inEachPackage } from "../shared/check-each-nested-package.ts";
|
|
15
|
+
import { lintConfigFile } from "../shared/declare-lint-config-task.ts";
|
|
16
|
+
import { typeScriptConfig } from "../shared/declare-typescript-config-task.ts";
|
|
17
|
+
import { TYPESCRIPT_PROJECT_FILE } from "../shared/query-the-typescript-project.ts";
|
|
18
|
+
import { runChecksOverOneTypeScriptProject } from "./run-checks-over-one-typescript-project.ts";
|
|
19
|
+
|
|
20
|
+
export const checkerQueries = Task.make(
|
|
21
|
+
"checker-queries",
|
|
22
|
+
Effect.andThen(
|
|
23
|
+
Task.all([typeScriptConfig, lintConfigFile]),
|
|
24
|
+
inEachPackage("checker-queries", ".", (packageDirectory) =>
|
|
25
|
+
Path.Path.use((path) =>
|
|
26
|
+
runChecksOverOneTypeScriptProject(path.join(packageDirectory, TYPESCRIPT_PROJECT_FILE), {
|
|
27
|
+
"service-yields": findRepeatedServiceYields,
|
|
28
|
+
"service-layers": findServiceLayerViolations,
|
|
29
|
+
stdio: findUngrantedStdioUses,
|
|
30
|
+
"inferrable-annotations": findInferrableAnnotations,
|
|
31
|
+
"import-boundaries": findImportBoundaryViolations,
|
|
32
|
+
"declared-uses": findDeclaredUseViolations,
|
|
33
|
+
"export-placement": findExportPlacementViolations,
|
|
34
|
+
"layer-provides": findLayerProvidesOutsideProgramStarts,
|
|
35
|
+
"error-mappings": findErrorMappingsToDone,
|
|
36
|
+
"re-exports": findIndexReExportViolations,
|
|
37
|
+
}),
|
|
38
|
+
),
|
|
39
|
+
),
|
|
40
|
+
),
|
|
41
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Task } from "@sshkeda/task";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
|
|
4
|
+
import { effectStrict } from "../lib/check-effect-diagnostics-with-effect-tsgo/index.ts";
|
|
5
|
+
import { oxlint } from "../lib/lint-with-oxlint/index.ts";
|
|
6
|
+
import { directives } from "../lib/refuse-disable-directives/index.ts";
|
|
7
|
+
import { lintedFilesTypeChecked } from "../lib/require-type-checking-every-linted-file/index.ts";
|
|
8
|
+
import { typeCheck } from "../lib/type-check-with-bun-check/index.ts";
|
|
9
|
+
import { typeScriptConfig } from "../shared/declare-typescript-config-task.ts";
|
|
10
|
+
import { checkerQueries } from "./declare-the-checker-queries-task.ts";
|
|
11
|
+
|
|
12
|
+
export const typedChecks: Task.Task<void> = Task.make(
|
|
13
|
+
"typed-checks",
|
|
14
|
+
Effect.andThen(
|
|
15
|
+
typeScriptConfig,
|
|
16
|
+
Task.allSettled([
|
|
17
|
+
typeCheck,
|
|
18
|
+
oxlint,
|
|
19
|
+
effectStrict,
|
|
20
|
+
directives,
|
|
21
|
+
checkerQueries,
|
|
22
|
+
lintedFilesTypeChecked,
|
|
23
|
+
]),
|
|
24
|
+
),
|
|
25
|
+
);
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ReportedErrors } from "@sshkeda/task/errors";
|
|
2
|
+
import { Array as Arrays, Cause, Effect, Exit, Option, Result } from "effect";
|
|
3
|
+
|
|
4
|
+
import { printableErrorWith } from "../../../shared/format-reported-failures.ts";
|
|
5
|
+
import {
|
|
6
|
+
couldNotRun,
|
|
7
|
+
quietViolations,
|
|
8
|
+
} from "../shared/print-failures-and-keep-detail-in-the-trace.ts";
|
|
9
|
+
import { CheckCrashed } from "../shared/project-config-and-tool-errors.ts";
|
|
10
|
+
import { openTypeScriptProjects } from "../shared/query-the-typescript-project.ts";
|
|
11
|
+
|
|
12
|
+
const OPENING_THE_PROJECT = "typescript-project";
|
|
13
|
+
|
|
14
|
+
export const runChecksOverOneTypeScriptProject = <Requirement>(
|
|
15
|
+
projectFile: string,
|
|
16
|
+
checks: Readonly<
|
|
17
|
+
Record<
|
|
18
|
+
string,
|
|
19
|
+
(
|
|
20
|
+
projectFile: string,
|
|
21
|
+
openedProjects: Effect.Effect<Effect.Success<ReturnType<typeof openTypeScriptProjects>>>,
|
|
22
|
+
) => Effect.Effect<
|
|
23
|
+
void,
|
|
24
|
+
Effect.Error<Parameters<ReturnType<typeof quietViolations>>[0]>,
|
|
25
|
+
Requirement
|
|
26
|
+
>
|
|
27
|
+
>
|
|
28
|
+
>,
|
|
29
|
+
) =>
|
|
30
|
+
Effect.gen(function* () {
|
|
31
|
+
const openedProjects = Effect.succeed(
|
|
32
|
+
yield* openTypeScriptProjects(projectFile).pipe(quietViolations(OPENING_THE_PROJECT)),
|
|
33
|
+
);
|
|
34
|
+
const results = yield* Effect.all(
|
|
35
|
+
Object.entries(checks).map(([name, runCheck]) =>
|
|
36
|
+
Effect.suspend(() => runCheck(projectFile, openedProjects)).pipe(
|
|
37
|
+
quietViolations(name),
|
|
38
|
+
Effect.exit,
|
|
39
|
+
Effect.flatMap((exit) => {
|
|
40
|
+
const defect = Exit.isFailure(exit)
|
|
41
|
+
? Result.getSuccess(Cause.findDefect(exit.cause))
|
|
42
|
+
: Option.none();
|
|
43
|
+
return Option.match(defect, {
|
|
44
|
+
onNone: () => exit,
|
|
45
|
+
onSome: (crash) =>
|
|
46
|
+
couldNotRun(
|
|
47
|
+
name,
|
|
48
|
+
new CheckCrashed({ check: name, reason: Cause.pretty(Cause.die(crash)) }),
|
|
49
|
+
),
|
|
50
|
+
});
|
|
51
|
+
}),
|
|
52
|
+
Effect.mapError(({ reportedErrors }) =>
|
|
53
|
+
Arrays.map(reportedErrors, (reported) =>
|
|
54
|
+
printableErrorWith(reported, { tag: `${name} ${reported.tag}` }),
|
|
55
|
+
),
|
|
56
|
+
),
|
|
57
|
+
Effect.withSpan(name),
|
|
58
|
+
),
|
|
59
|
+
),
|
|
60
|
+
{ concurrency: "unbounded", mode: "result" },
|
|
61
|
+
);
|
|
62
|
+
const reportedErrors = results.flatMap((result) =>
|
|
63
|
+
Result.isFailure(result) ? result.failure : [],
|
|
64
|
+
);
|
|
65
|
+
if (Arrays.isArrayNonEmpty(reportedErrors)) {
|
|
66
|
+
return yield* new ReportedErrors({ reportedErrors });
|
|
67
|
+
}
|
|
68
|
+
}).pipe(Effect.scoped);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Task } from "@sshkeda/task";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
|
|
4
|
+
import { inEachPackage } from "../../shared/check-each-nested-package.ts";
|
|
5
|
+
import { lintConfigFile } from "../../shared/declare-lint-config-task.ts";
|
|
6
|
+
import { typeScriptConfig } from "../../shared/declare-typescript-config-task.ts";
|
|
7
|
+
import { effectDiagnosticsIn } from "./internal/check-effect-diagnostics-with-effect-tsgo.ts";
|
|
8
|
+
|
|
9
|
+
export const effectStrict = Task.make(
|
|
10
|
+
"effect-tsgo",
|
|
11
|
+
Effect.andThen(
|
|
12
|
+
Task.all([typeScriptConfig, lintConfigFile]),
|
|
13
|
+
inEachPackage("effect-tsgo", ".", effectDiagnosticsIn),
|
|
14
|
+
),
|
|
15
|
+
);
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { Effect, Path } from "effect";
|
|
2
|
+
|
|
3
|
+
import { generatedPathsOf } from "../../../../../shared/record-and-grant-permissions-by-path.ts";
|
|
4
|
+
import { encodeJson } from "../../../shared/encode-compact-json.ts";
|
|
5
|
+
import { installedBinary } from "../../../shared/find-installed-package-binaries.ts";
|
|
6
|
+
import { loadedLintConfigIn } from "../../../shared/load-the-lint-config.ts";
|
|
7
|
+
import {
|
|
8
|
+
quietToolFailure,
|
|
9
|
+
quietViolations,
|
|
10
|
+
} from "../../../shared/print-failures-and-keep-detail-in-the-trace.ts";
|
|
11
|
+
import {
|
|
12
|
+
projectConfigFiles,
|
|
13
|
+
TYPESCRIPT_PROJECT_FILE,
|
|
14
|
+
} from "../../../shared/query-the-typescript-project.ts";
|
|
15
|
+
import { runTool } from "../../../shared/run-tools-and-decode-their-reports.ts";
|
|
16
|
+
import { effectViolationsReport } from "./read-effect-tsgo-json-report.ts";
|
|
17
|
+
|
|
18
|
+
const EFFECT_TSGO = "effect-tsgo";
|
|
19
|
+
|
|
20
|
+
export const EFFECT_DIAGNOSTIC_SEVERITY = {
|
|
21
|
+
abortControllerInEffect: "error",
|
|
22
|
+
acquireReleaseDisposable: "error",
|
|
23
|
+
allOfMapToForEach: "error",
|
|
24
|
+
anyUnknownInErrorContext: "error",
|
|
25
|
+
apiStabilityLeak: "off",
|
|
26
|
+
asyncFunction: "error",
|
|
27
|
+
catchAllTagDispatchToCatchTag: "error",
|
|
28
|
+
catchAllToMapError: "error",
|
|
29
|
+
catchChainToFirstSuccessOf: "off",
|
|
30
|
+
catchConditionalRefailToCatchIf: "off",
|
|
31
|
+
catchDieToOrDie: "off",
|
|
32
|
+
catchIfTagToCatchTag: "off",
|
|
33
|
+
catchRefailToTapError: "error",
|
|
34
|
+
catchTagToCatchReason: "error",
|
|
35
|
+
catchToIgnore: "off",
|
|
36
|
+
catchToOrElseSucceed: "off",
|
|
37
|
+
catchUnfailableEffect: "error",
|
|
38
|
+
classSelfMismatch: "error",
|
|
39
|
+
cryptoRandomUUID: "error",
|
|
40
|
+
cryptoRandomUUIDInEffect: "error",
|
|
41
|
+
deterministicKeys: "off",
|
|
42
|
+
duplicatePackage: "error",
|
|
43
|
+
effectDoNotation: "off",
|
|
44
|
+
effectFnIife: "error",
|
|
45
|
+
effectFnImplicitAny: "error",
|
|
46
|
+
effectFnOpportunity: "error",
|
|
47
|
+
effectGenUsesAdapter: "error",
|
|
48
|
+
effectInFailure: "error",
|
|
49
|
+
effectInVoidSuccess: "error",
|
|
50
|
+
effectMapFlatten: "error",
|
|
51
|
+
effectMapVoid: "error",
|
|
52
|
+
effectSleepZeroToYieldNow: "error",
|
|
53
|
+
effectSucceedWithVoid: "error",
|
|
54
|
+
errorPayloadShadowsName: "error",
|
|
55
|
+
experimentalApiUsage: "error",
|
|
56
|
+
extendsNativeError: "error",
|
|
57
|
+
flatMapConditionalToFilterOrFail: "error",
|
|
58
|
+
flatMapIgnoredParamToAndThen: "error",
|
|
59
|
+
flatMapToMap: "error",
|
|
60
|
+
flatMapToTap: "error",
|
|
61
|
+
floatingEffect: "error",
|
|
62
|
+
floatingEffectInVitest: "error",
|
|
63
|
+
genericEffectServices: "error",
|
|
64
|
+
globalConsole: "off",
|
|
65
|
+
globalConsoleInEffect: "off",
|
|
66
|
+
globalDate: "off",
|
|
67
|
+
globalDateInEffect: "off",
|
|
68
|
+
globalErrorInEffectCatch: "error",
|
|
69
|
+
globalErrorInEffectFailure: "error",
|
|
70
|
+
globalFetch: "error",
|
|
71
|
+
globalFetchInEffect: "error",
|
|
72
|
+
globalRandom: "error",
|
|
73
|
+
globalRandomInEffect: "error",
|
|
74
|
+
globalTimers: "off",
|
|
75
|
+
globalTimersInEffect: "off",
|
|
76
|
+
instanceOfSchema: "error",
|
|
77
|
+
layerMergeAllWithDependencies: "error",
|
|
78
|
+
lazyEffect: "error",
|
|
79
|
+
lazyPromiseInEffectSync: "error",
|
|
80
|
+
leakingRequirements: "error",
|
|
81
|
+
mapSomeToAsSome: "error",
|
|
82
|
+
matchEffectToMapBoth: "error",
|
|
83
|
+
matchEffectToMatch: "error",
|
|
84
|
+
missedPipeableOpportunity: "off",
|
|
85
|
+
missingEffectContext: "error",
|
|
86
|
+
missingEffectError: "error",
|
|
87
|
+
missingEffectServiceDependency: "off",
|
|
88
|
+
missingLayerContext: "error",
|
|
89
|
+
missingPipeableSignature: "off",
|
|
90
|
+
missingReturnYieldStar: "error",
|
|
91
|
+
missingStarInYieldEffectGen: "error",
|
|
92
|
+
multipleCatchTag: "error",
|
|
93
|
+
multipleEffectProvide: "error",
|
|
94
|
+
nestedEffectGenYield: "off",
|
|
95
|
+
newPromise: "error",
|
|
96
|
+
newSchemaClass: "off",
|
|
97
|
+
nodeBuiltinImport: "off",
|
|
98
|
+
nonObjectEffectServiceType: "error",
|
|
99
|
+
obsoleteMatchImport: "error",
|
|
100
|
+
obsoleteSchemaImport: "error",
|
|
101
|
+
optionMatchToFromOption: "error",
|
|
102
|
+
outdatedApi: "error",
|
|
103
|
+
overriddenSchemaConstructor: "error",
|
|
104
|
+
preferBarrelImport: "off",
|
|
105
|
+
preferEffectArray: "off",
|
|
106
|
+
preferEffectRecord: "off",
|
|
107
|
+
preferEffectString: "off",
|
|
108
|
+
preferNamespaceImport: "off",
|
|
109
|
+
preferSchemaOverJson: "off",
|
|
110
|
+
preferSchemaTaggedError: "off",
|
|
111
|
+
preferSchemaTypeProperty: "off",
|
|
112
|
+
preferSucceedSomeOrNone: "error",
|
|
113
|
+
preferTypedSchemaDecoder: "error",
|
|
114
|
+
preferUnsafeConstructor: "error",
|
|
115
|
+
processEnv: "off",
|
|
116
|
+
processEnvInEffect: "off",
|
|
117
|
+
promiseInEffectSuccess: "error",
|
|
118
|
+
provideLayerSucceedToProvideService: "error",
|
|
119
|
+
raceFirstWithSleepToTimeout: "error",
|
|
120
|
+
redundantMapError: "error",
|
|
121
|
+
redundantOrDie: "off",
|
|
122
|
+
redundantSchemaTagIdentifier: "error",
|
|
123
|
+
returnEffectInGen: "error",
|
|
124
|
+
runEffectInsideEffect: "error",
|
|
125
|
+
runOfExitToRunExit: "error",
|
|
126
|
+
schemaClassMissingBrand: "off",
|
|
127
|
+
schemaClassObjectLiteral: "error",
|
|
128
|
+
schemaLiteralNonFinite: "error",
|
|
129
|
+
schemaNumber: "error",
|
|
130
|
+
schemaOpaqueInstanceMember: "error",
|
|
131
|
+
schemaStructWithTag: "error",
|
|
132
|
+
schemaSync: "error",
|
|
133
|
+
schemaSyncInEffect: "error",
|
|
134
|
+
schemaUnionOfLiterals: "off",
|
|
135
|
+
scopeInLayerEffect: "error",
|
|
136
|
+
serviceNotAsClass: "off",
|
|
137
|
+
strictBooleanExpressions: "off",
|
|
138
|
+
strictEffectProvide: "off",
|
|
139
|
+
syncToSucceed: "error",
|
|
140
|
+
timeoutCatchTagToTimeoutOrElse: "error",
|
|
141
|
+
tryCatchInEffectGen: "error",
|
|
142
|
+
unknownInEffectCatch: "error",
|
|
143
|
+
unnecessaryArrowBlock: "off",
|
|
144
|
+
unnecessaryEffectGen: "error",
|
|
145
|
+
unnecessaryFailYieldableError: "error",
|
|
146
|
+
unnecessaryPipe: "error",
|
|
147
|
+
unnecessaryPipeChain: "error",
|
|
148
|
+
unnecessaryTypeofType: "error",
|
|
149
|
+
unsafeEffectTypeAssertion: "off",
|
|
150
|
+
unstableApiUsage: "off",
|
|
151
|
+
} as const satisfies Readonly<Record<string, "error" | "off">>;
|
|
152
|
+
|
|
153
|
+
export const checkEffectDiagnosticsOfProject = (
|
|
154
|
+
project: string,
|
|
155
|
+
generatedFiles: readonly string[] = [],
|
|
156
|
+
directory = ".",
|
|
157
|
+
) =>
|
|
158
|
+
Effect.gen(function* () {
|
|
159
|
+
const configuration = yield* encodeJson({
|
|
160
|
+
diagnosticSeverity: EFFECT_DIAGNOSTIC_SEVERITY,
|
|
161
|
+
overrides: generatedFiles.map((file) => ({
|
|
162
|
+
include: [file],
|
|
163
|
+
options: {
|
|
164
|
+
diagnosticSeverity: Object.fromEntries(
|
|
165
|
+
Object.keys(EFFECT_DIAGNOSTIC_SEVERITY).map((name) => [name, "off"]),
|
|
166
|
+
),
|
|
167
|
+
},
|
|
168
|
+
})),
|
|
169
|
+
});
|
|
170
|
+
const path = yield* Path.Path;
|
|
171
|
+
const checkDirectory = yield* path.fromFileUrl(new URL(".", import.meta.url));
|
|
172
|
+
const binary = yield* installedBinary(checkDirectory, "@effect/tsgo", EFFECT_TSGO);
|
|
173
|
+
yield* runTool(
|
|
174
|
+
EFFECT_TSGO,
|
|
175
|
+
process.execPath,
|
|
176
|
+
[
|
|
177
|
+
binary,
|
|
178
|
+
"diagnostics",
|
|
179
|
+
"--project",
|
|
180
|
+
path.resolve(directory, project),
|
|
181
|
+
"--strict",
|
|
182
|
+
"--format",
|
|
183
|
+
"json",
|
|
184
|
+
"--lspconfig",
|
|
185
|
+
configuration,
|
|
186
|
+
],
|
|
187
|
+
checkDirectory,
|
|
188
|
+
);
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
export const effectDiagnosticsIn = (directory: string) =>
|
|
192
|
+
Effect.gen(function* () {
|
|
193
|
+
const path = yield* Path.Path;
|
|
194
|
+
const generated = [
|
|
195
|
+
...generatedPathsOf(yield* loadedLintConfigIn(directory).pipe(quietViolations(EFFECT_TSGO))),
|
|
196
|
+
].map((file) => path.resolve(directory, file));
|
|
197
|
+
const configFiles = yield* projectConfigFiles(
|
|
198
|
+
path.join(directory, TYPESCRIPT_PROJECT_FILE),
|
|
199
|
+
).pipe(quietViolations(EFFECT_TSGO));
|
|
200
|
+
for (const configFile of configFiles) {
|
|
201
|
+
yield* checkEffectDiagnosticsOfProject(
|
|
202
|
+
path.relative(directory, configFile),
|
|
203
|
+
generated,
|
|
204
|
+
directory,
|
|
205
|
+
).pipe(
|
|
206
|
+
quietToolFailure(EFFECT_TSGO, (exited) =>
|
|
207
|
+
effectViolationsReport(EFFECT_TSGO, exited.standardOutput),
|
|
208
|
+
),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Effect, Schema } from "effect";
|
|
2
|
+
|
|
3
|
+
import { decodedReport } from "../../../shared/run-tools-and-decode-their-reports.ts";
|
|
4
|
+
|
|
5
|
+
const UPSTREAM_MESSAGE_REWRITES: ReadonlyMap<string, string> = new Map([
|
|
6
|
+
["effect(schemaNumber)", "Schema.Number accepts NaN, Infinity and -Infinity"],
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
const EFFECT_VIOLATIONS_REPORT = Schema.fromJsonString(
|
|
10
|
+
Schema.Struct({
|
|
11
|
+
diagnostics: Schema.Array(
|
|
12
|
+
Schema.Struct({
|
|
13
|
+
file: Schema.String,
|
|
14
|
+
line: Schema.Int,
|
|
15
|
+
column: Schema.Int,
|
|
16
|
+
name: Schema.String,
|
|
17
|
+
message: Schema.String,
|
|
18
|
+
}),
|
|
19
|
+
),
|
|
20
|
+
}),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
export const effectViolationsReport = (program: string, standardOutput: string) =>
|
|
24
|
+
standardOutput.trim() === ""
|
|
25
|
+
? Effect.succeed({ violations: [], notes: [] })
|
|
26
|
+
: decodedReport(program, Schema.decodeEffect(EFFECT_VIOLATIONS_REPORT), standardOutput).pipe(
|
|
27
|
+
Effect.map((report) => ({
|
|
28
|
+
violations: report.diagnostics.map((reported) => {
|
|
29
|
+
const tag = `effect(${reported.name})`;
|
|
30
|
+
const location = `${reported.file}:${reported.line}:${reported.column}`;
|
|
31
|
+
return {
|
|
32
|
+
tag,
|
|
33
|
+
location,
|
|
34
|
+
message: UPSTREAM_MESSAGE_REWRITES.get(tag) ?? reported.message,
|
|
35
|
+
};
|
|
36
|
+
}),
|
|
37
|
+
notes: [],
|
|
38
|
+
})),
|
|
39
|
+
);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { findImportBoundaryViolations } from "./internal/find-import-boundary-violations.ts";
|