Problem/Motivation
Issues like #2829185: Fix spelling errors in Drupal core comments are great, as they provide profit, but it'd be nice when things could be done more automatically.
Let's try to do some research how we could provide maybe a tool to check for spellchecking automatically.
Symfony for example corrects common mistakes using a bot.
Proposed resolution
Use cspell
The config file locates at core/.cspell.json
, you can add new words into it or adjust it when necessary. Visit https://github.com/streetsidesoftware/cspell/tree/master/packages/cspell and read the documentation for more information. Such as how to enable/disable checking etc.
Example usages:
- Checking files inside the core folder:
cd core yarn run spellcheck:core
Warning: the executing time for this command is about 5 to 30 minutes depending on your PC.
-
Or to checking any file or directory:
cd core yarn run spellcheck "path/to/file/or/directory/**/*"
Once an unknown word is reported, you have two options:
- If it's an incorrect word, fixing it
- if it's a correct word, adding it to the core/misc/cspell/dictionary.txt file
Regenerating the Drupal dictionary
Run:
cd core
rm misc/cspell/dictionary.txt
yarn -s spellcheck:core --unique --wordsOnly | sort -o misc/cspell/dictionary.txt
Remaining tasks
User interface changes
None
API changes
None
Data model changes
None
Dependency evaluation
- GitHub repo: https://github.com/streetsidesoftware/cspell
- Release cycle: first release was in January 2017, there has been approximately one major release a year (v4 is current, v5 is in alpha) and there are regular (monthly or sooner) patch releases.
- Security policy: cspell is a development tool that does not appear to have a security release process.
The package is used by:
- phpcs
- Code Spell Checker for Visual Studio Code, 1.3 million installs (see below about the Microsoft-authored dependency)
In addition to its own sub-packages, cspell installs all of the following:
- dot-prop (sindresorhus)
- graceful-fs (isaacs)
- is-obj (sindresorhus)
- make-dir (sindresorhus)
- write-file-atomic (isaacs)
- at-least-node (RyanZim)
- comment-json (kael)
- configstore (sindresorhus)
- crypto-random-string (yeoman)
- fs-extra (jprichardson)
- gensequence (Jason3S)
- has-own-prop (sindresorhus)
- iterable-to-stream (Jason3S)
- jsonfile (jprichardson)
- unique-string (sindresorhus)
- universalify (RyanZim)
- vscode-uri (Microsoft, apparently)
- xdg-basedir (sindresorhus)
Release notes snippet
@todo