cspell-lib 5.12.3 → 5.13.0

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.
@@ -95,6 +95,7 @@ exports.languageExtensionDefinitions = [
95
95
  { id: 'typescript', extensions: ['.ts'] },
96
96
  { id: 'typescriptreact', extensions: ['.tsx'] },
97
97
  { id: 'vb', extensions: ['.vb', '.brs', '.vbs', '.bas'] },
98
+ { id: 'vue', extensions: ['.vue'] },
98
99
  {
99
100
  id: 'xml',
100
101
  extensions: [
@@ -25,7 +25,7 @@ export declare function readRawSettings(filename: string, relativeTo?: string):
25
25
  *
26
26
  * @param filenames - settings files to read
27
27
  * @returns combined configuration
28
- * @deprecated
28
+ * @deprecated true
29
29
  */
30
30
  export declare function readSettingsFiles(filenames: string[]): CSpellSettings;
31
31
  export declare function mergeSettings(left: CSpellSettings, ...settings: CSpellSettings[]): CSpellSettings;
@@ -290,7 +290,7 @@ exports.readRawSettings = readRawSettings;
290
290
  *
291
291
  * @param filenames - settings files to read
292
292
  * @returns combined configuration
293
- * @deprecated
293
+ * @deprecated true
294
294
  */
295
295
  function readSettingsFiles(filenames) {
296
296
  return filenames.map((filename) => readSettings(filename)).reduce((a, b) => mergeSettings(a, b), defaultSettings);
@@ -25,7 +25,7 @@ const Text = __importStar(require("../util/text"));
25
25
  const CSpellSettingsServer_1 = require("./CSpellSettingsServer");
26
26
  // cspell:ignore gimuy
27
27
  const regExMatchRegEx = /\/.*\/[gimuy]*/;
28
- const regExInFileSettings = [/(?:spell-?checker|cSpell)::?\s*(.*)/gi, /(LocalWords:?\s+.*)/g];
28
+ const regExInFileSettings = [/(?:spell-?checker|c?spell)::?(.*)/gi, /(LocalWords:?.*)/g];
29
29
  function getInDocumentSettings(text) {
30
30
  const settings = getPossibleInDocSettings(text)
31
31
  .concatMap((a) => parseSettingMatch(a))
@@ -36,17 +36,19 @@ function getInDocumentSettings(text) {
36
36
  }
37
37
  exports.getInDocumentSettings = getInDocumentSettings;
38
38
  function parseSettingMatch(matchArray) {
39
- const [, possibleSetting = ''] = matchArray;
39
+ const [, match = ''] = matchArray;
40
+ const possibleSetting = match.trim();
40
41
  const settingParsers = [
41
42
  [/^(?:enable|disable)(?:allow)?CompoundWords/i, parseCompoundWords],
43
+ [/^(?:enable|disable)CaseSensitive/i, parseCaseSensitive],
42
44
  [/^words?\s/i, parseWords],
43
45
  [/^ignore(?:words?)?\s/i, parseIgnoreWords],
44
46
  [/^ignore_?Reg_?Exp\s+.+$/i, parseIgnoreRegExp],
45
47
  [/^include_?Reg_?Exp\s+.+$/i, parseIncludeRegExp],
46
- [/^locale?\s/i, parseLocal],
47
- [/^language\s/i, parseLocal],
48
+ [/^locale?\s/i, parseLocale],
49
+ [/^language\s/i, parseLocale],
48
50
  [/^dictionaries\s/i, parseDictionaries],
49
- [/^LocalWords:/, parseWords],
51
+ [/^LocalWords:/, (w) => parseWords(w.replace(/LocalWords:?/gi, ' '))],
50
52
  ];
51
53
  return settingParsers
52
54
  .filter(([regex]) => regex.test(possibleSetting))
@@ -57,13 +59,17 @@ function parseCompoundWords(match) {
57
59
  const allowCompoundWords = /enable/i.test(match);
58
60
  return { id: 'in-doc-allowCompoundWords', allowCompoundWords };
59
61
  }
62
+ function parseCaseSensitive(match) {
63
+ const caseSensitive = /enable/i.test(match);
64
+ return { id: 'in-doc-caseSensitive', caseSensitive };
65
+ }
60
66
  function parseWords(match) {
61
67
  const words = match.split(/[,\s]+/g).slice(1);
62
68
  return { id: 'in-doc-words', words };
63
69
  }
64
- function parseLocal(match) {
65
- const parts = match.trim().split(/\s+/);
66
- const language = parts.slice(1).join(' ');
70
+ function parseLocale(match) {
71
+ const parts = match.trim().split(/[\s,]+/);
72
+ const language = parts.slice(1).join(',');
67
73
  return language ? { id: 'in-doc-local', language } : {};
68
74
  }
69
75
  function parseIgnoreWords(match) {
@@ -27,13 +27,19 @@ function getDefaultLanguageSettings() {
27
27
  return defaultLanguageSettings;
28
28
  }
29
29
  exports.getDefaultLanguageSettings = getDefaultLanguageSettings;
30
+ function localesToList(locales) {
31
+ locales = typeof locales !== 'string' ? locales.join(',') : locales;
32
+ return stringToList(locales.replace(/\s+/g, ','));
33
+ }
30
34
  function stringToList(sList) {
31
- if (typeof sList === 'string') {
32
- sList = sList
33
- .replace(/[|;]/g, ',')
34
- .split(',')
35
- .map((s) => s.trim());
35
+ if (typeof sList !== 'string') {
36
+ sList = sList.join(',');
36
37
  }
38
+ sList = sList
39
+ .replace(/[|;]/g, ',')
40
+ .split(',')
41
+ .map((s) => s.trim())
42
+ .filter((s) => !!s);
37
43
  return sList;
38
44
  }
39
45
  function normalizeLanguageId(langId) {
@@ -45,7 +51,7 @@ function normalizeLanguageIdToString(langId) {
45
51
  return [...normalizeLanguageId(langId)].join(',');
46
52
  }
47
53
  function normalizeLocale(locale) {
48
- locale = stringToList(locale);
54
+ locale = localesToList(locale);
49
55
  return new Set(locale.map((locale) => locale.toLowerCase().replace(/[^a-z]/g, '')));
50
56
  }
51
57
  exports.normalizeLocale = normalizeLocale;
@@ -81,10 +81,13 @@ function lineValidator(dict, options) {
81
81
  function isWordIgnored(word) {
82
82
  return dict.isNoSuggestWord(word, options);
83
83
  }
84
- function checkFlagWords(word) {
84
+ function isWordFlagged(word) {
85
85
  const isIgnored = isWordIgnored(word.text);
86
86
  const isFlagged = !isIgnored && testForFlaggedWord(word);
87
- word.isFlagged = isFlagged;
87
+ return isFlagged;
88
+ }
89
+ function checkFlagWords(word) {
90
+ word.isFlagged = isWordFlagged(word);
88
91
  return word;
89
92
  }
90
93
  function checkWord(word, options) {
@@ -104,12 +107,9 @@ function lineValidator(dict, options) {
104
107
  }
105
108
  const codeWordResults = Text.extractWordsFromCodeTextOffset(vr)
106
109
  .filter(filterAlreadyChecked)
107
- .filter(rememberFilter((wo) => wo.text.length >= minWordLength))
108
110
  .map((t) => ({ ...t, line: vr.line }))
109
- .map((wo) => {
110
- const vr = wo;
111
- return vr;
112
- })
111
+ .map(checkFlagWords)
112
+ .filter(rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged))
113
113
  .map((wo) => (wo.isFlagged ? wo : checkWord(wo, hasWordOptions)))
114
114
  .filter(rememberFilter((wo) => wo.isFlagged || !wo.isFound))
115
115
  .filter(rememberFilter((wo) => !RxPat.regExRepeatedChar.test(wo.text))) // Filter out any repeated characters like xxxxxxxxxx
@@ -126,11 +126,19 @@ function lineValidator(dict, options) {
126
126
  return codeWordResults;
127
127
  }
128
128
  function checkPossibleWords(possibleWord) {
129
+ if (isWordFlagged(possibleWord)) {
130
+ const vr = {
131
+ ...possibleWord,
132
+ line: lineSegment,
133
+ isFlagged: true,
134
+ };
135
+ return [vr];
136
+ }
129
137
  const mismatches = Text.extractWordsFromTextOffset(possibleWord)
130
138
  .filter(filterAlreadyChecked)
131
- .filter(rememberFilter((wo) => wo.text.length >= minWordLength))
132
139
  .map((wo) => ({ ...wo, line: lineSegment }))
133
140
  .map(checkFlagWords)
141
+ .filter(rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged))
134
142
  .concatMap(checkFullWord)
135
143
  .toArray();
136
144
  if (mismatches.length) {
package/dist/trace.d.ts CHANGED
@@ -16,6 +16,7 @@ export interface TraceOptions {
16
16
  languageId?: LanguageId | LanguageId[];
17
17
  locale?: LocaleId;
18
18
  ignoreCase?: boolean;
19
+ allowCompoundWords?: boolean;
19
20
  }
20
21
  export declare function traceWords(words: string[], settings: CSpellSettings, options: TraceOptions | undefined): Promise<TraceResult[]>;
21
22
  //# sourceMappingURL=trace.d.ts.map
package/dist/trace.js CHANGED
@@ -26,10 +26,13 @@ const LanguageSettings_1 = require("./Settings/LanguageSettings");
26
26
  const SpellingDictionary_1 = require("./SpellingDictionary");
27
27
  const util = __importStar(require("./util/util"));
28
28
  async function traceWords(words, settings, options) {
29
- const { languageId, locale: language, ignoreCase = true } = options || {};
29
+ const { languageId, locale: language, ignoreCase = true, allowCompoundWords } = options || {};
30
30
  async function finalize(config) {
31
31
  var _a;
32
- const withLocale = (0, Settings_1.mergeSettings)(config, { language });
32
+ const withLocale = (0, Settings_1.mergeSettings)(config, {
33
+ language,
34
+ allowCompoundWords: allowCompoundWords !== null && allowCompoundWords !== void 0 ? allowCompoundWords : config.allowCompoundWords,
35
+ });
33
36
  const withLanguageId = (0, LanguageSettings_1.calcSettingsForLanguageId)(withLocale, (_a = languageId !== null && languageId !== void 0 ? languageId : withLocale.languageId) !== null && _a !== void 0 ? _a : 'plaintext');
34
37
  const settings = (0, Settings_1.finalizeSettings)(withLanguageId);
35
38
  const dictionaries = (settings.dictionaries || [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell-lib",
3
- "version": "5.12.3",
3
+ "version": "5.13.0",
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.12.3",
51
- "@cspell/cspell-types": "^5.12.3",
52
- "clear-module": "^4.1.1",
50
+ "@cspell/cspell-bundled-dicts": "^5.13.0",
51
+ "@cspell/cspell-types": "^5.13.0",
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.12.3",
57
- "cspell-io": "^5.12.3",
58
- "cspell-trie-lib": "^5.12.3",
56
+ "cspell-glob": "^5.13.0",
57
+ "cspell-io": "^5.13.0",
58
+ "cspell-trie-lib": "^5.13.0",
59
59
  "find-up": "^5.0.0",
60
60
  "fs-extra": "^10.0.0",
61
61
  "gensequence": "^3.1.1",
@@ -72,19 +72,19 @@
72
72
  "@cspell/dict-csharp": "^1.0.11",
73
73
  "@cspell/dict-css": "^1.0.12",
74
74
  "@cspell/dict-fa-ir": "^1.0.17",
75
- "@cspell/dict-fr-fr": "^1.2.21",
75
+ "@cspell/dict-fr-fr": "^2.0.1",
76
76
  "@cspell/dict-html": "^1.1.9",
77
- "@cspell/dict-nl-nl": "^2.0.1",
78
- "@cspell/dict-python": "^2.0.3",
77
+ "@cspell/dict-nl-nl": "^2.1.0",
78
+ "@cspell/dict-python": "^2.0.5",
79
79
  "@types/configstore": "^5.0.1",
80
80
  "@types/fs-extra": "^9.0.13",
81
81
  "@types/jest": "^27.0.2",
82
- "@types/node": "^16.10.3",
82
+ "@types/node": "^16.11.7",
83
83
  "cspell-dict-nl-nl": "^1.1.2",
84
- "jest": "^27.2.5",
84
+ "jest": "^27.3.1",
85
85
  "lorem-ipsum": "^2.0.4",
86
86
  "rimraf": "^3.0.2",
87
- "ts-jest": "^27.0.5"
87
+ "ts-jest": "^27.0.7"
88
88
  },
89
- "gitHead": "6c424aed933adb8d983ab09dd45042d63d7a5cd8"
89
+ "gitHead": "4cd5431b084824e172798ae97f2f520dbad4a8ac"
90
90
  }