Vale for Spelling, Grammar, Style and Readability Linting

DZone 's Guide to

Vale for Spelling, Grammar, Style and Readability Linting

If you've wanted a spell checker or autocorrect that simply does more, check out how this tool is bein used to check for tense and syle as well.

· Agile Zone ·
Free Resource

I spent last week hacking with contributors at the Test the Docs project in Szeged, Hungary. The project aims to create tools that are both usable by developers who aren't good writers, and writers who aren't good developers. The tools are for testing structural and content issues with writing, often called linting, a topic I have written about before. We're working on an easy to use wrapper tool (working title "redactor") that bundles a series of tests together, but for this post, I focus on one of those tests.

A common ask from writers is a tool that checks beyond standard grammar and spelling checks to also include personal or company style guides. We wanted to create a tool that handles this use case and a form of open source Grammarly or Hemmingway App.

A handful of tools are available that help you "codify" a style guide which all require a degree of configuration. We considered two options that allow you to combine human language linters into a cohesive tool, textlint and vale. Despite textlint's more active community, we opted to use vale.

Textlint takes a more JavaScript-esque approach, with a wide variety of textlint compatible plugins available to match a wide variety of tests. This means that lots of prebuilt options are available to install and use with a varying degree of configuration, but in true JavaScript fashion, this means a lot of dependencies and code for discrete and straightforward tasks.

Vale takes a different approach, providing one linter, and a selection of nine checks that you combine to recreate most common language linting tasks. For example, if you want to search for "weasel words," create an existence check for a selection of words, and Vale handles the rest. You can find prebuilt vale versions of popular style guides, but you need to research how to create specific tests not covered.

If you don't want to create your own style, or want a starting point to build from, we created a pre-packed test you can run. This test bundles a set of checks we feel are the most important that you can see in the <.vale.ini> configuration file (Read the vale docs for more configuration explanation), and we have a wide variety of reference checks available built from popular style guides.

Installation and Usage

For our packaged version, use Docker to pull and run the container, or you can dig into our setup and run vale how you like.

docker run -v <LOCAL-DOCS-FOLDER>:/srv/docs testthedocs/ttd-mdlint

Checks We Hoped to Replicate

Grammarly doesn't publish a list of the checks it runs, we used a test article to figure out some of the common ones, how to replicate them, and added a handful of others we felt were important. I'll explain a couple below (from our complete list) to help you understand how to create your own.

Removing TODOs and Other Annotations

This rule is part of the default vale.Annotations rule shipped with Vale.

extends: existence
message: "'%s' left in text."
ignorecase: false
level: error
  - TODO
  - NOTE

It uses the existence check to check if certain tokens exist in a file. If any do, it outputs a message and an error level, how these look depends if you use vale on the command line, or as an Atom or Visual Studio Code extension.

You can also override the level in the .vale.ini file:

vale.Annotations = warning


Vale supports spell checking with the spelling check and an in-built U.S. English Hunspell Dictionary that you can override to support other languages. Here's the configuration we use:

extends: spelling
message: "Did you really mean '%s'?"
level: error
ignore: vale-styles/ttd/tech/vocab.txt

You can create a list of words that you don't want vale to flag as an error by adding a file in the ignore property.

Future Tense

This test is still in progress and is currently simplified, but again uses the existence check to look for certain tokens:

extends: existence
message: "Possible future tense ??"
ignorecase: true
level: error
  - will
agile, best practice, documentation, linting, technical writing, textlint, tutorial, vale, writing

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}