Is your feature request related to a problem? Please describe.
It would be great to have a fix command where Cspell automatically takes the first suggestion and replaces the errors with that.
Describe the solution you'd like
I have written this Bash script to do that, however, I hope this is integrated into Cspell.
This requires the correct configuration of words to prevent false positive changes, which is needed anyway if a project wants to use Cspell.
#!/bin/bash
# Run cspell and capture output
pnpm i -g cspell || npm i -g cspell
output=$(cspell lint --show-suggestions --no-progress)
# Loop through each line of output
while read -r line; do
# if line is empty, skip
if [ -z "$line" ]; then
continue
fi
# Get the file, word, and first suggestion
file=$(echo "$line" | awk -F ':' '{print $1}')
word=$(echo "$line" | awk -F '[(|)]' '{print $2}')
first_suggestion=$(echo "$line" | awk -F 'Suggestions: ' '{print $2}' | awk -F '[[]|[]]' '{print $2}' | awk -F ',' '{print $1}' | sed 's/\*//g')
# Replace the word with the suggestion (full word)
sed -i "s/\b$word\b/$first_suggestion/g" "$file"
echo "Replaced $word with $first_suggestion in $file"
done <<<"$output"
Additional context
I use Cspell for my project to fix spelling errors. However, it takes time for new projects that haven't used Cspell before to fix the errors manually.
Is your feature request related to a problem? Please describe.
It would be great to have a
fix
command where Cspell automatically takes the first suggestion and replaces the errors with that.Describe the solution you'd like I have written this Bash script to do that, however, I hope this is integrated into Cspell.
This requires the correct configuration of
words
to prevent false positive changes, which is needed anyway if a project wants to use Cspell.Additional context
I use Cspell for my project to fix spelling errors. However, it takes time for new projects that haven't used Cspell before to fix the errors manually.