diff --git a/cspell.schema.json b/cspell.schema.json index 1706b6abd826..f42761607834 100644 --- a/cspell.schema.json +++ b/cspell.schema.json @@ -874,6 +874,11 @@ }, "type": "array" }, + "loadDefaultConfiguration": { + "default": "true;", + "description": "By default, the bundled dictionary configurations are loaded. Explicitly setting this to `false` will prevent ALL default configuration from being loaded.", + "type": "boolean" + }, "maxDuplicateProblems": { "default": 5, "description": "The maximum number of times the same word can be flagged as an error in a file.", @@ -1317,6 +1322,11 @@ }, "type": "array" }, + "loadDefaultConfiguration": { + "default": "true;", + "description": "By default, the bundled dictionary configurations are loaded. Explicitly setting this to `false` will prevent ALL default configuration from being loaded.", + "type": "boolean" + }, "maxDuplicateProblems": { "default": 5, "description": "The maximum number of times the same word can be flagged as an error in a file.", diff --git a/packages/cspell-lib/api/api.d.ts b/packages/cspell-lib/api/api.d.ts index 1d0edd67bc68..29f0061b2223 100644 --- a/packages/cspell-lib/api/api.d.ts +++ b/packages/cspell-lib/api/api.d.ts @@ -509,7 +509,8 @@ interface ConfigurationDependencies { } declare function extractDependencies(settings: CSpellSettingsWSTO | CSpellSettingsI): ConfigurationDependencies; -declare function getDefaultSettings(): CSpellSettingsInternal; +declare function getDefaultSettings(useDefaultDictionaries?: boolean): CSpellSettingsInternal; +declare function getDefaultBundledSettings(): CSpellSettingsInternal; declare class ImportError extends Error { readonly cause: Error | undefined; @@ -797,4 +798,4 @@ declare function resolveFile(filename: string, relativeTo: string): ResolveFileR declare function clearCachedFiles(): Promise; declare function getDictionary(settings: CSpellUserSettings): Promise; -export { CheckTextInfo, ConfigurationDependencies, CreateTextDocumentParams, DetermineFinalDocumentSettingsResult, Document, DocumentValidator, DocumentValidatorOptions, ENV_CSPELL_GLOB_ROOT, ExcludeFilesGlobMap, ExclusionFunction, exclusionHelper_d as ExclusionHelper, ImportError, ImportFileRefWithError, IncludeExcludeFlag, IncludeExcludeOptions, index_link_d as Link, Logger, SpellCheckFileOptions, SpellCheckFileResult, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryLoadError, SuggestOptions, SuggestedWord, SuggestionError, SuggestionOptions, SuggestionsForWordResult, text_d as Text, TextDocument, TextDocumentLine, TextInfoItem, TraceOptions, TraceResult, ValidationIssue, calcOverrideSettings, checkFilenameMatchesGlob, checkText, clearCachedFiles, clearCachedSettingsFiles, combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, createSpellingDictionary, createTextDocument, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, defaultFileName as defaultSettingsFilename, determineFinalDocumentSettings, extractDependencies, extractImportErrors, fileToDocument, finalizeSettings, getCachedFileSize, getDefaultSettings, getDictionary, getGlobalSettings, getLanguagesForExt, getLogger, getSources, isBinaryFile, isSpellingDictionaryLoadError, loadConfig, loadPnP, loadPnPSync, mergeInDocSettings, mergeSettings, readRawSettings, readSettings, readSettingsFiles, refreshDictionaryCache, resolveFile, searchForConfig, sectionCSpell, setLogger, spellCheckDocument, spellCheckFile, suggestionsForWord, suggestionsForWords, traceWords, traceWordsAsync, updateTextDocument, validateText }; +export { CheckTextInfo, ConfigurationDependencies, CreateTextDocumentParams, DetermineFinalDocumentSettingsResult, Document, DocumentValidator, DocumentValidatorOptions, ENV_CSPELL_GLOB_ROOT, ExcludeFilesGlobMap, ExclusionFunction, exclusionHelper_d as ExclusionHelper, ImportError, ImportFileRefWithError, IncludeExcludeFlag, IncludeExcludeOptions, index_link_d as Link, Logger, SpellCheckFileOptions, SpellCheckFileResult, SpellingDictionary, SpellingDictionaryCollection, SpellingDictionaryLoadError, SuggestOptions, SuggestedWord, SuggestionError, SuggestionOptions, SuggestionsForWordResult, text_d as Text, TextDocument, TextDocumentLine, TextInfoItem, TraceOptions, TraceResult, ValidationIssue, calcOverrideSettings, checkFilenameMatchesGlob, checkText, clearCachedFiles, clearCachedSettingsFiles, combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, createSpellingDictionary, createTextDocument, currentSettingsFileVersion, defaultConfigFilenames, defaultFileName, defaultFileName as defaultSettingsFilename, determineFinalDocumentSettings, extractDependencies, extractImportErrors, fileToDocument, finalizeSettings, getCachedFileSize, getDefaultBundledSettings, getDefaultSettings, getDictionary, getGlobalSettings, getLanguagesForExt, getLogger, getSources, isBinaryFile, isSpellingDictionaryLoadError, loadConfig, loadPnP, loadPnPSync, mergeInDocSettings, mergeSettings, readRawSettings, readSettings, readSettingsFiles, refreshDictionaryCache, resolveFile, searchForConfig, sectionCSpell, setLogger, spellCheckDocument, spellCheckFile, suggestionsForWord, suggestionsForWords, traceWords, traceWordsAsync, updateTextDocument, validateText }; diff --git a/packages/cspell-lib/src/Models/PatternRegExp.test.ts b/packages/cspell-lib/src/Models/PatternRegExp.test.ts new file mode 100644 index 000000000000..e78e8006e9f2 --- /dev/null +++ b/packages/cspell-lib/src/Models/PatternRegExp.test.ts @@ -0,0 +1,13 @@ +import { PatternRegExp } from './PatternRegExp'; + +describe('Pattern', () => { + test.each` + pattern | expected + ${/\b\w+/gi} | ${/\b\w+/gi} + ${'.*'} | ${/.*/} + `('pattern $pattern', ({ pattern, expected }) => { + const pat = new PatternRegExp(pattern); + expect(JSON.stringify(pat)).toEqual(JSON.stringify(expected.toString())); + expect(pat).toEqual(expected); + }); +}); diff --git a/packages/cspell-lib/src/Models/PatternRegExp.ts b/packages/cspell-lib/src/Models/PatternRegExp.ts new file mode 100644 index 000000000000..88346554dfcf --- /dev/null +++ b/packages/cspell-lib/src/Models/PatternRegExp.ts @@ -0,0 +1,9 @@ +export class PatternRegExp extends RegExp { + constructor(pattern: RegExp | string) { + super(pattern); + } + + toJSON() { + return this.toString(); + } +} diff --git a/packages/cspell-lib/src/Settings/CSpellSettingsServer.test.ts b/packages/cspell-lib/src/Settings/CSpellSettingsServer.test.ts index 1fd1643b5161..6fb8b11b4197 100644 --- a/packages/cspell-lib/src/Settings/CSpellSettingsServer.test.ts +++ b/packages/cspell-lib/src/Settings/CSpellSettingsServer.test.ts @@ -12,7 +12,7 @@ import { __testing__ as __configLoader_testing__, } from './configLoader'; import { calcOverrideSettings, checkFilenameMatchesGlob, getSources, mergeSettings } from './CSpellSettingsServer'; -import { getDefaultSettings, _defaultSettings } from './DefaultSettings'; +import { getDefaultBundledSettings, _defaultSettings } from './DefaultSettings'; const rootCspellLib = path.resolve(path.join(__dirname, '../..')); const samplesDir = path.resolve(rootCspellLib, 'samples'); @@ -246,19 +246,19 @@ describe('Validate CSpellSettingsServer', () => { test('makes sure global settings is an object', () => { const settings = getGlobalSettings(); expect(Object.keys(settings)).not.toHaveLength(0); - const merged = mergeSettings(getDefaultSettings(), getGlobalSettings()); + const merged = mergeSettings(getDefaultBundledSettings(), getGlobalSettings()); expect(Object.keys(merged)).not.toHaveLength(0); }); test('verify clearing the file cache works', () => { - mergeSettings(getDefaultSettings(), getGlobalSettings()); + mergeSettings(getDefaultBundledSettings(), getGlobalSettings()); expect(getCachedFileSize()).toBeGreaterThan(0); clearCachedSettingsFiles(); expect(getCachedFileSize()).toBe(0); }); test('the loaded defaults contain expected settings', () => { - const settings = getDefaultSettings(); + const settings = getDefaultBundledSettings(); const sources = getSources(settings); const sourceNames = sources.map((s) => s.name || '?'); expect(sourceNames).toEqual(expect.arrayContaining([_defaultSettings.name])); diff --git a/packages/cspell-lib/src/Settings/DefaultSettings.test.ts b/packages/cspell-lib/src/Settings/DefaultSettings.test.ts index fb23aa94f172..cf7c7c1cda50 100644 --- a/packages/cspell-lib/src/Settings/DefaultSettings.test.ts +++ b/packages/cspell-lib/src/Settings/DefaultSettings.test.ts @@ -7,7 +7,11 @@ describe('Validate Default Settings', () => { }); test('tests the default setting file is loaded', () => { - const defaultSetting = DefaultSettings.getDefaultSettings(); + const defaultSetting = DefaultSettings.getDefaultBundledSettings(); expect(defaultSetting.name).toBe('cspell default settings'); }); + + test('default', () => { + expect(DefaultSettings.getDefaultBundledSettings()).toEqual(DefaultSettings.getDefaultSettings(undefined)); + }); }); diff --git a/packages/cspell-lib/src/Settings/DefaultSettings.ts b/packages/cspell-lib/src/Settings/DefaultSettings.ts index 3bb9b2cce129..4c4d89b96950 100644 --- a/packages/cspell-lib/src/Settings/DefaultSettings.ts +++ b/packages/cspell-lib/src/Settings/DefaultSettings.ts @@ -1,5 +1,6 @@ import type { PredefinedPatterns, RegExpPatternDefinition } from '@cspell/cspell-types'; import { createCSpellSettingsInternal, CSpellSettingsInternal } from '../Models/CSpellSettingsInternalDef'; +import { PatternRegExp } from '../Models/PatternRegExp'; import { resolveFile } from '../util/resolveFile'; import { readSettings } from './configLoader'; import { mergeSettings } from './index'; @@ -12,9 +13,9 @@ const defaultConfigFileModuleRef = '@cspell/cspell-bundled-dicts/cspell-default. const defaultConfigFile = resolveConfigModule(defaultConfigFileModuleRef); const regExpSpellCheckerDisable = [ - RegPat.regExSpellingGuardBlock, - RegPat.regExSpellingGuardLine, - RegPat.regExSpellingGuardNext, + new PatternRegExp(RegPat.regExSpellingGuardBlock), + new PatternRegExp(RegPat.regExSpellingGuardLine), + new PatternRegExp(RegPat.regExSpellingGuardNext), ]; // cspell:ignore filetypes @@ -58,7 +59,7 @@ type ExtendsType = T extends U ? T : never; type PredefinedPatternNames = ExtendsType, PredefinedPatterns>; -const defaultRegExpPatterns: RegExpPatternDefinition[] = [...predefinedPatterns]; +const defaultRegExpPatterns: RegExpPatternDefinition[] = [...predefinedPatterns].map(normalizePattern); const definedDefaultRegExpExcludeList: PredefinedPatterns[] = [ 'SpellCheckerDisable', @@ -82,12 +83,32 @@ const definedDefaultRegExpExcludeList: PredefinedPatterns[] = [ // This bit of copying is done to have the complier ensure that the defaults exist. const defaultRegExpExcludeList: PredefinedPatternNames[] = definedDefaultRegExpExcludeList; -export const _defaultSettings: Readonly = Object.freeze( +export const _defaultSettingsBasis: Readonly = Object.freeze( createCSpellSettingsInternal({ id: 'static_defaults', language: 'en', name: 'Static Defaults', enabled: true, + enabledLanguageIds: [], + maxNumberOfProblems: 100, + numSuggestions: 10, + suggestionsTimeout: 500, + suggestionNumChanges: 3, + words: [], + userWords: [], + ignorePaths: [], + allowCompoundWords: false, + patterns: defaultRegExpPatterns, + ignoreRegExpList: [], + languageSettings: [], + source: { name: 'defaultSettings' }, + reporters: [], + }) +); + +export const _defaultSettings: Readonly = Object.freeze( + createCSpellSettingsInternal({ + ..._defaultSettingsBasis, enabledLanguageIds: [ 'ada', 'csharp', @@ -114,25 +135,17 @@ export const _defaultSettings: Readonly = Object.freeze( 'shellscript', 'toml', ], - maxNumberOfProblems: 100, - numSuggestions: 10, - suggestionsTimeout: 500, - suggestionNumChanges: 3, - words: [], - userWords: [], - ignorePaths: [], - allowCompoundWords: false, - patterns: defaultRegExpPatterns, ignoreRegExpList: defaultRegExpExcludeList, languageSettings: LanguageSettings.getDefaultLanguageSettings(), - source: { name: 'defaultSettings' }, - reporters: [], }) ); const getSettings = (function () { let settings: CSpellSettingsInternal | undefined = undefined; - return function () { + return function (useDefaultDictionaries: boolean) { + if (!useDefaultDictionaries) { + return _defaultSettingsBasis; + } if (!settings) { const jsonSettings = readSettings(defaultConfigFile); settings = mergeSettings(_defaultSettings, jsonSettings); @@ -150,6 +163,21 @@ function resolveConfigModule(configModuleName: string) { return resolveFile(configModuleName, __dirname).filename; } -export function getDefaultSettings(): CSpellSettingsInternal { - return getSettings(); +function normalizePattern(pat: RegExpPatternDefinition): RegExpPatternDefinition { + const { name, pattern, description } = pat; + if (!(pattern instanceof RegExp)) return pat; + + return { + name, + pattern: new PatternRegExp(pattern), + description, + }; +} + +export function getDefaultSettings(useDefaultDictionaries = true): CSpellSettingsInternal { + return getSettings(useDefaultDictionaries); +} + +export function getDefaultBundledSettings(): CSpellSettingsInternal { + return getDefaultSettings(); } diff --git a/packages/cspell-lib/src/Settings/DictionarySettings.test.ts b/packages/cspell-lib/src/Settings/DictionarySettings.test.ts index ffd556ffa3e5..c61b9295c811 100644 --- a/packages/cspell-lib/src/Settings/DictionarySettings.test.ts +++ b/packages/cspell-lib/src/Settings/DictionarySettings.test.ts @@ -3,11 +3,11 @@ import type { DictionaryDefinition, DictionaryDefinitionLegacy } from '@cspell/c import * as fsp from 'fs-extra'; import * as os from 'os'; import * as path from 'path'; -import { getDefaultSettings } from './DefaultSettings'; +import { getDefaultBundledSettings } from './DefaultSettings'; import { createDictionaryReferenceCollection as createRefCol } from './DictionaryReferenceCollection'; import * as DictSettings from './DictionarySettings'; -const defaultSettings = getDefaultSettings(); +const defaultSettings = getDefaultBundledSettings(); const oc = expect.objectContaining; describe('Validate DictionarySettings', () => { diff --git a/packages/cspell-lib/src/Settings/LanguageSettings.test.ts b/packages/cspell-lib/src/Settings/LanguageSettings.test.ts index b017d91e0f6b..87b85d071097 100644 --- a/packages/cspell-lib/src/Settings/LanguageSettings.test.ts +++ b/packages/cspell-lib/src/Settings/LanguageSettings.test.ts @@ -2,7 +2,7 @@ import type { CSpellUserSettings } from '@cspell/cspell-types'; import { getGlobalSettings } from './configLoader'; import { mergeSettings } from './CSpellSettingsServer'; -import { getDefaultSettings } from './DefaultSettings'; +import { getDefaultBundledSettings } from './DefaultSettings'; import * as LS from './LanguageSettings'; import { calcSettingsForLanguage, calcUserSettingsForLanguage } from './LanguageSettings'; @@ -25,12 +25,12 @@ const extraSettings: CSpellUserSettings = { ], }; -const defaultSettings = getDefaultSettings(); +const defaultSettings = getDefaultBundledSettings(); const defaultLanguageSettings = defaultSettings.languageSettings; describe('Validate LanguageSettings', () => { test('tests merging language settings', () => { - const defaultSettings = getDefaultSettings(); + const defaultSettings = getDefaultBundledSettings(); const languageSettings = defaultSettings.languageSettings || []; const sPython = calcSettingsForLanguage(languageSettings, 'python', 'en'); expect(sPython.allowCompoundWords).toBe(true); @@ -100,7 +100,7 @@ describe('Validate LanguageSettings', () => { ); test('merged settings with global', () => { - const merged = mergeSettings(getDefaultSettings(), getGlobalSettings()); + const merged = mergeSettings(getDefaultBundledSettings(), getGlobalSettings()); const sPHP = calcSettingsForLanguage(merged.languageSettings || [], 'php', 'en'); expect(Object.keys(sPHP)).not.toHaveLength(0); }); diff --git a/packages/cspell-lib/src/Settings/configLoader.test.ts b/packages/cspell-lib/src/Settings/configLoader.test.ts index 4dd3c6692a54..2b7552d59ff6 100644 --- a/packages/cspell-lib/src/Settings/configLoader.test.ts +++ b/packages/cspell-lib/src/Settings/configLoader.test.ts @@ -25,7 +25,7 @@ import { ImportFileRefWithError, mergeSettings, } from './CSpellSettingsServer'; -import { getDefaultSettings, _defaultSettings } from './DefaultSettings'; +import { getDefaultBundledSettings, _defaultSettings } from './DefaultSettings'; const { normalizeCacheSettings, normalizeSettings, validateRawConfigExports, validateRawConfigVersion } = __configLoader_testing__; @@ -103,19 +103,19 @@ describe('Validate CSpellSettingsServer', () => { test('makes sure global settings is an object', () => { const settings = getGlobalSettings(); expect(Object.keys(settings)).not.toHaveLength(0); - const merged = mergeSettings(getDefaultSettings(), getGlobalSettings()); + const merged = mergeSettings(getDefaultBundledSettings(), getGlobalSettings()); expect(Object.keys(merged)).not.toHaveLength(0); }); test('verify clearing the file cache works', () => { - mergeSettings(getDefaultSettings(), getGlobalSettings()); + mergeSettings(getDefaultBundledSettings(), getGlobalSettings()); expect(getCachedFileSize()).toBeGreaterThan(0); clearCachedSettingsFiles(); expect(getCachedFileSize()).toBe(0); }); test('the loaded defaults contain expected settings', () => { - const settings = getDefaultSettings(); + const settings = getDefaultBundledSettings(); const sources = getSources(settings); const sourceNames = sources.map((s) => s.name || '?'); expect(sourceNames).toEqual(expect.arrayContaining([_defaultSettings.name])); diff --git a/packages/cspell-lib/src/Settings/index.ts b/packages/cspell-lib/src/Settings/index.ts index 26fa31566ed4..dda2b83f851d 100644 --- a/packages/cspell-lib/src/Settings/index.ts +++ b/packages/cspell-lib/src/Settings/index.ts @@ -26,5 +26,5 @@ export { mergeSettings, } from './CSpellSettingsServer'; export type { ConfigurationDependencies, ImportFileRefWithError } from './CSpellSettingsServer'; -export { getDefaultSettings } from './DefaultSettings'; +export { getDefaultSettings, getDefaultBundledSettings } from './DefaultSettings'; export { ImportError } from './ImportError'; diff --git a/packages/cspell-lib/src/SpellingDictionary/Dictionaries.test.ts b/packages/cspell-lib/src/SpellingDictionary/Dictionaries.test.ts index 649cd4d50323..5ce0c4475b9f 100644 --- a/packages/cspell-lib/src/SpellingDictionary/Dictionaries.test.ts +++ b/packages/cspell-lib/src/SpellingDictionary/Dictionaries.test.ts @@ -2,7 +2,7 @@ import type { CSpellUserSettings } from '@cspell/cspell-types'; import * as fs from 'fs-extra'; import * as path from 'path'; import { createCSpellSettingsInternal as csi } from '../Models/CSpellSettingsInternalDef'; -import { getDefaultSettings, loadConfig } from '../Settings'; +import { getDefaultBundledSettings, loadConfig } from '../Settings'; import { createDictionaryReferenceCollection } from '../Settings/DictionaryReferenceCollection'; import { filterDictDefsToLoad, mapDictDefToInternal } from '../Settings/DictionarySettings'; import * as Dictionaries from './Dictionaries'; @@ -47,7 +47,7 @@ describe('Validate getDictionary', () => { ${'snarf'} | ${ignoreCaseTrue} | ${false} `('tests that userWords are included in the dictionary $word', async ({ word, opts, expected }) => { const settings = csi({ - ...getDefaultSettings(), + ...getDefaultBundledSettings(), dictionaries: [], words: ['one', 'two', 'three', 'café', '!snarf'], userWords: ['four', 'five', 'six', 'Rhône'], @@ -90,7 +90,7 @@ describe('Validate getDictionary', () => { ${'colour'} | ${{ found: 'colour', forbidden: true, noSuggest: false }} `('find words $word', async ({ word, expected }) => { const settings = csi({ - ...getDefaultSettings(), + ...getDefaultBundledSettings(), noSuggestDictionaries: ['companies'], words: ['one', 'two', 'three', 'café', '!snarf'], userWords: ['four', 'five', 'six', 'Rhône'], @@ -119,7 +119,7 @@ describe('Validate getDictionary', () => { ${'cafe'} | ${ignoreCaseTrue} | ${true} `('Case sensitive "$word" $opts', async ({ word, opts, expected }) => { const settings = { - ...getDefaultSettings(), + ...getDefaultBundledSettings(), dictionaries: [], words: ['one', 'two', 'three', 'café'], userWords: ['four', 'five', 'six', 'Rhône'], @@ -186,7 +186,7 @@ describe('Validate Refresh', () => { const tempDictPathNotFound = tempPath('not-found.txt'); await fs.mkdirp(path.dirname(tempDictPath)); await fs.writeFile(tempDictPath, 'one\ntwo\nthree\n'); - const settings = getDefaultSettings(); + const settings = getDefaultBundledSettings(); const defs = (settings.dictionaryDefinitions || []).concat([ di({ name: 'temp', path: tempDictPath }, __filename), di({ name: 'not_found', path: tempDictPathNotFound }, __filename), @@ -234,7 +234,7 @@ describe('Validate Refresh', () => { const tempDictPath = tempPath('words_sync.txt'); await fs.mkdirp(path.dirname(tempDictPath)); await fs.writeFile(tempDictPath, 'one\ntwo\nthree\n'); - const settings = getDefaultSettings(); + const settings = getDefaultBundledSettings(); const defs = (settings.dictionaryDefinitions || []).concat([ di({ name: 'temp', path: tempDictPath }, __filename), ]); diff --git a/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryCollection.ts b/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryCollection.ts index 058af748abf3..42d45c980d01 100644 --- a/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryCollection.ts +++ b/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryCollection.ts @@ -81,7 +81,7 @@ export class SpellingDictionaryCollection implements SpellingDictionary { public _suggest(word: string, suggestOptions: SuggestOptions): SuggestionResult[] { const { - numSuggestions = getDefaultSettings().numSuggestions || defaultNumSuggestions, + numSuggestions = getDefaultSettings(false).numSuggestions || defaultNumSuggestions, numChanges, ignoreCase, includeTies, diff --git a/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryFromTrie.ts b/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryFromTrie.ts index 200ec8174e49..9c7b68417c2a 100644 --- a/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryFromTrie.ts +++ b/packages/cspell-lib/src/SpellingDictionary/SpellingDictionaryFromTrie.ts @@ -153,7 +153,7 @@ export class SpellingDictionaryFromTrie implements SpellingDictionary { private _suggest(word: string, suggestOptions: SuggestOptions): SuggestionResult[] { const { - numSuggestions = getDefaultSettings().numSuggestions || defaultNumSuggestions, + numSuggestions = getDefaultSettings(false).numSuggestions || defaultNumSuggestions, numChanges, includeTies, ignoreCase, diff --git a/packages/cspell-lib/src/__snapshots__/index.test.ts.snap b/packages/cspell-lib/src/__snapshots__/index.test.ts.snap index 798dffdcd1d5..784f49b66ca5 100644 --- a/packages/cspell-lib/src/__snapshots__/index.test.ts.snap +++ b/packages/cspell-lib/src/__snapshots__/index.test.ts.snap @@ -35,6 +35,7 @@ Object { "language": "language", "languageId": "languageId", "languageSettings": "languageSettings", + "loadDefaultConfiguration": "loadDefaultConfiguration", "maxDuplicateProblems": "maxDuplicateProblems", "maxNumberOfProblems": "maxNumberOfProblems", "minWordLength": "minWordLength", @@ -153,6 +154,7 @@ Object { "fileToDocument": [Function], "finalizeSettings": [Function], "getCachedFileSize": [Function], + "getDefaultBundledSettings": [Function], "getDefaultSettings": [Function], "getDictionary": [Function], "getGlobalSettings": [Function], diff --git a/packages/cspell-lib/src/index.test.ts b/packages/cspell-lib/src/index.test.ts index b73e829ef55a..640cef383dde 100644 --- a/packages/cspell-lib/src/index.test.ts +++ b/packages/cspell-lib/src/index.test.ts @@ -4,7 +4,7 @@ describe('Validate the cspell API', () => { test('Tests the default configuration', () => { const ext = '.json'; const languageIds = cspell.getLanguagesForExt(ext); - const settings = cspell.getDefaultSettings(); + const settings = cspell.getDefaultBundledSettings(); // cspell:ignore jansons const text = '{ "name": "Jansons"}'; const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); diff --git a/packages/cspell-lib/src/suggestions.ts b/packages/cspell-lib/src/suggestions.ts index f5369bea5236..aa3a89bb501b 100644 --- a/packages/cspell-lib/src/suggestions.ts +++ b/packages/cspell-lib/src/suggestions.ts @@ -125,7 +125,9 @@ export async function suggestionsForWord( await refreshDictionaryCache(); - const config = includeDefaultConfig ? mergeSettings(getDefaultSettings(), getGlobalSettings(), settings) : settings; + const config = includeDefaultConfig + ? mergeSettings(getDefaultSettings(settings.loadDefaultConfiguration ?? true), getGlobalSettings(), settings) + : settings; const { dictionaryCollection, allDictionaryCollection } = await determineDictionaries(config); const opts: SuggestOptions = { ignoreCase, numChanges, numSuggestions, includeTies }; const suggestionsByDictionary = dictionaryCollection.dictionaries.map((dict) => diff --git a/packages/cspell-lib/src/test/bugs.spec.ts b/packages/cspell-lib/src/test/bugs.spec.ts index cad66edfe5eb..fb698cd250f5 100644 --- a/packages/cspell-lib/src/test/bugs.spec.ts +++ b/packages/cspell-lib/src/test/bugs.spec.ts @@ -15,7 +15,7 @@ describe('Validate Against Bug Fixes', () => { const ext = path.extname(filename); const text = await fsp.readFile(fullFilename, 'utf-8'); const languageIds = cspell.getLanguagesForExt(ext); - const settings = cspell.mergeSettings(cspell.getDefaultSettings(), cspell.readSettings(configFile)); + const settings = cspell.mergeSettings(cspell.getDefaultBundledSettings(), cspell.readSettings(configFile)); const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); const result = await cspell.validateText(text, fileSettings); expect(result).toMatchSnapshot(); diff --git a/packages/cspell-lib/src/test/dutch.spec.ts b/packages/cspell-lib/src/test/dutch.spec.ts index dddbec50d3c3..03bdd5fa2674 100644 --- a/packages/cspell-lib/src/test/dutch.spec.ts +++ b/packages/cspell-lib/src/test/dutch.spec.ts @@ -15,7 +15,7 @@ describe('Validate that Dutch text is correctly checked.', () => { const ext = path.extname(sampleFilename); const languageIds = cspell.getLanguagesForExt(ext); const dutchSettings = cspell.readSettings(dutchConfig); - const settings = cspell.mergeSettings(cspell.getDefaultSettings(), dutchSettings, { + const settings = cspell.mergeSettings(cspell.getDefaultBundledSettings(), dutchSettings, { language: 'en,nl', }); const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); diff --git a/packages/cspell-lib/src/test/english.spec.ts b/packages/cspell-lib/src/test/english.spec.ts index ecc1474c293a..8e95366f9431 100644 --- a/packages/cspell-lib/src/test/english.spec.ts +++ b/packages/cspell-lib/src/test/english.spec.ts @@ -6,7 +6,7 @@ describe('Validate English', () => { test('Tests suggestions', async () => { const ext = '.txt'; const languageIds = cspell.getLanguagesForExt(ext); - const settings = cspell.getDefaultSettings(); + const settings = cspell.getDefaultBundledSettings(); // cspell:ignore jansons const text = '{ "name": "Jansons"}'; const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); @@ -25,7 +25,7 @@ describe('Validate English', () => { test('validate some text', async () => { const ext = '.txt'; const languageIds = cspell.getLanguagesForExt(ext); - const settings = { ...cspell.getDefaultSettings(), words: ['é', 'î'] }; + const settings = { ...cspell.getDefaultBundledSettings(), words: ['é', 'î'] }; const text = ` Here are some words. thing and cpp are words. @@ -43,7 +43,7 @@ describe('Validate English', () => { test('validate some json', async () => { const ext = '.json'; const languageIds = cspell.getLanguagesForExt(ext); - const settings = { ...cspell.getDefaultSettings() }; + const settings = { ...cspell.getDefaultBundledSettings() }; const text = ` { 'bidi': False, @@ -63,7 +63,7 @@ describe('Validate English', () => { test('validate compound words', async () => { const ext = '.py'; const languageIds = cspell.getLanguagesForExt(ext); - const settings = { ...cspell.getDefaultSettings() }; + const settings = { ...cspell.getDefaultBundledSettings() }; // cspell:ignore setsid isinstance const text = ` setsid = 'R' diff --git a/packages/cspell-lib/src/test/fa.spec.ts b/packages/cspell-lib/src/test/fa.spec.ts index 2045af3cc444..bc97af1a7afe 100644 --- a/packages/cspell-lib/src/test/fa.spec.ts +++ b/packages/cspell-lib/src/test/fa.spec.ts @@ -15,7 +15,7 @@ describe('Validate that Persian text is correctly checked.', () => { const ext = path.extname(sampleFilename); const languageIds = cspell.getLanguagesForExt(ext); const frenchSettings = cspell.readSettings(frenchConfig); - const settings = cspell.mergeSettings(cspell.getDefaultSettings(), frenchSettings, { + const settings = cspell.mergeSettings(cspell.getDefaultBundledSettings(), frenchSettings, { language: 'en,fa', }); const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); diff --git a/packages/cspell-lib/src/test/french.spec.ts b/packages/cspell-lib/src/test/french.spec.ts index 35af671f3655..0755db37ff22 100644 --- a/packages/cspell-lib/src/test/french.spec.ts +++ b/packages/cspell-lib/src/test/french.spec.ts @@ -15,7 +15,7 @@ describe('Validate that French text is correctly checked.', () => { const ext = path.extname(sampleFilename); const languageIds = cspell.getLanguagesForExt(ext); const frenchSettings = cspell.readSettings(frenchConfig); - const settings = cspell.mergeSettings(cspell.getDefaultSettings(), frenchSettings, { + const settings = cspell.mergeSettings(cspell.getDefaultBundledSettings(), frenchSettings, { language: 'en,fr', }); const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); diff --git a/packages/cspell-lib/src/test/golang.spec.ts b/packages/cspell-lib/src/test/golang.spec.ts index 12cf2af08130..56ec4921f45f 100644 --- a/packages/cspell-lib/src/test/golang.spec.ts +++ b/packages/cspell-lib/src/test/golang.spec.ts @@ -12,7 +12,7 @@ describe('Validate that Go files are correctly checked.', () => { expect(Object.keys(text)).not.toHaveLength(0); const ext = '.go'; const languageIds = cspell.getLanguagesForExt(ext); - const settings = cspell.getDefaultSettings(); + const settings = cspell.getDefaultBundledSettings(); const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); // cspell:ignore weirdd garbbage const results1 = await cspell.validateText('some weirdd garbbage', fileSettings); diff --git a/packages/cspell-lib/src/test/python.spec.ts b/packages/cspell-lib/src/test/python.spec.ts index 0bd3b4f257f5..67de20d1b699 100644 --- a/packages/cspell-lib/src/test/python.spec.ts +++ b/packages/cspell-lib/src/test/python.spec.ts @@ -13,7 +13,7 @@ describe('Validate that Python files are correctly checked.', () => { expect(Object.keys(text)).not.toHaveLength(0); const ext = path.extname(sampleFilename); const languageIds = cspell.getLanguagesForExt(ext); - const settings = cspell.mergeSettings(cspell.getDefaultSettings(), cspell.readSettings(sampleConfig)); + const settings = cspell.mergeSettings(cspell.getDefaultBundledSettings(), cspell.readSettings(sampleConfig)); const fileSettings = cspell.combineTextAndLanguageSettings(settings, text, languageIds); return cspell.validateText(text, fileSettings).then((results) => { expect(results).toHaveLength(1); diff --git a/packages/cspell-lib/src/textValidation/determineTextDocumentSettings.ts b/packages/cspell-lib/src/textValidation/determineTextDocumentSettings.ts index 5b4923e448c8..adb4a0b05715 100644 --- a/packages/cspell-lib/src/textValidation/determineTextDocumentSettings.ts +++ b/packages/cspell-lib/src/textValidation/determineTextDocumentSettings.ts @@ -21,7 +21,11 @@ import { combineTextAndLanguageSettings } from '../Settings/TextDocumentSettings export function determineTextDocumentSettings(doc: TextDocument, settings: CSpellUserSettings): CSpellSettingsInternal { const filename = doc.uri.fsPath; - const settingsWithDefaults = mergeSettings(getDefaultSettings(), getGlobalSettings(), settings); + const settingsWithDefaults = mergeSettings( + getDefaultSettings(settings.loadDefaultConfiguration ?? true), + getGlobalSettings(), + settings + ); const fileSettings = calcOverrideSettings(settingsWithDefaults, filename); const languageIds = fileSettings?.languageId?.length ? fileSettings.languageId diff --git a/packages/cspell-lib/src/textValidation/validator.test.ts b/packages/cspell-lib/src/textValidation/validator.test.ts index 898b4da3e6fa..a4b3b929a527 100644 --- a/packages/cspell-lib/src/textValidation/validator.test.ts +++ b/packages/cspell-lib/src/textValidation/validator.test.ts @@ -250,7 +250,7 @@ const ignoreWords = ['ignored', 'crazzzy-code']; const words = sampleWords.concat(rejectWords).concat(['hyphen-wordz']); const sampleCSpell: CSpellSettings = { - ...getDefaultSettings(), + ...getDefaultSettings(true), version: '0.2', flagWords, words, @@ -258,7 +258,7 @@ const sampleCSpell: CSpellSettings = { }; const defaultSettings: CSpellSettings = { - ...getDefaultSettings(), + ...getDefaultSettings(true), enabledLanguageIds: ['plaintext', 'javascript'], }; diff --git a/packages/cspell-lib/src/trace.test.ts b/packages/cspell-lib/src/trace.test.ts index 6ce4a81b0477..682388513f0c 100644 --- a/packages/cspell-lib/src/trace.test.ts +++ b/packages/cspell-lib/src/trace.test.ts @@ -110,5 +110,5 @@ function oc(t: T): T { } function getSettings(...settings: CSpellSettings[]): CSpellSettings { - return settings.reduce((a, b) => mergeSettings(a, b), getDefaultSettings()); + return settings.reduce((a, b) => mergeSettings(a, b), getDefaultSettings(true)); } diff --git a/packages/cspell-types/cspell.schema.json b/packages/cspell-types/cspell.schema.json index 1706b6abd826..f42761607834 100644 --- a/packages/cspell-types/cspell.schema.json +++ b/packages/cspell-types/cspell.schema.json @@ -874,6 +874,11 @@ }, "type": "array" }, + "loadDefaultConfiguration": { + "default": "true;", + "description": "By default, the bundled dictionary configurations are loaded. Explicitly setting this to `false` will prevent ALL default configuration from being loaded.", + "type": "boolean" + }, "maxDuplicateProblems": { "default": 5, "description": "The maximum number of times the same word can be flagged as an error in a file.", @@ -1317,6 +1322,11 @@ }, "type": "array" }, + "loadDefaultConfiguration": { + "default": "true;", + "description": "By default, the bundled dictionary configurations are loaded. Explicitly setting this to `false` will prevent ALL default configuration from being loaded.", + "type": "boolean" + }, "maxDuplicateProblems": { "default": 5, "description": "The maximum number of times the same word can be flagged as an error in a file.", diff --git a/packages/cspell-types/src/CSpellSettingsDef.ts b/packages/cspell-types/src/CSpellSettingsDef.ts index 35a1a576b771..5f5ebb87f344 100644 --- a/packages/cspell-types/src/CSpellSettingsDef.ts +++ b/packages/cspell-types/src/CSpellSettingsDef.ts @@ -161,6 +161,13 @@ export interface Settings extends ReportingConfiguration, BaseSetting, PnPSettin /** Forces the spell checker to assume a give language id. Used mainly as an Override. */ languageId?: LanguageId; + + /** + * By default, the bundled dictionary configurations are loaded. Explicitly setting this to `false` + * will prevent ALL default configuration from being loaded. + * @default true; + */ + loadDefaultConfiguration?: boolean; } export interface ReportingConfiguration extends SuggestionsConfiguration { @@ -788,7 +795,7 @@ export interface RegExpPatternDefinition { /** * Description of the pattern. */ - description?: string; + description?: string | undefined; } export type CSpellUserSettingsWithComments = CSpellUserSettings; diff --git a/packages/cspell-types/src/configFields.ts b/packages/cspell-types/src/configFields.ts index cd8085aa2b8b..e226d10f508d 100644 --- a/packages/cspell-types/src/configFields.ts +++ b/packages/cspell-types/src/configFields.ts @@ -31,6 +31,7 @@ export const ConfigFields: CSpellUserSettingsFields = { language: 'language', languageId: 'languageId', languageSettings: 'languageSettings', + loadDefaultConfiguration: 'loadDefaultConfiguration', maxDuplicateProblems: 'maxDuplicateProblems', maxNumberOfProblems: 'maxNumberOfProblems', minWordLength: 'minWordLength', diff --git a/packages/cspell/src/__snapshots__/app.test.ts.snap b/packages/cspell/src/__snapshots__/app.test.ts.snap index e3a4f2490bee..51e832703e9b 100644 --- a/packages/cspell/src/__snapshots__/app.test.ts.snap +++ b/packages/cspell/src/__snapshots__/app.test.ts.snap @@ -155,6 +155,8 @@ Array [ " looks for cspell.json in the current directory.", " --no-color Turn off color.", " --color Force color", + " --no-default-configuration Do not load the default configuration and", + " dictionaries.", " -h, --help display help for command", "", ] @@ -440,6 +442,8 @@ Array [ " root.", " --no-color Turn off color.", " --color Force color.", + " --no-default-configuration Do not load the default configuration and", + " dictionaries.", " --debug Output information useful for debugging", " cspell.json files.", " -h, --help display help for command", @@ -1155,6 +1159,8 @@ Array [ " --stdin Read words from stdin.", " --no-color Turn off color.", " --color Force color", + " --no-default-configuration Do not load the default configuration and", + " dictionaries.", " -h, --help display help for command", "", ] diff --git a/packages/cspell/src/application.test.ts b/packages/cspell/src/application.test.ts index aeb2e1226696..d054e2ce412c 100644 --- a/packages/cspell/src/application.test.ts +++ b/packages/cspell/src/application.test.ts @@ -36,7 +36,7 @@ describe('Validate the Application', () => { return lint.then((result) => { expect(reporter.errorCount).toBe(0); expect(reporter.infoCount).toBeGreaterThan(0); - expect(reporter.debugCount).toBeGreaterThan(0); + expect(reporter.debugCount).toBe(0); expect(reporter.runResult).toEqual(result); expect(result.files).toBe(1); return; @@ -51,7 +51,7 @@ describe('Validate the Application', () => { return lint.then((result) => { expect(reporter.errorCount).toBe(0); expect(reporter.infoCount).toBeGreaterThan(0); - expect(reporter.debugCount).toBeGreaterThan(0); + expect(reporter.debugCount).toBe(0); expect(reporter.runResult).toEqual(result); expect(result.files).toBe(1); return; @@ -66,7 +66,7 @@ describe('Validate the Application', () => { return lint.then((result) => { expect(reporter.errorCount).toBe(0); expect(reporter.infoCount).toBeGreaterThan(0); - expect(reporter.debugCount).toBeGreaterThan(0); + expect(reporter.debugCount).toBe(0); expect(reporter.runResult).toEqual(result); expect(result.files).toBe(1); return; @@ -114,7 +114,7 @@ describe('Validate the Application', () => { test('running the application from stdin', async () => { const files = ['stdin']; - const options = { ...sampleOptions, wordsOnly: true, unique: true }; + const options = { ...sampleOptions, wordsOnly: true, unique: true, debug: true }; const reporter = new InMemoryReporter(); // cspell:ignore texxt getStdinResult.value = ` diff --git a/packages/cspell/src/application.ts b/packages/cspell/src/application.ts index f5abc243b92e..3626ccefcc2d 100644 --- a/packages/cspell/src/application.ts +++ b/packages/cspell/src/application.ts @@ -35,7 +35,9 @@ export async function* trace(words: string[], options: TraceOptions): AsyncItera const iWords = options.stdin ? toAsyncIterable(words, readStdin()) : words; const { languageId, locale, allowCompoundWords, ignoreCase } = options; const configFile = await readConfig(options.config, undefined); - const config = mergeSettings(getDefaultSettings(), getGlobalSettings(), configFile.config); + const loadDefault = options.defaultConfiguration ?? configFile.config.loadDefaultConfiguration ?? true; + + const config = mergeSettings(getDefaultSettings(loadDefault), getGlobalSettings(), configFile.config); yield* traceWordsAsync(iWords, config, { languageId, locale, ignoreCase, allowCompoundWords }); } @@ -48,6 +50,7 @@ export async function checkText(filename: string, options: BaseOptions & LegacyO const settingsFromCommandLine = util.clean({ languageId: options.languageId || undefined, language: options.locale || options.local || undefined, + loadDefaultConfiguration: options.defaultConfiguration, }); const info = calcFinalConfigInfo(foundSettings, settingsFromCommandLine, filename, text); return cspellLibCheckText(text, info.configInfo.config); diff --git a/packages/cspell/src/commandCheck.ts b/packages/cspell/src/commandCheck.ts index a54f257e85cb..44f4fab58b81 100644 --- a/packages/cspell/src/commandCheck.ts +++ b/packages/cspell/src/commandCheck.ts @@ -1,4 +1,4 @@ -import { Command } from 'commander'; +import { Command, Option as CommanderOption } from 'commander'; import * as App from './application'; import { checkText } from './application'; import { BaseOptions } from './options'; @@ -17,6 +17,15 @@ export function commandCheck(prog: Command): Command { ) .option('--no-color', 'Turn off color.') .option('--color', 'Force color') + .addOption( + new CommanderOption( + '--default-configuration', + 'Load the default configuration and dictionaries.' + ).hideHelp() + ) + .addOption( + new CommanderOption('--no-default-configuration', 'Do not load the default configuration and dictionaries.') + ) .action(async (files: string[], options: CheckCommandOptions) => { let issueCount = 0; for (const filename of files) { diff --git a/packages/cspell/src/commandLint.ts b/packages/cspell/src/commandLint.ts index b5407f136940..28a18dbdb514 100644 --- a/packages/cspell/src/commandLint.ts +++ b/packages/cspell/src/commandLint.ts @@ -97,6 +97,15 @@ export function commandLint(prog: Command): Command { .option('--gitignore-root ', 'Prevent searching for .gitignore files past root.', collect) .option('--no-color', 'Turn off color.') .option('--color', 'Force color.') + .addOption( + new CommanderOption( + '--default-configuration', + 'Load the default configuration and dictionaries.' + ).hideHelp() + ) + .addOption( + new CommanderOption('--no-default-configuration', 'Do not load the default configuration and dictionaries.') + ) .option('--debug', 'Output information useful for debugging cspell.json files.') .addHelpText('after', usage) .arguments('[globs...]') diff --git a/packages/cspell/src/commandTrace.ts b/packages/cspell/src/commandTrace.ts index 635392818e85..4c87c5fc7bf7 100644 --- a/packages/cspell/src/commandTrace.ts +++ b/packages/cspell/src/commandTrace.ts @@ -31,6 +31,15 @@ export function commandTrace(prog: Command): Command { .option('--stdin', 'Read words from stdin.') .option('--no-color', 'Turn off color.') .option('--color', 'Force color') + .addOption( + new CommanderOption( + '--default-configuration', + 'Load the default configuration and dictionaries.' + ).hideHelp() + ) + .addOption( + new CommanderOption('--no-default-configuration', 'Do not load the default configuration and dictionaries.') + ) .arguments('[words...]') .action(async (words: string[], options: TraceCommandOptions) => { let numFound = 0; diff --git a/packages/cspell/src/lint/lint.ts b/packages/cspell/src/lint/lint.ts index 553efbc73051..ee5597126f46 100644 --- a/packages/cspell/src/lint/lint.ts +++ b/packages/cspell/src/lint/lint.ts @@ -75,7 +75,6 @@ export async function runLint(cfg: LintRequest): Promise { const doc = fileInfoToDocument(fileInfo, cfg.options.languageId, cfg.locale); const { text } = fileInfo; - reporter.debug(`Filename: ${filename}, LanguageIds: ${doc.languageId ?? 'default'}`); result.fileInfo = fileInfo; let spellResult: Partial = {}; @@ -99,12 +98,6 @@ export async function runLint(cfg: LintRequest): Promise { result.configErrors += await reportConfigurationErrors(config); - if (cfg.options.debug) { - const { id: _id, name: _name, ...cfg } = config; - const debugCfg = { config: { ...cfg, source: null }, source: spellResult.localConfigFilepath }; - reporter.debug(JSON.stringify(debugCfg, undefined, 2)); - } - const elapsed = result.elapsedTimeMs / 1000.0; const dictionaries = config.dictionaries || []; reporter.info( @@ -114,6 +107,17 @@ export async function runLint(cfg: LintRequest): Promise { reporter.info(`Config file Used: ${spellResult.localConfigFilepath || configInfo.source}`, MessageTypes.Info); reporter.info(`Dictionaries Used: ${dictionaries.join(', ')}`, MessageTypes.Info); + if (cfg.options.debug) { + const { id: _id, name: _name, __imports, __importRef, ...cfg } = config; + const debugCfg = { + filename, + languageId: doc.languageId ?? cfg.languageId ?? 'default', + config: { ...cfg, source: null }, + source: spellResult.localConfigFilepath, + }; + reporter.debug(JSON.stringify(debugCfg, undefined, 2)); + } + const dep = calcDependencies(config); cache.setCachedLintResults(result, dep.files); @@ -236,6 +240,9 @@ export async function runLint(cfg: LintRequest): Promise { } const configInfo: ConfigInfo = await readConfig(cfg.configFile, cfg.root); + if (cfg.options.defaultConfiguration !== undefined) { + configInfo.config.loadDefaultConfiguration = cfg.options.defaultConfiguration; + } reporter = mergeReporters(cfg.reporter, ...loadReporters(configInfo.config)); cspell.setLogger(getLoggerFromReporter(reporter)); diff --git a/packages/cspell/src/options.ts b/packages/cspell/src/options.ts index 889bb3512cf8..07a28a57621c 100644 --- a/packages/cspell/src/options.ts +++ b/packages/cspell/src/options.ts @@ -134,6 +134,12 @@ export interface BaseOptions { * Locale to use. */ locale?: string; + + /** + * Load the default configuration + * @default true + */ + defaultConfiguration?: boolean; } export interface LinterCliOptions extends Omit { diff --git a/packages/cspell/src/util/fileHelper.ts b/packages/cspell/src/util/fileHelper.ts index d919c571811e..07ca72a73875 100644 --- a/packages/cspell/src/util/fileHelper.ts +++ b/packages/cspell/src/util/fileHelper.ts @@ -114,8 +114,13 @@ export function calcFinalConfigInfo( ): FileConfigInfo { const ext = path.extname(filename); const fileSettings = cspell.calcOverrideSettings(configInfo.config, path.resolve(filename)); + const loadDefault = + settingsFromCommandLine.loadDefaultConfiguration ?? + configInfo.config.loadDefaultConfiguration ?? + fileSettings.loadDefaultConfiguration ?? + true; const settings = cspell.mergeSettings( - cspell.getDefaultSettings(), + cspell.getDefaultSettings(loadDefault), cspell.getGlobalSettings(), fileSettings, settingsFromCommandLine