Problem/Motivation
Our CI currently is letting us know there are several spelling issues throughout the codebase. Some of them are noticeable on the user side.
Attached are the current artifacts as generated by the GitlabCI CSpell Job
Steps to reproduce
see https://git.drupalcode.org/project/simplenews/-/jobs/11195020
Proposed resolution
We would like an easily maintainable spelling check that includes both en-gb & en-us to accommodate both styles of spelling.
Currently, CSpell defaults only include en-us spelling so a change to the base setting for this check will need to be made.
Then spelling corrections will need to be checked to identify if it's a legitimate spelling error or needs to be whitelisted.
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| artifacts-903243-cspell.zip | 2.13 KB | generalredneck |
Issue fork simplenews-3613453
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
generalredneck@adamps made the following comments in the parent issue:
For 3. I originally made changes that allowed for EN-GB by the spell checker. The default .cspell.json we grab from gitlabci defines en-US as the defacto default. As noted in the comment in the description of the that asset, some of the items are expanded in scripts/prepare-cspell.php. You can find this expanded copy as part of the assets you download in the gitlab cspell job (also attached to this task)
I change the language to
"en-US,en-GB"and committed it as part of the change so that we will always have the new language.By default, the CI gives you the option to add a list of words you want to add as "correct" to your project as .cspell_project_words.txt. They even make an assest that you can download directly from the CI so you can easily replace this file with the new words that it finds. This simplifies things for maintainers. So typically, this is the only extra file you ever have to touch.
So for response to 5), I kept both because for the language change I need at least .cspell.json, but opted to keep .cspell_project_words.txt to keep this feature of ease of use.
If preferred I can instead add the list to the "words" property inside of .cspell.json.
Comment #4
generalredneckComment #5
adamps commentedGreat thanks.
1) .cspell.json seems to contain quite a lot we don't need in many of the sections. Any chance of a bit of a trim down? I.e. take out all the words, dictionaries, paths, then add back in the few that seem relevant.
2) I am confused by having two lists of words - can we put them all in the project file?
3) behaviour, analysing should be fine in UK spelling
Comment #6
generalredneck#1) We can. What I have though is what we are currently testing against with JUST en-GB enabled. In other words I grabbed what gitlabci is generating for the project and making the single change. That is the only way I know to change the language. I don't know how to "add in" the language to the default without altering the cspell job. What I'm saying is if we didn't want to add in en-gb we wouldn't add a .cspell.json to our project and just have the .cpsell-project-words.txt file.
That said if you are saying you don't care about the defaults that the Drupal community is pulling in I can do that but you will want some of those dictionaries and the like and several of the words like "allowlist vs white/blacklist are cultural indicators that if removed may send the wrong message to people supporting the project.
#2) The second list was like I said, ease of use because the current CI generates lists of all the "wrong" words that you can download over this list making it super easy to maintain. Not that altering a json list is much harder... Just explaining my reasoning. Now that we are creating our own .cspell.json file we can deviate as much as you like including getting rid of the txt.
#3 is an oops from when I got started using the defaults and can reverse those changes.
Comment #7
adamps commentedThanks for explaining. The part I don't really like is that we seem to duplicate the entire long default config file locally. I am very happy to with the default settings for all the reasons you suggest, however if we make our own copy we are then responsible for updating it, which I guess we won't😃.
How about if we drop the local copy of the config file and instead just individually whitelist all the UK spellings that are already present?
Comment #8
generalredneckI can absolutely do that. 👍
Comment #9
generalredneckadamps,
So everything went well. The only thing that I want to make you aware of is that the word "e-mail" (among a few other words) are set up in the "flagwords" section of the default .cspell.json.
I had to
sedthe code and replace e-mail with email. Both are considered correct spelling in the English language, but Drupal has made a very opinionated change in #3505522: Miscellaneous CSPELL fixes without any comments as to why. I can only guess for consistency sake. Same with the word "grey" vs "gray".I ensured that all the automated tests passed after the change as some of them rely on the labeling being identical.
Comment #11
adamps commentedGreat thanks