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 Video Library
Refcards
Trend Reports

Events

View Events Video Library

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
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

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Debugging With Confidence in the Age of Observability-First Systems
  • Accelerating Debugging in Integration Testing: An Efficient Search-Based Workflow for Impact Localization
  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • The Cypress Edge: Next-Level Testing Strategies for React Developers

Trending

  • Stateless vs Stateful Stream Processing With Kafka Streams and Apache Flink
  • Grafana Loki Fundamentals and Architecture
  • Ensuring Configuration Consistency Across Global Data Centers
  • Unlocking AI Coding Assistants Part 1: Real-World Use Cases
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Vale for Spelling, Grammar, Style and Readability Linting

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.

By 
Chris Ward user avatar
Chris Ward
DZone Core CORE ·
Updated Aug. 14, 18 · Tutorial
Likes (4)
Comment
Save
Tweet
Share
10.4K 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.

Related

  • Debugging With Confidence in the Age of Observability-First Systems
  • Accelerating Debugging in Integration Testing: An Efficient Search-Based Workflow for Impact Localization
  • Comprehensive Guide to Property-Based Testing in Go: Principles and Implementation
  • The Cypress Edge: Next-Level Testing Strategies for React Developers

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

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

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: