@sshkeda/check 2.2.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +52 -22
  2. package/docs/how-to-make-check-pass.md +1 -0
  3. package/package.json +7 -10
  4. package/scripts/check.ts +10 -0
  5. package/src/internal/ban-re-exports.ts +14 -1
  6. package/src/internal/define-the-lint-plugin-and-configs.ts +0 -2
  7. package/src/lib/project-directory/index.ts +5 -0
  8. package/src/lib/project-directory/internal/read-the-project-directory.ts +13 -0
  9. package/src/lib/tasks/internal/declare-the-check-task.ts +18 -10
  10. package/src/lib/tasks/internal/declare-the-checker-queries-task.ts +3 -1
  11. package/src/lib/tasks/internal/verify-where-check-was-started.ts +50 -0
  12. package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/index.ts +1 -1
  13. package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/find-layer-provides-outside-program-starts.ts +6 -36
  14. package/src/lib/tasks/lib/detect-duplicate-functions/internal/find-duplicate-functions.ts +2 -3
  15. package/src/lib/tasks/lib/enforce-file-layout/internal/check-the-layout-of-each-package.ts +1 -1
  16. package/src/lib/tasks/lib/enforce-file-layout/internal/file-layout-errors.ts +19 -2
  17. package/src/lib/tasks/lib/enforce-file-layout/internal/find-file-layout-violations.ts +53 -19
  18. package/src/lib/tasks/lib/enforce-file-types/internal/find-file-type-violations.ts +1 -1
  19. package/src/lib/tasks/lib/format-with-bun-fmt/internal/check-formatting-with-bun-fmt.ts +16 -15
  20. package/src/lib/tasks/lib/format-with-bun-fmt/internal/declare-the-formatting-task.ts +22 -14
  21. package/src/lib/tasks/lib/lint-with-oxlint/index.ts +1 -1
  22. package/src/lib/tasks/lib/lint-with-oxlint/internal/check-lint-rules-with-oxlint.ts +7 -0
  23. package/src/lib/tasks/lib/lint-with-oxlint/internal/find-shebangs-outside-bin.ts +38 -0
  24. package/src/lib/tasks/lib/lint-with-oxlint/internal/shebang-errors.ts +22 -0
  25. package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-export-placement-violations.ts +9 -1
  26. package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-the-importer-graph.ts +21 -0
  27. package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/recognise-task-default-exports.ts +76 -0
  28. package/src/lib/tasks/lib/refuse-disable-directives/index.ts +1 -1
  29. package/src/lib/tasks/lib/refuse-forks-whose-failures-nothing-observes/index.ts +1 -0
  30. package/src/lib/tasks/lib/refuse-forks-whose-failures-nothing-observes/internal/find-unobserved-fork-failures.ts +402 -0
  31. package/src/lib/tasks/lib/refuse-forks-whose-failures-nothing-observes/internal/fork-failure-errors.ts +28 -0
  32. package/src/lib/tasks/lib/require-type-checking-every-linted-file/internal/find-linted-files-not-type-checked.ts +15 -9
  33. package/src/lib/tasks/lib/type-check-with-bun-check/index.ts +1 -1
  34. package/src/lib/tasks/shared/check-each-nested-package.ts +12 -4
  35. package/src/lib/tasks/shared/declare-lint-config-task.ts +1 -1
  36. package/src/lib/tasks/shared/declare-typescript-config-task.ts +1 -1
  37. package/src/lib/tasks/shared/find-installed-package-binaries.ts +10 -0
  38. package/src/lib/tasks/shared/read-piped-steps-through-wrappers.ts +41 -0
  39. package/src/lib/tasks/shared/report-paths-from-the-project.ts +56 -0
  40. package/src/shared/format-reported-failures.ts +8 -6
  41. package/src/shared/record-and-grant-permissions-by-path.ts +4 -1
  42. package/src/internal/ban-shebang-lines.ts +0 -22
