@sshkeda/check 1.1.0 → 2.1.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 +7 -6
- package/docs/how-to-make-check-pass.md +4 -14
- package/package.json +4 -4
- package/src/internal/ban-abbreviated-words-in-declared-names.ts +0 -4
- package/src/internal/ban-checked-members-outside-calls.ts +8 -8
- package/src/internal/ban-comments.ts +0 -1
- package/src/internal/ban-comparing-or-switching-on-tag.ts +50 -10
- package/src/internal/ban-deadlines-inside-tests.ts +3 -4
- package/src/internal/ban-declared-values.ts +2 -5
- package/src/internal/ban-dropped-failures-detached-fibers-sleeps-and-untraced-functions.ts +0 -2
- package/src/internal/ban-failures-collected-as-results.ts +0 -4
- package/src/internal/ban-fallbacks-of-named-recoveries.ts +1 -29
- package/src/internal/ban-function-overloads.ts +0 -4
- package/src/internal/ban-global-error-in-failure-types.ts +10 -15
- package/src/internal/ban-instanceof-in-effect-recovery-callbacks.ts +17 -26
- package/src/internal/ban-let-and-effect-mutable-ref.ts +0 -8
- package/src/internal/ban-logic-in-index-files.ts +0 -3
- package/src/internal/ban-namespaces-used-without-a-member.ts +0 -3
- package/src/internal/ban-node-builtins-that-effect-replaces.ts +0 -3
- package/src/internal/ban-parsing-outside-data-without-a-schema.ts +0 -4
- package/src/internal/ban-re-exports.ts +54 -18
- package/src/internal/ban-reading-the-clock-and-sleeping-outside-effect.ts +88 -4
- package/src/internal/ban-recovering-file-system-exists.ts +300 -0
- package/src/internal/ban-retired-words-in-names.ts +1 -4
- package/src/internal/ban-retries-without-a-wait.ts +292 -0
- package/src/internal/ban-scanning-directories-with-bun-glob.ts +0 -3
- package/src/internal/ban-shebang-lines.ts +0 -4
- package/src/internal/ban-timer-globals-and-the-global-object.ts +0 -1
- package/src/internal/ban-timer-schedules-without-deadlines.ts +129 -45
- package/src/internal/ban-type-and-interface-declarations.ts +0 -4
- package/src/internal/ban-type-predicates.ts +0 -4
- package/src/internal/ban-unknown-in-function-signatures.ts +49 -13
- package/src/internal/ban-vague-error-class-names.ts +0 -4
- package/src/internal/ban-vague-file-names.ts +3 -7
- package/src/internal/ban-what-a-file-is-not-granted.ts +37 -14
- package/src/internal/ban-while-do-while-and-for-loops.ts +0 -4
- package/src/internal/ban-writing-captured-objects-inside-effect-callbacks.ts +210 -0
- package/src/internal/confine-service-declarations-to-granted-files.ts +0 -7
- package/src/internal/confine-the-stdio-service-to-terminal-output.ts +2 -16
- package/src/internal/define-the-lint-plugin-and-configs.ts +6 -0
- package/src/internal/keep-assertions-in-the-test-home-and-ban-test-runners.ts +0 -6
- package/src/internal/keep-effect-testing-helpers-in-test-files.ts +2 -14
- package/src/internal/require-a-named-const-for-compound-conditions.ts +0 -4
- package/src/internal/require-capital-snake-case-and-as-const-on-literal-constants.ts +0 -4
- package/src/internal/require-service-keys-to-end-with-their-class-name.ts +5 -2
- package/src/internal/resolve-what-an-expression-imports.ts +115 -28
- package/src/internal/visit-every-declared-name.ts +13 -0
- package/src/lib/tasks/internal/declare-the-check-task.ts +2 -0
- package/src/lib/tasks/internal/declare-the-checker-queries-task.ts +2 -1
- package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/index.ts +2 -1
- package/src/lib/tasks/lib/check-effect-diagnostics-with-effect-tsgo/internal/check-effect-diagnostics-with-effect-tsgo.ts +17 -0
- package/src/lib/tasks/lib/check-import-boundaries/internal/decide-what-each-home-may-import.ts +62 -0
- package/src/lib/tasks/lib/check-import-boundaries/internal/find-import-boundary-violations.ts +215 -187
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/find-layer-provides-outside-program-starts.ts +13 -16
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/layer-provide-errors.ts +2 -1
- package/src/lib/tasks/lib/confine-layer-provides-to-program-starts/internal/resolve-imported-package-apis.ts +3 -1
- package/src/lib/tasks/lib/detect-duplicate-functions/index.ts +10 -0
- package/src/lib/tasks/lib/detect-duplicate-functions/internal/duplicate-function-errors.ts +23 -0
- package/src/lib/tasks/lib/detect-duplicate-functions/internal/find-duplicate-functions.ts +150 -0
- package/src/lib/tasks/lib/detect-duplicate-functions/internal/list-named-functions.ts +416 -0
- package/src/lib/tasks/lib/detect-inferrable-annotations/internal/find-inferrable-annotations.ts +31 -12
- package/src/lib/tasks/lib/enforce-file-layout/index.ts +6 -1
- package/src/lib/tasks/lib/enforce-file-layout/internal/file-layout-errors.ts +11 -1
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-export-path-mismatches.ts +39 -7
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-file-layout-violations.ts +11 -4
- package/src/lib/tasks/lib/enforce-file-layout/internal/find-module-layout-violations.ts +6 -4
- package/src/lib/tasks/lib/enforce-file-types/index.ts +6 -1
- package/src/lib/tasks/lib/format-with-bun-fmt/internal/declare-the-formatting-task.ts +3 -2
- package/src/lib/tasks/lib/judge-index-re-exports/internal/find-index-re-export-violations.ts +27 -21
- package/src/lib/tasks/lib/lint-with-oxlint/index.ts +2 -1
- package/src/lib/tasks/lib/lint-with-oxlint/internal/check-lint-rules-with-oxlint.ts +11 -8
- package/src/lib/tasks/lib/lint-with-oxlint/internal/read-oxlint-json-report.ts +18 -2
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/export-placement-errors.ts +12 -1
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-export-placement-violations.ts +75 -21
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-package-entry-sources.ts +146 -0
- package/src/lib/tasks/lib/place-exports-in-the-narrowest-directory/internal/find-the-importer-graph.ts +24 -190
- package/src/lib/tasks/lib/refuse-disable-directives/index.ts +2 -1
- package/src/lib/tasks/lib/refuse-disable-directives/internal/find-disable-directives.ts +9 -3
- package/src/lib/tasks/lib/refuse-error-mappings-that-end-streams/internal/find-error-mappings-to-done.ts +108 -9
- package/src/lib/tasks/lib/require-separate-service-layers/internal/find-service-layer-violations.ts +1 -5
- package/src/lib/tasks/lib/require-type-checking-every-linted-file/index.ts +2 -1
- package/src/lib/tasks/lib/require-type-checking-every-linted-file/internal/find-linted-files-not-type-checked.ts +2 -4
- package/src/lib/tasks/shared/check-each-nested-package.ts +13 -1
- package/src/lib/tasks/shared/classify-files-by-role.ts +12 -2
- package/src/lib/tasks/shared/count-the-line-of-an-offset.ts +20 -2
- package/src/lib/tasks/shared/create-the-module-resolver.ts +39 -23
- package/src/lib/tasks/shared/declare-lint-config-task.ts +2 -1
- package/src/lib/tasks/shared/declare-typescript-config-task.ts +30 -2
- package/src/lib/tasks/shared/find-unmet-typescript-config-requirements.ts +19 -6
- package/src/lib/tasks/shared/list-ignored-files-imported-by-source.ts +25 -16
- package/src/lib/tasks/shared/load-the-lint-config.ts +14 -12
- package/src/lib/tasks/shared/parse-config-files-that-import-from-check.ts +6 -7
- package/src/lib/tasks/shared/project-config-and-tool-errors.ts +46 -2
- package/src/lib/tasks/shared/provide-project-query-caches.ts +11 -0
- package/src/lib/tasks/shared/query-the-typescript-project.ts +108 -43
- package/src/lib/tasks/shared/resolve-absolute-paths.ts +4 -1
- package/src/lib/tasks/shared/resolve-module-requests.ts +131 -90
- package/src/lib/tasks/shared/run-tools-and-decode-their-reports.ts +15 -11
- package/src/shared/bans-each-permission-lifts.ts +4 -21
- package/src/shared/find-retired-words.ts +1 -1
- package/src/shared/lint-rule-messages-and-patterns.ts +7 -12
- package/src/shared/record-and-grant-permissions-by-path.ts +41 -65
|
@@ -2,6 +2,7 @@ import { defineRule } from "@oxlint/plugins";
|
|
|
2
2
|
import type { ESTree, SourceCode } from "@oxlint/plugins";
|
|
3
3
|
|
|
4
4
|
import { serviceFactoryOf } from "./match-effect-service-factories.ts";
|
|
5
|
+
import { constantValue } from "./resolve-what-an-expression-imports.ts";
|
|
5
6
|
|
|
6
7
|
const isServiceFactoryCall = (expression: ESTree.Node, sourceCode: SourceCode): boolean =>
|
|
7
8
|
expression.type === "CallExpression"
|
|
@@ -28,7 +29,6 @@ const staticKeySuffix = (expression: ESTree.Node | undefined): string | undefine
|
|
|
28
29
|
export const noMismatchedServiceKeys = defineRule({
|
|
29
30
|
meta: {
|
|
30
31
|
type: "problem",
|
|
31
|
-
docs: { description: "Require Effect service keys to end with their class name." },
|
|
32
32
|
messages: {
|
|
33
33
|
key: "the service key ends with {{suffix}}, not {{className}}",
|
|
34
34
|
unknownKey: "the service key of {{className}} has no static last segment",
|
|
@@ -51,7 +51,10 @@ export const noMismatchedServiceKeys = defineRule({
|
|
|
51
51
|
if (declaration.id === null) {
|
|
52
52
|
return;
|
|
53
53
|
}
|
|
54
|
-
const
|
|
54
|
+
const [key] = parent.arguments;
|
|
55
|
+
const suffix = staticKeySuffix(
|
|
56
|
+
key === undefined ? undefined : constantValue(key, context.sourceCode),
|
|
57
|
+
);
|
|
55
58
|
const className = declaration.id.name;
|
|
56
59
|
if (suffix === undefined) {
|
|
57
60
|
context.report({ node: parent, messageId: "unknownKey", data: { className } });
|
|
@@ -16,20 +16,6 @@ const variableVisibleFrom = (scope: Scope, name: string): Variable | undefined =
|
|
|
16
16
|
export const moduleExportName = (name: ESTree.ModuleExportName) =>
|
|
17
17
|
name.type === "Identifier" ? name.name : name.value;
|
|
18
18
|
|
|
19
|
-
export const enclosingFunction = (
|
|
20
|
-
node: ESTree.Node,
|
|
21
|
-
): ESTree.ArrowFunctionExpression | ESTree.Function | undefined => {
|
|
22
|
-
const parent = node.parent;
|
|
23
|
-
if (!parent) {
|
|
24
|
-
return undefined;
|
|
25
|
-
}
|
|
26
|
-
const isFunction =
|
|
27
|
-
parent.type === "ArrowFunctionExpression" ||
|
|
28
|
-
parent.type === "FunctionExpression" ||
|
|
29
|
-
parent.type === "FunctionDeclaration";
|
|
30
|
-
return isFunction ? parent : enclosingFunction(parent);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
19
|
export const resolvedVariable = (
|
|
34
20
|
node: ESTree.Node,
|
|
35
21
|
sourceCode: SourceCode,
|
|
@@ -56,6 +42,19 @@ export const memberName = (node: ESTree.MemberExpression) => {
|
|
|
56
42
|
return isUncomputedIdentifierProperty ? node.property.name : staticKeyName(node.property);
|
|
57
43
|
};
|
|
58
44
|
|
|
45
|
+
export const rootOf = (node: ESTree.Node): ESTree.Node =>
|
|
46
|
+
node.type === "MemberExpression" ? rootOf(node.object) : node;
|
|
47
|
+
|
|
48
|
+
export const typeNameParts = (name: ESTree.Node): readonly string[] => {
|
|
49
|
+
if (name.type === "TSQualifiedName") {
|
|
50
|
+
return [...typeNameParts(name.left), name.right.name];
|
|
51
|
+
}
|
|
52
|
+
return name.type === "Identifier" ? [name.name] : [];
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export const typeNameRoot = (name: ESTree.Node): ESTree.Node =>
|
|
56
|
+
name.type === "TSQualifiedName" ? typeNameRoot(name.left) : name;
|
|
57
|
+
|
|
59
58
|
const withMember = (
|
|
60
59
|
imported: ReturnType<typeof importedExpression>,
|
|
61
60
|
member: string | undefined,
|
|
@@ -75,6 +74,78 @@ export const unwrappedExpression = (node: ESTree.Node): ESTree.Node => {
|
|
|
75
74
|
return isTypeScriptWrapper ? unwrappedExpression(node.expression) : node;
|
|
76
75
|
};
|
|
77
76
|
|
|
77
|
+
export const constantValue = (
|
|
78
|
+
node: ESTree.Node,
|
|
79
|
+
sourceCode: SourceCode,
|
|
80
|
+
seen: ReadonlySet<ESTree.Node> = new Set(),
|
|
81
|
+
): ESTree.Node => {
|
|
82
|
+
const expression = unwrappedExpression(node);
|
|
83
|
+
const variable = resolvedVariable(expression, sourceCode);
|
|
84
|
+
const definitions = variable?.defs ?? [];
|
|
85
|
+
const declarator = definitions.length === 1 ? definitions[0]?.node : undefined;
|
|
86
|
+
const isUnchangedFunctionDeclaration =
|
|
87
|
+
declarator?.type === "FunctionDeclaration" &&
|
|
88
|
+
variable?.references.some((reference) => reference.isWrite() && !reference.init) === false;
|
|
89
|
+
if (isUnchangedFunctionDeclaration) {
|
|
90
|
+
return declarator;
|
|
91
|
+
}
|
|
92
|
+
const isConstantDeclarator =
|
|
93
|
+
declarator?.type === "VariableDeclarator" &&
|
|
94
|
+
declarator.id.type === "Identifier" &&
|
|
95
|
+
declarator.parent.type === "VariableDeclaration" &&
|
|
96
|
+
declarator.parent.kind === "const" &&
|
|
97
|
+
!seen.has(expression);
|
|
98
|
+
const value = isConstantDeclarator ? declarator.init : null;
|
|
99
|
+
return value === null
|
|
100
|
+
? expression
|
|
101
|
+
: constantValue(value, sourceCode, new Set([...seen, expression]));
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
export const returnedExpression = (handler: ESTree.Node | undefined): ESTree.Node | undefined => {
|
|
105
|
+
const isFunction =
|
|
106
|
+
handler?.type === "ArrowFunctionExpression" ||
|
|
107
|
+
handler?.type === "FunctionExpression" ||
|
|
108
|
+
handler?.type === "FunctionDeclaration";
|
|
109
|
+
const body = isFunction ? handler.body : null;
|
|
110
|
+
if (body === null) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (body.type !== "BlockStatement") {
|
|
114
|
+
return body;
|
|
115
|
+
}
|
|
116
|
+
const [statement] = body.body;
|
|
117
|
+
const isSoleReturn = body.body.length === 1 && statement?.type === "ReturnStatement";
|
|
118
|
+
const argument = isSoleReturn ? statement.argument : null;
|
|
119
|
+
return argument ?? undefined;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const PATTERN_TYPES: ReadonlySet<string> = new Set([
|
|
123
|
+
"ArrayPattern",
|
|
124
|
+
"AssignmentPattern",
|
|
125
|
+
"ObjectPattern",
|
|
126
|
+
"Property",
|
|
127
|
+
"RestElement",
|
|
128
|
+
]);
|
|
129
|
+
|
|
130
|
+
export const isAssignmentTarget = (node: ESTree.Node): boolean => {
|
|
131
|
+
const { parent } = node;
|
|
132
|
+
if (parent === null) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
const isLeftOfAnAssignmentOrLoop =
|
|
136
|
+
(parent.type === "AssignmentExpression" ||
|
|
137
|
+
parent.type === "ForOfStatement" ||
|
|
138
|
+
parent.type === "ForInStatement") &&
|
|
139
|
+
parent.left === node;
|
|
140
|
+
if (isLeftOfAnAssignmentOrLoop) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const isDefaultValue = parent.type === "AssignmentPattern" && parent.right === node;
|
|
144
|
+
const isComputedKey = parent.type === "Property" && parent.value !== node;
|
|
145
|
+
const isInsideAPattern = PATTERN_TYPES.has(parent.type) && !isDefaultValue && !isComputedKey;
|
|
146
|
+
return isInsideAPattern && isAssignmentTarget(parent);
|
|
147
|
+
};
|
|
148
|
+
|
|
78
149
|
export const importedExpression = (
|
|
79
150
|
expression: ESTree.Node,
|
|
80
151
|
sourceCode: SourceCode,
|
|
@@ -266,30 +337,46 @@ const LINE_BREAKS = /\r\n|[\n\r]/gu;
|
|
|
266
337
|
|
|
267
338
|
const LINE_BREAK = String.raw`\n`;
|
|
268
339
|
|
|
269
|
-
const
|
|
340
|
+
export const textOnOneLine = (node: ESTree.Node, sourceCode: SourceCode) =>
|
|
341
|
+
sourceCode.getText(node).replace(LINE_BREAKS, LINE_BREAK);
|
|
342
|
+
|
|
343
|
+
const rootOfStaticMembers = (node: ESTree.Node): ESTree.Node | undefined => {
|
|
344
|
+
if (node.type !== "MemberExpression") {
|
|
345
|
+
return node;
|
|
346
|
+
}
|
|
347
|
+
return memberName(node) === undefined ? undefined : rootOfStaticMembers(node.object);
|
|
348
|
+
};
|
|
270
349
|
|
|
271
350
|
export const importedBindingOf = (expression: ESTree.Node, sourceCode: SourceCode) => {
|
|
272
351
|
const value = unwrappedExpression(expression);
|
|
273
|
-
const
|
|
274
|
-
|
|
275
|
-
if (binding.type !== "Identifier") {
|
|
352
|
+
const binding = rootOfStaticMembers(value);
|
|
353
|
+
if (binding?.type !== "Identifier") {
|
|
276
354
|
return;
|
|
277
355
|
}
|
|
278
356
|
const imported = importedExpression(binding, sourceCode);
|
|
279
357
|
if (imported === undefined) {
|
|
280
358
|
return;
|
|
281
359
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
: {
|
|
288
|
-
name: binding.name,
|
|
289
|
-
member: onOneLine(sourceCode.getText(value)),
|
|
290
|
-
module: imported.module,
|
|
291
|
-
};
|
|
360
|
+
return {
|
|
361
|
+
name: binding.name,
|
|
362
|
+
member: value === binding ? undefined : textOnOneLine(value, sourceCode),
|
|
363
|
+
module: imported.module,
|
|
364
|
+
};
|
|
292
365
|
};
|
|
293
366
|
|
|
294
367
|
export const isImportBinding = (node: ESTree.Node, sourceCode: SourceCode) =>
|
|
295
368
|
resolvedVariable(node, sourceCode)?.defs[0]?.node.parent?.type === "ImportDeclaration";
|
|
369
|
+
|
|
370
|
+
const PIPE = "pipe";
|
|
371
|
+
|
|
372
|
+
export const isPipeFunction = (callee: ESTree.Node, sourceCode: SourceCode) => {
|
|
373
|
+
const imported = importedExpression(callee, sourceCode);
|
|
374
|
+
const path = imported?.members.join(".");
|
|
375
|
+
const isFromEffect =
|
|
376
|
+
imported?.module === "effect" && (path === PIPE || path === `Function.${PIPE}`);
|
|
377
|
+
const isFromFunction = imported?.module === "effect/Function" && path === PIPE;
|
|
378
|
+
return isFromEffect || isFromFunction;
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
export const isImportMeta = (node: ESTree.Node) =>
|
|
382
|
+
node.type === "MetaProperty" && node.meta.name === "import" && node.property.name === "meta";
|
|
@@ -260,5 +260,18 @@ export const declaredNameListeners = (
|
|
|
260
260
|
check(node.local);
|
|
261
261
|
}
|
|
262
262
|
},
|
|
263
|
+
ExportSpecifier(node) {
|
|
264
|
+
const exportsUnderADifferentName =
|
|
265
|
+
node.exported.type === "Identifier" &&
|
|
266
|
+
(node.local.type !== "Identifier" || node.local.name !== node.exported.name);
|
|
267
|
+
if (exportsUnderADifferentName) {
|
|
268
|
+
check(node.exported);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
ExportAllDeclaration(node) {
|
|
272
|
+
if (node.exported?.type === "Identifier") {
|
|
273
|
+
check(node.exported);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
263
276
|
} satisfies Visitor;
|
|
264
277
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Task } from "@sshkeda/task";
|
|
2
2
|
import { Effect, Path } from "effect";
|
|
3
3
|
|
|
4
|
+
import { duplicateFunctions } from "../lib/detect-duplicate-functions/index.ts";
|
|
4
5
|
import { layout } from "../lib/enforce-file-layout/index.ts";
|
|
5
6
|
import { fileTypes } from "../lib/enforce-file-types/index.ts";
|
|
6
7
|
import { formatting } from "../lib/format-with-bun-fmt/index.ts";
|
|
@@ -25,5 +26,6 @@ export const check: Task.Task<void> = Task.make(
|
|
|
25
26
|
formatting,
|
|
26
27
|
layout,
|
|
27
28
|
fileTypes,
|
|
29
|
+
duplicateFunctions,
|
|
28
30
|
]).pipe(Effect.tapError(() => pointAtTheGuide)),
|
|
29
31
|
);
|
|
@@ -14,6 +14,7 @@ import { findServiceLayerViolations } from "../lib/require-separate-service-laye
|
|
|
14
14
|
import { inEachPackage } from "../shared/check-each-nested-package.ts";
|
|
15
15
|
import { lintConfigFile } from "../shared/declare-lint-config-task.ts";
|
|
16
16
|
import { typeScriptConfig } from "../shared/declare-typescript-config-task.ts";
|
|
17
|
+
import { ProjectQueryCachesLive } from "../shared/provide-project-query-caches.ts";
|
|
17
18
|
import { TYPESCRIPT_PROJECT_FILE } from "../shared/query-the-typescript-project.ts";
|
|
18
19
|
import { runChecksOverOneTypeScriptProject } from "./run-checks-over-one-typescript-project.ts";
|
|
19
20
|
|
|
@@ -37,5 +38,5 @@ export const checkerQueries = Task.make(
|
|
|
37
38
|
}),
|
|
38
39
|
),
|
|
39
40
|
),
|
|
40
|
-
),
|
|
41
|
+
).pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
41
42
|
);
|
|
@@ -4,6 +4,7 @@ import { Effect } from "effect";
|
|
|
4
4
|
import { inEachPackage } from "../../shared/check-each-nested-package.ts";
|
|
5
5
|
import { lintConfigFile } from "../../shared/declare-lint-config-task.ts";
|
|
6
6
|
import { typeScriptConfig } from "../../shared/declare-typescript-config-task.ts";
|
|
7
|
+
import { ProjectQueryCachesLive } from "../../shared/provide-project-query-caches.ts";
|
|
7
8
|
import { effectDiagnosticsIn } from "./internal/check-effect-diagnostics-with-effect-tsgo.ts";
|
|
8
9
|
|
|
9
10
|
export const effectStrict = Task.make(
|
|
@@ -11,5 +12,5 @@ export const effectStrict = Task.make(
|
|
|
11
12
|
Effect.andThen(
|
|
12
13
|
Task.all([typeScriptConfig, lintConfigFile]),
|
|
13
14
|
inEachPackage("effect-tsgo", ".", effectDiagnosticsIn),
|
|
14
|
-
),
|
|
15
|
+
).pipe(Effect.provide(ProjectQueryCachesLive)),
|
|
15
16
|
);
|
|
@@ -50,11 +50,15 @@ export const EFFECT_DIAGNOSTIC_SEVERITY = {
|
|
|
50
50
|
effectMapFlatten: "error",
|
|
51
51
|
effectMapVoid: "error",
|
|
52
52
|
effectSleepZeroToYieldNow: "error",
|
|
53
|
+
effectSucceedWithUndefined: "error",
|
|
53
54
|
effectSucceedWithVoid: "error",
|
|
55
|
+
effectTryWithoutCatch: "error",
|
|
54
56
|
errorPayloadShadowsName: "error",
|
|
55
57
|
experimentalApiUsage: "error",
|
|
56
58
|
extendsNativeError: "error",
|
|
59
|
+
failCauseToConstructor: "error",
|
|
57
60
|
flatMapConditionalToFilterOrFail: "error",
|
|
61
|
+
flatMapIdentityToFlatten: "error",
|
|
58
62
|
flatMapIgnoredParamToAndThen: "error",
|
|
59
63
|
flatMapToMap: "error",
|
|
60
64
|
flatMapToTap: "error",
|
|
@@ -69,6 +73,8 @@ export const EFFECT_DIAGNOSTIC_SEVERITY = {
|
|
|
69
73
|
globalErrorInEffectFailure: "error",
|
|
70
74
|
globalFetch: "error",
|
|
71
75
|
globalFetchInEffect: "error",
|
|
76
|
+
globalJson: "off",
|
|
77
|
+
globalJsonInEffect: "off",
|
|
72
78
|
globalRandom: "error",
|
|
73
79
|
globalRandomInEffect: "error",
|
|
74
80
|
globalTimers: "off",
|
|
@@ -78,9 +84,15 @@ export const EFFECT_DIAGNOSTIC_SEVERITY = {
|
|
|
78
84
|
lazyEffect: "error",
|
|
79
85
|
lazyPromiseInEffectSync: "error",
|
|
80
86
|
leakingRequirements: "error",
|
|
87
|
+
manualMetricTapToTrack: "error",
|
|
88
|
+
mapConstToAs: "error",
|
|
89
|
+
mapMapErrorToMapBoth: "error",
|
|
90
|
+
mapSomeCatchNoSuchElement: "error",
|
|
81
91
|
mapSomeToAsSome: "error",
|
|
92
|
+
matchBooleanToIsSuccess: "error",
|
|
82
93
|
matchEffectToMapBoth: "error",
|
|
83
94
|
matchEffectToMatch: "error",
|
|
95
|
+
matchToResultOrOption: "error",
|
|
84
96
|
missedPipeableOpportunity: "off",
|
|
85
97
|
missingEffectContext: "error",
|
|
86
98
|
missingEffectError: "error",
|
|
@@ -116,10 +128,12 @@ export const EFFECT_DIAGNOSTIC_SEVERITY = {
|
|
|
116
128
|
processEnvInEffect: "off",
|
|
117
129
|
promiseInEffectSuccess: "error",
|
|
118
130
|
provideLayerSucceedToProvideService: "error",
|
|
131
|
+
provideMergeAllToArray: "error",
|
|
119
132
|
raceFirstWithSleepToTimeout: "error",
|
|
120
133
|
redundantMapError: "error",
|
|
121
134
|
redundantOrDie: "off",
|
|
122
135
|
redundantSchemaTagIdentifier: "error",
|
|
136
|
+
resultMatchToFromResult: "error",
|
|
123
137
|
returnEffectInGen: "error",
|
|
124
138
|
runEffectInsideEffect: "error",
|
|
125
139
|
runOfExitToRunExit: "error",
|
|
@@ -136,9 +150,11 @@ export const EFFECT_DIAGNOSTIC_SEVERITY = {
|
|
|
136
150
|
serviceNotAsClass: "off",
|
|
137
151
|
strictBooleanExpressions: "off",
|
|
138
152
|
strictEffectProvide: "off",
|
|
153
|
+
suspendFailToFailSync: "error",
|
|
139
154
|
syncToSucceed: "error",
|
|
140
155
|
timeoutCatchTagToTimeoutOrElse: "error",
|
|
141
156
|
tryCatchInEffectGen: "error",
|
|
157
|
+
typeUnionToSchemaUnion: "off",
|
|
142
158
|
unknownInEffectCatch: "error",
|
|
143
159
|
unnecessaryArrowBlock: "off",
|
|
144
160
|
unnecessaryEffectGen: "error",
|
|
@@ -148,6 +164,7 @@ export const EFFECT_DIAGNOSTIC_SEVERITY = {
|
|
|
148
164
|
unnecessaryTypeofType: "error",
|
|
149
165
|
unsafeEffectTypeAssertion: "off",
|
|
150
166
|
unstableApiUsage: "off",
|
|
167
|
+
yieldInCallArgument: "off",
|
|
151
168
|
} as const satisfies Readonly<Record<string, "error" | "off">>;
|
|
152
169
|
|
|
153
170
|
export const checkEffectDiagnosticsOfProject = (
|
package/src/lib/tasks/lib/check-import-boundaries/internal/decide-what-each-home-may-import.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileNameOf,
|
|
3
|
+
isEntryFileName,
|
|
4
|
+
isWithin,
|
|
5
|
+
} from "../../../../../shared/match-file-names-and-path-prefixes.ts";
|
|
6
|
+
import {
|
|
7
|
+
SCRIPTS_DIRECTORY,
|
|
8
|
+
SOURCE_DIRECTORY,
|
|
9
|
+
TEST_DIRECTORY,
|
|
10
|
+
} from "../../../../../shared/test-home-directories.ts";
|
|
11
|
+
import { directoryOf } from "../../../shared/classify-files-by-role.ts";
|
|
12
|
+
|
|
13
|
+
const OTHER_HOME = "other";
|
|
14
|
+
const HOMES = [TEST_DIRECTORY, SCRIPTS_DIRECTORY, SOURCE_DIRECTORY] as const;
|
|
15
|
+
|
|
16
|
+
const IMPORT_POLICY_BY_HOME = {
|
|
17
|
+
[TEST_DIRECTORY]: {
|
|
18
|
+
checksModuleUrls: false,
|
|
19
|
+
mayImportDevDependencies: true,
|
|
20
|
+
mayImportTests: true,
|
|
21
|
+
seesPastModuleBoundaries: ({ path }) => !isWithin(path, TEST_DIRECTORY),
|
|
22
|
+
},
|
|
23
|
+
[SCRIPTS_DIRECTORY]: {
|
|
24
|
+
checksModuleUrls: true,
|
|
25
|
+
mayImportDevDependencies: true,
|
|
26
|
+
mayImportTests: true,
|
|
27
|
+
seesPastModuleBoundaries: ({ path, isInAnotherPackage, moduleDirectories }) =>
|
|
28
|
+
isWithin(path, SOURCE_DIRECTORY) &&
|
|
29
|
+
!isInAnotherPackage &&
|
|
30
|
+
isEntryFileName(fileNameOf(path)) &&
|
|
31
|
+
moduleDirectories.has(directoryOf(path)),
|
|
32
|
+
},
|
|
33
|
+
[SOURCE_DIRECTORY]: {
|
|
34
|
+
checksModuleUrls: true,
|
|
35
|
+
mayImportDevDependencies: false,
|
|
36
|
+
mayImportTests: false,
|
|
37
|
+
seesPastModuleBoundaries: () => false,
|
|
38
|
+
},
|
|
39
|
+
[OTHER_HOME]: {
|
|
40
|
+
checksModuleUrls: true,
|
|
41
|
+
mayImportDevDependencies: true,
|
|
42
|
+
mayImportTests: false,
|
|
43
|
+
seesPastModuleBoundaries: () => false,
|
|
44
|
+
},
|
|
45
|
+
} as const satisfies Readonly<
|
|
46
|
+
Record<
|
|
47
|
+
(typeof HOMES)[number] | typeof OTHER_HOME,
|
|
48
|
+
{
|
|
49
|
+
readonly checksModuleUrls: boolean;
|
|
50
|
+
readonly mayImportDevDependencies: boolean;
|
|
51
|
+
readonly mayImportTests: boolean;
|
|
52
|
+
readonly seesPastModuleBoundaries: (imported: {
|
|
53
|
+
readonly path: string;
|
|
54
|
+
readonly isInAnotherPackage: boolean;
|
|
55
|
+
readonly moduleDirectories: ReadonlySet<string>;
|
|
56
|
+
}) => boolean;
|
|
57
|
+
}
|
|
58
|
+
>
|
|
59
|
+
>;
|
|
60
|
+
|
|
61
|
+
export const importPolicyOf = (importer: string) =>
|
|
62
|
+
IMPORT_POLICY_BY_HOME[HOMES.find((home) => isWithin(importer, home)) ?? OTHER_HOME];
|