Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 294605

Add .cspell.json to automate spellchecking in Drupal core

$
0
0

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

Followups:
#3122088: [META] Go through the .cspell.json to remove spelling errors from the word list and fix them

User interface changes

None

API changes

None

Data model changes

None

Dependency evaluation

  1. GitHub repo: https://github.com/streetsidesoftware/cspell
  2. 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.
  3. 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:

  1. dot-prop (sindresorhus)
  2. graceful-fs (isaacs)
  3. is-obj (sindresorhus)
  4. make-dir (sindresorhus)
  5. write-file-atomic (isaacs)
  6. at-least-node (RyanZim)
  7. comment-json (kael)
  8. configstore (sindresorhus)
  9. crypto-random-string (yeoman)
  10. fs-extra (jprichardson)
  11. gensequence (Jason3S)
  12. has-own-prop (sindresorhus)
  13. iterable-to-stream (Jason3S)
  14. jsonfile (jprichardson)
  15. unique-string (sindresorhus)
  16. universalify (RyanZim)
  17. vscode-uri (Microsoft, apparently)
  18. xdg-basedir (sindresorhus)

Release notes snippet

@todo


Viewing all articles
Browse latest Browse all 294605

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>