Skip to content

Commit 0cea7f3

Browse files
authored
[servicebus] Precise Typechecking (#32118)
1 parent b93087d commit 0cea7f3

18 files changed

+58
-27
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -195,3 +195,6 @@ sdk/**/sshKey.pub
195195

196196
# vitest results
197197
.vite/vitest/results.json
198+
199+
# typescript
200+
*.tsbuildinfo

common/tools/eslint-plugin-azure-sdk/src/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,13 @@ function config(customConfigs?: FlatConfig.ConfigArray) {
4949
})
5050
: [];
5151

52-
return [...configs.recommended, ...updated];
52+
return [
53+
...configs.recommended,
54+
...updated,
55+
{
56+
ignores: ["**/test/snippets.spec.ts", "**/test/stress"],
57+
},
58+
];
5359
}
5460

5561
export = {

sdk/servicebus/service-bus/eslint.config.mjs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ import azsdkEslint from "@azure/eslint-plugin-azure-sdk";
22

33
export default azsdkEslint.config([
44
{
5-
ignores: ["test/stress/"],
6-
},
7-
{
8-
rules: {
9-
"@azure/azure-sdk/ts-package-json-types": "off",
5+
files: ["**/*.ts", "**/*.cts", "**/*.mts"],
6+
languageOptions: {
7+
parserOptions: {
8+
project: ["./tsconfig.test.json"],
9+
},
1010
},
1111
},
1212
]);

sdk/servicebus/service-bus/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"format": "dev-tool run vendored prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"samples/**/*.{ts,js}\" \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
4343
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
4444
"integration-test:browser": "dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser --no-test-proxy",
45-
"integration-test:node": "dev-tool run test:vitest --no-test-proxy",
45+
"integration-test:node": "dev-tool run test:vitest --no-test-proxy --esm",
4646
"lint": "eslint package.json api-extractor.json README.md src test",
4747
"lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]",
4848
"pack": "npm pack 2>&1",
@@ -137,6 +137,7 @@
137137
},
138138
"type": "module",
139139
"tshy": {
140+
"project": "./tsconfig.src.json",
140141
"exports": {
141142
"./package.json": "./package.json",
142143
".": "./src/index.ts",

sdk/servicebus/service-bus/src/core/managementClient.ts

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import {
5252
throwTypeErrorIfParameterTypeMismatch,
5353
} from "../util/errors.js";
5454
import { max32BitNumber } from "../util/constants.js";
55-
// eslint-disable-next-line @typescript-eslint/no-redeclare
5655
import { Buffer } from "buffer";
5756
import type { OperationOptionsBase } from "./../modelsToBeSharedWithEventHubs.js";
5857
import type { AbortSignalLike } from "@azure/abort-controller";

sdk/servicebus/service-bus/src/dataTransformer.ts

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import { message } from "rhea-promise";
55
import isBuffer from "is-buffer";
6-
// eslint-disable-next-line @typescript-eslint/no-redeclare
76
import { Buffer } from "buffer";
87
import { logErrorStackTrace, logger } from "./log.js";
98

sdk/servicebus/service-bus/src/receivers/receiverCommon.ts

-1
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ export async function retryForever<T>(
387387

388388
// The retries are broken up into cycles, giving the user some control over how often
389389
// we actually attempt to retry.
390-
// eslint-disable-next-line no-constant-condition
391390
while (true) {
392391
++numRetryCycles;
393392

sdk/servicebus/service-bus/src/serviceBusMessage.ts

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the MIT License.
33

44
import { AmqpAnnotatedMessage, Constants } from "@azure/core-amqp";
5-
// eslint-disable-next-line @typescript-eslint/no-redeclare
65
import { Buffer } from "buffer";
76
import Long from "long";
87
import type {

sdk/servicebus/service-bus/src/util/atomXmlHelper.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { parseXML, stringifyXML } from "@azure/core-xml";
1212

1313
import * as Constants from "./constants.js";
1414
import { administrationLogger as logger } from "../log.js";
15-
// eslint-disable-next-line @typescript-eslint/no-redeclare
1615
import { Buffer } from "buffer";
1716

1817
import { parseURL } from "./parseUrl.js";

sdk/servicebus/service-bus/src/util/utils.ts

-1
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ export async function waitForTimeoutOrAbortOrResolve<T>(args: {
562562
}
563563
};
564564

565-
// eslint-disable-next-line promise/param-names
566565
const abortOrTimeoutPromise = new Promise<T>((_resolve, reject) => {
567566
clearAbortSignal = checkAndRegisterWithAbortSignal(reject, args.abortSignal);
568567

sdk/servicebus/service-bus/test/internal/unit/dataTransformer.spec.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4-
// eslint-disable-next-line @typescript-eslint/no-redeclare
54
import { Buffer } from "buffer";
65
import isBuffer from "is-buffer";
76
import { defaultDataTransformer } from "../../../src/dataTransformer.js";
+6-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
{
22
"extends": "../../../tsconfig",
3-
"compilerOptions": {
4-
"target": "ES2020",
5-
"module": "NodeNext",
6-
"paths": {
7-
"@azure/service-bus": ["./src/index"]
8-
},
9-
"moduleResolution": "NodeNext",
10-
"rootDir": ".",
11-
"skipLibCheck": true
12-
},
13-
"exclude": ["node_modules", "./types/**/*.d.ts", "./samples/**/*.ts", "test/stress*"],
14-
"include": ["src/**/*.ts", "src/**/*.mts", "src/**/*.cts", "samples-dev/**/*.ts", "test/**/*.ts"]
3+
"references": [
4+
{ "path": "./tsconfig.src.json" },
5+
{ "path": "./tsconfig.samples.json" },
6+
{ "path": "./tsconfig.test.json" }
7+
],
8+
"files": []
159
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "../../../tsconfig.samples.base.json",
3+
"compilerOptions": {
4+
"paths": {
5+
"@azure/service-bus": ["./dist/esm"]
6+
}
7+
}
8+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../../../tsconfig.lib.json",
3+
"compilerOptions": {
4+
"skipLibCheck": true
5+
}
6+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"]
3+
}

sdk/servicebus/service-bus/vitest.config.ts

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ export default mergeConfig(
2424
"Date",
2525
],
2626
},
27+
typecheck: {
28+
enabled: true,
29+
tsconfig: "tsconfig.test.json",
30+
include: ["test/**/*.ts", "test/**/*.mts", "test/**/*.cts"],
31+
},
2732
},
2833
}),
2934
);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
import { mergeConfig } from "vitest/config";
5+
import vitestConfig from "./vitest.config.ts";
6+
import vitestEsmConfig from "../../../vitest.esm.shared.config.ts";
7+
8+
export default mergeConfig(
9+
vitestConfig,
10+
vitestEsmConfig
11+
);

tsconfig.test.base.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"compilerOptions": {
44
"skipLibCheck": true
55
},
6-
"include": ["${configDir}/test", "${configDir}/src"]
6+
"include": ["${configDir}/test", "${configDir}/src"],
7+
"exclude": ["${configDir}/test/stress"]
78
}

0 commit comments

Comments
 (0)