Overview of @cspell/cspell-service-bus
main@cspell/cspell-service-bus is a library designed to connect requests to services capable of fulfilling them. It acts as a communication layer or bus for routing requests to appropriate service providers.repository·main·Indexed 23 days ago
https://github.com/streetsidesoftware/cspellA powerful spell checker specifically designed for code, provided as a mono-repo. It includes a CLI, ESLint integration via @cspell/eslint-plugin, and various libraries for dictionary management, such as cspell-config, cspell-dictionary, and @cspell/cspell-bundled-dicts. It supports programmatic invocation via the lint() function and provides a dictionary-bundler-plugin for build tools including Vite, Rollup, esbuild, Webpack, Rspack, Rolldown, and tsdown.
@cspell/cspell-service-bus is a library designed to connect requests to services capable of fulfilling them. It acts as a communication layer or bus for routing requests to appropriate service providers.CSpell is organized as a monorepo containing several specialized packages. Depending on your use case, you may need different components:
cspell for the standard command-line spelling checker.@cspell/eslint-plugin to integrate spell checking into your ESLint workflow.cspell-lib if you want to perform code-driven spelling checks within your own applications.cspell-types to access TypeScript definitions and JSON schemas for CSpell configuration files.cspell-bundled-dicts provides the standard collection of dictionaries used by the tool.cspell-glob, cspell-io, cspell-trie-lib, and hunspell-reader provide specialized I/O, globbing, and data structure support used by the core engine.cspell-dictionary library is designed to facilitate the creation of in-memory dictionaries. This is useful when you need to provide a custom set of words for spell checking during runtime without relying on external files.@cspell/cspell-performance-monitor package provides a library of methods designed to measure performance metrics within CSpell. It is built upon the standard Web Performance API.The @cspell/cspell-worker package is designed to enable spelling checking of documents on a NodeJS worker thread. This allows you to offload the CPU-intensive spelling check process from the main thread, preventing UI or main-loop blocking in NodeJS applications.
CAUTION This package is currently experimental. Its exports and APIs are subject to change.
Simple RPC is a basic client/server Remote Procedure Call implementation designed for sending requests over a MessagePort. It is compatible with environments providing a MessagePortLike interface, such as Node.js Worker Threads or Web Workers.
Communication is handled via RPCMessage objects sent over the MessagePort. Each message includes a signature (sig: 'RPC0'), a unique identifier (id), and a type indicating the message's purpose.
export interface RPCMessage {
sig: 'RPC0';
/**
* A Unique identifier for the request/response.
* Ideally this is a randomUUID.
*/
id: RequestID;
/**
* The type of message being sent.
*/
type: 'request' | 'response' | 'cancel' | 'canceled' | 'ok' | 'ready';
}
export type RPCRequestType = 'request' | 'cancel' | 'ok' | 'ready';
export type RPCResponseType = 'response' | 'canceled' | 'ok' | 'ready';languageId refers to file types (e.g., javascript, python, markdown) rather than spoken languages (e.g., English, German). This terminology is used for historical reasons to maintain compatibility with VSCode conventions. The languageId determines which dictionaries are enabled, which rules apply, and whether a file is subject to spell-checking.You can add spell check settings directly into your source code using comments. This is useful for file-specific configurations that shouldn't apply to the entire project. All settings must be prefixed with cSpell:, spell-checker:, or spellchecker:.
Supported settings include:
disable / enable: Turn the spell checker on or off.ignore: Specify a list of words to ignore for the entire file.words: Specify a list of words to be considered correct (added to suggestions) for the entire file.ignoreRegExp: Any text matching this regular expression will NOT be checked.includeRegExp: Only text matching this regular expression will be checked.enableCompoundWords / disableCompoundWords: Allow or disallow joined words (e.g., "stringlength"). Note: The last setting in the file determines the value for the entire file.dictionaries: Specify a list of dictionary names to use.// cSpell:words woorxs sweeetbeat
// cSpell:ignore zaallano, wooorrdd
// cSpell:enableCompoundWords
// cSpell:ignoreRegExp 0x[0-9a-f]+CSpell uses a simple strategy of splitting camelCase and snake_case words before checking them against known dictionaries.
Examples of splitting:
camelCase $\rightarrow$ camel caseHTMLInput $\rightarrow$ html inputsrcCode $\rightarrow$ src codesnake_case_words $\rightarrow$ snake case wordscamel2snake $\rightarrow$ camel snake (the 2 is ignored)function parseJson(text: string) $\rightarrow$ function parse json text stringSpecial Cases & Limitations:
\n or \t are removed if the resulting word doesn't match. For example, \narrow becomes narrow (a match), but \ncode becomes ncode (not a match).english instead of English.jsj is ignored, but jsja is checked).CSpell dictionaries can operate in two modes: case-insensitive (default) or case-sensitive.
To enable fast lookups while maintaining flexibility, case-sensitive dictionaries store words using the ~ prefix to indicate that case or accents have been normalized.