@shivaedev/quality 0.41.0 → 0.42.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/CHANGELOG.md +20 -0
- package/README.md +12 -8
- package/biome/plugins/effect-test-bodies.grit +1 -1
- package/dist/appTestConfig.js +1 -1
- package/dist/appTestConfig.js.map +1 -1
- package/dist/biome/withoutEntryPointImports.d.ts +4 -0
- package/dist/biome/withoutEntryPointImports.d.ts.map +1 -0
- package/dist/biome/withoutEntryPointImports.js +46 -0
- package/dist/biome/withoutEntryPointImports.js.map +1 -0
- package/dist/imports/pnpmWorkspacePatterns.d.ts +1 -0
- package/dist/imports/pnpmWorkspacePatterns.d.ts.map +1 -1
- package/dist/imports/pnpmWorkspacePatterns.js +28 -22
- package/dist/imports/pnpmWorkspacePatterns.js.map +1 -1
- package/dist/imports/runtime.d.ts +6 -0
- package/dist/imports/runtime.d.ts.map +1 -1
- package/dist/imports/runtime.js +54 -8
- package/dist/imports/runtime.js.map +1 -1
- package/dist/manifests/entryPoints.d.ts +15 -0
- package/dist/manifests/entryPoints.d.ts.map +1 -0
- package/dist/manifests/entryPoints.js +60 -0
- package/dist/manifests/entryPoints.js.map +1 -0
- package/dist/rules/biome.d.ts.map +1 -1
- package/dist/rules/biome.js +4 -2
- package/dist/rules/biome.js.map +1 -1
- package/dist/rules/builtIn.d.ts +1 -1
- package/dist/rules/builtIn.d.ts.map +1 -1
- package/dist/rules/builtIn.js +2 -0
- package/dist/rules/builtIn.js.map +1 -1
- package/dist/rules/imports/fences.d.ts +1 -1
- package/dist/rules/imports/manifest.d.ts.map +1 -1
- package/dist/rules/imports/manifest.js +27 -14
- package/dist/rules/imports/manifest.js.map +1 -1
- package/dist/rules/imports/runtime.d.ts.map +1 -1
- package/dist/rules/imports/runtime.js +10 -4
- package/dist/rules/imports/runtime.js.map +1 -1
- package/dist/rules/manifestsApplication.d.ts +2 -0
- package/dist/rules/manifestsApplication.d.ts.map +1 -0
- package/dist/rules/manifestsApplication.js +99 -0
- package/dist/rules/manifestsApplication.js.map +1 -0
- package/dist/rules/manifestsExportsShape.d.ts.map +1 -1
- package/dist/rules/manifestsExportsShape.js +5 -2
- package/dist/rules/manifestsExportsShape.js.map +1 -1
- package/dist/rules/stories/engineOf.js +1 -1
- package/dist/rules/stories/engineOf.js.map +1 -1
- package/dist/rules/test-names/colocated.d.ts.map +1 -1
- package/dist/rules/test-names/colocated.js +10 -6
- package/dist/rules/test-names/colocated.js.map +1 -1
- package/package.json +1 -1
- package/src/appTestConfig.ts +1 -1
- package/src/biome/withoutEntryPointImports.ts +52 -0
- package/src/imports/pnpmWorkspacePatterns.ts +29 -22
- package/src/imports/runtime.ts +69 -9
- package/src/manifests/entryPoints.ts +87 -0
- package/src/rules/biome.ts +4 -2
- package/src/rules/builtIn.ts +2 -0
- package/src/rules/imports/manifest.ts +42 -14
- package/src/rules/imports/runtime.ts +10 -4
- package/src/rules/manifestsApplication.ts +117 -0
- package/src/rules/manifestsExportsShape.ts +6 -2
- package/src/rules/stories/engineOf.ts +1 -1
- package/src/rules/test-names/colocated.ts +13 -6
- package/tsconfig/package.json +2 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
1
2
|
import { Effect, Schema } from "effect";
|
|
2
3
|
import ignore from "ignore";
|
|
3
|
-
import { testName } from "#naming/testName.ts";
|
|
4
|
+
import { isTestCode, testName } from "#naming/testName.ts";
|
|
4
5
|
import { defineRule, type Finding } from "#rule.ts";
|
|
5
6
|
|
|
6
7
|
const MIRROR_FOLDERS: ReadonlySet<string> = new Set(["__tests__", "spec", "test", "tests"]);
|
|
@@ -9,9 +10,13 @@ const TestsColocatedOptions = Schema.Struct({
|
|
|
9
10
|
suites: Schema.Array(Schema.String).pipe(Schema.withDecodingDefaultKey(Effect.succeed([]))),
|
|
10
11
|
});
|
|
11
12
|
|
|
12
|
-
function findingOf(path: string): readonly Finding[] {
|
|
13
|
+
function findingOf(path: string, sourceFolders: ReadonlySet<string>): readonly Finding[] {
|
|
13
14
|
const name = testName(path);
|
|
14
|
-
const mirror = name?.folder
|
|
15
|
+
const mirror = name?.folder
|
|
16
|
+
.split("/")
|
|
17
|
+
.find(
|
|
18
|
+
(folder, index, folders) => MIRROR_FOLDERS.has(folder) && (folder === "__tests__" || !sourceFolders.has(folders.slice(0, index + 1).join("/"))),
|
|
19
|
+
);
|
|
15
20
|
if (name === undefined || mirror === undefined) {
|
|
16
21
|
return [];
|
|
17
22
|
}
|
|
@@ -19,7 +24,7 @@ function findingOf(path: string): readonly Finding[] {
|
|
|
19
24
|
return [
|
|
20
25
|
{
|
|
21
26
|
file: path,
|
|
22
|
-
message: `Sits in the test folder "${mirror}/". A test sits beside the file it covers, as ${name.stem}${modifiers}.test${name.extension} beside ${name.stem}.ts, or as a <behaviour>${modifiers}.spec${name.extension}
|
|
27
|
+
message: `Sits in the test folder "${mirror}/". A test, tests or spec folder is test-only when its directly contained checked files are all tests or test support; __tests__ is always a test folder. A test sits beside the file it covers, as ${name.stem}${modifiers}.test${name.extension} beside ${name.stem}.ts, or as a <behaviour>${modifiers}.spec${name.extension} at the module root or directly beside the module folder. Shared test support belongs in test-support/. A folder of tests that cover several packages is a suite in the "suites" option.`,
|
|
23
28
|
},
|
|
24
29
|
];
|
|
25
30
|
}
|
|
@@ -27,9 +32,11 @@ function findingOf(path: string): readonly Finding[] {
|
|
|
27
32
|
export const testsColocated = defineRule({
|
|
28
33
|
check: ({ files, options }) => {
|
|
29
34
|
const suites = ignore().add([...options.suites]);
|
|
30
|
-
|
|
35
|
+
const sourceFolders = new Set(files.filter((path) => !isTestCode(path)).map((path) => posix.dirname(path)));
|
|
36
|
+
return files.filter((path) => !suites.ignores(path)).flatMap((path) => findingOf(path, sourceFolders));
|
|
31
37
|
},
|
|
32
|
-
description:
|
|
38
|
+
description:
|
|
39
|
+
"A test sits beside the code it covers, at its module root or directly beside its module folder. Outside declared suites, __tests__ is always a test folder; test, tests and spec are test folders only when their directly contained checked files are all tests or test support. Shared test support belongs in test-support/.",
|
|
33
40
|
id: "tests/colocated",
|
|
34
41
|
options: Schema.toStandardSchemaV1(TestsColocatedOptions, { parseOptions: { errors: "all", onExcessProperty: "error" } }),
|
|
35
42
|
});
|