Standardize/enforce code formatting on the project
See original GitHub issuePrescribed Solution:
- Format all of the extension code
- Python (using
black
) - js, jsx, ts, tsx, json, css, less, sass (using
prettier
)
- Python (using
- ~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:~
- ~Prettier~
- ~Black ~
- ~tslint~
- ~pre-commit~
~… etc.~
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
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.