From d698b5156f850df4db061d0c9981dd8e192d0a0b Mon Sep 17 00:00:00 2001 From: Timothee Guerin Date: Tue, 13 Aug 2024 11:12:21 -0700 Subject: [PATCH] Fix: Revert unix style warning (#4173) This actually prevent passing windows style path via the CLI in emitter options which is really a blocker --- ...rt-unix-path-warning-2024-7-13-17-50-15.md | 8 ++++++ packages/compiler/src/config/config-loader.ts | 14 +++++------ .../compiler/src/core/schema-validator.ts | 25 ++++++------------- .../test/core/emitter-options.test.ts | 3 ++- 4 files changed, 25 insertions(+), 25 deletions(-) create mode 100644 .chronus/changes/fix-revert-unix-path-warning-2024-7-13-17-50-15.md diff --git a/.chronus/changes/fix-revert-unix-path-warning-2024-7-13-17-50-15.md b/.chronus/changes/fix-revert-unix-path-warning-2024-7-13-17-50-15.md new file mode 100644 index 0000000000..5837e2aff6 --- /dev/null +++ b/.chronus/changes/fix-revert-unix-path-warning-2024-7-13-17-50-15.md @@ -0,0 +1,8 @@ +--- +# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking +changeKind: fix +packages: + - "@typespec/compiler" +--- + +Fix: Revert `unix-style` warning that was preventing windows path via the CLI as well diff --git a/packages/compiler/src/config/config-loader.ts b/packages/compiler/src/config/config-loader.ts index be487838ca..fad9997534 100644 --- a/packages/compiler/src/config/config-loader.ts +++ b/packages/compiler/src/config/config-loader.ts @@ -260,13 +260,13 @@ function validatePathAbsolute( target: target === NoTarget ? target : getLocationInYamlScript(target.file, target.path), }); } - if (path.includes("\\")) { - return createDiagnostic({ - code: "path-unix-style", - format: { path }, - target: target === NoTarget ? target : getLocationInYamlScript(target.file, target.path), - }); - } + // if (path.includes("\\")) { + // return createDiagnostic({ + // code: "path-unix-style", + // format: { path }, + // target: target === NoTarget ? target : getLocationInYamlScript(target.file, target.path), + // }); + // } return undefined; } diff --git a/packages/compiler/src/core/schema-validator.ts b/packages/compiler/src/core/schema-validator.ts index 4c3a2894c1..b11ee8b047 100644 --- a/packages/compiler/src/core/schema-validator.ts +++ b/packages/compiler/src/core/schema-validator.ts @@ -22,9 +22,9 @@ function absolutePathStatus(path: string): "valid" | "not-absolute" | "windows-s if (path.startsWith(".") || !isPathAbsolute(path)) { return "not-absolute"; } - if (path.includes("\\")) { - return "windows-style"; - } + // if (path.includes("\\")) { + // return "windows-style"; + // } return "valid"; } @@ -75,20 +75,11 @@ function ajvErrorToDiagnostic( const tspTarget = resolveTarget(error, target); if (error.params.format === "absolute-path") { const value = getErrorValue(obj, error) as any; - const status = absolutePathStatus(value); - if (status === "windows-style") { - return createDiagnostic({ - code: "path-unix-style", - format: { path: value }, - target: tspTarget, - }); - } else { - return createDiagnostic({ - code: "config-path-absolute", - format: { path: value }, - target: tspTarget, - }); - } + return createDiagnostic({ + code: "config-path-absolute", + format: { path: value }, + target: tspTarget, + }); } const messageLines = [`Schema violation: ${error.message} (${error.instancePath || "/"})`]; diff --git a/packages/compiler/test/core/emitter-options.test.ts b/packages/compiler/test/core/emitter-options.test.ts index b4ea88c8d9..ae51a51f69 100644 --- a/packages/compiler/test/core/emitter-options.test.ts +++ b/packages/compiler/test/core/emitter-options.test.ts @@ -118,7 +118,8 @@ describe("compiler: emitter options", () => { }); }); - it("emit diagnostic if passing windows style path", async () => { + // This was disabled due to making it impossible to use windows path via the cli https://github.com/microsoft/typespec/pull/4173 + it.skip("emit diagnostic if passing windows style path", async () => { const diagnostics = await diagnoseEmitterOptions({ "asset-dir": "C:\\abc\\def", });