New:Microsoft Teams Notifications Are Now Available in Socket.Learn more
Get Started

cspell-glob

Package Overview
Dependencies
Maintainers
1
Versions
331
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cspell-glob

Glob matcher for cspell

Source
npmnpm
Version
10.3.2
Version published
Weekly downloads
1.3M
8.17%
Maintainers
1
Weekly downloads
 
Created
Source

cspell-glob

A simple library for checking filenames against a set of glob rules. It attempts to emulate the .gitignore rules.

Purpose

The purpose behind this library is a bit different than the other glob matchers. The goal here is to see if a file name matches a glob, not to find files that match globs. This library doesn't do any file i/o. It uses micromatch under the hood for the actual matching.

Usage

import { GlobMatcher } from 'cspell-glob';

// Patterns behave like the contents of a `.gitignore` file.
const patterns = ['*.test.js', '!important.test.js'];

const matcher = new GlobMatcher(patterns, process.cwd());

matcher.match('src/app.test.js'); // true -- matches `*.test.js`
matcher.match('src/important.test.js'); // false -- excluded by the negated pattern
matcher.match('src/app.js'); // false -- does not match any pattern

By default, GlobMatcher runs in exclude mode (like .gitignore). Use include mode when searching for files to check, where patterns must be more explicit to match:

const matcher = new GlobMatcher(['src/**/*.ts'], { root: process.cwd(), mode: 'include' });

matcher.match('src/app.ts'); // true
matcher.match('node_modules/lib/index.ts'); // false

CSpell for Enterprise

Available as part of the Tidelift Subscription.

The maintainers of cspell and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source packages you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact packages you use. Learn more.


Brought to you byStreet Side Software Logo Street Side Software

Keywords

cspell

FAQs

Package last updated on 15 Sep 2026

Related posts