@@ -0,0 +1,56 @@
1
+ import { ReportedErrors } from "@sshkeda/task/errors";
2
+ import type { PrintableError } from "@sshkeda/task/errors";
3
+ import { Array as Arrays, Effect, Path } from "effect";
4
+
5
+ import { printableError } from "../../../shared/format-reported-failures.ts";
6
+ import { projectDirectory } from "../../project-directory/index.ts";
7
+
8
+ const locationFromTheProject = (
9
+ pathModule: Path.Path,
10
+ checkedProject: string,
11
+ location: string,
12
+ ) => {
13
+ if (!pathModule.isAbsolute(location)) {
14
+ return location;
15
+ }
16
+ const fromTheProject = pathModule.relative(checkedProject, location);
17
+ const isInsideTheProject =
18
+ fromTheProject !== "" &&
19
+ !fromTheProject.startsWith("..") &&
20
+ !pathModule.isAbsolute(fromTheProject);
21
+ return isInsideTheProject ? fromTheProject : location;
22
+ };
23
+
24
+ const locatedWith = Effect.gen(function* () {
25
+ const pathModule = yield* Path.Path;
26
+ const checkedProject = pathModule.resolve(
27
+ yield* projectDirectory.pipe(
28
+ Effect.mapError(
29
+ (configError) => new ReportedErrors({ reportedErrors: [printableError(configError)] }),
30
+ ),
31
+ ),
32
+ );
33
+ return ({ tag, location, message }: PrintableError): PrintableError => ({
34
+ tag,
35
+ ...(location === undefined
36
+ ? {}
37
+ : { location: locationFromTheProject(pathModule, checkedProject, location) }),
38
+ message,
39
+ });
40
+ });
41
+
42
+ export const printedFromTheProject = (printables: readonly PrintableError[]) =>
43
+ locatedWith.pipe(Effect.map((located) => printables.map((printable) => located(printable))));
44
+
45
+ export const locatedFromTheProject = <Success, Requirements>(
46
+ effect: Effect.Effect<Success, ReportedErrors, Requirements>,
47
+ ) =>
48
+ effect.pipe(
49
+ Effect.catchTag("ReportedErrors", ({ reportedErrors }) =>
50
+ locatedWith.pipe(
51
+ Effect.flatMap((located) =>
52
+ Effect.fail(new ReportedErrors({ reportedErrors: Arrays.map(reportedErrors, located) })),
53
+ ),
54
+ ),
55
+ ),
56
+ );
@@ -1,16 +1,18 @@
1
- import type { PrintableError } from "@sshkeda/task/errors";
2
-
3
1
  export const printableError = (failure: {
4
2
  readonly _tag: string;
5
3
  readonly message: string;
6
4
  readonly location?: string;
7
- }): PrintableError => ({
5
+ }) => ({
8
6
  tag: failure._tag,
9
7
  ...(failure.location === undefined ? {} : { location: failure.location }),
10
8
  message: failure.message,
11
9
  });
12
10
 
13
- export const formattedError = (printable: PrintableError) => {
11
+ export const formattedError = (printable: {
12
+ readonly tag: string;
13
+ readonly location?: string | undefined;
14
+ readonly message: string;
15
+ }) => {
14
16
  const [firstLine = "", ...continuationLines] = printable.message.split("\n");
15
17
  return [
16
18
  `${printable.location === undefined ? "" : `${printable.location}: `}error ${printable.tag}: ${firstLine}`,
@@ -22,9 +24,9 @@ export const listedViolations = (violations: readonly Parameters<typeof printabl
22
24
  violations.map((found) => formattedError(printableError(found))).join("\n");
23
25
 
24
26
  export const printableErrorWith = (
25
- printable: PrintableError,
27
+ printable: Parameters<typeof formattedError>[0],
26
28
  replacement: { readonly tag?: string; readonly message?: string },
27
- ): PrintableError => ({
29
+ ) => ({
28
30
  tag: replacement.tag ?? printable.tag,
29
31
  ...(printable.location === undefined ? {} : { location: printable.location }),
30
32
  message: replacement.message ?? printable.message,
@@ -362,7 +362,10 @@ export const rulesACodeGrantChanges = (
362
362
 
363
363
  const SCRIPTS_OVERRIDE = {
364
364
  files: [`./${SCRIPTS_DIRECTORY}/*`],
365
- rules: { [permissionBanRuleId(SCRIPT)]: "off" },
365
+ rules: {
366
+ [permissionBanRuleId(SCRIPT)]: "off",
367
+ "sshkeda/no-re-exports": ["error", { defaultExportOfAnImport: "allowed" }],
368
+ },
366
369
  } as const;
367
370
 
368
371
  const DECODE_OPTIONS = {
@@ -1,22 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- export const noShebang = defineRule({
4
- meta: {
5
- type: "suggestion",
6
- messages: {
7
- shebang: "file starts with a shebang line",
8
- },
9
- },
10
- create(context) {
11
- return {
12
- Program() {
13
- const shebang = context.sourceCode
14
- .getAllComments()
15
- .find((comment) => comment.type === "Shebang");
16
- if (shebang !== undefined) {
17
- context.report({ loc: shebang.loc, messageId: "shebang" });
18
- }
19
- },
20
- };
21
- },
22
- });