Skip to content

[Bug]: cspell fails when have a directory with name constructor in it #7194

@AlexeyDmitriev

Description

@AlexeyDmitriev

Kind of Issue

Crash / Error

Tool or Library

cspell

Version

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

  1. Go to any directory (it may or may not have a directory called constructor in it)
  2. Run ➜ ~ /path/to/cspell constructor
  3. 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)
  1. Run ➜ ~ /path/to/cspell example/of/path/with/constructor/in/it
  2. 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)

cspell.json

{}

cspell.config.yaml

Example Repository

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions