cspell-lib 5.14.0 → 5.15.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Settings/CSpellSettingsServer.d.ts +14 -1
- package/dist/Settings/CSpellSettingsServer.js +44 -9
- package/dist/Settings/DefaultSettings.js +8 -2
- package/dist/Settings/DictionarySettings.d.ts +2 -1
- package/dist/Settings/DictionarySettings.js +14 -1
- package/dist/Settings/RegExpPatterns.d.ts +21 -0
- package/dist/Settings/RegExpPatterns.js +26 -6
- package/dist/SpellingDictionary/Dictionaries.d.ts +2 -2
- package/dist/SpellingDictionary/Dictionaries.js +5 -15
- package/dist/SpellingDictionary/SpellingDictionary.d.ts +2 -1
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.d.ts +4 -2
- package/dist/SpellingDictionary/SpellingDictionaryFromTrie.js +3 -1
- package/dist/index.d.ts +1 -1
- package/dist/textValidator.js +1 -1
- package/package.json +11 -11
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { CSpellSettingsWithSourceTrace, CSpellUserSettings, Glob, ImportFileRef, PnPSettings } from '@cspell/cspell-types';
|
|
2
2
|
import { URI } from 'vscode-uri';
|
|
3
3
|
import { LoaderResult } from './pnpLoader';
|
|
4
|
+
export declare const currentSettingsFileVersion = "0.2";
|
|
4
5
|
export declare const sectionCSpell = "cSpell";
|
|
5
6
|
export declare const defaultFileName = "cspell.json";
|
|
6
7
|
export declare const ENV_CSPELL_GLOB_ROOT = "CSPELL_GLOB_ROOT";
|
|
@@ -28,6 +29,10 @@ export declare function readRawSettings(filename: string, relativeTo?: string):
|
|
|
28
29
|
* @deprecated true
|
|
29
30
|
*/
|
|
30
31
|
export declare function readSettingsFiles(filenames: string[]): CSpellSettings;
|
|
32
|
+
declare function mergeObjects(left: undefined, right: undefined): undefined;
|
|
33
|
+
declare function mergeObjects<T>(left: T, right: undefined): T;
|
|
34
|
+
declare function mergeObjects<T>(left: T, right: T): T;
|
|
35
|
+
declare function mergeObjects<T>(left: undefined, right: T): T;
|
|
31
36
|
export declare function mergeSettings(left: CSpellSettings, ...settings: CSpellSettings[]): CSpellSettings;
|
|
32
37
|
export declare function mergeInDocSettings(left: CSpellSettings, right: CSpellSettings): CSpellSettings;
|
|
33
38
|
export declare function calcOverrideSettings(settings: CSpellSettings, filename: string): CSpellSettings;
|
|
@@ -45,14 +50,22 @@ export interface ImportFileRefWithError extends ImportFileRef {
|
|
|
45
50
|
error: Error;
|
|
46
51
|
}
|
|
47
52
|
export declare function extractImportErrors(settings: CSpellSettings): ImportFileRefWithError[];
|
|
53
|
+
export interface ConfigurationDependencies {
|
|
54
|
+
configFiles: string[];
|
|
55
|
+
dictionaryFiles: string[];
|
|
56
|
+
}
|
|
57
|
+
export declare function extractDependencies(settings: CSpellSettings): ConfigurationDependencies;
|
|
58
|
+
declare function normalizeCacheSettings(settings: Pick<CSpellSettings, 'cache'>, pathToSettingsDir: string): Pick<CSpellSettings, 'cache'>;
|
|
48
59
|
declare function validateRawConfigVersion(config: CSpellUserSettings | {
|
|
49
60
|
version: unknown;
|
|
50
61
|
}, fileRef: ImportFileRef): void;
|
|
51
62
|
declare function validateRawConfigExports(config: CSpellUserSettings, fileRef: ImportFileRef): void;
|
|
52
63
|
export declare const __testing__: {
|
|
64
|
+
mergeObjects: typeof mergeObjects;
|
|
65
|
+
normalizeCacheSettings: typeof normalizeCacheSettings;
|
|
53
66
|
normalizeSettings: typeof normalizeSettings;
|
|
54
|
-
validateRawConfigVersion: typeof validateRawConfigVersion;
|
|
55
67
|
validateRawConfigExports: typeof validateRawConfigExports;
|
|
68
|
+
validateRawConfigVersion: typeof validateRawConfigVersion;
|
|
56
69
|
};
|
|
57
70
|
export {};
|
|
58
71
|
//# sourceMappingURL=CSpellSettingsServer.d.ts.map
|
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.__testing__ = exports.extractImportErrors = exports.getSources = exports.checkFilenameMatchesGlob = exports.clearCachedSettingsFiles = exports.getCachedFileSize = exports.getGlobalSettings = exports.finalizeSettings = exports.calcOverrideSettings = exports.mergeInDocSettings = exports.mergeSettings = exports.readSettingsFiles = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.searchForConfig = exports.readSettings = exports.defaultConfigFilenames = exports.ENV_CSPELL_GLOB_ROOT = exports.defaultFileName = exports.sectionCSpell = void 0;
|
|
22
|
+
exports.__testing__ = exports.extractDependencies = exports.extractImportErrors = exports.getSources = exports.checkFilenameMatchesGlob = exports.clearCachedSettingsFiles = exports.getCachedFileSize = exports.getGlobalSettings = exports.finalizeSettings = exports.calcOverrideSettings = exports.mergeInDocSettings = exports.mergeSettings = exports.readSettingsFiles = exports.readRawSettings = exports.loadPnPSync = exports.loadPnP = exports.loadConfig = exports.searchForConfig = exports.readSettings = exports.defaultConfigFilenames = exports.ENV_CSPELL_GLOB_ROOT = exports.defaultFileName = exports.sectionCSpell = exports.currentSettingsFileVersion = void 0;
|
|
23
23
|
const json = __importStar(require("comment-json"));
|
|
24
24
|
const cosmiconfig_1 = require("cosmiconfig");
|
|
25
25
|
const cspell_glob_1 = require("cspell-glob");
|
|
@@ -36,7 +36,7 @@ const pnpLoader_1 = require("./pnpLoader");
|
|
|
36
36
|
const supportedCSpellConfigVersions = ['0.2'];
|
|
37
37
|
const configSettingsFileVersion0_1 = '0.1';
|
|
38
38
|
const configSettingsFileVersion0_2 = '0.2';
|
|
39
|
-
|
|
39
|
+
exports.currentSettingsFileVersion = configSettingsFileVersion0_2;
|
|
40
40
|
const setOfSupportedConfigVersions = new Set(supportedCSpellConfigVersions);
|
|
41
41
|
exports.sectionCSpell = 'cSpell';
|
|
42
42
|
exports.defaultFileName = 'cspell.json';
|
|
@@ -90,7 +90,7 @@ const cspellConfigExplorerSync = (0, cosmiconfig_1.cosmiconfigSync)('cspell', cs
|
|
|
90
90
|
const defaultSettings = {
|
|
91
91
|
id: 'default',
|
|
92
92
|
name: 'default',
|
|
93
|
-
version: currentSettingsFileVersion,
|
|
93
|
+
version: exports.currentSettingsFileVersion,
|
|
94
94
|
};
|
|
95
95
|
const defaultPnPSettings = {};
|
|
96
96
|
let globalSettings;
|
|
@@ -137,6 +137,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
|
|
|
137
137
|
loadPnPSync(pnpSettingsToUse, vscode_uri_1.URI.file(pathToSettingsDir));
|
|
138
138
|
// Fix up dictionaryDefinitions
|
|
139
139
|
const settings = {
|
|
140
|
+
version: defaultSettings.version,
|
|
140
141
|
...rawSettings,
|
|
141
142
|
id,
|
|
142
143
|
name,
|
|
@@ -149,6 +150,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
|
|
|
149
150
|
const normalizedOverrides = normalizeOverrides(settings, pathToSettingsFile);
|
|
150
151
|
const normalizedReporters = normalizeReporters(settings, pathToSettingsFile);
|
|
151
152
|
const normalizedGitignoreRoot = normalizeGitignoreRoot(settings, pathToSettingsFile);
|
|
153
|
+
const normalizedCacheSettings = normalizeCacheSettings(settings, pathToSettingsDir);
|
|
152
154
|
const imports = typeof settings.import === 'string' ? [settings.import] : settings.import || [];
|
|
153
155
|
const source = settings.source || {
|
|
154
156
|
name: settings.name,
|
|
@@ -162,6 +164,7 @@ function normalizeSettings(rawSettings, pathToSettingsFile, pnpSettings) {
|
|
|
162
164
|
...normalizedOverrides,
|
|
163
165
|
...normalizedReporters,
|
|
164
166
|
...normalizedGitignoreRoot,
|
|
167
|
+
...normalizedCacheSettings,
|
|
165
168
|
};
|
|
166
169
|
if (!imports.length) {
|
|
167
170
|
return fileSettings;
|
|
@@ -311,6 +314,13 @@ function mergeList(left, right) {
|
|
|
311
314
|
return left;
|
|
312
315
|
return left.concat(right);
|
|
313
316
|
}
|
|
317
|
+
function mergeObjects(left, right) {
|
|
318
|
+
if (left === undefined)
|
|
319
|
+
return right;
|
|
320
|
+
if (right === undefined)
|
|
321
|
+
return left;
|
|
322
|
+
return { ...left, ...right };
|
|
323
|
+
}
|
|
314
324
|
function tagLanguageSettings(tag, settings = []) {
|
|
315
325
|
return settings.map((s) => ({
|
|
316
326
|
id: tag + '.' + (s.id || s.locale || s.languageId),
|
|
@@ -377,6 +387,7 @@ function merge(left, right) {
|
|
|
377
387
|
files: mergeListUnique(left.files, right.files),
|
|
378
388
|
ignorePaths: versionBasedMergeList(left.ignorePaths, right.ignorePaths, version),
|
|
379
389
|
overrides: versionBasedMergeList(left.overrides, right.overrides, version),
|
|
390
|
+
features: mergeObjects(left.features, right.features),
|
|
380
391
|
source: mergeSources(left, right),
|
|
381
392
|
globRoot: undefined,
|
|
382
393
|
import: undefined,
|
|
@@ -534,7 +545,7 @@ function getSources(settings) {
|
|
|
534
545
|
return sources;
|
|
535
546
|
}
|
|
536
547
|
exports.getSources = getSources;
|
|
537
|
-
function mergeImportRefs(left, right) {
|
|
548
|
+
function mergeImportRefs(left, right = {}) {
|
|
538
549
|
var _a;
|
|
539
550
|
const imports = new Map(left.__imports || []);
|
|
540
551
|
if (left.__importRef) {
|
|
@@ -553,10 +564,19 @@ function isImportFileRefWithError(ref) {
|
|
|
553
564
|
return !!ref.error;
|
|
554
565
|
}
|
|
555
566
|
function extractImportErrors(settings) {
|
|
556
|
-
const imports = mergeImportRefs(settings
|
|
567
|
+
const imports = mergeImportRefs(settings);
|
|
557
568
|
return !imports ? [] : [...imports.values()].filter(isImportFileRefWithError);
|
|
558
569
|
}
|
|
559
570
|
exports.extractImportErrors = extractImportErrors;
|
|
571
|
+
function extractDependencies(settings) {
|
|
572
|
+
const configFiles = [...(mergeImportRefs(settings) || [])].map(([filename]) => filename);
|
|
573
|
+
const dictionaryFiles = (0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings).map((dict) => dict.path);
|
|
574
|
+
return {
|
|
575
|
+
configFiles,
|
|
576
|
+
dictionaryFiles,
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
exports.extractDependencies = extractDependencies;
|
|
560
580
|
function resolveGlobRoot(settings, pathToSettingsFile) {
|
|
561
581
|
var _a;
|
|
562
582
|
const settingsFileDirRaw = path.dirname(pathToSettingsFile);
|
|
@@ -573,6 +593,10 @@ function resolveGlobRoot(settings, pathToSettingsFile) {
|
|
|
573
593
|
const globRoot = path.resolve(settingsFileDir, rawRoot.replace('${cwd}', cwd));
|
|
574
594
|
return globRoot;
|
|
575
595
|
}
|
|
596
|
+
function resolveFilePath(filename, pathToSettingsFile) {
|
|
597
|
+
const cwd = process.cwd();
|
|
598
|
+
return path.resolve(pathToSettingsFile, filename.replace('${cwd}', cwd));
|
|
599
|
+
}
|
|
576
600
|
function toGlobDef(g, root, source) {
|
|
577
601
|
if (g === undefined)
|
|
578
602
|
return undefined;
|
|
@@ -670,6 +694,15 @@ function normalizeSettingsGlobs(settings, pathToSettingsFile) {
|
|
|
670
694
|
ignorePaths,
|
|
671
695
|
};
|
|
672
696
|
}
|
|
697
|
+
function normalizeCacheSettings(settings, pathToSettingsDir) {
|
|
698
|
+
const { cache } = settings;
|
|
699
|
+
if (cache === undefined)
|
|
700
|
+
return {};
|
|
701
|
+
const { cacheLocation } = cache;
|
|
702
|
+
if (cacheLocation === undefined)
|
|
703
|
+
return { cache };
|
|
704
|
+
return { cache: { ...cache, cacheLocation: resolveFilePath(cacheLocation, pathToSettingsDir) } };
|
|
705
|
+
}
|
|
673
706
|
function validationMessage(msg, fileRef) {
|
|
674
707
|
return msg + `\n File: "${fileRef.filename}"`;
|
|
675
708
|
}
|
|
@@ -687,9 +720,9 @@ function validateRawConfigVersion(config, fileRef) {
|
|
|
687
720
|
(0, logger_1.logError)(validationMessage(`Unsupported config file version: "${version}"`, fileRef));
|
|
688
721
|
return;
|
|
689
722
|
}
|
|
690
|
-
const msg = version > currentSettingsFileVersion
|
|
691
|
-
? `Newer config file version found: "${version}". Supported version is "${currentSettingsFileVersion}"`
|
|
692
|
-
: `Legacy config file version found: "${version}", upgrade to "${currentSettingsFileVersion}"`;
|
|
723
|
+
const msg = version > exports.currentSettingsFileVersion
|
|
724
|
+
? `Newer config file version found: "${version}". Supported version is "${exports.currentSettingsFileVersion}"`
|
|
725
|
+
: `Legacy config file version found: "${version}", upgrade to "${exports.currentSettingsFileVersion}"`;
|
|
693
726
|
(0, logger_1.logWarning)(validationMessage(msg, fileRef));
|
|
694
727
|
}
|
|
695
728
|
function validateRawConfigExports(config, fileRef) {
|
|
@@ -707,8 +740,10 @@ function validateRawConfig(config, fileRef) {
|
|
|
707
740
|
validations.forEach((fn) => fn(config, fileRef));
|
|
708
741
|
}
|
|
709
742
|
exports.__testing__ = {
|
|
743
|
+
mergeObjects,
|
|
744
|
+
normalizeCacheSettings,
|
|
710
745
|
normalizeSettings,
|
|
711
|
-
validateRawConfigVersion,
|
|
712
746
|
validateRawConfigExports,
|
|
747
|
+
validateRawConfigVersion,
|
|
713
748
|
};
|
|
714
749
|
//# sourceMappingURL=CSpellSettingsServer.js.map
|
|
@@ -45,10 +45,14 @@ const predefinedPatterns = [
|
|
|
45
45
|
{ name: 'SpellCheckerDisable', pattern: regExpSpellCheckerDisable },
|
|
46
46
|
{ name: 'PublicKey', pattern: RegPat.regExPublicKey },
|
|
47
47
|
{ name: 'RsaCert', pattern: RegPat.regExCert },
|
|
48
|
+
{ name: 'SshRsa', pattern: RegPat.regExSshRSA },
|
|
48
49
|
{ name: 'EscapeCharacters', pattern: RegPat.regExEscapeCharacters },
|
|
49
50
|
{ name: 'Base64', pattern: RegPat.regExBase64 },
|
|
51
|
+
{ name: 'Base64SingleLine', pattern: RegPat.regExBase64SingleLine },
|
|
52
|
+
{ name: 'Base64MultiLine', pattern: RegPat.regExBase64MultiLine },
|
|
50
53
|
{ name: 'Email', pattern: RegPat.regExEmail },
|
|
51
54
|
{ name: 'SHA', pattern: RegPat.regExSha },
|
|
55
|
+
{ name: 'HashStrings', pattern: RegPat.regExHashStrings },
|
|
52
56
|
{ name: 'UnicodeRef', pattern: RegPat.regExUnicodeRef },
|
|
53
57
|
{ name: 'UUID', pattern: RegPat.regExUUID },
|
|
54
58
|
{ name: 'href', pattern: RegPat.regExHRef },
|
|
@@ -68,14 +72,16 @@ const definedDefaultRegExpExcludeList = [
|
|
|
68
72
|
'SpellCheckerIgnoreInDocSetting',
|
|
69
73
|
'Urls',
|
|
70
74
|
'Email',
|
|
71
|
-
'PublicKey',
|
|
72
75
|
'RsaCert',
|
|
73
|
-
'
|
|
76
|
+
'SshRsa',
|
|
77
|
+
'Base64MultiLine',
|
|
78
|
+
'Base64SingleLine',
|
|
74
79
|
'CommitHash',
|
|
75
80
|
'CommitHashLink',
|
|
76
81
|
'CStyleHexValue',
|
|
77
82
|
'CSSHexValue',
|
|
78
83
|
'SHA',
|
|
84
|
+
'HashStrings',
|
|
79
85
|
'UnicodeRef',
|
|
80
86
|
'UUID',
|
|
81
87
|
];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DictionaryDefinition, DictionaryDefinitionPreferred, DictionaryReference } from '@cspell/cspell-types';
|
|
1
|
+
import type { DictionaryDefinition, DictionaryDefinitionPreferred, DictionaryReference, CSpellSettingsWithSourceTrace } from '@cspell/cspell-types';
|
|
2
2
|
export interface DictionaryDefinitionWithSource extends DictionaryDefinitionPreferred {
|
|
3
3
|
/** The path to the config file that contains this dictionary definition */
|
|
4
4
|
__source: string;
|
|
@@ -22,4 +22,5 @@ export declare function normalizePathForDictDefs(defs: DictionaryDefinition[], p
|
|
|
22
22
|
export declare function normalizePathForDictDefs(defs: DictionaryDefinition[] | undefined, pathToSettingsFile: string): DictionaryDefinitionWithSource[] | undefined;
|
|
23
23
|
export declare function normalizePathForDictDef(def: DictionaryDefinition, pathToSettingsFile: string): DictionaryDefinitionWithSource;
|
|
24
24
|
export declare function isDictionaryDefinitionWithSource(d: DictionaryDefinition | DictionaryDefinitionWithSource): d is DictionaryDefinitionWithSource;
|
|
25
|
+
export declare function calcDictionaryDefsToLoad(settings: CSpellSettingsWithSourceTrace): DictionaryDefinitionPreferred[];
|
|
25
26
|
//# sourceMappingURL=DictionarySettings.d.ts.map
|
|
@@ -19,7 +19,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
-
exports.isDictionaryDefinitionWithSource = exports.normalizePathForDictDef = exports.normalizePathForDictDefs = exports.filterDictDefsToLoad = void 0;
|
|
22
|
+
exports.calcDictionaryDefsToLoad = exports.isDictionaryDefinitionWithSource = exports.normalizePathForDictDef = exports.normalizePathForDictDefs = exports.filterDictDefsToLoad = void 0;
|
|
23
23
|
const path = __importStar(require("path"));
|
|
24
24
|
const resolveFile_1 = require("../util/resolveFile");
|
|
25
25
|
const DictionaryReferenceCollection_1 = require("./DictionaryReferenceCollection");
|
|
@@ -87,4 +87,17 @@ exports.isDictionaryDefinitionWithSource = isDictionaryDefinitionWithSource;
|
|
|
87
87
|
function determineName(filename, options) {
|
|
88
88
|
return options.name || path.basename(filename);
|
|
89
89
|
}
|
|
90
|
+
function calcDictionaryDefsToLoad(settings) {
|
|
91
|
+
const { dictionaries = [], dictionaryDefinitions = [], noSuggestDictionaries = [] } = settings;
|
|
92
|
+
const colNoSug = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(noSuggestDictionaries);
|
|
93
|
+
const colDicts = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(dictionaries.concat(colNoSug.enabled()));
|
|
94
|
+
const modDefs = dictionaryDefinitions.map((def) => {
|
|
95
|
+
const enabled = colNoSug.isEnabled(def.name);
|
|
96
|
+
if (enabled === undefined)
|
|
97
|
+
return def;
|
|
98
|
+
return { ...def, noSuggest: enabled };
|
|
99
|
+
});
|
|
100
|
+
return filterDictDefsToLoad(colDicts.enabled(), modDefs);
|
|
101
|
+
}
|
|
102
|
+
exports.calcDictionaryDefsToLoad = calcDictionaryDefsToLoad;
|
|
90
103
|
//# sourceMappingURL=DictionarySettings.js.map
|
|
@@ -13,8 +13,19 @@ export declare const regExSpellingGuardLine: RegExp;
|
|
|
13
13
|
export declare const regExIgnoreSpellingDirectives: RegExp;
|
|
14
14
|
export declare const regExPublicKey: RegExp;
|
|
15
15
|
export declare const regExCert: RegExp;
|
|
16
|
+
export declare const regExSshRSA: RegExp;
|
|
16
17
|
export declare const regExEscapeCharacters: RegExp;
|
|
17
18
|
export declare const regExBase64: RegExp;
|
|
19
|
+
/**
|
|
20
|
+
* Detect a string of characters that look like a Base64 string.
|
|
21
|
+
*
|
|
22
|
+
* It must be:
|
|
23
|
+
* - at least 40 characters
|
|
24
|
+
* - contain at least 1 of [0-9+=]
|
|
25
|
+
* - end at the end of the line or with [,"'\]
|
|
26
|
+
*/
|
|
27
|
+
export declare const regExBase64SingleLine: RegExp;
|
|
28
|
+
export declare const regExBase64MultiLine: RegExp;
|
|
18
29
|
export declare const regExPhpHereDoc: RegExp;
|
|
19
30
|
export declare const regExString: RegExp;
|
|
20
31
|
export declare const regExCStyleComments: RegExp;
|
|
@@ -22,4 +33,14 @@ export declare const rexExPythonStyleComments: RegExp;
|
|
|
22
33
|
export declare const regExEmail: RegExp;
|
|
23
34
|
export declare const regExRepeatedChar: RegExp;
|
|
24
35
|
export declare const regExSha: RegExp;
|
|
36
|
+
/**
|
|
37
|
+
* Detect common hash strings like:
|
|
38
|
+
* - `sha1`, `sha256`, `sha512`
|
|
39
|
+
* - `md5`
|
|
40
|
+
* - `base64` - used in email
|
|
41
|
+
* - `crypt`, `bcrypt`, `script`
|
|
42
|
+
* - `token`
|
|
43
|
+
* - `assertion` - use with jwt
|
|
44
|
+
*/
|
|
45
|
+
export declare const regExHashStrings: RegExp;
|
|
25
46
|
//# sourceMappingURL=RegExpPatterns.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.regExSha = exports.regExRepeatedChar = exports.regExEmail = exports.rexExPythonStyleComments = exports.regExCStyleComments = exports.regExString = exports.regExPhpHereDoc = exports.regExBase64 = exports.regExEscapeCharacters = exports.regExCert = exports.regExPublicKey = exports.regExIgnoreSpellingDirectives = exports.regExSpellingGuardLine = exports.regExSpellingGuardNext = exports.regExSpellingGuardBlock = exports.regExUnicodeRef = exports.regExUUID = exports.regExCSSHexValue = exports.regExCStyleHexValue = exports.regExCommitHashLink = exports.regExCommitHash = exports.regExMatchCommonHexFormats = exports.regExHRef = exports.regExMatchUrls = void 0;
|
|
3
|
+
exports.regExHashStrings = exports.regExSha = exports.regExRepeatedChar = exports.regExEmail = exports.rexExPythonStyleComments = exports.regExCStyleComments = exports.regExString = exports.regExPhpHereDoc = exports.regExBase64MultiLine = exports.regExBase64SingleLine = exports.regExBase64 = exports.regExEscapeCharacters = exports.regExSshRSA = exports.regExCert = exports.regExPublicKey = exports.regExIgnoreSpellingDirectives = exports.regExSpellingGuardLine = exports.regExSpellingGuardNext = exports.regExSpellingGuardBlock = exports.regExUnicodeRef = exports.regExUUID = exports.regExCSSHexValue = exports.regExCStyleHexValue = exports.regExCommitHashLink = exports.regExCommitHash = exports.regExMatchCommonHexFormats = exports.regExHRef = exports.regExMatchUrls = void 0;
|
|
4
4
|
// Exclude Expressions
|
|
5
5
|
// cSpell:ignore anrvtbf
|
|
6
6
|
exports.regExMatchUrls = /(?:https?|ftp):\/\/[^\s"]+/gi;
|
|
@@ -16,10 +16,21 @@ exports.regExSpellingGuardBlock = /(\bc?spell(?:-?checker)?::?)\s*disable(?!-lin
|
|
|
16
16
|
exports.regExSpellingGuardNext = /\bc?spell(?:-?checker)?::?\s*disable-next\b.*\s\s?.*/gi;
|
|
17
17
|
exports.regExSpellingGuardLine = /^.*\bc?spell(?:-?checker)?::?\s*disable-line\b.*/gim;
|
|
18
18
|
exports.regExIgnoreSpellingDirectives = /\bc?spell(?:-?checker)?::?\s*ignoreRegExp.*/gim;
|
|
19
|
-
exports.regExPublicKey =
|
|
20
|
-
exports.regExCert =
|
|
19
|
+
exports.regExPublicKey = /-{5}BEGIN\s+((?:RSA\s+)?PUBLIC\s+KEY)[\w=+\-/=\\\s]+?END\s+\1-{5}/g;
|
|
20
|
+
exports.regExCert = /-{5}BEGIN\s+(CERTIFICATE|(?:RSA\s+)?(?:PRIVATE|PUBLIC)\s+KEY)[\w=+\-/=\\\s]+?END\s+\1-{5}/g;
|
|
21
|
+
exports.regExSshRSA = /ssh-rsa\s+[a-z0-9/+]{28,}={0,3}(?![a-z0-9/+=])/gi;
|
|
21
22
|
exports.regExEscapeCharacters = /\\(?:[anrvtbf]|[xu][a-f0-9]+)/gi;
|
|
22
|
-
exports.regExBase64 = /(?<![
|
|
23
|
+
exports.regExBase64 = /(?<![A-Za-z0-9/+])(?:[A-Za-z0-9/+]{40,})(?:\s^\s*[A-Za-z0-9/+]{40,})*(?:\s^\s*[A-Za-z0-9/+]+=*)?(?![A-Za-z0-9/+=])/gm;
|
|
24
|
+
/**
|
|
25
|
+
* Detect a string of characters that look like a Base64 string.
|
|
26
|
+
*
|
|
27
|
+
* It must be:
|
|
28
|
+
* - at least 40 characters
|
|
29
|
+
* - contain at least 1 of [0-9+=]
|
|
30
|
+
* - end at the end of the line or with [,"'\]
|
|
31
|
+
*/
|
|
32
|
+
exports.regExBase64SingleLine = /(?<![A-Za-z0-9/+])(?=[^/]|[/][A-Za-z0-9/+]+?[=+])(?![A-Za-z/]+(?![A-Za-z0-9/+=]))(?=[A-Za-z0-9/+=]*?(?:[A-Z]{2}|[0-9]{2}))(?:[A-Za-z0-9/+]{4}){10,}(?:[A-Za-z0-9/+]{3}={1}|[A-Za-z0-9/+]{2}={2}|[A-Za-z0-9/+]{1}={3})?(?![A-Za-z0-9/+=])(?=$|[:.,"'\\)])/gm;
|
|
33
|
+
exports.regExBase64MultiLine = /(?<![A-Za-z0-9/+])["']?(?:[A-Za-z0-9/+]{40,})["']?(?:\s^\s*["']?[A-Za-z0-9/+]{40,}["']?)+(?:\s^\s*["']?[A-Za-z0-9/+]+={0,3}["']?)?(?![A-Za-z0-9/+=])/gm;
|
|
23
34
|
// cspell:ignore aeiou
|
|
24
35
|
// The following is an attempt at detecting random strings.
|
|
25
36
|
// export const regExRandomString =
|
|
@@ -32,6 +43,15 @@ exports.regExCStyleComments = /(?<!\w:)(?:\/\/.*)|(?:\/\*[\s\S]*?\*\/)/g;
|
|
|
32
43
|
exports.rexExPythonStyleComments = /#.*|(?:('''|""")[^\1]+?\1)/gm;
|
|
33
44
|
exports.regExEmail = /<?\b[\w.\-+]{1,128}@\w{1,63}(\.\w{1,63}){1,4}\b>?/gi;
|
|
34
45
|
exports.regExRepeatedChar = /^(\w)\1{3,}$/i;
|
|
35
|
-
|
|
36
|
-
|
|
46
|
+
exports.regExSha = /\bsha\d+-[a-z0-9+/]{25,}={0,3}/gi;
|
|
47
|
+
/**
|
|
48
|
+
* Detect common hash strings like:
|
|
49
|
+
* - `sha1`, `sha256`, `sha512`
|
|
50
|
+
* - `md5`
|
|
51
|
+
* - `base64` - used in email
|
|
52
|
+
* - `crypt`, `bcrypt`, `script`
|
|
53
|
+
* - `token`
|
|
54
|
+
* - `assertion` - use with jwt
|
|
55
|
+
*/
|
|
56
|
+
exports.regExHashStrings = /(?:\b(?:sha\d+|md5|base64|crypt|bcrypt|scrypt|security-token|assertion)[-,:$=]|#code[/])[-\w/+%.]{25,}={0,3}(?:(['"])\s*\+?\s*\1?[-\w/+%.]+={0,3})*(?![-\w/+=%.])/gi;
|
|
37
57
|
//# sourceMappingURL=RegExpPatterns.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CSpellUserSettings,
|
|
1
|
+
import type { CSpellUserSettings, DictionaryDefinitionPreferred } from '@cspell/cspell-types';
|
|
2
2
|
import { SpellingDictionaryCollection } from './index';
|
|
3
3
|
import { SpellingDictionary } from './SpellingDictionary';
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function loadDictionaryDefs(defsToLoad: DictionaryDefinitionPreferred[]): Promise<SpellingDictionary>[];
|
|
5
5
|
export declare function refreshDictionaryCache(maxAge?: number): Promise<void>;
|
|
6
6
|
export declare function getDictionary(settings: CSpellUserSettings): Promise<SpellingDictionaryCollection>;
|
|
7
7
|
//# sourceMappingURL=Dictionaries.d.ts.map
|
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDictionary = exports.refreshDictionaryCache = exports.
|
|
4
|
-
const DictionaryReferenceCollection_1 = require("../Settings/DictionaryReferenceCollection");
|
|
3
|
+
exports.getDictionary = exports.refreshDictionaryCache = exports.loadDictionaryDefs = void 0;
|
|
5
4
|
const DictionarySettings_1 = require("../Settings/DictionarySettings");
|
|
6
5
|
const createSpellingDictionary_1 = require("./createSpellingDictionary");
|
|
7
6
|
const DictionaryLoader_1 = require("./DictionaryLoader");
|
|
8
7
|
const SpellingDictionaryCollection_1 = require("./SpellingDictionaryCollection");
|
|
9
|
-
function
|
|
10
|
-
const defsToLoad = (0, DictionarySettings_1.filterDictDefsToLoad)(dictIds, defs);
|
|
8
|
+
function loadDictionaryDefs(defsToLoad) {
|
|
11
9
|
return defsToLoad.map((def) => (0, DictionaryLoader_1.loadDictionary)(def.path, def));
|
|
12
10
|
}
|
|
13
|
-
exports.
|
|
11
|
+
exports.loadDictionaryDefs = loadDictionaryDefs;
|
|
14
12
|
function refreshDictionaryCache(maxAge) {
|
|
15
13
|
return (0, DictionaryLoader_1.refreshCacheEntries)(maxAge);
|
|
16
14
|
}
|
|
17
15
|
exports.refreshDictionaryCache = refreshDictionaryCache;
|
|
18
16
|
function getDictionary(settings) {
|
|
19
|
-
const { words = [], userWords = [],
|
|
20
|
-
const
|
|
21
|
-
const colDicts = (0, DictionaryReferenceCollection_1.createDictionaryReferenceCollection)(dictionaries.concat(colNoSug.enabled()));
|
|
22
|
-
const modDefs = dictionaryDefinitions.map((def) => {
|
|
23
|
-
const enabled = colNoSug.isEnabled(def.name);
|
|
24
|
-
if (enabled === undefined)
|
|
25
|
-
return def;
|
|
26
|
-
return { ...def, noSuggest: enabled };
|
|
27
|
-
});
|
|
28
|
-
const spellDictionaries = loadDictionaries(colDicts.enabled(), modDefs);
|
|
17
|
+
const { words = [], userWords = [], flagWords = [], ignoreWords = [] } = settings;
|
|
18
|
+
const spellDictionaries = loadDictionaryDefs((0, DictionarySettings_1.calcDictionaryDefsToLoad)(settings));
|
|
29
19
|
const settingsDictionary = (0, createSpellingDictionary_1.createSpellingDictionary)(words.concat(userWords), '[words]', 'From Settings `words` and `userWords`', {
|
|
30
20
|
caseSensitive: true,
|
|
31
21
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReplaceMap } from '@cspell/cspell-types';
|
|
1
|
+
import type { ReplaceMap, SuggestionCostsDefs } from '@cspell/cspell-types';
|
|
2
2
|
import { CompoundWordsMethod, SuggestionCollector, SuggestionResult } from 'cspell-trie-lib';
|
|
3
3
|
export { CompoundWordsMethod, SuggestionCollector, SuggestionResult } from 'cspell-trie-lib';
|
|
4
4
|
export interface SearchOptions {
|
|
@@ -50,6 +50,7 @@ export interface SpellingDictionaryOptions {
|
|
|
50
50
|
useCompounds?: boolean;
|
|
51
51
|
caseSensitive?: boolean;
|
|
52
52
|
noSuggest?: boolean;
|
|
53
|
+
suggestionDefs?: SuggestionCostsDefs | undefined;
|
|
53
54
|
}
|
|
54
55
|
export interface SpellingDictionary {
|
|
55
56
|
readonly name: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { SuggestionCollector, SuggestionResult } from 'cspell-trie-lib';
|
|
2
|
+
import { CompoundWordsMethod, Trie } from 'cspell-trie-lib';
|
|
3
|
+
import { FindResult, HasOptions, SpellingDictionary, SpellingDictionaryOptions, SuggestOptions } from './SpellingDictionary';
|
|
3
4
|
export declare class SpellingDictionaryFromTrie implements SpellingDictionary {
|
|
4
5
|
readonly trie: Trie;
|
|
5
6
|
readonly name: string;
|
|
@@ -13,6 +14,7 @@ export declare class SpellingDictionaryFromTrie implements SpellingDictionary {
|
|
|
13
14
|
readonly type = "SpellingDictionaryFromTrie";
|
|
14
15
|
readonly isDictionaryCaseSensitive: boolean;
|
|
15
16
|
readonly containsNoSuggestWords: boolean;
|
|
17
|
+
private weightMap;
|
|
16
18
|
constructor(trie: Trie, name: string, options: SpellingDictionaryOptions, source?: string, size?: number);
|
|
17
19
|
get size(): number;
|
|
18
20
|
has(word: string, hasOptions?: HasOptions): boolean;
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createSpellingDictionaryTrie = exports.SpellingDictionaryFromTrie = void 0;
|
|
4
4
|
const cspell_trie_lib_1 = require("cspell-trie-lib");
|
|
5
|
-
const repMap_1 = require("../util/repMap");
|
|
6
5
|
const Settings_1 = require("../Settings");
|
|
7
6
|
const Memorizer_1 = require("../util/Memorizer");
|
|
7
|
+
const repMap_1 = require("../util/repMap");
|
|
8
8
|
const SpellingDictionaryMethods_1 = require("./SpellingDictionaryMethods");
|
|
9
9
|
class SpellingDictionaryFromTrie {
|
|
10
10
|
constructor(trie, name, options, source = 'from trie', size) {
|
|
@@ -22,6 +22,7 @@ class SpellingDictionaryFromTrie {
|
|
|
22
22
|
this.isDictionaryCaseSensitive = (_a = options.caseSensitive) !== null && _a !== void 0 ? _a : !trie.isLegacy;
|
|
23
23
|
this.containsNoSuggestWords = options.noSuggest || false;
|
|
24
24
|
this._size = size || 0;
|
|
25
|
+
this.weightMap = options.suggestionDefs ? (0, cspell_trie_lib_1.createWeightedMap)(options.suggestionDefs) : undefined;
|
|
25
26
|
}
|
|
26
27
|
get size() {
|
|
27
28
|
if (!this._size) {
|
|
@@ -106,6 +107,7 @@ class SpellingDictionaryFromTrie {
|
|
|
106
107
|
includeTies,
|
|
107
108
|
ignoreCase,
|
|
108
109
|
timeout,
|
|
110
|
+
weightMap: this.weightMap,
|
|
109
111
|
});
|
|
110
112
|
this.genSuggestions(collector, suggestOptions);
|
|
111
113
|
return collector.suggestions.map((r) => ({ ...r, word: r.word }));
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './Settings';
|
|
|
9
9
|
export { defaultFileName as defaultSettingsFilename } from './Settings';
|
|
10
10
|
export { combineTextAndLanguageSettings, combineTextAndLanguageSettings as constructSettingsForText, } from './Settings/TextDocumentSettings';
|
|
11
11
|
export { determineFinalDocumentSettings, DetermineFinalDocumentSettingsResult, Document, fileToDocument, isBinaryFile, spellCheckDocument, spellCheckFile, SpellCheckFileOptions, SpellCheckFileResult, } from './spellCheckFile';
|
|
12
|
-
export { CompoundWordsMethod, createSpellingDictionary, getDictionary, isSpellingDictionaryLoadError, refreshDictionaryCache, SpellingDictionary, SpellingDictionaryLoadError, SuggestionCollector, SuggestionResult, SpellingDictionaryCollection, } from './SpellingDictionary';
|
|
12
|
+
export { CompoundWordsMethod, createSpellingDictionary, getDictionary, isSpellingDictionaryLoadError, refreshDictionaryCache, SpellingDictionary, SpellingDictionaryLoadError, SuggestionCollector, SuggestionResult, SpellingDictionaryCollection, SuggestOptions, } from './SpellingDictionary';
|
|
13
13
|
export * from './trace';
|
|
14
14
|
export { getLogger, Logger, setLogger } from './util/logger';
|
|
15
15
|
export { resolveFile } from './util/resolveFile';
|
package/dist/textValidator.js
CHANGED
|
@@ -42,7 +42,7 @@ function validateText(text, dict, options) {
|
|
|
42
42
|
const n = (mapOfProblems.get(word) || 0) + 1;
|
|
43
43
|
mapOfProblems.set(word, n);
|
|
44
44
|
// Filter out if there is too many
|
|
45
|
-
return n
|
|
45
|
+
return n <= maxDuplicateProblems;
|
|
46
46
|
})
|
|
47
47
|
.take(maxNumberOfProblems);
|
|
48
48
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cspell-lib",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.15.3",
|
|
4
4
|
"description": "A library of useful functions used across various cspell tools.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -47,15 +47,15 @@
|
|
|
47
47
|
},
|
|
48
48
|
"homepage": "https://github.com/streetsidesoftware/cspell#readme",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@cspell/cspell-bundled-dicts": "^5.
|
|
51
|
-
"@cspell/cspell-types": "^5.
|
|
50
|
+
"@cspell/cspell-bundled-dicts": "^5.15.3",
|
|
51
|
+
"@cspell/cspell-types": "^5.15.3",
|
|
52
52
|
"clear-module": "^4.1.2",
|
|
53
53
|
"comment-json": "^4.1.1",
|
|
54
54
|
"configstore": "^5.0.1",
|
|
55
55
|
"cosmiconfig": "^7.0.1",
|
|
56
|
-
"cspell-glob": "^5.
|
|
57
|
-
"cspell-io": "^5.
|
|
58
|
-
"cspell-trie-lib": "^5.
|
|
56
|
+
"cspell-glob": "^5.15.3",
|
|
57
|
+
"cspell-io": "^5.15.3",
|
|
58
|
+
"cspell-trie-lib": "^5.15.3",
|
|
59
59
|
"find-up": "^5.0.0",
|
|
60
60
|
"fs-extra": "^10.0.0",
|
|
61
61
|
"gensequence": "^3.1.1",
|
|
@@ -78,13 +78,13 @@
|
|
|
78
78
|
"@cspell/dict-python": "^2.0.5",
|
|
79
79
|
"@types/configstore": "^5.0.1",
|
|
80
80
|
"@types/fs-extra": "^9.0.13",
|
|
81
|
-
"@types/jest": "^27.0
|
|
82
|
-
"@types/node": "^17.0.
|
|
81
|
+
"@types/jest": "^27.4.0",
|
|
82
|
+
"@types/node": "^17.0.10",
|
|
83
83
|
"cspell-dict-nl-nl": "^1.1.2",
|
|
84
|
-
"jest": "^27.4.
|
|
84
|
+
"jest": "^27.4.7",
|
|
85
85
|
"lorem-ipsum": "^2.0.4",
|
|
86
86
|
"rimraf": "^3.0.2",
|
|
87
|
-
"ts-jest": "^27.1.
|
|
87
|
+
"ts-jest": "^27.1.3"
|
|
88
88
|
},
|
|
89
|
-
"gitHead": "
|
|
89
|
+
"gitHead": "8a7c55b7d0b340d3c4e964ba91390a405f2cda2d"
|
|
90
90
|
}
|