question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Standardize/enforce code formatting on the project

See original GitHub issue

Prescribed Solution:

  • Format all of the extension code
    • Python (using black)
    • js, jsx, ts, tsx, json, css, less, sass (using prettier)
  • ~Format on commit~
  • Format on save (user settings, opt in using)
    • Use prettier extension
    • Use python extension with black
  • Recommend prettier extension in .vscode/extensions.json
    • Use prettier extension
    • Use python extension with black
  • Prettier Config settings
    • Prettier rc config (editor agnostic, also picked by CI)
    • ~.vscode/settings~
  • CI check for all pipelines (black & prettier)
    • PR pipeline
    • CI Pipeline
  • Update contributing guide
  • Configure prettier to use tslint (ensure this works on CI)
    • TIP - Look for prettier plugins (plenty good ones)
~Set up [pre-commit](https://pre-commit.com/) and some [hooks](https://pre-commit.com/hooks.html) for anything which runs quickly:~

~… etc.~

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
brettcannoncommented, Jul 9, 2019

@DonJayamanne why do you not want to install Python to work on the Python extension for VS Code? Inquiring minds want to know! 😉

And I think we can skip doing pre-commit hooks because we have something called extensions. 😁 Pre-commit hooks are great as a standardized way to help make sure people meet some requirement before sending code to CI. But since we have standardized our tooling all the way up to the editor, we can actually just standardize on VS Code extensions to do the formatting for us and then let CI enforce that requirement as @d3r3kk suggested.

2reactions
d3r3kkcommented, Jul 9, 2019

As an alternate view: Why don’t we simply use a faster check at the onset of the CI build to handle these pre-commit issues, and give contributors all the information they need to reproduce the CI build ‘quick checks’ on their own machine should the need arise?

Note: I personally have never been a huge fan of pre-commit checks.

Until I found the npm run -s precommit command so I could run it at my will, I found my enjoyment of checking in somewhat… reduced. I like it when the build machine tells me (quickly, preferably) when I’ve messed up simple stuff like linting/etc… and then gives me the tools to just check it on my own.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why You Should Use EditorConfig to Standardize Code Styles
You use EditorConfig to define formatting conventions for textual files in a project. It's great because it's widely supported, ...
Read more >
Code style options and code cleanup - Visual Studio (Windows)
Learn how to configure Visual Studio to apply code style preferences using the Code Cleanup (Visual Studio 2019) and Format Document (Visual ...
Read more >
Enforce code consistency with clang-format - Red Hat Developer
Get started with clang-format, an LLVM tool that you can use to set and maintain a consistent code style in your open source...
Read more >
Standardize code formatting with Spotless - DEV Community ‍ ‍
Organizing and formatting code as a standard for the whole team is important and useful. Without a standard being followed for formatting code...
Read more >
How to configure and enforce coding standard rules - Devbridge
Code standards enforced by automated rule checks improve the readability and maintainability of code—as well as reduce the number of bugs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found