Code style and analysis settings that we can share across the HealthCatalyst organization. These include general editor settings, Microsoft/C#-specific settings, ReSharper settings, Code Analysis/StyleCop severity settings, and Prettier/eslint settings for javascript applications.
Check out the Wiki for suggestions on dealing with common error messages.
Copy the SharedSettings/.editorconfig
file from this repository into your solution's root folder. This is a good baseline for health catalyst's preferred styles.
- For .NET applications, append the contents of
SharedSettings/Catalyst.MostRules.Error.ruleset.editorconfig
to the.editorconfig
file. This will cause many common programming mistakes to cause compile-time errors instead of just warnings. Also ensure you have analyzers enabled/installed. We recommend: - If you have projects that represent libraries for external use (for example, they get published as Nuget packages), add the contents of
SharedSettings/Catalyst.ClassLibrary.ruleset.editorconfig
to the.editorconfig
file for those projects. These will make some rules stricter, for things like adding.ConfigureAwait(false)
to Tasks, and enforcing good documentation practices. - If you have automated test projects, add the contents of
SharedSettings/Catalyst.TestRules.ruleset.editorconfig
to the.editorconfig
file for those projects. This will loosen some rules around things like having multiple classes in the same file, which tend to be more acceptable in test libraries. - Make sure you're not unintentionally overriding these settings via Resharper DotSettings files or Code Analysis Rulesets.
- We also recommend adding the following to your csproj files:
<Nullable>enable</Nullable>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
<CodeAnalysisTreatWarningsAsErrors>true</CodeAnalysisTreatWarningsAsErrors>
<TreatWarningsAsErrors></TreatWarningsAsErrors>
<WarningsAsErrors>nullable</WarningsAsErrors>
For web applications (TypeScript/Javascript/Angular):
- Put the
SharedSettings/.prettierrc
andSharedSettings/.eslintrc.js
files in the root of your application folder. - Incorporate the elements from the
SharedSettings/package.json
file into yourpackage.json
file. This file contains versions of the required packages (as of 2021-3-4), along with an npm command to run the linter.
The .editorconfig
file allows a development team to share consistent coding style rules between different editors and IDEs independent of platform.
To apply the shared .editorconfig
settings to your project, move the .editorconfig
file from the SharedSettings
folder into the root folder of your repository. You can create other .editorconfig
files in subfolders to override these settings, or you can use glob definitions in the root .editorconfig
to change the settings for files matching specific patterns.
For more details, see https://editorconfig.org/
Useful Resources:
- Visual Studio Extension for easier editing of
.editorconfig
files - Create portable, custom editor settings with EditorConfig
- .NET coding convention settings for EditorConfig
- This repository also has an
EditorConfigFileComparisonTool.linq
file, which is a LINQPad script to help compare the code analysis rules found in.editorconfig
files.
For styling and linting purposes, we use a combination of ESLint and Prettier, along with minimal configuration files. The bulk of the linting rules use the built-in recommended lists, along with rules for using eslint with Prettier.
Recommended extensions:
Please use the GitHub repository to suggest and make changes to these baseline settings file. Log an issue, create a pull request, comment on proposed changes with other developers, etc.