Skip to content

Commit 0416e0d

Browse files
committed
update packages
1 parent 212129f commit 0416e0d

10 files changed

Lines changed: 839 additions & 561 deletions

File tree

base.tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"compilerOptions": {
33
"alwaysStrict": true,
4-
"lib": ["ESNEXT", "ES2019"],
4+
"lib": ["ESNEXT"],
55
"module": "commonjs",
66
"noImplicitAny": true,
77
"noImplicitThis": true,
88
"noImplicitReturns": true,
9+
"skipLibCheck": true,
910
"sourceMap": true,
1011
"strict": true,
1112
"target": "ES2019"

package-lock.json

Lines changed: 804 additions & 516 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,22 +45,19 @@
4545
"homepage": "https://github.com/Deskbot/Cognitive-Complexity-TS#readme",
4646
"repository": "https://github.com/Deskbot/Cognitive-Complexity-TS",
4747
"dependencies": {
48-
"js-beautify": "^1.11.0",
49-
"minimist": "^1.2.5",
50-
"open": "^7.1.0",
51-
"source-map-support": "^0.5.19",
52-
"typescript": "^5.2.2"
48+
"js-beautify": "^1.15.4",
49+
"minimist": "^1.2.8",
50+
"open": "^11.0.0",
51+
"source-map-support": "^0.5.21",
52+
"typescript": "^5.9.3"
5353
},
5454
"devDependencies": {
55-
"@types/deep-diff": "^1.0.0",
56-
"@types/glob": "^7.1.1",
57-
"@types/js-beautify": "^1.8.2",
58-
"@types/minimist": "^1.2.0",
59-
"@types/node": "^12.12.6",
60-
"@types/tempfile": "^3.0.0",
55+
"@types/deep-diff": "^1.0.5",
56+
"@types/glob": "^9.0.0",
57+
"@types/js-beautify": "^1.14.3",
58+
"@types/minimist": "^1.2.5",
59+
"@types/node": "^24.10.4",
6160
"deep-diff": "^1.0.2",
62-
"glob": "^7.1.6",
63-
"json-stream": "^1.0.0",
64-
"tempfile": "^3.0.0"
61+
"glob": "^13.0.0"
6562
}
6663
}

shared/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import ts from "typescript";
2-
import { Scope } from "../src/cognitive-complexity/Scope";
3-
41
export interface ColumnAndLine {
52
column: number;
63
line: number;

src/cognitive-complexity/cognitive-complexity.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function fileCost(file: ts.SourceFile): FileOutput {
9292
}
9393

9494
function aggregateCostOfChildren(
95-
children: ts.Node[],
95+
children: readonly ts.Node[],
9696
ctx: TraversalContext,
9797
mutCtx: MutableTraversalContext,
9898
): ScoreAndInner {

src/cognitive-complexity/depth.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ interface DepthOfChildren {
1010
/**
1111
* The same level of depth.
1212
*/
13-
sameDepth: ts.Node[];
13+
sameDepth: readonly ts.Node[];
1414

1515
/**
1616
* One level of depth below.
1717
*/
18-
below: ts.Node[];
18+
below: readonly ts.Node[];
1919
};
2020

2121
/**

src/util/util.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,6 @@ export function repeat(str: string, times: number): string {
8686
return res;
8787
}
8888

89-
export function toPromise<T, E>(
90-
action: (callback: (err: E, successData: T) => void) => void,
91-
errorTransformer?: (err: E) => Error
92-
): Promise<T> {
93-
return new Promise((resolve, reject) => {
94-
action((err, successData) => {
95-
if (err) {
96-
reject(errorTransformer ? errorTransformer(err) : err);
97-
} else {
98-
resolve(successData);
99-
}
100-
});
101-
});
102-
}
103-
10489
export class Unreachable extends Error {
10590
constructor(reason: string) {
10691
super("Unreachable branch.\n" + reason);

test/main.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
import { promises as fsP } from "fs";
2-
import * as fs from "fs"
3-
import glob from "glob";
2+
import * as fs from "fs";
3+
import { glob } from "glob";
44
import { js_beautify } from "js-beautify";
55
import * as path from "path";
66
import * as process from "process";
7-
import tempfile from "tempfile";
8-
import { toPromise } from "../src/util/util";
97
import { programOutput } from "../src/api";
10-
import { compare } from "./util";
8+
import { compare, tempfile } from "./util";
119

1210
const casesDir = path.normalize(__dirname + "/../../test/cases");
1311

1412
main();
1513

1614
function allCaseFilePaths(): Promise<string[]> {
17-
return toPromise(cb => glob(`${casesDir}/*`, cb));
15+
return glob(`${casesDir}/*`);
1816
}
1917

2018
async function getExpectation(fileName: string): Promise<any> {
2119
const tsIndex = fileName.lastIndexOf(".");
2220
if (tsIndex !== -1) {
23-
fileName = fileName.substr(0, tsIndex);
21+
fileName = fileName.substring(0, tsIndex);
2422
}
2523
const caseExpectationFile = fileName + ".expected.json";
2624
const expectedJsonFile = await fsP.readFile(caseExpectationFile);
@@ -52,7 +50,7 @@ async function main() {
5250

5351
// run program on case
5452
// convert output to json
55-
const outputPath = tempfile();
53+
const outputPath = await tempfile();
5654
try {
5755
const resultObj = await runCase(caseFilePath, outputPath);
5856
// read json expected for case

test/util.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
import { randomUUID } from "crypto";
12
import * as deep_diff from "deep-diff";
3+
import * as fs from "fs/promises";
4+
import * as os from "os";
25

36
export function compare(expected: any, actual: any): any[] | undefined {
47
const differences = deep_diff.diff(expected, actual);
@@ -22,3 +25,9 @@ function renameKeys(diff: any) {
2225

2326
return newDiff;
2427
}
28+
29+
export async function tempfile() {
30+
const path = os.tmpdir() + "/ccts-tests-" + randomUUID()
31+
await fs.writeFile(path, "")
32+
return path
33+
}

ui/tsconfig.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
"extends": "../base.tsconfig.json",
33
"compilerOptions": {
44
"module": "ESNEXT",
5+
"moduleResolution": "classic",
56
"lib": [
67
"DOM",
7-
"ES2019.Array"
88
],
99
"outDir": "../build",
1010
"removeComments": true,
1111
},
1212
"include": [
1313
"./ts"
14+
],
15+
"exclude": [
16+
"node_modules"
1417
]
1518
}

0 commit comments

Comments
 (0)