ESLint plugin that integrates CSpell spell checking capabilities directly into the ESLint workflow for catching spelling errors in code.
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Core plugin setup and configuration options for integrating spell checking into ESLint workflows.
Main configuration interface for the CSpell ESLint plugin.
/**
* Main configuration options for the CSpell ESLint plugin
*/
interface Options extends Check {
/**
* Number of spelling suggestions to make.
* @default 8
*/
numSuggestions: number;
/**
* Generate suggestions
* @default true
*/
generateSuggestions: boolean;
/**
* Automatically fix common mistakes.
* This is only possible if a single preferred suggestion is available.
* @default false
*/
autoFix: boolean;
/**
* Output debug logs to `.cspell-eslint-plugin.log`
* @default false
*/
debugMode?: boolean;
}Spell checking behavior configuration options.
/**
* Configuration options for spell checking behavior
*/
interface Check {
/**
* Ignore import and require names
* @default true
*/
ignoreImports?: boolean;
/**
* Ignore the properties of imported variables, structures, and types.
* Example: import { example } from 'third-party';
* const msg = example.property; // `property` is not spell checked.
* @default true
*/
ignoreImportProperties?: boolean;
/**
* Spell check identifiers (variables names, function names, class names, etc.)
* @default true
*/
checkIdentifiers?: boolean;
/**
* Spell check strings
* @default true
*/
checkStrings?: boolean;
/**
* Spell check template strings
* @default true
*/
checkStringTemplates?: boolean;
/**
* Spell check JSX Text
* @default true
*/
checkJSXText?: boolean;
/**
* Spell check comments
* @default true
*/
checkComments?: boolean;
/**
* Path to the cspell configuration file.
* Relative paths, will be relative to the current working directory.
* @since 8.8.0
*/
configFile?: string;
/**
* CSpell options to pass to the spell checker.
*/
cspell?: CSpellOptions;
/**
* Specify the root path of the cspell configuration.
* It is used to resolve `imports` found in cspell.
* Example: import.meta.url or __filename
*/
cspellOptionsRoot?: string | URL;
/**
* Specify a path to a custom word list file.
* Example: "./myWords.txt"
*/
customWordListFile?: CustomWordListFilePath | CustomWordListFile | undefined;
/**
* Scope selectors to spell check.
* This is a list of scope selectors to spell check.
* @since 8.9.0
*/
checkScope?: ScopeSelectorList;
}Default configuration values for the plugin.
/**
* Default options for the CSpell ESLint plugin
*/
const defaultOptions: Options;Usage Examples:
import { defaultOptions, defineCSpellPluginOptions } from '@cspell/eslint-plugin';
// Using default options
const config = {
plugins: { '@cspell': cspellPlugin },
rules: {
'@cspell/spellchecker': ['warn', defaultOptions]
}
};
// Customizing options
const customOptions = defineCSpellPluginOptions({
numSuggestions: 5,
autoFix: true,
checkComments: false,
cspell: {
words: ['customword', 'companyname'],
dictionaries: ['typescript', 'node']
}
});Advanced configuration for targeting specific AST contexts.
/**
* The scope selector is a string that defines the context in which a rule applies.
* Examples:
* - 'YAMLPair[value] YAMLScalar' - check the value of a YAML pair.
* - 'YAMLPair[key] YAMLScalar' - check the key of a YAML pair.
*/
type ScopeSelector = string;
/**
* A scope selector entry is a tuple that defines a scope selector and whether to spell check it.
*/
type ScopeSelectorEntry = [ScopeSelector, boolean];
/**
* A list of scope selectors.
*/
type ScopeSelectorList = ScopeSelectorEntry[];Usage Example:
// Check specific YAML and JSON contexts
const options = {
checkScope: [
['YAMLPair[key] YAMLScalar', true],
['YAMLPair[value] YAMLScalar', true],
['YAMLSequence[entries] YAMLScalar', true],
['JSONProperty[key] JSONLiteral', true],
['JSONProperty[value] JSONLiteral', true],
['JSONArrayExpression JSONLiteral', true],
]
};Configuration for custom dictionaries and word lists.
/**
* Specify a path to a custom word list file
*/
type CustomWordListFilePath = string;
/**
* Custom word list file configuration
*/
interface CustomWordListFile {
/**
* Path to word list file.
* File format: 1 word per line
*/
path: CustomWordListFilePath;
}Usage Example:
// Using custom word list file path
const options = {
customWordListFile: './company-terms.txt'
};
// Using custom word list file object
const options = {
customWordListFile: {
path: './technical-terms.txt'
}
};