@skuba-lib/detect-invalid-spies 1.1.1 → 1.1.2-test-sbpaths-20261009033720
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/lib/bin.mjs +3 -2
- package/lib/index.d.mts +3 -4
- package/lib/index.mjs +1 -1
- package/lib/{src-C1vrUCkn.mjs → src-ByxvbFtt.mjs} +8 -5
- package/package.json +9 -10
package/lib/bin.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as detectSameFileSpyUsage } from "./src-
|
|
2
|
+
import { t as detectSameFileSpyUsage } from "./src-ByxvbFtt.mjs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import process from "node:process";
|
|
5
5
|
import { styleText } from "node:util";
|
|
6
6
|
//#region src/bin.ts
|
|
7
|
-
const
|
|
7
|
+
const dir = path.resolve(process.argv[2] ?? process.cwd());
|
|
8
|
+
const warnings = await detectSameFileSpyUsage(dir);
|
|
8
9
|
if (warnings.length === 0) process.exit(0);
|
|
9
10
|
for (const { testFile, importSpecifier, resolvedFile, spiedFunction, line, column } of warnings) {
|
|
10
11
|
const rel = `${path.relative(process.cwd(), testFile)}:${line}:${column}`;
|
package/lib/index.d.mts
CHANGED
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
* .mockResolvedValue({ authorization: 'Bearer token' });
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
type SameFileSpyWarning = {
|
|
35
|
+
export type SameFileSpyWarning = {
|
|
36
36
|
/** The file that contains the `jest.spyOn` call. */
|
|
37
37
|
testFile: string;
|
|
38
38
|
/** The raw import specifier used in the namespace import, e.g. `#src/framework/http.js`. */
|
|
@@ -52,6 +52,5 @@ type SameFileSpyWarning = {
|
|
|
52
52
|
* also used internally within the same source module, meaning the spy will not
|
|
53
53
|
* intercept those internal calls.
|
|
54
54
|
*/
|
|
55
|
-
declare const detectSameFileSpyUsage: (dir?: string) => Promise<SameFileSpyWarning[]>;
|
|
56
|
-
//#endregion
|
|
57
|
-
export { SameFileSpyWarning, detectSameFileSpyUsage };
|
|
55
|
+
export declare const detectSameFileSpyUsage: (dir?: string) => Promise<SameFileSpyWarning[]>;
|
|
56
|
+
//#endregion
|
package/lib/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as detectSameFileSpyUsage } from "./src-
|
|
1
|
+
import { t as detectSameFileSpyUsage } from "./src-ByxvbFtt.mjs";
|
|
2
2
|
export { detectSameFileSpyUsage };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { parseAsync } from "@ast-grep/napi";
|
|
4
|
-
import fg from "fast-glob";
|
|
5
4
|
import fs from "fs-extra";
|
|
6
5
|
import ts from "typescript";
|
|
7
6
|
//#region src/index.ts
|
|
@@ -45,11 +44,15 @@ import ts from "typescript";
|
|
|
45
44
|
* intercept those internal calls.
|
|
46
45
|
*/
|
|
47
46
|
const detectSameFileSpyUsage = async (dir = process.cwd()) => {
|
|
48
|
-
const filePaths =
|
|
49
|
-
|
|
47
|
+
const filePaths = [];
|
|
48
|
+
for await (const entry of fs.promises.glob(["**/*.ts", "**/*.tsx"], {
|
|
50
49
|
cwd: dir,
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
exclude: ["**/.git", "**/node_modules"],
|
|
51
|
+
withFileTypes: true
|
|
52
|
+
})) {
|
|
53
|
+
if (!entry.isFile()) continue;
|
|
54
|
+
filePaths.push(path.join(entry.parentPath, entry.name));
|
|
55
|
+
}
|
|
53
56
|
return (await Promise.all(filePaths.map((filePath) => analyzeFileForSpyUsage(filePath)))).flat();
|
|
54
57
|
};
|
|
55
58
|
const analyzeFileForSpyUsage = async (filePath) => {
|
package/package.json
CHANGED
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skuba-lib/detect-invalid-spies",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2-test-sbpaths-20261009033720",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Detect invalid spies in Jest and Vitest tests",
|
|
6
6
|
"homepage": "https://github.com/seek-oss/skuba/tree/main/packages/detect-invalid-spies#readme",
|
|
7
7
|
"bugs": {
|
|
8
8
|
"url": "https://github.com/seek-oss/skuba/issues"
|
|
9
9
|
},
|
|
10
|
+
"license": "MIT",
|
|
10
11
|
"repository": {
|
|
11
12
|
"type": "git",
|
|
12
13
|
"url": "git+https://github.com/seek-oss/skuba.git",
|
|
13
14
|
"directory": "packages/detect-invalid-spies"
|
|
14
15
|
},
|
|
15
|
-
"license": "MIT",
|
|
16
|
-
"sideEffects": false,
|
|
17
|
-
"type": "module",
|
|
18
|
-
"exports": {
|
|
19
|
-
".": "./lib/index.mjs",
|
|
20
|
-
"./bin": "./lib/bin.mjs",
|
|
21
|
-
"./package.json": "./package.json"
|
|
22
|
-
},
|
|
23
16
|
"bin": {
|
|
24
17
|
"detect-invalid-spies": "./lib/bin.mjs"
|
|
25
18
|
},
|
|
26
19
|
"files": [
|
|
27
20
|
"lib"
|
|
28
21
|
],
|
|
22
|
+
"type": "module",
|
|
23
|
+
"sideEffects": false,
|
|
24
|
+
"exports": {
|
|
25
|
+
".": "./lib/index.mjs",
|
|
26
|
+
"./bin": "./lib/bin.mjs",
|
|
27
|
+
"./package.json": "./package.json"
|
|
28
|
+
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@ast-grep/napi": "~0.45.0",
|
|
31
|
-
"fast-glob": "^3.3.2",
|
|
32
31
|
"fs-extra": "^11.0.0",
|
|
33
32
|
"typescript": "~6.0.0"
|
|
34
33
|
},
|