You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: cspell fails when have a directory with name constructor in it #7194
8.19.0 [8.17.5 already fails, 8.12.1 is fine, I didn't bisect further]
Supporting Library
Not sure / None
OS
Linux
OS Version
ubuntu 20.04
Description
Running cspell with a path that contains directory called constructor in it fails with Linter error inside picomatch (expected string to call .startsWith("./") on it, but [Function: Object] is given (Even before opening files))
Steps to Reproduce
Go to any directory (it may or may not have a directory called constructor in it)
Run ➜ ~ /path/to/cspell constructor
See result:
TypeError: output.startsWith is not a function
at exports.removePrefix (/home/alexeyd/node_modules/picomatch/lib/utils.js:48:14)
at parse (/home/alexeyd/node_modules/picomatch/lib/parse.js:130:17)
at picomatch.makeRe (/home/alexeyd/node_modules/picomatch/lib/picomatch.js:298:14)
at micromatch.makeRe (/home/alexeyd/node_modules/micromatch/index.js:392:44)
at file:///home/alexeyd/node_modules/cspell-glob/dist/GlobMatcher.js:98:24
at Array.map (<anonymous>)
at buildMatcherFn (file:///home/alexeyd/node_modules/cspell-glob/dist/GlobMatcher.js:94:10)
at new GlobMatcher (file:///home/alexeyd/node_modules/cspell-glob/dist/GlobMatcher.js:58:24)
at buildGlobMatcher (file:///home/alexeyd/node_modules/cspell/dist/esm/util/glob.js:83:12)
at normalizeGlobsToRoot (file:///home/alexeyd/node_modules/cspell/dist/esm/util/glob.js:91:43)
Run ➜ ~ /path/to/cspell example/of/path/with/constructor/in/it
See result:
Linter Error: output.startsWith is not a function
-------------------------------------------
CSpell: Files checked: 0, Issues found: 0 in 0 files with 1 error.
Expected Behavior
File is checked for correctness (if it doesn't exists then something else)
Additional Information
That happens with empty cspell.json as well as with no cspell.json at all (not sure it's read by this point)
In that case, I suggest using --file or --file-list:
--file-list <path or stdin> Specify a list of files to be spell checked. The
list is filtered against the glob file patterns.
Note: the format is 1 file path per line.
--file [file...] Specify files to spell check. They are filtered
by the [globs...].
Activity
Jason3S commentedon Apr 17, 2025
@AlexeyDmitriev,
Thank you. I'll follow up with
picomatch.Jason3S commentedon Apr 17, 2025
There seem to be an old PR: micromatch/picomatch#132
Jason3S commentedon Apr 18, 2025
I have opened a PR: micromatch/picomatch#144
Jason3S commentedon Apr 18, 2025
@AlexeyDmitriev,
This is a bug, but there isn't a lot I can do about it until picomatch is fixed.
But there are workarounds: Do you globs actually have
constructorin them? Or are the trying to spell check a filename?The
--fileoption allows you to specify file names instead of globs.If you must have
constructorin the glob, consider using:{}Look at
cspell lint --helpfor more options.AlexeyDmitriev commentedon Apr 19, 2025
I only ever pass list of file generated automatically (and some of them happen to have constructor in it). I'll try to workaround with
--fileJason3S commentedon Apr 19, 2025
@AlexeyDmitriev,
In that case, I suggest using
--fileor--file-list:AlexeyDmitriev commentedon Apr 24, 2025
that helped indeed, thank you
github-actions commentedon May 25, 2025
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.