There are a few coding conventions and style guides for C#:
For practical advice, I recommend starting a project with
dotnet new editorconfig
which covers many of the .NET coding conventions. If you want more strict standards you can use StyleCop, but you will need to configure it a bit to be consistent with the .NET conventions.C# has the Microsoft coding standards that are most accepted. PHP has the PSR standards. JavaScript has pretty much nothing and is the Wild West.
Those are the only ones I know about.
There’s
dotnet format
which will format your code. You can configure it with editorconfigSomeone else already mentioned Rust, but to add to it,
rustup
installsrustfmt
(opinionated formatter) andclippy
(linter) by default, but you can choose not to run them or even install them.rustfmt
has a few configuration options, but is for the most part strict in how it formats code.PEP8 is nice since it sets some common rules across Python projects, but I’m not a fan of some of the decisions they made. The biggest one for me was discouraging defining variables/attributes/etc that use the same name as built-ins. That means no variable named
input
, no attr on your data model namedid
, etc. Still, since the language doesn’t strictly enforce this, you can easily adjust these rules to meet your project’s needs.I believe
go
requires you to run the bundled formatter to even compile the code, but I could be misremembering.go fmt has been a thing for almost 11 years
Rust has a style guide and comes with a linter. But I don’t think you need to follow it if you don’t want.
PHP has PSR-1, PSR-2 and now the updated PSR-12: https://www.php-fig.org/psr/psr-12/
I refuse to believe that people use a php style guide. I have yet to open a php file in the course of any job that doesn’t mix tabs and spaces arbitrarily on top of numerous other horrors.
Luckily it’s not often that I have to, so sample size may play in a bit…
lots of languages have linters to enforce style. Examples are jslint/eslint phplint, etc…
ESLint will hurt your feelings.
Anyway, I didn’t setup the tooling, and it can be configured to enforce code styles, as it does with each commit. It also enforces rules, but can enforce code style as well.