From f3a435443adab606a4aeb09f879e5f8e4499fe0e Mon Sep 17 00:00:00 2001 From: Jason Dent Date: Thu, 15 Feb 2024 14:29:04 +0100 Subject: [PATCH] feat: Add `langauge` option to cspell eslint plugin fixes: #5232 --- packages/cspell-eslint-plugin/assets/options.schema.json | 5 +++++ packages/cspell-eslint-plugin/src/common/options.cts | 1 + packages/cspell-eslint-plugin/src/common/options.test.cts | 7 +++++++ 3 files changed, 13 insertions(+) diff --git a/packages/cspell-eslint-plugin/assets/options.schema.json b/packages/cspell-eslint-plugin/assets/options.schema.json index 41298158a1f..5e257f0e545 100644 --- a/packages/cspell-eslint-plugin/assets/options.schema.json +++ b/packages/cspell-eslint-plugin/assets/options.schema.json @@ -158,6 +158,11 @@ }, "type": "array" }, + "language": { + "default": "en", + "description": "Current active spelling language. This specifies the language locale to use in choosing the general dictionary.\n\nFor example:\n\n- \"en-GB\" for British English.\n- \"en,nl\" to enable both English and Dutch.", + "type": "string" + }, "words": { "description": "List of words to be considered correct.", "items": { diff --git a/packages/cspell-eslint-plugin/src/common/options.cts b/packages/cspell-eslint-plugin/src/common/options.cts index 061bd8949c7..884b4abb347 100644 --- a/packages/cspell-eslint-plugin/src/common/options.cts +++ b/packages/cspell-eslint-plugin/src/common/options.cts @@ -41,6 +41,7 @@ export type CSpellOptions = Pick< | 'ignoreRegExpList' | 'includeRegExpList' | 'import' + | 'language' | 'words' > & { dictionaryDefinitions?: DictionaryDefinition[]; diff --git a/packages/cspell-eslint-plugin/src/common/options.test.cts b/packages/cspell-eslint-plugin/src/common/options.test.cts index 6723ed36525..8d5cfc496a8 100644 --- a/packages/cspell-eslint-plugin/src/common/options.test.cts +++ b/packages/cspell-eslint-plugin/src/common/options.test.cts @@ -11,4 +11,11 @@ describe('options', () => { const settings: CSpellSettings = options.cspell; assert(settings, 'it is expected to compile.'); }); + + test('Make sure `language` is allowed.', () => { + const options: Options = { ...defaultOptions, cspell: { language: 'en-gb' } }; + assert(options.cspell); + const settings: CSpellSettings = options.cspell; + assert(settings, 'it is expected to compile.'); + }); });