Repository navigation
Releases
v10.5.2
Fixes
fix: `--gitignore` skips nested repositories in ignored folders again (#9648)
fix: --gitignore skips nested repositories in ignored folders again (#9648)
Summary
With --gitignore (useGitignore), cspell again skips a git repository kept in a folder that .gitignore excludes, such as a tool's cache of cloned dependencies. Since 10.4.0, these files were checked. A submodule in an ignored folder is still checked, as git does.
Fixes #9645
Before and after
A project with a clone in an ignored cache folder, and a submodule in an ignored vendor/ folder:
project/
.gitignore .cache/ and vendor/
.gitmodules lists vendor/lib
README.md
.cache/dep/ a clone, with its own .git
vendor/lib/ a submodule
Before, cspell checked the clone:
$ cspell lint --gitignore --dot "**/*.md"
.cache/dep/NOTES.md:1:1 - Unknown word (Thsi) fix: (This)
.cache/dep/NOTES.md:1:9 - Unknown word (misspeled) fix: (misspelled)
vendor/lib/NOTES.md:1:1 - Unknown word (Anothr) fix: (Another)
vendor/lib/NOTES.md:1:8 - Unknown word (typpo) fix: (typo)
CSpell: Files checked: 3, Issues found: 4 in 2 files.
After, it skips the clone and checks the submodule:
$ cspell lint --gitignore --dot "**/*.md"
vendor/lib/NOTES.md:1:1 - Unknown word (Anothr) fix: (Another)
vendor/lib/NOTES.md:1:8 - Unknown word (typpo) fix: (typo)
CSpell: Files checked: 2, Issues found: 2 in 1 file.
What to know:
- A repository in an ignored folder is skipped with all its files, unless
.gitmoduleslists it as a submodule. - A repository added with plain
git add, without a.gitmodulesentry, is skipped too. - A worktree in an ignored folder is skipped too.
- Running cspell inside the nested repository still checks its files.
- In a folder that isn't ignored, the
.gitignorefiles above a nested repository still don't apply to its files.
Technical Details
- When the search for
.gitignorefiles reaches a nested repository belowgitignoreRoot(by default, the repository cspell runs in), it first asks the outer repository's.gitignorefiles whether the nested repository's folder is ignored. If it is, every file in it is ignored, whatever the.gitignorefiles inside it say. - Submodules are read from the outer repository's
.gitmodulesfile. The submodules of an ignored repository are ignored with it.
fix: Detect file types by folder, such as `.git/config` (#9641)
fix: Detect file types by folder, such as .git/config (#9641)
Summary
File types can now be detected by the folder a file is in, not only by its name. The first two are git's own files, which had no file type before.
.git/configis detected asproperties, like.gitconfig..git/info/excludeis detected asignore, like.gitignore.
Technical Details
- In
@cspell/filetypes, an entry in a file type'sfilenamesmay now contain/. It matches the end of a path. A\in the path is read as/. - In such an entry,
*stays within one folder, and**spans folders. - A match on the path wins over a match on the name or extension.
- cspell-lib now passes the full path when it looks up a file's type.
findMatchingFileTypescould return no file type for a path, depending on the path given in the previous call. That is fixed.
v10.5.1
Fixes
fix: Let `--force-check` check files skipped by `ignorePathPresets` (#9634)
fix: Let --force-check check files skipped by ignorePathPresets (#9634)
With --force-check, cspell lint now checks git's own files when they are named on the command line. Before, they were still skipped by the git preset of ignorePathPresets, even though --force-check already overrides ignorePaths and --exclude.
cspell lint --force-check --file .git/configBefore:
CSpell: Files checked: 0, skipped: 1, Issues found: 0 in 0 files.
No files found to check (1 skipped).
After:
.git/config:1:1 - Unknown word (zqxword)
CSpell: Files checked: 1, Issues found: 1 in 1 file.
This also covers the .git file that git puts in a worktree or a submodule.
fix: Spell check .env files like .env.\* files (#9624)
fix: Spell check .env files like .env.* files (#9624)
Summary
.env and .env.* files, such as .env.local, are now spell checked the same way. Before, .env was treated as a properties file, while .env.* files were treated as shell scripts. A word could pass in .env.local and be flagged in .env.
Both now have both file types, properties and shellscript. So .env files now also use the shell, Bash, and Git dictionaries, and any languageSettings for either file type apply to both. .envrc is still a shell script only.
fix: Keep every locale in a locale directive followed by punctuation (#9629)
fix: Keep every locale in a locale directive followed by punctuation (#9629)
Summary
A locale directive with punctuation right after a locale lost that locale and every locale after it. This was a regression in 10.4.1.
For example, a Markdown guide that shows the directive in backticks:
Use `cSpell:locale fr,en` here.- 10.4.0: the locales are
fr,en. - 10.4.1: the locale is
fronly. English words in the file are reported as unknown. - Now: the locales are
fr,enagain.
The fix for comment closers (#9496) and the fix for locales that aren't valid (#9501) still hold. Each of these gives en, or fr,en for the last one, because text after the locales that isn't a locale doesn't become one:
<!-- cspell:locale en -->
/* cspell:locale en*/
cspell:locale fr,en -- the rest
Technical Details
A directive's text runs to the end of the line. Before, the locale list was split only on spaces and commas, and the list was cut at the first piece that didn't look like a locale. A piece like en` failed that check, so the list stopped at fr.
Now the list ends at the first character that can't be part of a locale or a separator, such as a backtick or */, or at --, as in -->. The rest is then split into pieces, and the list still ends at the first piece that isn't a locale.
fix: Make `[!…]` in globs match characters that are not listed (#9622)
fix: Make [!…] in globs match characters that are not listed (#9622)
Summary
A [!…] bracket in a glob now matches any character that is not listed, as it does in git and shell globs. Before, e[!a].txt in .gitignore (with useGitignore) or ignorePaths matched ea.txt and e!.txt and skipped eb.txt, so cspell checked the files you meant to ignore and ignored the files you meant to check.
- Applies to
ignorePaths,.gitignorefiles read withuseGitignore,files, and thefilenameglobs inoverrides. [^…]already worked and is unchanged.
Fixes #9621
Technical Details
cspell-globnow asks picomatch to read globs in POSIX mode. The only change this makes is that[!starts a negated bracket, like[^.- Include mode gets the same fix, so
[!a]means the same thing infilesand inignorePaths.
fix: Skip more lock files, including pnpm-lock.yaml (#9619)
fix: Skip more lock files, including pnpm-lock.yaml (#9619)
Summary
cspell now recognizes more lock files. Lock files are generated, so cspell skips them when checking files, as it already does for package-lock.json, yarn.lock, and other files ending in .lock.
Newly skipped:
pnpm-lock.yaml(pnpm)npm-shrinkwrap.json(npm)bun.lockb(Bun, before 1.2)packages.lock.json(NuGet)Package.resolved(Swift Package Manager)gradle.lockfile(Gradle).terraform.lock.hcl(Terraform)go.sumandgo.work.sum(Go)
v10.5.0
Features
feat: Skip nested git worktrees by default (#9604)
feat: Skip nested git worktrees by default (#9604)
Summary
cspell now skips git worktrees inside the root folder, such as .worktrees/feature or .claude/worktrees/feature. A worktree is another checkout of the same repository, often of another branch, so its files are not the files being checked.
A new preset in ignorePathPresets, nestedWorktrees, can disable this.
Fixes #9515
Feature
A repository with a worktree of its feature branch, made with git worktree add worktrees/feature feature:
project/
README.md
worktrees/
feature/
README.md
Before, running cspell in project/ checked both copies of README.md:
$ cspell .
README.md:3:21 - Unknown word (finshed) fix: (finished)
worktrees/feature/README.md:3:21 - Unknown word (finshed) fix: (finished)
CSpell: Files checked: 2, Issues found: 2 in 2 files.
After, it checks only the repository's own README.md:
$ cspell .
README.md:3:21 - Unknown word (finshed) fix: (finished)
CSpell: Files checked: 1, Issues found: 1 in 1 file.
Running cspell in worktrees/feature/ still checks that worktree.
To check nested worktrees again:
cspell.json
{
"ignorePathPresets": { "nestedWorktrees": false }
}What the nestedWorktrees preset does:
- It is enabled by default.
- It skips the worktrees whether or not
.gitignoreexcludes them, and with or without--gitignore. - It finds the worktrees in the repository's own records, in
.git/worktrees. Finding them does not search the worktrees' folders, so it stays fast however many worktrees there are. - It skips only the worktrees of the repository that holds the root folder. Submodules and other repositories inside the root folder are still checked.
- A run started inside a worktree checks that worktree's files.
- When the path to the root folder goes through a symbolic link, it doesn't match the paths git recorded, so the worktrees are checked.
- A file in a nested worktree named on the command line is skipped too, unless
--force-checkis given, as withignorePaths.
Technical Details
The worktree folders are added to the globs the file search ignores, so the search never enters them. Glob symbols in a folder's name, such as (, are escaped.
feat: Add `ignorePathPresets` and skip git's own files by default (#9600)
feat: Add ignorePathPresets and skip git's own files by default (#9600)
Summary
cspell now skips git's own files inside the root folder:
- the
.gitfile that git puts in a worktree or a submodule - the files inside
.gitfolders
Git's message files, such as .git/COMMIT_EDITMSG, are still checked, so a commit-msg hook that runs cspell .git/COMMIT_EDITMSG keeps working.
A new setting, ignorePathPresets, can disable this.
Fixes #9590
Feature
cspell only reaches these files when dot files are checked (--dot or enableGlobDot), or when they are named on the command line.
Before, checking a git worktree with --dot reported the words in its .git file:
$ cspell --dot .
.git:1:1 - Unknown word (gitdir)
.git:1:31 - Unknown word (worktrees)
CSpell: Files checked: 2, Issues found: 2 in 1 file.
After:
$ cspell --dot .
CSpell: Files checked: 1, skipped: 1, Issues found: 0 in 0 files.
No ignorePaths glob could do this before: one that ignores the .git file also ignores .git/COMMIT_EDITMSG. Rules you already have for .git keep working.
To check git's own files again:
cspell.json
{
"ignorePathPresets": { "git": false }
}What the git preset does:
- It is enabled by default.
- It keeps git's message files: the files whose names end in
MSG, such asCOMMIT_EDITMSG,MERGE_MSG, andTAG_EDITMSG, andEDIT_DESCRIPTION. They are kept directly inside a.gitfolder, and inside a linked worktree's folder in.git/worktrees. - It skips only files inside the root folder. A hook in a worktree or a submodule that passes the message file with
--filekeeps working: git keeps that file in the main repository's.gitfolder, outside the root. - With the root inside a
.gitfolder, the files there are checked. - A config that sets
ignorePathPresetsonly changes the presets it names. Presets from imported configs are combined.
Technical Details
The preset's globs are relative to the root, so they match only below it. The file search skips the files and folders inside a .git folder, except the message files and the folders that hold the message files of linked worktrees. A .git file it finds, or one named with --file, is reported as skipped.
New exports:
cspell-lib:calcIgnorePathGlobs, which returns the globs of the enabled presets. Thecspellcommand line adds them to the globs it ignores while searching.cspell-lib:isIgnoredByPresets, which checks one file's URL against the enabled presets, relative to a root URL. Thecspellcommand line uses it to skip a file such as the.gitfile.@cspell/cspell-types:IgnorePathPresets, the type of the setting.
feat: Add `features.overrideGlobsMatchFilesOnly` so override globs match only the path they name (#9598)
feat: Add features.overrideGlobsMatchFilesOnly so override globs match only the path they name (#9598)
Summary
New feature option features.overrideGlobsMatchFilesOnly. When it is enabled, a filename glob in overrides matches only the path it names, not the files inside a folder with that name. It is disabled by default, so existing configs keep working.
See #9590.
Feature
Today an override glob also matches the files inside a folder with the same name. For example, examples.ts also matches every file inside a folder named examples.ts, and src/** also matches a file named src.
With the option enabled, each glob matches only what it names. To apply an override to the files in a folder, end the glob with /.
cspell.config.yaml
features:
overrideGlobsMatchFilesOnly: true
overrides:
# The files in every folder named `fixtures`.
- filename: 'fixtures/'
enabled: falseWhat a glob matches:
| Glob | Disabled (default) | Enabled |
|---|---|---|
examples.ts |
A file named examples.ts, and the files in a folder with that name. |
A file named examples.ts. |
/src |
A file named src at the root, and the files in the src folder. |
A file named src at the root. |
src/** |
The files in the src folder, and a file named src. |
The files in the src folder. |
- The option can be set in an imported config. It applies to all overrides, including the ones from imported configs.
- The default is planned to become
truein v11.
Technical Details
cspell-glob: the glob matcher has a new option,extendNested. It defaults totrue, which keeps today's behavior: a glob is extended to also match the files nested beneath a folder with that name. Withfalse, the glob is not extended, and a glob ending in/**matches only the files beneath the folder.- With the feature enabled, override globs are matched with
extendNested: false.
fix: Add a Vim file type for .vim files and .vimrc (#9579)
fix: Add a Vim file type for .vim files and .vimrc (#9579)
Adds a vim file type with the .vim extension and the filenames .vimrc, _vimrc, vimrc, .gvimrc and _gvimrc, as Jason3S confirmed on the issue. filetypes.test.ts checks each of them.
Closes #9489
Fixes
fix: Check files in a folder whose name starts with a space (#9608)
fix: Check files in a folder whose name starts with a space (#9608)
Summary
Files in a folder whose name starts with a space can now be checked. Before, cspell found the file but dropped the space from its path, then reported it as not found.
This affects:
- globs, such as
cspell "**/readme.txt"orcspell "./ notes/readme.txt" --fileand--file-listentries, such asnotes/readme.txt
Globs, such as those in ignorePaths and overrides, now match a file whose name ends with a space correctly. For a file named b (with a trailing space):
bno longer matches it.b[ ]now matches it.
Before, with notes/readme.txt (the folder name starts with a space):
$ cspell --no-progress "**/readme.txt"
Linter: File not found: "/projects/demo/notes/readme.txt"
CSpell: Files checked: 0, skipped: 1, Issues found: 0 in 1 file with 1 error.
After:
$ cspell --no-progress "**/readme.txt"
notes/readme.txt:1:12 - Unknown word (mispeling)
CSpell: Files checked: 1, Issues found: 1 in 1 file.
Entries in --file and --file-list keep their leading spaces. Trailing spaces and Windows line endings are still removed.
Technical Details
- Found paths and command-line paths are relative to the current folder, and cspell turns them into file URLs. The URL standard drops spaces and control characters from both ends of a relative URL, so
notes/readme.txtbecamenotes/readme.txt.@cspell/urlnow encodes those characters before it builds the URL. --fileand--file-listentries were trimmed on both sides. Now only the end is trimmed.
fix: Check folders named on the command line with `#` or a leading space (#9610)
fix: Check folders named on the command line with # or ...
v10.4.1
Fixes
fix: Show "stdin" as the file name when checking stdin (#9487)
fix: Show "stdin" as the file name when checking stdin (#9487)
Summary
When cspell lint checks text from stdin, the issues it reports now name the file stdin. Before, the file name was empty.
This applies to cspell lint stdin, cspell lint --file stdin, and cspell lint stdin://. With stdin://<path>, the issues still show <path>.
Before:
$ echo 'const recieve = 1;' | cspell lint --no-progress --file stdin
:1:7 - Unknown word (recieve) fix: (receive)
After:
$ echo 'const recieve = 1;' | cspell lint --no-progress --file stdin
stdin:1:7 - Unknown word (recieve) fix: (receive)
With --no-relative, the name is also stdin, instead of a stdin: URL that points to the current folder.
fix: Recognize Fortran source files (#9490)
fix: Recognize Fortran source files (#9490)
Summary
cspell now recognizes Fortran source files. Each one gets the file type fortran, plus FortranFreeForm or FortranFixedForm, the language IDs used by the Modern Fortran extension for VS Code. Settings and dictionaries can now target Fortran files.
Feature
| File type | Extensions |
|---|---|
fortran |
all of the extensions below |
FortranFreeForm |
.f90, .f95, .f03, .f08, .f18, .fpp, .fypp, .pf, .cuf (CUDA Fortran) |
FortranFixedForm |
.f, .f77, .for, .ftn |
Uppercase extensions, such as .F90, match too.
Use fortran to match both forms:
{
"languageSettings": [
{
"languageId": "fortran",
"words": ["gfortran", "nvfortran"]
}
]
}To match a Fortran file opened in VS Code, list the VS Code IDs too: "languageId": "fortran,FortranFreeForm,FortranFixedForm".
Dictionary Updates
fix: Workflow Bot -- Update Dictionaries (main) (#9494)
fix: Workflow Bot -- Update Dictionaries (main) (#9494)
Update Dictionaries (main)
Summary
.../MicrosoftDocs/PowerShell-Docs/report.yaml | 37 ++++++++++------------
.../MicrosoftDocs/PowerShell-Docs/snapshot.txt | 7 +---
.../snapshots/php/php-src/report.yaml | 6 +---
.../snapshots/php/php-src/snapshot.txt | 14 +++-----
packages/cspell-bundled-dicts/package.json | 8 ++---
packages/cspell/src/__snapshots__/app.test.ts.snap | 12 ++++---
pnpm-lock.yaml | 37 +++++++++++++++-------
7 files changed, 61 insertions(+), 60 deletions(-)
v10.4.0
Features
feat: Add `--glob-symlinks` to follow symbolic links when matching globs (#9342)
feat: Add --glob-symlinks to follow symbolic links when matching globs (#9342)
Summary
cspell lint can now follow symbolic links in glob searches, with --glob-symlinks. Glob searches skip linked files and linked directories by default, so a tree made of links, such as Bazel runfiles, found nothing to check.
Closes #7700.
Feature
cspell lint --glob-symlinks "**"--glob-symlinksfollows symbolic links, and searches linked directories, when matching globs. Links are followed wherever they point.CSPELL_GLOB_SYMLINKS=truedoes the same for a whole job.--no-glob-symlinksoverrides it.- API:
globSymlinksin thelintoptions. - It can't be set in a configuration file.
- Files are reported by the path through the link. A file reached by two paths is checked under both.
- It applies only to glob searches. For
--file,--files, and--file-listdocuments, use--follow-symlinks.
Technical Details
- The design decisions are recorded in
docs/ADRs/glob-symlinks/. - Link loops, such as a link to a parent directory, are stopped by the glob search after one level.
feat: Respect `COLUMNS` for help and table width (#9358)
feat: Respect COLUMNS for help and table width (#9358)
Summary
Help, and the tables from cspell trace and cspell dictionaries, now follow the COLUMNS environment variable. That lets you choose a narrower width, which helps with large fonts and screen magnifiers. The help in the cspell README now fits on npmjs.com without scrolling sideways.
Feature
Set COLUMNS to pick the output width:
COLUMNS=60 cspell lint --helpBefore, cspell lint --help at 80 columns:
Usage: cspell lint [options] [globs...] [file://<path> ...] [stdin[://<path>]]
...
Options:
-c, --config <cspell.json> Configuration file to use. By default cspell
looks for cspell.json in the current directory.
--no-config-search Disable automatic searching for additional
configuration files in parent directories. Only
the specified config file (if any) will be
used.
After, COLUMNS=72 cspell lint --help:
Usage: cspell lint [options] [globs...] [file://<path> ...]
[stdin[://<path>]]
...
Options:
-c, --config <cspell.json> Configuration file to use. By default
cspell looks for cspell.json in the
current directory.
--no-config-search Disable automatic searching for
additional configuration files in
parent directories. Only the specified
config file (if any) will be used.
COLUMNStakes priority over the terminal width when it is set to a positive number.- Without it, cspell uses the terminal width as before, or 80 when output isn't a terminal.
- Option descriptions in help now wrap at narrower widths. Before, anything narrower than about 73 columns left them unwrapped.
Other changes
- A few lines in
cspell lint --helpare shorter, so the help fits in 72 columns. The usage line now breaks before[stdin[://<path>]]. - The help in the
cspellREADME is generated at 72 columns, which is what npmjs.com shows in a code block.
feat: Add `--follow-symlinks` and skip files referenced by symbolic links (#9340)
feat: Add --follow-symlinks and skip files referenced by symbolic links (#9340)
Summary
cspell lint now skips files that are symbolic links, or are in a linked directory, and adds --follow-symlinks to check them.
Glob searches already skipped linked files and linked directories. Files named explicitly were read through links. Now every way of naming files behaves the same:
- A file that is a symbolic link, or is in a linked directory, is skipped. This applies to
--file,--files,--file-listentries, thefilesoption oflint, and file or glob arguments. - A glob that goes through a linked directory, such as
docs/*.mdwhendocsis a link, is not searched. - A
--file-listfile that is a symbolic link is an error, like a missing list. - A linked file named with
--file,--files, or--file-listshows asskippedin the progress. File and glob arguments leave links out, as glob searches always have. Use--verboseto see why a file or glob was skipped. - With
--force-check, a linked file is an error instead of being skipped.
If you check linked files on purpose, for example Bazel runfiles, add --follow-symlinks.
Feature
cspell lint --follow-symlinks --file-list files.txt--follow-symlinksallows checking--fileand--file-listdocuments referenced by symbolic links. Glob searches don't follow links unless--glob-symlinksis used (#9342).CSPELL_FOLLOW_SYMLINKS=truedoes the same for a whole job.--no-follow-symlinksoverrides it.- API:
followSymlinksin thelintoptions.
Technical Details
- For a file under the root, each folder from the root down, and the file itself, is checked for a symbolic link. For a file outside the root, only the file itself is checked, so paths such as a worktree's commit message file still work.
- Links above the root, such as
/tmpon macOS, don't count. - A link is recognized without following it, so a link to a missing file is skipped the same way as any other link.
feat: `--must-find-files` fails when every file was skipped (#9327)
feat: --must-find-files fails when every file was skipped (#9327)
Summary
With --must-find-files, which is on by default, cspell lint now fails when every file it found was skipped, and says so. Since 10.2.0 the summary shows skipped files, but they still counted as found, so a run that checked nothing could pass.
Fixes #9326.
Feature
A file is skipped when it is excluded by ignorePaths, .gitignore, or the files setting, when it is binary, or when an override or language setting turns off checking for it. Skipped files are still listed in the summary, but they no longer count as found.
$ cspell lint --file sub/doc.md
CSpell: Files checked: 0, skipped: 1, Issues found: 0 in 0 files.
No files found to check (1 skipped).
$ echo $?
1
- This applies to
--file,--file-list, and globs alike. - A run that checks at least one file is not affected.
- To let a run pass when every file is skipped, use
--no-must-find-files. --silenthides the new message.
Technical Details
- The file count passed to custom reporters has included skipped files since 10.2.0. Its documentation now says so.
Fixes
fix: Apply `.gitignore` and `ignorePaths` rules in order (#9408)
fix: Apply .gitignore and ignorePaths rules in order (#9408)
Summary
Glob patterns in a list are now applied in the order they are written, and the last pattern that matches a file decides. Before, a pattern that starts with ! always won, wherever it was in the list.
For example, in a .gitignore file, a later node_modules/ rule now ignores files beneath an earlier !un-ignored/ rule.
This applies to:
- Rules in
.gitignorefiles. - Patterns in
ignorePathsthat start with!, when files are checked through thecspell-libAPI. Thecspellcommand line still skips these patterns and shows a warning. - Patterns in
overrides[].filename. - The globs that filter files passed with
--fileor--file-list.
Part of #5104.
fix: cspell-tools: build case-insensitive forms with the dictionary's locale (#9458)
fix: cspell-tools: build case-insensitive forms with the dictionary's locale (#9458)
Summary
cspell-tools can now build a dictionary with its language's case rules. Set locale in cspell-tools.config.yaml, and words are lower-cased with that locale's rules instead of the default ones. In a Turkish dictionary, Irak then gets the case-insensitive form ırak, not irak.
Feature
Set locale at the top level, or per target:
targets:
- name: turkish
format: trie3
sources:
- src/turkish.txt
generateNonStrict: true
locale: tr-TRSet dictionaryInformation.locale in the dictionary definition to the same locale, so cspell searches the dictionary with the case rules it was built with. If the definition lists more than one locale, cspell uses the first valid one for case rules, so put this locale first.
The locale applies everywhere cspell-tools lower-cases a word:
- the case-insensitive forms made with
generateNonStrict - words lower-cased before they're stored, for example with the
legacysplitter removeDuplicates- matching words against
allowedSplitWords,excludeWordsFrom, andexcludeWordsNotFoundIn
An invalid locale stops the build with an error that names the target.
Before, the case-insensitive form stored for Irak in a Turkish dictionary:
~irak
After, with locale: tr-TR:
~ırak
Without locale, dictionaries are built as before.
This is the last part of the dictionary locale feature (#6282, #9449). Once dictionaries are rebuilt with their locale, a lower-case word such as ırak is found in a Turkish dictionary that has Irak.
Technical Details
cspell-trie-lib: `normalizeWord...
v10.4.0-alpha.1
Fixes
fix: Deprecate `cspell-lib/rpc`; import from `@cspell/rpc` (#9376)
fix: Deprecate cspell-lib/rpc; import from @cspell/rpc (#9376)
Summary
cspell-lib/rpc is deprecated: import from @cspell/rpc instead. It still works, and editors now mark each of its exports as deprecated.
cspell-lib/rpconly passes@cspell/rpcthrough. Everything it exports (RPCClient,RPCServer, the RPC error classes, and their types) is available from@cspell/rpcdirectly.- Nothing else changes for users: every package exports the same names as before.
Technical Details
- The published packages now list their exports by name instead of re-exporting whole modules, so the public API of each package is visible in its entry file, and anything added to an internal module only becomes public on purpose.
cspellandcspell-libstill re-export everything from@cspell/cspell-types, so everything their users need comes from one place.- The
@cspell/eslint-pluginrecommendedconfig, from@cspell/eslint-plugin/configs, is now a plain config object with the samepluginsandrules. - Unused files that only re-exported other modules were removed from
@cspell/cspell-typesandcspell-grammar.
v10.4.0-alpha.0
Note
This prerelease was not published to npm because of a problem in the release workflow. Its changes are included in v10.4.0-alpha.1.
Features
feat: Add `--glob-symlinks` to follow symbolic links when matching globs (#9342)
feat: Add --glob-symlinks to follow symbolic links when matching globs (#9342)
Summary
cspell lint can now follow symbolic links in glob searches, with --glob-symlinks. Glob searches skip linked files and linked directories by default, so a tree made of links, such as Bazel runfiles, found nothing to check.
Closes #7700.
Feature
cspell lint --glob-symlinks "**"--glob-symlinksfollows symbolic links, and searches linked directories, when matching globs. Links are followed wherever they point.CSPELL_GLOB_SYMLINKS=truedoes the same for a whole job.--no-glob-symlinksoverrides it.- API:
globSymlinksin thelintoptions. - It can't be set in a configuration file.
- Files are reported by the path through the link. A file reached by two paths is checked under both.
- It applies only to glob searches. For
--file,--files, and--file-listdocuments, use--follow-symlinks.
Technical Details
- The design decisions are recorded in
docs/ADRs/glob-symlinks/. - Link loops, such as a link to a parent directory, are stopped by the glob search after one level.
feat: Respect `COLUMNS` for help and table width (#9358)
feat: Respect COLUMNS for help and table width (#9358)
Summary
Help, and the tables from cspell trace and cspell dictionaries, now follow the COLUMNS environment variable. That lets you choose a narrower width, which helps with large fonts and screen magnifiers. The help in the cspell README now fits on npmjs.com without scrolling sideways.
Feature
Set COLUMNS to pick the output width:
COLUMNS=60 cspell lint --helpBefore, cspell lint --help at 80 columns:
Usage: cspell lint [options] [globs...] [file://<path> ...] [stdin[://<path>]]
...
Options:
-c, --config <cspell.json> Configuration file to use. By default cspell
looks for cspell.json in the current directory.
--no-config-search Disable automatic searching for additional
configuration files in parent directories. Only
the specified config file (if any) will be
used.
After, COLUMNS=72 cspell lint --help:
Usage: cspell lint [options] [globs...] [file://<path> ...]
[stdin[://<path>]]
...
Options:
-c, --config <cspell.json> Configuration file to use. By default
cspell looks for cspell.json in the
current directory.
--no-config-search Disable automatic searching for
additional configuration files in
parent directories. Only the specified
config file (if any) will be used.
COLUMNStakes priority over the terminal width when it is set to a positive number.- Without it, cspell uses the terminal width as before, or 80 when output isn't a terminal.
- Option descriptions in help now wrap at narrower widths. Before, anything narrower than about 73 columns left them unwrapped.
Other changes
- A few lines in
cspell lint --helpare shorter, so the help fits in 72 columns. The usage line now breaks before[stdin[://<path>]]. - The help in the
cspellREADME is generated at 72 columns, which is what npmjs.com shows in a code block.
feat: Add `--follow-symlinks` and skip files referenced by symbolic links (#9340)
feat: Add --follow-symlinks and skip files referenced by symbolic links (#9340)
Summary
cspell lint now skips files that are symbolic links, or are in a linked directory, and adds --follow-symlinks to check them.
Glob searches already skipped linked files and linked directories. Files named explicitly were read through links. Now every way of naming files behaves the same:
- A file that is a symbolic link, or is in a linked directory, is skipped. This applies to
--file,--files,--file-listentries, thefilesoption oflint, and file or glob arguments. - A glob that goes through a linked directory, such as
docs/*.mdwhendocsis a link, is not searched. - A
--file-listfile that is a symbolic link is an error, like a missing list. - A linked file named with
--file,--files, or--file-listshows asskippedin the progress. File and glob arguments leave links out, as glob searches always have. Use--verboseto see why a file or glob was skipped. - With
--force-check, a linked file is an error instead of being skipped.
If you check linked files on purpose, for example Bazel runfiles, add --follow-symlinks.
Feature
cspell lint --follow-symlinks --file-list files.txt--follow-symlinksallows checking--fileand--file-listdocuments referenced by symbolic links. Glob searches don't follow links unless--glob-symlinksis used (#9342).CSPELL_FOLLOW_SYMLINKS=truedoes the same for a whole job.--no-follow-symlinksoverrides it.- API:
followSymlinksin thelintoptions.
Technical Details
- For a file under the root, each folder from the root down, and the file itself, is checked for a symbolic link. For a file outside the root, only the file itself is checked, so paths such as a worktree's commit message file still work.
- Links above the root, such as
/tmpon macOS, don't count. - A link is recognized without following it, so a link to a missing file is skipped the same way as any other link.
feat: `--must-find-files` fails when every file was skipped (#9327)
feat: --must-find-files fails when every file was skipped (#9327)
Summary
With --must-find-files, which is on by default, cspell lint now fails when every file it found was skipped, and says so. Since 10.2.0 the summary shows skipped files, but they still counted as found, so a run that checked nothing could pass.
Fixes #9326.
Feature
A file is skipped when it is excluded by ignorePaths, .gitignore, or the files setting, when it is binary, or when an override or language setting turns off checking for it. Skipped files are still listed in the summary, but they no longer count as found.
$ cspell lint --file sub/doc.md
CSpell: Files checked: 0, skipped: 1, Issues found: 0 in 0 files.
No files found to check (1 skipped).
$ echo $?
1
- This applies to
--file,--file-list, and globs alike. - A run that checks at least one file is not affected.
- To let a run pass when every file is skipped, use
--no-must-find-files. --silenthides the new message.
Technical Details
- The file count passed to custom reporters has included skipped files since 10.2.0. Its documentation now says so.
Fixes
fix: `@cspell/strong-weak-map` types compile with the `esnext` lib (#9371)
fix: @cspell/strong-weak-map types compile with the esnext lib (#9371)
Summary
@cspell/strong-weak-map's types now compile in projects that use TypeScript's esnext lib with skipLibCheck: false.
keys(),values(),entries(), and iterating aStrongWeakMapare now typed as returning aMapIterator, like aMap, so the iterator helpers (map,filter,take, …) are typed too. Before, they returnedIterableIterator, whichesnextrejects.StrongWeakMapno longer declares that it implementsMap. Withesnext,MaphasgetOrInsertandgetOrInsertComputed, whichStrongWeakMapdoesn't have, so the declaration was already an error there. It keeps all of its methods and works the same. Code that passes aStrongWeakMapwhere aMapis expected only compiles where the two still match.
fix: Published types no longer need `@types/node` (#9359)
fix: Published types no longer need @types/node (#9359)
Summary
The TypeScript types published with cspell, cspell-lib, and cspell-io no longer need @types/node. Projects that use these packages' types, but don't install Node.js types, now type-check cleanly.
cspell-io: the types no longer import fromnode:buffer.cspell-lib: theencodingoption ofspellCheckFile, andresolveDocument, accept the same encodings as before, without Node's globalBufferEncoding.cspell:AppErrorkeeps the same shape. A reporter'sconsole.stdoutChannel.streamandconsole.stderrChannel.streamare now typed as the parts of the stream cspell uses:write,isTTY,rows,columns, and optionalhasColors,clearLine, andgetColorDepth. A reporter written in TypeScript that calls other stream methods, such asonorend, needs to cast.- The types still use the standard web globals, such as
URLandAbortSignal, so thedomlib (or@types/node) is still needed for those.
Technical Details
- The
cspelltypes no longer pull inchalk's types, which themselves need Node.js types.
fix: Show the lint options in cspell --help (#9362)
fix: Show the lint options in cspell --help (#9362)
Summary
cspell --help now lists the options for cspell lint, the command that runs when no command is given. Before, it only listed the commands, so you had to know to run cspell lint --help to see options such as --no-progress or `-...
v10.3.6
Fixes
fix: Report unknown CSpell directives again (#9319)
fix: Report unknown CSpell directives again (#9319)
Summary
cspell lint reports unknown in-document directives again, such as cspell:bad-dir, when --validate-directives or validateDirectives: true in the config asks for them. Since 9.1.0 they were found but never shown or counted.
--validate-directivesand--no-validate-directivesoverride the config setting.- An unknown directive counts as an issue, so
cspell lintexits with an error, as it did before 9.1.0. - The JSON reporter,
@cspell/cspell-json-reporter, includes them in its output again.
Technical Details
- The default reporter and the JSON reporter now ask to receive directive issues. Other reporters still only get them if they ask for them.
- The command-line flag is now applied as a setting, like
--report, so it controls what is shown as well as what is checked.
fix(cspell-io): Keep redirected requests under the private root (#9329)
fix(cspell-io): Keep redirected requests under the private root (#9329)
Summary
createRedirectProvider in cspell-io now only serves requests that map to a location under its private root. A request that would resolve outside the private root is refused with VFSErrorUnsupportedRequest, the same error as a request outside the public root.
- Refused: a path that starts with a separator (
/,\,%2F,%5C) right after the public root. - Now served from inside the private root: file names that look like a URL scheme or a drive, such as
a:b.txtorC|. They used to resolve to a different URL.
cspell itself does not use createRedirectProvider. This affects projects that use cspell-io directly.
Technical Details
- The part of the URL after the public root is resolved as a relative path under the private root, and the result is checked to be under the private root: same protocol, same host, and the same path prefix.
- Results coming back from the private file system are checked the same way before they are shown under the public root.
- The change is in commit 25359026e1.
fix: Don't reuse cached results made with different command-line options (#9318)
fix: Don't reuse cached results made with different command-line options (#9318)
Summary
With --cache, cspell lint now rechecks a file when --language-id, --locale, --report, --show-suggestions, or --validate-directives differ from the run that cached its result. Before, the cached result was reused, so a run could report issues from the wrong language, at the wrong reporting level, or without suggestions.
Existing cache files keep working.
Technical Details
- Each cached result now also records which of these options were set.
- A result cached without any of them, including every result in an existing cache file, is still reused by a run that doesn't set them either.
fix(cspell-lib): Don't scan the text of documents that won't be checked (#9311)
fix(cspell-lib): Don't scan the text of documents that won't be checked (#9311)
Summary
cspell-lib no longer searches the whole text of a document that won't be checked, such as one excluded by ignorePaths or with enabled: false. Tools built on cspell-lib that pass it such documents get their result faster, most noticeably for large files like lockfiles.
The cspell command line isn't affected: it already skips excluded files before this point.
Technical Details
- Before checking a document, cspell marks the parts of the text to skip, such as URLs and long hex strings, by searching the whole text with each ignore pattern.
- That search used to run for every document, even one that then wasn't checked, and the result was thrown away.
- Now the search runs only when the text is actually checked. Forcing a check of an excluded document still works.
- In this repository, the 38 files excluded by
ignorePaths, mostly lockfiles with 33 million characters in total, took about 1.2 seconds of this wasted work. DocumentValidator._getPreparations()is deprecated. It was only meant for use inside cspell-lib, and will be removed in a future major version.
fix: `--show-perf-summary` shows where all of the run's time goes (#9307)
fix: --show-perf-summary shows where all of the run's time goes (#9307)
Summary
--show-perf-summary now accounts for all of Total Time. Before, about a sixth of it wasn't shown anywhere. Three new lines, together with Processing Time, add up to Total Time:
- Setup Time: before the first file is checked: loading configuration and finding files.
- Between Files: between one file and the next: deciding whether to check it, and reading it.
- Other Time: everything else.
v10.3.5
Fixes
fix(cspell-lib): `shouldCheckDocument` honors the `forceCheck` option (#9303)
fix(cspell-lib): shouldCheckDocument honors the forceCheck option (#9303)
Summary
For users of the cspell-lib API:
shouldCheckDocumentnow honorsforceCheck. It returnsshouldCheck: truefor a document excluded byignorePaths, or disabled byoverridesorlanguageSettings. Before, the option was accepted but ignored.DocumentValidatoralready worked this way.SpellCheckFileOptionsnow declaresforceCheck, so it can be passed tospellCheckDocumentandspellCheckFilewith type checking.
fix: `--force-check` checks the listed files even when `ignorePaths` or `files` would skip them (#9300)
fix: --force-check checks the listed files even when ignorePaths or files would skip them (#9300)
Summary
--force-check now checks every file given with --file or --file-list, as its help says. Before, some of those files were still skipped:
- files matched by
ignorePathsin the config; - files that don't match the
filessetting in the config.
Using globs on the command line together with --force-check is now an error, the same as globs with --file:
error: mixing globs and --force-check is not supported
Before, cspell lint --file-list list.txt "**/*.md" --force-check was accepted. To filter a file list by glob, leave out --force-check.
fix: `files` globs starting with `**` no longer skip `--file` and `--file-list` files in a project under a dot folder (#9299)
fix: files globs starting with ** no longer skip --file and --file-list files in a project under a dot folder (#9299)
Summary
When a project was under a folder whose name starts with a dot, such as ~/.local/src/my-project or a git worktree in .claude/worktrees/, files given with --file or --file-list could be skipped without any warning. CSpell then reported Files checked: 0 and exited with success.
This happened when the listed files were filtered by a glob starting with **:
- from the
filessetting in the config, for--fileand--file-list; - from globs on the command line, for
--file-list, for examplecspell lint --file-list changed-files.txt "**/*.md".
These files are now checked.
- Files and folders inside the project whose names start with a dot are still left out unless
--dotorenableGlobDotis set, as before. - Checking with globs alone (
cspell lint "**/*.md") was not affected.
fix: Thai text and substitutions are checked and reported correctly (#9289)
fix: Thai text and substitutions are checked and reported correctly (#9289)
Fixes problems with checking text that cspell changes before spell checking, such as Thai text split into words with useIntlWordSegmentation, or text changed by substitutions (for example HTML entities or escaped quotes).
- Thai text no longer stops the check with an error. Checking Thai text, or any text with
useIntlWordSegmentationturned on, could stop with an internal error (AssertionError [ERR_ASSERTION]) on certain words. In cspell 10.3.3 and earlier, the file was reported as skipped and not checked. Starting with 10.3.4, the whole run failed. These files are now checked normally. The problem was found with the Thai wordกระดูกสฟีนอยด์. - Issues are reported at the right place. When text was changed more than once before checking, for example by two sets of substitutions, issues after the first change could be reported at the wrong position in the file. They are now reported where the word actually is.
- Substitutions without definitions are applied. Substitutions given directly as
[find, replacement]pairs were ignored unlesssubstitutionDefinitionswas also set. They are now always applied.
Fixes #9281
v10.3.4
Fixes
fix: Report errors (#9267)
fix: Report errors (#9267)
This pull request introduces improvements to error handling and debugging information in the spell-checking workflow. The main changes focus on providing more informative error messages and ensuring that errors encountered during document processing are surfaced promptly.
Error handling improvements:
- In
processFile(packages/cspell/src/lint/processFile.ts), the function now throws the first error fromr.errorsif any are present, ensuring that errors encountered during spell checking are not silently ignored.
Debugging and diagnostics:
- In
resolveParser(packages/cspell-lib/src/lib/Settings/CSpellSettingsServer.ts), the assertion message has been enhanced to include a list of available parsers when a requested parser is not found, making it easier to diagnose configuration issues.
fix: ParsedTag can only be boolean values for now. (#9268)
fix: ParsedTag can only be boolean values for now. (#9268)
This pull request updates the ParsedTag type throughout the codebase to remove the possibility of a string value, restricting it to only boolean or undefined. This change is applied consistently across type definitions and source files.
Note: The is possible because it has only been an experimental feature and isn't used.
Type definition changes:
- Updated the
ParsedTagtype inpackages/cspell-types/api/Parser/index.d.mtsto only allowbooleanorundefined, removing support forstring. - Updated the
ParsedTagtype inpackages/cspell-types/api/index.d.mtsto only allowbooleanorundefined, removing support forstring. - Updated the
ParsedTagtype inpackages/cspell-types/src/Parser/parser.tsto only allowbooleanorundefined, removing support forstring.
Dictionary Updates
fix: Workflow Bot -- Update Dictionaries (main) (#9266)
fix: Workflow Bot -- Update Dictionaries (main) (#9266)
Update Dictionaries (main)
Summary
.../snapshots/dart-lang/sdk/report.yaml | 6 +----
.../snapshots/dart-lang/sdk/snapshot.txt | 4 +--
.../snapshots/gitbucket/gitbucket/report.yaml | 3 +--
.../snapshots/gitbucket/gitbucket/snapshot.txt | 3 +--
packages/cspell-bundled-dicts/package.json | 6 ++---
pnpm-lock.yaml | 29 +++++++++++++---------
6 files changed, 24 insertions(+), 27 deletions(-)