Top Related Projects
Quick Overview
CSpell is a spell checker for code, designed to catch common misspellings while ignoring code syntax and structure. It supports multiple programming languages and can be integrated into various development environments and workflows, making it an essential tool for maintaining clean and professional code.
Pros
- Supports a wide range of programming languages and file types
- Easily customizable with user-defined dictionaries and settings
- Integrates well with popular code editors and CI/CD pipelines
- Actively maintained and regularly updated
Cons
- May produce false positives for domain-specific terminology
- Configuration can be complex for advanced use cases
- Performance may slow down with very large codebases
- Limited support for non-English languages
Code Examples
- Basic usage in a Node.js script:
const { CSpell } = require('cspell');
const text = 'This is a smple exmple with misspelled wrds.';
const cspell = new CSpell();
cspell.checkText(text).then(issues => {
console.log(issues);
});
- Using CSpell with custom dictionary:
const { CSpell } = require('cspell');
const customDictionary = ['customword1', 'customword2'];
const cspell = new CSpell({
dictionaries: ['en_US', { name: 'custom', words: customDictionary }]
});
cspell.checkText('This is a customword1 in the text.').then(issues => {
console.log(issues);
});
- Checking a file:
const { CSpell } = require('cspell');
const fs = require('fs');
const cspell = new CSpell();
const fileContent = fs.readFileSync('path/to/file.txt', 'utf8');
cspell.checkText(fileContent, 'path/to/file.txt').then(issues => {
console.log(issues);
});
Getting Started
To use CSpell in your project, follow these steps:
- Install CSpell:
npm install cspell
- Create a configuration file (cspell.json) in your project root:
{
"version": "0.2",
"language": "en",
"words": [],
"flagWords": [],
"ignorePaths": []
}
- Run CSpell on your project:
npx cspell "**/*.{js,ts,html,css}"
This will check all JavaScript, TypeScript, HTML, and CSS files in your project for spelling errors.
Competitor Comparisons
Source code spell checker
Pros of typos
- Written in Rust, offering better performance and memory safety
- Supports multiple file formats beyond just code (e.g., Markdown, LaTeX)
- Provides a simple, straightforward CLI interface
Cons of typos
- Smaller community and ecosystem compared to cspell
- Less extensive configuration options and customization features
- Limited integration with IDEs and text editors
Code Comparison
cspell configuration example:
{
"language": "en",
"words": ["customword"],
"ignoreWords": ["ignoredword"],
"import": ["./custom-dictionary.txt"]
}
typos configuration example:
[default]
extend-ignore-re = [
"customword",
]
extend-ignore-identifiers-re = [
"ignoredword",
]
Both tools offer configuration options, but cspell provides more granular control over language settings and dictionary management. typos focuses on a simpler approach with regex-based ignore patterns.
While cspell is more widely adopted and offers extensive integrations, typos excels in performance and supports a broader range of file formats. The choice between the two depends on specific project requirements, team preferences, and the need for customization versus simplicity.
:pencil: A markup-aware linter for prose built with speed and extensibility in mind.
Pros of Vale
- More comprehensive linting capabilities, including style, grammar, and consistency checks
- Highly customizable with support for custom rules and styles
- Integration with multiple markup formats (Markdown, AsciiDoc, reStructuredText)
Cons of Vale
- Steeper learning curve due to more complex configuration
- Potentially slower performance for large documents compared to CSpell
- Requires more setup and maintenance for custom rules
Code Comparison
Vale configuration example:
StylesPath = styles
MinAlertLevel = suggestion
[*.md]
BasedOnStyles = Vale, proselint
CSpell configuration example:
{
"version": "0.2",
"language": "en",
"words": ["customword", "anotherword"],
"ignoreWords": ["ignoredword"]
}
Both tools offer configuration options, but Vale's configuration is more extensive and allows for more fine-grained control over linting rules and styles. CSpell's configuration is simpler and primarily focused on managing custom dictionaries and ignored words.
Catch insensitive, inconsiderate writing
Pros of Alex
- Focuses on inclusive and non-offensive language, promoting better communication
- Integrates well with various text editors and CI/CD pipelines
- Provides explanations for flagged issues, helping users understand and learn
Cons of Alex
- More limited in scope compared to CSpell's general spell-checking capabilities
- May have a higher rate of false positives due to context-sensitive nature of language
- Requires more manual configuration for project-specific terminology
Code Comparison
Alex usage:
const alex = require('alex');
const report = alex('He\'s very talented.');
console.log(report);
CSpell usage:
const cspell = require('cspell');
const result = cspell.spellFile('document.txt');
console.log(result);
Both tools can be integrated into various workflows and offer CLI usage. Alex focuses on identifying potentially insensitive language, while CSpell provides broader spell-checking functionality. Alex may be more suitable for content-heavy projects where inclusive language is a priority, whereas CSpell excels in catching general spelling errors across various file types, making it more versatile for code-centric projects.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
CSpell
The CSpell mono-repo, a spell checker for code.
Support Future Development
Documentation
Third-Party Video Presentations
Some videos related to CSpell and the Code Spell Checker for VS Code.
- Spell Checking Documentation in DevOps Pipelines by Houssem Dellai
- Don't Worry About Spelling...VS Code Can Do It For You!! by James Q Quick
- Spell Checking In VSCode - VSCode Pro Tips
- Spell Check in VS Code with Code Spell Checker - Extension Highlight
- Spell check your code from the command line with Cspell
- How to Use VS Code Spell Checker - Detailed walkthrough to setup and use multiple languages
- Code Spell Checker Extension for Visual Studio Code
Packages
- cspell -- cspell command-line application
- @cspell/eslint-plugin -- CSpell ESLint Plugin
- cspell-bundled-dicts -- collection of dictionaries bundled with cspell.
- cspell-glob -- glob library.
- cspell-io -- i/o library.
- cspell-lib -- cspell library used for code driven spelling checking (used by the application).
- cspell-types -- cspell types and JSON schema for cspell configuration files.
- cspell-tools -- tool used to compile dictionaries.
- cspell-trie-lib -- trie data structure used to store words.
- cspell-trie -- trie data tool used to store words.
- hunspell-reader -- reads Hunspell files and outputs words.
Related Packages
-
cspell-cli --
cspell-cli
is useful for includingcspell
directly from GitHub.Example install:
npm install -g git+https://github.com/streetsidesoftware/cspell-cli
.This will add the
cspell-cli
command, which is an alias of thecspell
command.
Live Discussions
Join us on:
RFCs
Link | Description | Status |
---|---|---|
rfc-0001 | Fixing common misspellings | Done |
rfc-0002 | Improving Generated Suggestions | Done |
rfc-0003 | Plug-ins: Adding file parsers | In Progress |
rfc-0004 | Support Marking Issues as Known | Not started |
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.
Security contact information
To report a security vulnerability, please email security@streetsidesoftware.com or use the Tidelift security contact. Tidelift will coordinate the fix and disclosure.
Versions
version | Node | Status | Maintenance | End of Free Support | |
---|---|---|---|---|---|
cspell | 8.x | 18.x | In Active Development | TBD | TBD |
cspell | 7.x | 16.x | Maintenance | 2023-10-01 | 2023-11-07 |
cspell | 6.x | 14.14.x | Paid support only1 | 2023-04-01 | 2023-05-01 |
cspell | 5.x | 12.x | Paid support only1 | - | 2022-10-01 |
cspell | 4.x | 10.x | Paid support only1 | - | 2022-05-01 |
Contributing
Contributions are welcome! See our contribution notes. Note: To add or remove words in a dictionary, visit cspell-dicts.
ð Special thanks to all of our amazing contributors! ð¥°
Brought to you by Street Side Software
Footnotes
Top Related Projects
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot