Skip to content

Commit

Permalink
feat: enable "sloppy-imports" by tsconfig prompt (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn authored Nov 14, 2024
1 parent 0361a50 commit 556b79b
Showing 1 changed file with 22 additions and 8 deletions.
30 changes: 22 additions & 8 deletions client/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,30 @@ async function maybeShowTsConfigPrompt(
);
if (selection == "Copy to deno.json[c]") {
try {
const editResult = jsoncParser.modify(
let newDenoJsonContent = jsoncParser.applyEdits(
denoJsonText,
["compilerOptions"],
compilerOptions,
{ formattingOptions: { insertSpaces: true, tabSize: 2 } },
);
const newDenoJsonContent = jsoncParser.applyEdits(
denoJsonText,
editResult,
jsoncParser.modify(
denoJsonText,
["compilerOptions"],
compilerOptions,
{ formattingOptions: { insertSpaces: true, tabSize: 2 } },
),
);
const unstable = Array.isArray(denoJsonContent.unstable)
? denoJsonContent.unstable as unknown[]
: [];
if (!unstable.includes("sloppy-imports")) {
unstable.push("sloppy-imports");
newDenoJsonContent = jsoncParser.applyEdits(
newDenoJsonContent,
jsoncParser.modify(
newDenoJsonContent,
["unstable"],
unstable,
{ formattingOptions: { insertSpaces: true, tabSize: 2 } },
),
);
}
await fs.promises.writeFile(denoJsonPath, newDenoJsonContent);
} catch (error) {
vscode.window.showErrorMessage(
Expand Down

0 comments on commit 556b79b

Please sign in to comment.