@opensip-tools/checks-cpp 1.0.4 → 1.0.6
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/.turbo/turbo-build.log +4 -0
- package/.turbo/turbo-test.log +15 -0
- package/.turbo/turbo-typecheck.log +1 -1
- package/dist/__tests__/clang-tidy.test.d.ts +2 -0
- package/dist/__tests__/clang-tidy.test.d.ts.map +1 -0
- package/dist/__tests__/clang-tidy.test.js +48 -0
- package/dist/__tests__/clang-tidy.test.js.map +1 -0
- package/dist/__tests__/parse.test.d.ts +2 -0
- package/dist/__tests__/parse.test.d.ts.map +1 -0
- package/dist/__tests__/parse.test.js +40 -0
- package/dist/__tests__/parse.test.js.map +1 -0
- package/dist/checks/clang-tidy-passthrough.d.ts +19 -0
- package/dist/checks/clang-tidy-passthrough.d.ts.map +1 -0
- package/dist/checks/clang-tidy-passthrough.js +57 -0
- package/dist/checks/clang-tidy-passthrough.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
> @opensip-tools/checks-cpp@1.0.6 test /home/runner/work/opensip-tools/opensip-tools/packages/fitness/checks-cpp
|
|
3
|
+
> vitest run --passWithNoTests
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
[1m[7m[36m RUN [39m[27m[22m [36mv2.1.9 [39m[90m/home/runner/work/opensip-tools/opensip-tools/packages/fitness/checks-cpp[39m
|
|
7
|
+
|
|
8
|
+
[32m✓[39m src/__tests__/clang-tidy.test.ts [2m([22m[2m6 tests[22m[2m)[22m[90m 66[2mms[22m[39m
|
|
9
|
+
[32m✓[39m src/__tests__/parse.test.ts [2m([22m[2m7 tests[22m[2m)[22m[90m 70[2mms[22m[39m
|
|
10
|
+
|
|
11
|
+
[2m Test Files [22m [1m[32m2 passed[39m[22m[90m (2)[39m
|
|
12
|
+
[2m Tests [22m [1m[32m13 passed[39m[22m[90m (13)[39m
|
|
13
|
+
[2m Start at [22m 17:46:38
|
|
14
|
+
[2m Duration [22m 9.56s[2m (transform 2.62s, setup 0ms, collect 15.34s, tests 135ms, environment 1ms, prepare 1.19s)[22m
|
|
15
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clang-tidy.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/clang-tidy.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { parseClangTidyOutput } from '../checks/clang-tidy-passthrough.js';
|
|
3
|
+
describe('parseClangTidyOutput', () => {
|
|
4
|
+
it('parses a single warning with a lint name', () => {
|
|
5
|
+
const out = `/abs/path/foo.cpp:42:10: warning: do not use 'goto' [hicpp-avoid-goto]`;
|
|
6
|
+
const violations = parseClangTidyOutput(out, '', 0, ['/abs/path/foo.cpp'], '/abs');
|
|
7
|
+
expect(violations).toHaveLength(1);
|
|
8
|
+
expect(violations[0]?.severity).toBe('warning');
|
|
9
|
+
expect(violations[0]?.line).toBe(42);
|
|
10
|
+
expect(violations[0]?.message).toContain('hicpp-avoid-goto');
|
|
11
|
+
});
|
|
12
|
+
it('parses errors with severity error', () => {
|
|
13
|
+
const out = `/x/y.cpp:5:1: error: expected ';' [clang-diagnostic-error]`;
|
|
14
|
+
const violations = parseClangTidyOutput(out, '', 1, ['/x/y.cpp'], '/x');
|
|
15
|
+
expect(violations).toHaveLength(1);
|
|
16
|
+
expect(violations[0]?.severity).toBe('error');
|
|
17
|
+
});
|
|
18
|
+
it('skips note: lines (notes are continuations of prior diagnostics)', () => {
|
|
19
|
+
const out = [
|
|
20
|
+
'/x/y.cpp:5:1: warning: prefer enum class [modernize-use-enum-class]',
|
|
21
|
+
'/x/y.cpp:5:1: note: change here',
|
|
22
|
+
].join('\n');
|
|
23
|
+
const violations = parseClangTidyOutput(out, '', 0, [], '/x');
|
|
24
|
+
expect(violations).toHaveLength(1);
|
|
25
|
+
});
|
|
26
|
+
it('handles diagnostics without a lint name', () => {
|
|
27
|
+
const out = `/a/b.cpp:1:1: warning: bare warning`;
|
|
28
|
+
const violations = parseClangTidyOutput(out, '', 0, [], '/a');
|
|
29
|
+
expect(violations).toHaveLength(1);
|
|
30
|
+
expect(violations[0]?.message).toBe('bare warning');
|
|
31
|
+
});
|
|
32
|
+
it('returns empty array on empty stdout', () => {
|
|
33
|
+
expect(parseClangTidyOutput('', '', 0, [], '/x')).toHaveLength(0);
|
|
34
|
+
});
|
|
35
|
+
it('returns multiple violations for multi-line output', () => {
|
|
36
|
+
const out = [
|
|
37
|
+
'/x/y.cpp:1:1: warning: a [check-a]',
|
|
38
|
+
'/x/y.cpp:5:1: warning: b [check-b]',
|
|
39
|
+
'/x/y.cpp:9:1: error: c [check-c]',
|
|
40
|
+
].join('\n');
|
|
41
|
+
const violations = parseClangTidyOutput(out, '', 0, [], '/x');
|
|
42
|
+
expect(violations).toHaveLength(3);
|
|
43
|
+
expect(violations[0]?.line).toBe(1);
|
|
44
|
+
expect(violations[1]?.line).toBe(5);
|
|
45
|
+
expect(violations[2]?.line).toBe(9);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
//# sourceMappingURL=clang-tidy.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clang-tidy.test.js","sourceRoot":"","sources":["../../src/__tests__/clang-tidy.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAE7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAA;AAE1E,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,0CAA0C,EAAE,GAAG,EAAE;QAClD,MAAM,GAAG,GAAG,wEAAwE,CAAA;QACpF,MAAM,UAAU,GA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0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/parse.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { parseClangTidyOutput } from '../checks/clang-tidy-passthrough.js';
|
|
3
|
+
describe('parseClangTidyOutput', () => {
|
|
4
|
+
it('parses a warning line with a [check-name] tag', () => {
|
|
5
|
+
const out = parseClangTidyOutput('src/foo.cpp:42:10: warning: unused variable [misc-unused]', '', 0, [], '');
|
|
6
|
+
expect(out).toHaveLength(1);
|
|
7
|
+
expect(out[0]?.severity).toBe('warning');
|
|
8
|
+
expect(out[0]?.line).toBe(42);
|
|
9
|
+
expect(out[0]?.message).toContain('[misc-unused]');
|
|
10
|
+
expect(out[0]?.message).toContain('unused variable');
|
|
11
|
+
});
|
|
12
|
+
it('parses an error line', () => {
|
|
13
|
+
const out = parseClangTidyOutput('src/x.cpp:5:1: error: something exploded [bugprone-foo]', '', 0, [], '');
|
|
14
|
+
expect(out[0]?.severity).toBe('error');
|
|
15
|
+
});
|
|
16
|
+
it('parses a line without a [check-name] tag', () => {
|
|
17
|
+
const out = parseClangTidyOutput('src/y.cpp:1:1: warning: unparsed', '', 0, [], '');
|
|
18
|
+
expect(out).toHaveLength(1);
|
|
19
|
+
expect(out[0]?.message).toBe('unparsed');
|
|
20
|
+
});
|
|
21
|
+
it('skips note: lines', () => {
|
|
22
|
+
const out = parseClangTidyOutput('src/a.cpp:1:1: warning: w [misc]\nsrc/a.cpp:1:1: note: more info', '', 0, [], '');
|
|
23
|
+
expect(out).toHaveLength(1);
|
|
24
|
+
});
|
|
25
|
+
it('skips lines that do not match the expected format', () => {
|
|
26
|
+
const out = parseClangTidyOutput('random output\n2 warnings generated.\n', '', 0, [], '');
|
|
27
|
+
expect(out).toEqual([]);
|
|
28
|
+
});
|
|
29
|
+
it('handles empty output', () => {
|
|
30
|
+
expect(parseClangTidyOutput('', '', 0, [], '')).toEqual([]);
|
|
31
|
+
});
|
|
32
|
+
it('parses multiple diagnostics', () => {
|
|
33
|
+
const stdout = 'a.cpp:1:1: warning: w1 [m1]\nb.cpp:2:2: error: e1 [m2]';
|
|
34
|
+
const out = parseClangTidyOutput(stdout, '', 0, [], '');
|
|
35
|
+
expect(out).toHaveLength(2);
|
|
36
|
+
expect(out[0]?.severity).toBe('warning');
|
|
37
|
+
expect(out[1]?.severity).toBe('error');
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
//# sourceMappingURL=parse.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parse.test.js","sourceRoot":"","sources":["../../src/__tests__/parse.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;IACpC,EAAE,CAAC,+CAA+C,EAAE,GAAG,EAAE;QACvD,MAAM,GAAG,GAAG,oBAAoB,CAC9B,2DAA2D,EAC3D,EAAE,EACF,CAAC,EACD,EAAE,EACF,EAAE,CACH,CAAC;QACF,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC9B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;QACnD,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,SAAS,CAAC,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AE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6BAA6B,EAAE,GAAG,EAAE;QACrC,MAAM,MAAM,GAAG,wDAAwD,CAAC;QACxE,MAAM,GAAG,GAAG,oBAAoB,CAAC,MAAM,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QACxD,MAAM,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;QAC5B,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview clang-tidy passthrough check.
|
|
3
|
+
*
|
|
4
|
+
* Runs `clang-tidy` against the matched files and surfaces its
|
|
5
|
+
* diagnostics as opensip-tools violations. The user's `.clang-tidy`
|
|
6
|
+
* config (if present) controls which lints fire — we don't override
|
|
7
|
+
* it. Use `--checks=...` in the args if you want a fixed lint set.
|
|
8
|
+
*/
|
|
9
|
+
import { type CheckViolation } from '@opensip-tools/fitness';
|
|
10
|
+
/**
|
|
11
|
+
* Pure parser for clang-tidy stdout. Accepts the diagnostic format:
|
|
12
|
+
* path/to/file.cpp:LINE:COL: warning: <message> [check-name]
|
|
13
|
+
* Returns one CheckViolation per warning/error line. `note:` lines
|
|
14
|
+
* are attached to the prior diagnostic when possible (kept simple
|
|
15
|
+
* for MVP — current implementation skips them).
|
|
16
|
+
*/
|
|
17
|
+
export declare function parseClangTidyOutput(stdout: string, _stderr: string, _exitCode: number, _files: readonly string[], _cwd: string): CheckViolation[];
|
|
18
|
+
export declare const clangTidyPassthrough: import("@opensip-tools/fitness").Check;
|
|
19
|
+
//# sourceMappingURL=clang-tidy-passthrough.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clang-tidy-passthrough.d.ts","sourceRoot":"","sources":["../../src/checks/clang-tidy-passthrough.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAe,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAA;AAKzE;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,MAAM,EAAE,EACzB,IAAI,EAAE,MAAM,GACX,cAAc,EAAE,CAmBlB;AAED,eAAO,MAAM,oBAAoB,wCAe/B,CAAA"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview clang-tidy passthrough check.
|
|
3
|
+
*
|
|
4
|
+
* Runs `clang-tidy` against the matched files and surfaces its
|
|
5
|
+
* diagnostics as opensip-tools violations. The user's `.clang-tidy`
|
|
6
|
+
* config (if present) controls which lints fire — we don't override
|
|
7
|
+
* it. Use `--checks=...` in the args if you want a fixed lint set.
|
|
8
|
+
*/
|
|
9
|
+
import { defineCheck } from '@opensip-tools/fitness';
|
|
10
|
+
// eslint-disable-next-line sonarjs/slow-regex -- input is one bounded line of clang-tidy output; no real ReDoS exposure
|
|
11
|
+
const CLANG_TIDY_LINE = /^(.+?):(\d+):(\d+):\s+(warning|error|note):\s+(.+?)(?:\s+\[([\w\-,.]+)\])?$/;
|
|
12
|
+
/**
|
|
13
|
+
* Pure parser for clang-tidy stdout. Accepts the diagnostic format:
|
|
14
|
+
* path/to/file.cpp:LINE:COL: warning: <message> [check-name]
|
|
15
|
+
* Returns one CheckViolation per warning/error line. `note:` lines
|
|
16
|
+
* are attached to the prior diagnostic when possible (kept simple
|
|
17
|
+
* for MVP — current implementation skips them).
|
|
18
|
+
*/
|
|
19
|
+
export function parseClangTidyOutput(stdout, _stderr, _exitCode, _files, _cwd) {
|
|
20
|
+
const violations = [];
|
|
21
|
+
const lines = stdout.split('\n');
|
|
22
|
+
for (const line of lines) {
|
|
23
|
+
const match = CLANG_TIDY_LINE.exec(line);
|
|
24
|
+
if (!match)
|
|
25
|
+
continue;
|
|
26
|
+
const lineStr = match[2];
|
|
27
|
+
const severity = match[4];
|
|
28
|
+
const message = match[5];
|
|
29
|
+
const lintName = match[6];
|
|
30
|
+
if (severity === 'note')
|
|
31
|
+
continue;
|
|
32
|
+
violations.push({
|
|
33
|
+
message: lintName ? `[${lintName}] ${message}` : message ?? 'clang-tidy diagnostic',
|
|
34
|
+
severity: severity === 'error' ? 'error' : 'warning',
|
|
35
|
+
line: lineStr ? Number.parseInt(lineStr, 10) : 1,
|
|
36
|
+
suggestion: 'See clang-tidy docs for the named lint',
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return violations;
|
|
40
|
+
}
|
|
41
|
+
export const clangTidyPassthrough = defineCheck({
|
|
42
|
+
id: 'e1f2a3b4-9876-4321-eeee-500000000001',
|
|
43
|
+
slug: 'cpp-clang-tidy',
|
|
44
|
+
description: 'Run clang-tidy and surface its diagnostics as opensip-tools violations',
|
|
45
|
+
scope: { languages: ['cpp'], concerns: [] },
|
|
46
|
+
tags: ['quality', 'cpp'],
|
|
47
|
+
command: {
|
|
48
|
+
bin: 'clang-tidy',
|
|
49
|
+
args: (files) => [...files, '--quiet'],
|
|
50
|
+
parseOutput: parseClangTidyOutput,
|
|
51
|
+
// clang-tidy returns 1 when warnings are emitted with -warnings-as-errors,
|
|
52
|
+
// but with --quiet and default config, exit 0 means clean run.
|
|
53
|
+
// Diagnostics are present on stdout regardless.
|
|
54
|
+
expectedExitCodes: [0, 1],
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=clang-tidy-passthrough.js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E,wCAAwC;SACrD,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAC;IAC9C,EAAE,EAAE,sCAAsC;IAC1C,IAAI,EAAE,gBAAgB;IACtB,WAAW,EAAE,wEAAwE;IACrF,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC3C,IAAI,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC;IACxB,OAAO,EAAE;QACP,GAAG,EAAE,YAAY;QACjB,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,EAAE,SAAS,CAAC;QACtC,WAAW,EAAE,oBAAoB;QACjC,2EAA2E;QAC3E,+DAA+D;QAC/D,gDAAgD;QAChD,iBAAiB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;KAC1B;CACF,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const checks: readonly [import("@opensip-tools/fitness").Check];
|
|
2
|
+
export { clangTidyPassthrough, parseClangTidyOutput } from './checks/clang-tidy-passthrough.js';
|
|
3
|
+
export declare const metadata: {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
description: string;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM,mDAAkC,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE/F,eAAO,MAAM,QAAQ;;;;CAIpB,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { clangTidyPassthrough } from './checks/clang-tidy-passthrough.js';
|
|
2
|
+
export const checks = [clangTidyPassthrough];
|
|
3
|
+
export { clangTidyPassthrough, parseClangTidyOutput } from './checks/clang-tidy-passthrough.js';
|
|
4
|
+
export const metadata = {
|
|
5
|
+
name: '@opensip-tools/checks-cpp',
|
|
6
|
+
version: '0.6.1',
|
|
7
|
+
description: 'C/C++ fitness checks (clang-tidy backed)',
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAEzE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,oBAAoB,CAAU,CAAA;AACrD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAE/F,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,IAAI,EAAE,2BAA2B;IACjC,OAAO,EAAE,OAAO;IAChB,WAAW,EAAE,0CAA0C;CACxD,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensip-tools/checks-cpp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.6",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "C/C++ fitness checks (clang-tidy backed)",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
".": "./dist/index.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@opensip-tools/fitness": "1.0.
|
|
22
|
+
"@opensip-tools/fitness": "1.0.6"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@types/node": "^22.0.0",
|