Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make VS Code autoformat QL files on save #6809

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Marcono1234
Copy link
Contributor

@Marcono1234 Marcono1234 commented Oct 4, 2021

Specifies that VS Code autoformats QL files on save. This VS Code feature might not work correctly in some cases when used with auto-saving (see microsoft/vscode#45997 (comment)), but it hopefully works most of the time.

Autoformatting is quite useful because this repository enforces formatted QL files, and it is easy to forget manually formatting them.

⚠️ Autoformatting might be an intrusive change; additionally especially for larger files formatting might take some time.
Would it make sense to enable this for a 'trial' period and see what effects it has on regular development in this repository? E.g. whether it helps speeding up the work, or whether it hinder the work.

I am also not sure if for the queries of all programming languages in this repository formatting is enforced yet; if not, this pull request might cause undesired formatting changes.

"omnisharp.autoStart": false
"omnisharp.autoStart": false,
"[ql]": {
"editor.formatOnSave": true,
Copy link
Contributor Author

@Marcono1234 Marcono1234 Oct 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: When I typed this in VS Code it recommended "editor.wordBasedSuggestions": false, probably because the VS Code extension specifies that, see github/vscode-codeql#217. But it looks like this does not have to be specified here explicitly, it is apparently inherited from the extension settings.

@smowton
Copy link
Contributor

smowton commented Oct 5, 2021

Would a pre-commit hook be better?

@Marcono1234
Copy link
Contributor Author

Marcono1234 commented Oct 5, 2021

The Git documentation says:

It’s important to note that client-side hooks are not copied when you clone a repository.

Additionally it would require users to have the CodeQL CLI on their PATH, which might not be the case for everyone.
(Though on the other hand, not everyone might have installed the CodeQL VS Code extension either, but at least VS Code recommends usage of the extension.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants