From e1a827cfa1d5139f0605ededc72e0bd637d0d4ef Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Sat, 24 Jan 2026 17:56:47 -0600 Subject: [PATCH] update spellcheck to use cspell --- tools/spell-check/.aspell.en.prepl | 1 - tools/spell-check/.aspell.en.pws | 22 ---- tools/spell-check/git-spell-check | 189 ---------------------------- tools/spell-check/spell-check | 10 -- tools/spellcheck/baseball-words.txt | 5 + tools/spellcheck/cspell.yml | 25 ++++ 6 files changed, 30 insertions(+), 222 deletions(-) delete mode 100644 tools/spell-check/.aspell.en.prepl delete mode 100644 tools/spell-check/.aspell.en.pws delete mode 100755 tools/spell-check/git-spell-check delete mode 100755 tools/spell-check/spell-check create mode 100644 tools/spellcheck/baseball-words.txt create mode 100644 tools/spellcheck/cspell.yml diff --git a/tools/spell-check/.aspell.en.prepl b/tools/spell-check/.aspell.en.prepl deleted file mode 100644 index 4c3ecb8..0000000 --- a/tools/spell-check/.aspell.en.prepl +++ /dev/null @@ -1 +0,0 @@ -personal_repl-1.1 en 0 diff --git a/tools/spell-check/.aspell.en.pws b/tools/spell-check/.aspell.en.pws deleted file mode 100644 index e6e1bbb..0000000 --- a/tools/spell-check/.aspell.en.pws +++ /dev/null @@ -1,22 +0,0 @@ -personal_ws-1.1 en 19 -BBCOR -MLB -RO -Rawlings -chicagoland -cmba -cp -ePUB -epub -gh -gitdriver -github -html -jgm -lua -md -pandoc -repo -rostered -src -timeframe diff --git a/tools/spell-check/git-spell-check b/tools/spell-check/git-spell-check deleted file mode 100755 index 2ee3f32..0000000 --- a/tools/spell-check/git-spell-check +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/bash -# mprpic/git-spell-check -# https://github.com/mprpic/git-spell-check/ -set -e - -#adding this for use on a Mac -if command -v gsed &> /dev/null -then - sed=gsed -else - sed=sed -fi - -# Instructions: -# -# This script is a Git pre-commit hook that spell checks any content you are about to commit. -# -# Place this script into the ".git/hooks/" directory in your repository. It must be called "pre-commit" and be -# executable. A Git hook only works in a single repository. You need to copy this hook into every repository you wish to -# use it in manually. Optionally, you can set up a symlink in the ".git/hooks/" directory pointing to the script. -# -# Each time you try to commit something, this script is run and spell checks the content you are committing. -# -# Should you want to bypass the pre-commit hook (though not recommended), you can commit with "git commit --no-verify". - - -# The following is a text file that represents your custom dictionary; edit as necessary. Add words to it that you wish -# to ignore for the spell check. -dict=~/.git-spell-check -if [ ! -f $dict ]; then - touch ~/.git-spell-check - dict=~/.git-spell-check - printf "%s\n" "Custom dictionary not found. Created ~/.git-spell-check..." -fi - - -# The following is a temporary dictionary (a binary file) created from the dict text file. It is deleted after the -# script finishes. -temp_dict=$(mktemp docs-dictionary-XXXXXX) - -# Language of your doc. When using a non-English language, make sure you have the appropriate aspell libraries -# installed: "yum search aspell". For example, to spell check in Slovak, you must have the aspell-sk package installed. -lang=en - -# Define an extension for any additional dictionaries (containing words that are ignored during the spell check) that -# are kept locally in your repository. These dictionaries will be loaded on top of the existing global dictionary (by -# default ~/.git-spell-check). -extension=pws - -# Clean up if script is interrupted or terminated. -trap "cleanup" SIGINT SIGTERM - -# Prepares the dictionary from scratch in case new words were added since last time. -function prepare_dictionary() { - - local_dict=$(find . -name *.$extension -exec ls {} \;) - if [ -z "$local_dict" ]; then - sort -u $temp_dict -o $temp_dict - aspell --lang="$lang" create master "$temp_dict" < "$dict" - else - temp_file=$(mktemp temp_file-XXXXXX) - for file in $local_dict; do - cat $file >> $temp_file - done - cat $dict >> $temp_file - ## Remove header line - $sed -i '/personal_ws-/d' "${temp_file}" - sort -u $temp_file -o $temp_file - aspell --lang="$lang" create master "$temp_dict" < "$temp_file" - /bin/rm -f "$temp_file" - fi - -} - -# Removes the temporary dictionary. -function cleanup() { - - /bin/rm -f "$temp_dict" - -} - -# Spell checks content you're about to commit. Writes out words that are misspelled or exits with 0 (i.e. continues with -# commit). -function spell_check() { - - words=$(git diff --cached | grep -e "^+[^+]" | aspell --mode=sgml list --add-sgml-skip={ulink,code,literal,firstname,parameter,option,package,replaceable,programlisting,userinput,screen,filename,command,computeroutput,abbrev,accel,orgname,surname,foreignphrase,acronym,hardware,keycap,systemitem,application} --lang="$lang" --extra-dicts="$temp_dict" | sort -u) - if [ ! "$words" ]; then - printf "%s\n" "No typos found. Proceeding with commit..." - cleanup; exit 0 - fi - printf "%s\n" "Spell check failed on the following words: --------------------------------------------------" - echo $words - for word in $words; do - grep --color=always --exclude-dir={.git,tmp} -HIrone "\<$word\>" $(git diff --cached --name-only --diff-filter=ACMRTUXB) | awk -F ":" '{print "File: " $1 "\ton line: " $2 "\tTypo: " $3}' - printf "%s\n" "-------------------" - done - -} - -# Adds all, some, or none of the misspelled words to the custom dictionary. -function add_words_to_dict() { - - printf "%s\n" " -Add any of the misspelled words into your custom dictionary? - * a[ll] (add all words into dict, continue with commit) - * s[ome] (add some words into dict, fix others, no commit) - * i[gnore] (add some words into dict, ignore rest, continue with commit) - * n[one] (no commit) -" - - while true; do - exec < /dev/tty # Simply reading user input does not work because Git hooks have stdin detached. - read answer - shopt -s nocasematch - case "$answer" in - a|all) - add_all - cleanup; exit 0 - ;; - s|some) - add_some - printf "%s\n" "Please fix remaining typos, use \"git add\" to add fixed files, and commit." - cleanup; exit 1 - ;; - i|ignore) - add_some - cleanup; exit 0 - ;; - n|none) - add_none - cleanup; exit 1 - ;; - *) - printf "%s\n" "Incorrect answer. Try again." - continue - esac - shopt -u nocasematch - done - -} - -# Adds all words to the custom dictionary and continues with the commit. -function add_all() { - - for word in $words; do - echo $word >> "$dict" - done - -} - -# Adds some (selected by user) of the words to the dictionary and exits with 1. -function add_some() { - - for word in $words; do - printf "%s\n" "Do you want to add the following word to your custom dictionary: $word (y[es] or n[o])" - while true; do - exec < /dev/tty - read answer - shopt -s nocasematch - case "$answer" in - y|yes) - echo $word >> "$dict" - printf "%s\n" "\"$word\" added to your custom dictionary." - break ;; - n|no) - break ;; - *) - printf "%s\n" "Incorrect answer. Try again." - continue - esac - shopt -u nocasematch - done - done - -} - -# Adds none of the words and exits with 1. -function add_none() { - - printf "%s\n" "No words were added to your custom dictionary." - printf "%s\n" "Please fix remaining typos, use \"git add\" to add fixed files, and commit." - -} - - -prepare_dictionary -spell_check -add_words_to_dict \ No newline at end of file diff --git a/tools/spell-check/spell-check b/tools/spell-check/spell-check deleted file mode 100755 index ba705bc..0000000 --- a/tools/spell-check/spell-check +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash -set -e - -extension_files_to_check=md - -function spell_check(){ - find . -type f -name "*.${extension_files_to_check}" -exec aspell check {} --mode=markdown --home-dir=./.spell-check \; -} - -spell_check \ No newline at end of file diff --git a/tools/spellcheck/baseball-words.txt b/tools/spellcheck/baseball-words.txt new file mode 100644 index 0000000..2ff5e85 --- /dev/null +++ b/tools/spellcheck/baseball-words.txt @@ -0,0 +1,5 @@ +BBCOR +MLB +RO +Rawlings +rostered \ No newline at end of file diff --git a/tools/spellcheck/cspell.yml b/tools/spellcheck/cspell.yml new file mode 100644 index 0000000..3c23a09 --- /dev/null +++ b/tools/spellcheck/cspell.yml @@ -0,0 +1,25 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json + +# The version of the configuration file format. +version: "0.2" +# The locale to use when spell checking. (e.g., en, en-GB, de-DE +language: en-US +useGitignore: true +globRoot: "../.." +allowCompoundWords: true + +files: + - "**/*.md" + - ./README.md + +dictionaryDefinitions: + - name: baseball-words + path: ./baseball-words.txt + +dictionaries: + - baseball-words + +words: + - cmba + - chicagoland + - gitdriver \ No newline at end of file