From 6bcec540a686d5c645072322b91b16a978e5465d Mon Sep 17 00:00:00 2001 From: Deyaaeldeen Almahallawi Date: Tue, 10 Dec 2024 12:07:29 -0800 Subject: [PATCH] [instrumentation] Precise Typechecking --- .../eslint.config.mjs | 12 ++++++++++ .../package.json | 3 ++- .../tsconfig.browser.config.json | 16 +------------ .../tsconfig.json | 23 +++++-------------- .../tsconfig.samples.json | 8 +++++++ .../tsconfig.src.json | 3 +++ .../tsconfig.test.json | 3 +++ .../vitest.config.ts | 5 ++++ .../vitest.esm.config.ts | 11 +++++++++ 9 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/eslint.config.mjs create mode 100644 sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.samples.json create mode 100644 sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.src.json create mode 100644 sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.test.json create mode 100644 sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.esm.config.ts diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/eslint.config.mjs b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/eslint.config.mjs new file mode 100644 index 000000000000..864298dcd2da --- /dev/null +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/eslint.config.mjs @@ -0,0 +1,12 @@ +import azsdkEslint from "@azure/eslint-plugin-azure-sdk"; + +export default azsdkEslint.config([ + { + files: ["**/*.ts", "**/*.cts", "**/*.mts"], + languageOptions: { + parserOptions: { + project: ["./tsconfig.test.json"], + }, + }, + }, +]); diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/package.json b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/package.json index 5308571b83ef..d99b738f64a9 100644 --- a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/package.json +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/package.json @@ -29,7 +29,7 @@ "generate:client": "autorest --typescript ./swagger/README.md", "integration-test": "npm run integration-test:node && npm run integration-test:browser", "integration-test:browser": "echo skipped", - "integration-test:node": "dev-tool run test:vitest --no-test-proxy", + "integration-test:node": "dev-tool run test:vitest --no-test-proxy --esm", "lint": "eslint package.json api-extractor.json README.md src test", "lint:fix": "eslint package.json api-extractor.json README.md src test --fix --fix-type [problem,suggestion]", "pack": "npm pack 2>&1", @@ -96,6 +96,7 @@ "requiredResources": {} }, "tshy": { + "project": "./tsconfig.src.json", "exports": { "./package.json": "./package.json", ".": "./src/index.ts" diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.browser.config.json b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.browser.config.json index 6281c560eb3c..75871518e3a0 100644 --- a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.browser.config.json +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.browser.config.json @@ -1,17 +1,3 @@ { - "extends": "./.tshy/build.json", - "include": [ - "./src/**/*.ts", - "./src/**/*.cts", - "./src/**/*.mts", - "./test/**/*.mts", - "./test/**/*.cts", - "./test/**/*.ts" - ], - "exclude": ["./test/**/node/**/*.ts", "./test/snippets.spec.ts"], - "compilerOptions": { - "outDir": "./dist-test/browser", - "rootDir": ".", - "skipLibCheck": true - } + "extends": ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"] } diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.json b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.json index 6207fc106570..b186a5a177d8 100644 --- a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.json +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.json @@ -1,20 +1,9 @@ { "extends": "../../../tsconfig", - "compilerOptions": { - "module": "NodeNext", - "moduleResolution": "NodeNext", - "rootDir": ".", - "paths": { - "@azure/opentelemetry-instrumentation-azure-sdk": ["./src/index"] - } - }, - "include": [ - "src/**/*.ts", - "src/**/*.cts", - "src/**/*.mts", - "test/**/*.ts", - "test/**/*.cts", - "test/**/*.mts", - "samples-dev/**/*.ts" - ] + "references": [ + { "path": "./tsconfig.src.json" }, + { "path": "./tsconfig.samples.json" }, + { "path": "./tsconfig.test.json" } + ], + "files": [] } diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.samples.json b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.samples.json new file mode 100644 index 000000000000..8d6d70d22fbe --- /dev/null +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.samples.json @@ -0,0 +1,8 @@ +{ + "extends": "../../../tsconfig.samples.base.json", + "compilerOptions": { + "paths": { + "@azure/opentelemetry-instrumentation-azure-sdk": ["./dist/esm"] + } + } +} diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.src.json b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.src.json new file mode 100644 index 000000000000..bae70752dd38 --- /dev/null +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.src.json @@ -0,0 +1,3 @@ +{ + "extends": "../../../tsconfig.lib.json" +} diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.test.json b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.test.json new file mode 100644 index 000000000000..290ca214aebc --- /dev/null +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/tsconfig.test.json @@ -0,0 +1,3 @@ +{ + "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] +} diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.config.ts b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.config.ts index 49798d657fbf..7ce75713ef99 100644 --- a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.config.ts +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.config.ts @@ -10,6 +10,11 @@ export default mergeConfig( test: { include: ["test/**/*.spec.ts"], exclude: ["test/snippets.spec.ts"], + typecheck: { + enabled: true, + tsconfig: "tsconfig.test.json", + include: ["test/**/*.ts", "test/**/*.mts", "test/**/*.cts"], + }, }, }), ); diff --git a/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.esm.config.ts b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.esm.config.ts new file mode 100644 index 000000000000..2f6e757a54f7 --- /dev/null +++ b/sdk/instrumentation/opentelemetry-instrumentation-azure-sdk/vitest.esm.config.ts @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { mergeConfig } from "vitest/config"; +import vitestConfig from "./vitest.config.ts"; +import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; + +export default mergeConfig( + vitestConfig, + vitestEsmConfig +);