Setting Up Vale: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 13: Line 13:
We use the '''''Microsoft Style Guide''''' and a custom set of style rules relevant to Qt.  
We use the '''''Microsoft Style Guide''''' and a custom set of style rules relevant to Qt.  


The Vale configuration and the style files are hosted in the qtqa.git repository. The qtqa.git repository is also part of the qt5.git repository as a git submodule. See [[Setting up Gerrit]] for more information.
The Vale configuration and the style files are hosted in the qtqa.git repository, which is also a git submodule of the qt5.git. See [[Setting up Gerrit]] for more information.


The qtqa.git repository has the style rules that we use. Clone the '''qtqa.git''' repository and the relevant directory is at <code>qtqa/vale_linter_config</code>
Clone the '''qtqa.git''' repository and the relevant directory is at <code>qtqa/vale_linter_config</code>. This directory contains the styles and configuration file for Vale.


Next, configure Vale by setting <code>VALE_CONFIG_PATH</code> to the directory of your .vale.ini. The '''.vale.ini''' file in the qtqa.git repository is at  <code>qtqa/vale_linter_config/.vale.ini</code>
Next, configure Vale by setting <code>VALE_CONFIG_PATH</code> to the directory of your .vale.ini. The '''.vale.ini''' file in the qtqa.git repository is at  <code>qtqa/vale_linter_config/.vale.ini</code>
Line 22: Line 22:
#Vale config for QDoc sources: C++, QDoc, QML, snippet files
#Vale config for QDoc sources: C++, QDoc, QML, snippet files
StylesPath = styles
StylesPath = styles
MinAlertLevel = suggestion
MinAlertLevel = suggestion
Packages = Microsoft
Packages = Microsoft
Vocab = Qt
Vocab = Qt


#Add file extensions here.  
#Add file extensions here.  
[*.{cpp,qdoc,qml,qdocinc,js}]
[*.{cpp,qdoc,qml,qdocinc,js}]
#for HTML output
#[*.html]


#These are directories in the StylesPath. Turns on all rules in style
#These are directories in the StylesPath. Turns on all rules in style
#BasedOnStyles = Microsoft, Qt, Vale
# Enable/disable each rule offered by the style
# Enable/disable each rule offered by the style
# Style.Rule = {YES, NO} to enable or disable a specific rule
# Style.Rule = {YES, NO} to enable or disable a specific rule
Line 53: Line 45:
# Extends the built-in spell checker with additional filters
# Extends the built-in spell checker with additional filters
Qt.Spelling = YES
Qt.Spelling = YES
</syntaxhighlight>To test if Vale finds the configuration file is to run:
</syntaxhighlight>To test if Vale finds the configuration file, run:
  vale ls-config
  vale ls-config
Vale should output a processed configuration in JSON format. Check that the JSON output corresponds to the values in the &lt;code&gt;.vale.ini&lt;/code&gt; file.
Vale should output the processed configuration in JSON format. Check that the JSON output corresponds to the values in the &lt;code&gt;.vale.ini&lt;/code&gt; file.


== Configure Vale for VS Code ==
== Configure Vale for VS Code ==

Revision as of 15:16, 17 October 2024

Vale is a linter that highlights language issues such as grammar, terminology, and style issues.

Vale is available as a tool for Qt Creator and as a VS Code extension.

This page helps you set up Vale on VS Code or Qt Creator.

1. Install Vale

First, install Vale on your computer. The https://vale.sh/docs/vale-cli/installation/ page shows how to install Vale on various desktop platforms.

2. Download Microsoft Style Guide Rules and Configure Vale

We use the Microsoft Style Guide and a custom set of style rules relevant to Qt.

The Vale configuration and the style files are hosted in the qtqa.git repository, which is also a git submodule of the qt5.git. See Setting up Gerrit for more information.

Clone the qtqa.git repository and the relevant directory is at <code>qtqa/vale_linter_config</code>. This directory contains the styles and configuration file for Vale.

Next, configure Vale by setting <code>VALE_CONFIG_PATH</code> to the directory of your .vale.ini. The .vale.ini file in the qtqa.git repository is at <code>qtqa/vale_linter_config/.vale.ini</code>

The following is an example of .vale.ini file.

#Vale config for QDoc sources: C++, QDoc, QML, snippet files
StylesPath = styles
MinAlertLevel = suggestion
Packages = Microsoft
Vocab = Qt

#Add file extensions here. 
[*.{cpp,qdoc,qml,qdocinc,js}]

#These are directories in the StylesPath. Turns on all rules in style
# Enable/disable each rule offered by the style
# Style.Rule = {YES, NO} to enable or disable a specific rule
Vale.Terms = YES
Vale.Avoid = YES
Microsoft.OxfordComma = YES
Microsoft.Passive = YES
Microsoft.Dashes = YES
Microsoft.Spacing = YES
Microsoft.Wordiness = YES
Microsoft.We = YES
Microsoft.OxfordComma = YES
Qt.Repetition = YES
Qt.Headings = YES
# Extends the built-in spell checker with additional filters
Qt.Spelling = YES

To test if Vale finds the configuration file, run:

vale ls-config

Vale should output the processed configuration in JSON format. Check that the JSON output corresponds to the values in the <code>.vale.ini</code> file.

Configure Vale for VS Code

/extension

Configure Vale for Qt Creator

/outline tool