• DrDeadCrash@programming.dev
    ·
    6 months ago

    If you're using visual studio (2022 is current) the idiomatic styling will be mostly correct by default (Ctrl k,e will reformat).

    • brian@programming.dev
      ·
      edit-2
      6 months ago

      I've found it to be less strict than I'd prefer. Things like whether parameters are aligned or indented, whether or not the first one is on its own line, what statements are indented in fluent calls that have blocks, etc.

      A lot of other formatters (prettier, anything for python, etc) force something consistent in those cases, whereas it seems like the dotnet formatter prefers to leave things as they were.

      I'd love for it to be more opinionated and heavy handed if anyone has suggestions

      • DrDeadCrash@programming.dev
        ·
        6 months ago

        I've never looked into it very deeply, but it uses a styling spec called EditorConfig. Check it out, https://editorconfig.org/

  • NuXCOM_90Percent@lemmy.zip
    ·
    6 months ago

    Most languages with "official" formatting guidelines are due to limitations of the compiler/interpreter. Mixing whitespace in Python (or older Fortran) is a great way to error out massively.

    For the more modern compiled languages, there is no need. But there still tend to be popular formats from companies like Google

  • nephs@lemmygrad.ml
    ·
    6 months ago

    Javascript has airbnb style guide, enforceable through eslint. There's also react related eslint extensions to give you a lot of best practices to follow.

    There's also prettier, which is just about formatting.

  • IonicFrog@lemmy.sdf.org
    ·
    6 months ago

    For Java, I guess this as official as you can get.

    https://www.oracle.com/technetwork/java/codeconventions-150003.pdf

  • Ephera@lemmy.ml
    ·
    6 months ago

    In my experience, they're rarely as strictly enforced as e.g. flake8 does it for Python, but yeah, there is usually some resource suggesting a code style. If all else fails, you can look at some of the code the language authors have written. They'll usually have developed a rather consistent style...