DEV Community

Andreas Riedmüller
Andreas Riedmüller

Posted on

Sharing Recommended VSCode Settings in Your Project Repository

Maintaining a consistent development environment in team projects, such as sharing recommended VSCode settings, can significantly improve developer experience.

Recent experience has shown me that committing a settings.json file directly may clash with personal preferences. Providing a settings.json.sample file, on the other hand, allows team members to quickly adopt project standards while retaining the freedom to customize their environment.

Step-by-Step Guide

1. Create Your Sample Settings File

First, create a settings.json.sample file in your project's .vscode directory. It serves as a template for the recommended VSCode settings specific to your project and should contain all the recommended settings that you believe will benefit your team. For example:

{
  "typescript.tsdk": "node_modules/typescript/lib",
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": "explicit"
  }
}
Enter fullscreen mode Exit fullscreen mode

Note to self (author): In the future I qant to add a link to an article explaining my full recommended VSCode settings.json for javascript projects, which I plan to publish in the series "My default project setup".

2. Add Instructions to Your Documentation

In your README.md or contributing guidelines, include a section on setting up the development environment. Here, mention the settings.json.sample file and provide instructions for using it:

### Copy Recommended VSCode Settings

To align your VSCode settings with the project's recommended configuration:

1. Navigate to the `.vscode` directory at the root of the project.
2. Copy the `settings.json.sample` file and rename the copy to `settings.json`.
3. If desired, customize the `settings.json` with your personal preferences.
Enter fullscreen mode Exit fullscreen mode

3. Update Your .gitignore

To prevent the actual settings.json from being committed to the repository, ensure your .gitignore file includes the following line:

.vscode/*
!.vscode/settings.json.sample
Enter fullscreen mode Exit fullscreen mode

This step is crucial to keeping personal or sensitive settings out of the repository.

Best Practices

  • Commenting: Include comments in your settings.json.sample to explain the purpose and benefit of each setting. This will help team members understand why certain settings are recommended.
  • Regular Updates: Periodically review and update the sample file to reflect any changes in your development environment or new best practices.
  • Encourage Feedback: Invite your team to suggest additions or changes to the settings.json.sample file. This collaborative approach ensures that the file remains relevant and beneficial to everyone.

Conclusion

Sharing a settings.json.sample file is less intrusive approach to share recommended VSCode settings. But it might be a bit more work to maintain the file compared to just committing .vscode/settings.json (What I still prefer for a personal project)

Happy coding!

Top comments (0)