cspell-lib 5.12.2 → 5.12.6

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 @@ 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,18 @@ 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],
42
43
  [/^words?\s/i, parseWords],
43
44
  [/^ignore(?:words?)?\s/i, parseIgnoreWords],
44
45
  [/^ignore_?Reg_?Exp\s+.+$/i, parseIgnoreRegExp],
45
46
  [/^include_?Reg_?Exp\s+.+$/i, parseIncludeRegExp],
46
- [/^locale?\s/i, parseLocal],
47
- [/^language\s/i, parseLocal],
47
+ [/^locale?\s/i, parseLocale],
48
+ [/^language\s/i, parseLocale],
48
49
  [/^dictionaries\s/i, parseDictionaries],
49
- [/^LocalWords:/, parseWords],
50
+ [/^LocalWords:/, (w) => parseWords(w.replace(/LocalWords:?/gi, ' '))],
50
51
  ];
51
52
  return settingParsers
52
53
  .filter(([regex]) => regex.test(possibleSetting))
@@ -61,9 +62,9 @@ function parseWords(match) {
61
62
  const words = match.split(/[,\s]+/g).slice(1);
62
63
  return { id: 'in-doc-words', words };
63
64
  }
64
- function parseLocal(match) {
65
- const parts = match.trim().split(/\s+/);
66
- const language = parts.slice(1).join(' ');
65
+ function parseLocale(match) {
66
+ const parts = match.trim().split(/[\s,]+/);
67
+ const language = parts.slice(1).join(',');
67
68
  return language ? { id: 'in-doc-local', language } : {};
68
69
  }
69
70
  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;
@@ -14,6 +14,7 @@ export interface Loaders {
14
14
  S: Loader;
15
15
  C: Loader;
16
16
  T: Loader;
17
+ W: Loader;
17
18
  default: Loader;
18
19
  }
19
20
  export declare function loadDictionary(uri: string, options: DictionaryDefinitionPreferred): Promise<SpellingDictionary>;
@@ -31,6 +31,7 @@ const MAX_AGE = 10000;
31
31
  const loaders = {
32
32
  S: loadSimpleWordList,
33
33
  C: legacyWordList,
34
+ W: wordsPerLineWordList,
34
35
  T: loadTrie,
35
36
  default: loadSimpleWordList,
36
37
  };
@@ -115,6 +116,16 @@ async function legacyWordList(filename, options) {
115
116
  .filter((word) => !!word);
116
117
  return (0, createSpellingDictionary_1.createSpellingDictionary)(words, determineName(filename, options), filename, options);
117
118
  }
119
+ async function wordsPerLineWordList(filename, options) {
120
+ const lines = await (0, fileReader_1.readLines)(filename);
121
+ const words = (0, gensequence_1.genSequence)(lines)
122
+ // Remove comments
123
+ .map((line) => line.replace(/#.*/g, ''))
124
+ // Split on everything else
125
+ .concatMap((line) => line.split(/\s+/gu))
126
+ .filter((word) => !!word);
127
+ return (0, createSpellingDictionary_1.createSpellingDictionary)(words, determineName(filename, options), filename, options);
128
+ }
118
129
  async function loadSimpleWordList(filename, options) {
119
130
  const lines = await (0, fileReader_1.readLines)(filename);
120
131
  return (0, createSpellingDictionary_1.createSpellingDictionary)(lines, determineName(filename, options), filename, options);
@@ -104,12 +104,9 @@ function lineValidator(dict, options) {
104
104
  }
105
105
  const codeWordResults = Text.extractWordsFromCodeTextOffset(vr)
106
106
  .filter(filterAlreadyChecked)
107
- .filter(rememberFilter((wo) => wo.text.length >= minWordLength))
108
107
  .map((t) => ({ ...t, line: vr.line }))
109
- .map((wo) => {
110
- const vr = wo;
111
- return vr;
112
- })
108
+ .map(checkFlagWords)
109
+ .filter(rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged))
113
110
  .map((wo) => (wo.isFlagged ? wo : checkWord(wo, hasWordOptions)))
114
111
  .filter(rememberFilter((wo) => wo.isFlagged || !wo.isFound))
115
112
  .filter(rememberFilter((wo) => !RxPat.regExRepeatedChar.test(wo.text))) // Filter out any repeated characters like xxxxxxxxxx
@@ -128,9 +125,9 @@ function lineValidator(dict, options) {
128
125
  function checkPossibleWords(possibleWord) {
129
126
  const mismatches = Text.extractWordsFromTextOffset(possibleWord)
130
127
  .filter(filterAlreadyChecked)
131
- .filter(rememberFilter((wo) => wo.text.length >= minWordLength))
132
128
  .map((wo) => ({ ...wo, line: lineSegment }))
133
129
  .map(checkFlagWords)
130
+ .filter(rememberFilter((wo) => wo.text.length >= minWordLength || !!wo.isFlagged))
134
131
  .concatMap(checkFullWord)
135
132
  .toArray();
136
133
  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.2",
3
+ "version": "5.12.6",
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.2",
51
- "@cspell/cspell-types": "^5.12.2",
52
- "clear-module": "^4.1.1",
50
+ "@cspell/cspell-bundled-dicts": "^5.12.6",
51
+ "@cspell/cspell-types": "^5.12.6",
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.2",
57
- "cspell-io": "^5.12.2",
58
- "cspell-trie-lib": "^5.12.2",
56
+ "cspell-glob": "^5.12.6",
57
+ "cspell-io": "^5.12.6",
58
+ "cspell-trie-lib": "^5.12.6",
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
77
  "@cspell/dict-nl-nl": "^2.0.1",
78
- "@cspell/dict-python": "^2.0.3",
78
+ "@cspell/dict-python": "^2.0.4",
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.6",
83
83
  "cspell-dict-nl-nl": "^1.1.2",
84
- "jest": "^27.2.4",
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": "1418785bb9c3a29b794a6e9d447b5638f8eb9fbf"
89
+ "gitHead": "430bb6103b03793d5f0b746e7c643d12fa313216"
90
90
  }