DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

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.

Chris Ward user avatar by
Chris Ward
CORE ·
Aug. 14, 18 · Tutorial
Like (3)
Save
Tweet
Share
8.99K Views

Join the DZone community and get the full member experience.

Join For Free

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
tokens:
  - FIXME
  - 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

Spelling

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
tokens:
  - will
Testing

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Fixing Bottlenecks in Your Microservices App Flows
  • Distributed Tracing: A Full Guide
  • DeveloperWeek 2023: The Enterprise Community Sharing Security Best Practices
  • Create a CLI Chatbot With the ChatGPT API and Node.js

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: