What is @cspell/cspell-types?
@cspell/cspell-types is a TypeScript library that provides type definitions for the CSpell spelling checker configuration. It allows developers to define and manage spelling configurations programmatically, ensuring that their spelling rules are consistent and easily maintainable.
What are @cspell/cspell-types's main functionalities?
Define CSpell Configuration
This feature allows you to define a CSpell configuration using TypeScript. You can specify the language, custom words, paths to ignore, and dictionaries to use.
{
"import { CSpellUserSettings } from '@cspell/cspell-types';
const config: CSpellUserSettings = {
language: 'en',
words: ['typescript', 'npm'],
ignorePaths: ['node_modules', 'dist'],
dictionaries: ['softwareTerms']
};
console.log(config);"
}
Extend Existing Configuration
This feature demonstrates how to extend an existing CSpell configuration. You can merge configurations to add new words or ignore paths while keeping the base configuration intact.
{
"import { CSpellUserSettings } from '@cspell/cspell-types';
const baseConfig: CSpellUserSettings = {
language: 'en',
words: ['typescript']
};
const extendedConfig: CSpellUserSettings = {
...baseConfig,
words: [...baseConfig.words, 'npm'],
ignorePaths: ['node_modules']
};
console.log(extendedConfig);"
}
Validate Configuration
This feature allows you to validate a CSpell configuration to ensure it meets the required schema. The `validateConfig` function checks the configuration and returns any validation errors.
{
"import { CSpellUserSettings, validateConfig } from '@cspell/cspell-types';
const config: CSpellUserSettings = {
language: 'en',
words: ['typescript', 'npm'],
ignorePaths: ['node_modules', 'dist'],
dictionaries: ['softwareTerms']
};
const validationResult = validateConfig(config);
console.log(validationResult);"
}
Other packages similar to @cspell/cspell-types
eslint
ESLint is a tool for identifying and reporting on patterns found in ECMAScript/JavaScript code. It helps developers maintain code quality and consistency. Unlike @cspell/cspell-types, which focuses on spelling, ESLint focuses on code linting and style enforcement.
stylelint
Stylelint is a linter for CSS and other style sheet languages. It helps developers avoid errors and enforce consistent conventions in their styles. While @cspell/cspell-types is for spelling configurations, Stylelint is specifically for style sheet linting.
prettier
Prettier is an opinionated code formatter that supports many languages. It enforces a consistent style by parsing your code and re-printing it with its own rules. Unlike @cspell/cspell-types, which is for spelling configurations, Prettier focuses on code formatting.
Cspell Types
Contains cspell types and json-schema.
This package contains no dependencies to avoid any security issues.
Support Future Development
Installation
npm i -S @cspell/cspell-types
Usage
Can be use to make writing cspell.config.js
files easier.
'use strict';
const cspell = {
description: 'cspell.config.js file in samples/js-config',
languageSettings: [
{
languageId: 'cpp',
allowCompoundWords: false,
patterns: [
{
name: 'pound-includes',
pattern: /^\s*#include.*/g
}
],
ignoreRegExpList: ['pound-includes']
}
],
dictionaryDefinitions: [
{
name: 'custom-words',
path: './custom-words.txt'
}
],
dictionaries: ['custom-words']
};
module.exports = cspell;
API
CSpellSettings
alias CSpellUserSettings
is the formal definition of the configuration that controls the spell checker.
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 by Street Side Software