Skip to main content

Globs

Globs are used extensively by CSpell to determine which files to check and what settings to apply.

Here are some of the places globs are used:

LocationModeNote
files[]strictThe glob patterns used to search for files to spell check.
ignorePaths[]looseGlob patterns used to exclude files and directories from being checked. ! are only partially supported due to an issue with the Glob library1
overrides[].filenamelooseUsed to apply configuration settings to files whose path matches the glob

Mode - Strict

Strict mode is used to explicitly select files to be checked. It gives more nuanced control over the file search process.

Examples:

GlobMeaning
*.mdOnly check the Markdown files in the current directory. It will not scan subdirectories.
*.{md,js} or {*.md,*.js}Only check the Markdown or JavaScript files in the current directory. It will not scan subdirectories.
**/*.mdScan all directories (except hidden ones starting with .) looking for markdown files.
**/{*,.*}/**/*.mdScan all directories including a hidden one looking for markdown files. Does not match *.md in root.
src/**Scan the src directory looking for all non-hidden files.
**Use the --dot option to include hidden directories or files.
**/.*Scan for only hidden files.

Mode - Loose

Loose mode is used to match files that have been found. It is designed to emulate .gitignore rules closely. By default, loose mode matches hidden files and directories.

Examples:

GlobMeaning
*.mdWill match against any path containing *.md
node_modulesWill match against any path containing node_modules
/node_modulesMatches against ./node_modules and all contained files. It will not match nested paths like: ./package/node_modules/*
/node_modules/Matches the ./node_modules directory and any files it contains.
/node_modules/**Same as /node_modules/
testMatches any directory or file called test. Equivalent to using both **/test and **/test/**.
**/test/**Similar to test, but only matches paths contained in a test directory.