katayama8000
katayama80007mo ago

How to format on save with devcontainer

I'd like to automatically format my code when saving, but it's not working. devcontainer.json
{
"name": "Deno DevContainer",
"dockerComposeFile": ["../compose.yml", "compose.yml"],
"service": "deno_devcontainer",
"workspaceFolder": "/workspace",
"forwardPorts": [8080],
"customizations": {
"vscode": {
"settings": {
"deno.enable": true,
"deno.lint": true,
"deno.unstable": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "denoland.vscode-deno"
},
"extensions": [
"denoland.vscode-deno",
"GitHub.copilot"
]
}
}
}
{
"name": "Deno DevContainer",
"dockerComposeFile": ["../compose.yml", "compose.yml"],
"service": "deno_devcontainer",
"workspaceFolder": "/workspace",
"forwardPorts": [8080],
"customizations": {
"vscode": {
"settings": {
"deno.enable": true,
"deno.lint": true,
"deno.unstable": false,
"editor.formatOnSave": true,
"editor.defaultFormatter": "denoland.vscode-deno"
},
"extensions": [
"denoland.vscode-deno",
"GitHub.copilot"
]
}
}
}
Can anyone help me ensure my code stays clean and organized? this is repository of deno with devcontainer. https://github.com/katayama8000/deno-devcontainer
GitHub
GitHub - katayama8000/deno-devcontainer
Contribute to katayama8000/deno-devcontainer development by creating an account on GitHub.
4 Replies
Deno AI Helper
Deno AI Helper7mo ago
To ensure that your code is automatically formatted on save within a devcontainer using the Deno extension for Visual Studio Code, you've already taken the right steps by setting the appropriate options in your devcontainer.json. According to the documentation, the Deno CLI comes with a built-in formatter which can be accessed using deno fmt and can be configured to be used by Visual Studio Code. The editor.formatOnSave setting should trigger the formatter on each save, and the editor.defaultFormatter set to "denoland.vscode-deno" specifies that the Deno formatter should be used. Your devcontainer.json looks correctly configured for this purpose. However, if it's not working as expected, here are a few troubleshooting steps you can take: 1. Ensure the Deno extension is active: When you open the project in the devcontainer, make sure that the Deno extension is active and not showing any errors. 2. Check the Deno version: Make sure that the version of Deno installed in the devcontainer is compatible with the Deno extension in VSCode. 3. Check for conflicting settings: Sometimes, other settings or extensions can interfere with the formatter. Try disabling other extensions temporarily to see if there's a conflict. 4. Check the output of the Deno language server: Use the Deno: Language Server Status command from the command palette to check the current active configuration and ensure that the language server is recognizing your settings correctly. 5. Reload the window: Sometimes, changes in settings might require you to reload the VSCode window. You can do this by opening the command palette and typing Developer: Reload Window. 6. Rebuild the devcontainer: If you've made changes to the devcontainer.json after the container
Deno AI Helper
Deno AI Helper7mo ago
was built, you might need to rebuild the container for the changes to take effect. 7. Check the Deno extension documentation: The documentation might have additional information or steps for troubleshooting issues with formatting on save. If you've gone through these steps and the issue persists, you might want to check the repository's issues or discussions to see if others have encountered similar problems or if there's an ongoing issue with the extension itself. 🦕
razzi
razzi7mo ago
Check the documentation here: https://marketplace.visualstudio.com/items?itemName=denoland.vscode-deno#formatting In particular, note that their example puts the default formatter under the "[typescript]" key
Deno - Visual Studio Marketplace
Extension for Visual Studio Code - A language server client for Deno.
katayama8000
katayama80007mo ago
thank you for the explain 🙂 finally format works!!
{
"name": "Deno DevContainer",
"dockerComposeFile": ["../compose.yml", "compose.yml"],
"service": "deno_devcontainer",
"workspaceFolder": "/workspace",
"forwardPorts": [8080],
"customizations": {
"vscode": {
"settings": {
"[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }
},
"extensions": [
"denoland.vscode-deno",
"GitHub.copilot"
]
}
}
}
{
"name": "Deno DevContainer",
"dockerComposeFile": ["../compose.yml", "compose.yml"],
"service": "deno_devcontainer",
"workspaceFolder": "/workspace",
"forwardPorts": [8080],
"customizations": {
"vscode": {
"settings": {
"[typescript]": { "editor.defaultFormatter": "denoland.vscode-deno" }
},
"extensions": [
"denoland.vscode-deno",
"GitHub.copilot"
]
}
}
}
More Posts
How does form submission work?I'm following the tutorial: https://fresh.deno.dev/docs/getting-started/form-submissions It says: >Won't install `npm:@supabase/ssr`I'm trying to build something with Fresh and Supabase and would like to use the [`@supabase/ssr`](ht`RangeError: Offset is outside the bounds of the DataView` when trying to encrypt with AES-CRTHi, I'm trying to encrypt some files with aes128-crt, but I always get the error below. (Even if I jAny way for VS Code to auto-complete library subdirectory in import?Is there any way for VS Code to suggest subdirectory in a package (especially for npm package) when get hours & minutes in a specific timezoneMaybe I search the wrong way, but all I'd like to do is to use a specific timezone in my project runConnection refused when creating a local API serverI'm following [Simple API server | Deno Docs](https://docs.deno.com/deploy/tutorials/simple-api "Simdeno deploy queuesis there a special flag or setting required for queues in deno deploy , i ceated a very simple exampWhat is the difference between importing "preact" via esm.sh or npm:...?What is the difference between importing "preact" via esm.sh or npm:...? "preact": "https://esm.sh/pDeployctl, error: Uncaught (in promise) NotFound: Failed to spawn 'start': program not found```powershell > deployctl logs a i Provisioning a new access token... i Authorization URL: https://dis there a way to make the call stack in deno larger?I already think this is a no from what I have gathered but I thought Id ask