@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.
- package/README.md +52 -22
- package/docs/how-to-make-check-pass.md +1 -0
- package/package.json +7 -10
- package/scripts/check.ts +10 -0
- package/src/internal/ban-re-exports.ts +14 -1
- package/src/internal/define-the-lint-plugin-and-configs.ts +0 -2
- package/src/lib/project-directory/index.ts +5 -0
- package/src/lib/project-directory/internal/read-the-project-directory.ts +13 -0
- package/src/lib/tasks/internal/declare-the-check-task.ts +18 -10
- package/src/lib/tasks/internal/declare-the-checker-queries-task.ts +3 -1
- package/src/lib/tasks/internal/verify-where-check-was-started.ts +50 -0
- package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/index.ts +1 -1
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/find-layer-provides-outside-program-starts.ts +6 -36
- package/src/lib/tasks/lib/detect-duplicate-functions/internal/find-duplicate-functions.ts +2 -3
- package/src/lib/tasks/lib/enforce-file-layout/internal/check-the-layout-of-each-package.ts +1 -1
- package/src/lib/tasks/lib/enforce-file-layout/internal/file-layout-errors.ts +19 -2
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-file-layout-violations.ts +53 -19
- package/src/lib/tasks/lib/enforce-file-types/internal/find-file-type-violations.ts +1 -1
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/check-formatting-with-bun-fmt.ts +16 -15
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/declare-the-formatting-task.ts +22 -14
- package/src/lib/tasks/lib/lint-with-oxlint/index.ts +1 -1
- package/src/lib/tasks/lib/lint-with-oxlint/internal/check-lint-rules-with-oxlint.ts +7 -0
- package/src/lib/tasks/lib/lint-with-oxlint/internal/find-shebangs-outside-bin.ts +38 -0
- package/src/lib/tasks/lib/lint-with-oxlint/internal/shebang-errors.ts +22 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-export-placement-violations.ts +9 -1
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-the-importer-graph.ts +21 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/recognise-task-default-exports.ts +76 -0
- package/src/lib/tasks/lib/refuse-disable-directives/index.ts +1 -1
- package/src/lib/tasks/lib/refuse-forks-whose-failures-nothing-observes/index.ts +1 -0
- package/src/lib/tasks/lib/refuse-forks-whose-failures-nothing-observes/internal/find-unobserved-fork-failures.ts +402 -0
- package/src/lib/tasks/lib/refuse-forks-whose-failures-nothing-observes/internal/fork-failure-errors.ts +28 -0
- package/src/lib/tasks/lib/require-type-checking-every-linted-file/internal/find-linted-files-not-type-checked.ts +15 -9
- package/src/lib/tasks/lib/type-check-with-bun-check/index.ts +1 -1
- package/src/lib/tasks/shared/check-each-nested-package.ts +12 -4
- package/src/lib/tasks/shared/declare-lint-config-task.ts +1 -1
- package/src/lib/tasks/shared/declare-typescript-config-task.ts +1 -1
- package/src/lib/tasks/shared/find-installed-package-binaries.ts +10 -0
- package/src/lib/tasks/shared/read-piped-steps-through-wrappers.ts +41 -0
- package/src/lib/tasks/shared/report-paths-from-the-project.ts +56 -0
- package/src/shared/format-reported-failures.ts +8 -6
- package/src/shared/record-and-grant-permissions-by-path.ts +4 -1
- 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
|
-
})
|
|
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:
|
|
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:
|
|
27
|
+
printable: Parameters<typeof formattedError>[0],
|
|
26
28
|
replacement: { readonly tag?: string; readonly message?: string },
|
|
27
|
-
)
|
|
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: {
|
|
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
|
-
});
|