💡: `caseSensitive` word by word
Problem
We want IPv4, not ipV4, ipv4 nor Ipv4. But we allow install, Install, INSTALL.
Solution
Extending the caseSensitive option into list:
caseSensitive:
- IPv4
Alternatives
No response
Additional Context
No response
Code of Conduct
- [x] I agree to follow this project's Code of Conduct
@JounQin,
Words list are case aware, but they generate non-case sensitive versions on load. There are directive you can add to your word list file.
my-words.txt
# This is a comment
# The following directives are supported:
# - 'no-split' - do not split words (default)
# - 'split' - split words on spaces
# - 'generate-alternatives' - generate non-case sensitive and accent alternatives (default)
# - 'no-generate-alternatives' - do not change the case.
# Example
# cspell-dictionary:split
This line will be split into individual words.
# The words will be: `This`, `line`, ... `words.`
# By default, lower case versions are generated for when `caseSensitive` is `false`.
# cspell-dictionary:no-generate-alternatives
IPv4 # IPv4 is allowed, but ipv4 is not in this list.
!ipv4 # use `!` to forbid a word, this is useful if it is in another dictionary and you do not want it.
~english # `~` prefix is used to specify use only in non-case sensitive checking.
# cspell-dictionary:generate-alternatives
# Start generating again.
Resumé # will also generate `~resume`
Thanks @Jason3S first!
Your solution should work absolutely, but IMO it's not that convenient when building a high level linter built on top of ESLint + cspell like https://github.com/alauda/doom/blob/47379bb0459377c003abc931ea0a8b8bfabc45bf/src/cli/lint.ts#L47-L59
Is there any downside to support what I'm proposing? I believe the interface is just simple enough.
Friendly ping @Jason3S.
I'm very reluctant to add another type of word list, there are already 4 (words, ignoreWords, flagWords, and suggestions).
All word list are by definition case sensitive. For speed purposes, they also make a parallel list with case and accents removed. This second list is used when caseSensitive is false, which it is by default.
#7351 Adds the ability to specify supportNonStrictSearches: false when specifying a dictionary. This will prevent the spell checker from auto generating the second list.
Example: https://github.com/streetsidesoftware/cspell/pull/7352/files#r2095017131
I'm going to close this as completed. There is a way to achieve the desired outcome. So far the only issues seen is with respect to words found in other dictionaries.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.