cspell-lib 9.3.1 → 9.4.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.
@@ -94,6 +94,7 @@ export interface IConfigLoader {
94
94
  readonly isTrusted: boolean;
95
95
  setIsTrusted(isTrusted: boolean): void;
96
96
  }
97
+ export declare const defaultExtensionsAll: string[];
97
98
  export declare class ConfigLoader implements IConfigLoader {
98
99
  #private;
99
100
  readonly fs: VFileSystem;
@@ -30,11 +30,12 @@ const setOfSupportedConfigVersions = Object.freeze(new Set(supportedCSpellConfig
30
30
  export const sectionCSpell = 'cSpell';
31
31
  export const defaultFileName = 'cspell.json';
32
32
  let defaultConfigLoader = undefined;
33
- const defaultExtensions = ['.json', '.yaml', '.yml', '.jsonc'];
34
- const defaultJsExtensions = ['.js', '.cjs', '.mjs'];
33
+ const defaultExtensions = ['.json', '.yaml', '.yml', '.jsonc', '.toml'];
34
+ const defaultJsExtensions = ['.js', '.cjs', '.mjs', '.ts', '.mts'];
35
+ export const defaultExtensionsAll = [...defaultExtensions, ...defaultJsExtensions];
35
36
  const trustedSearch = new Map([
36
37
  ['*', defaultExtensions],
37
- ['file:', [...defaultExtensions, ...defaultJsExtensions]],
38
+ ['file:', defaultExtensionsAll],
38
39
  ]);
39
40
  const unTrustedSearch = new Map([['*', defaultExtensions]]);
40
41
  export class ConfigLoader {
@@ -1,3 +1,4 @@
1
+ export declare const supportedExtensions: string[];
1
2
  export declare const searchPlaces: readonly string[];
2
3
  export declare const defaultConfigFilenames: readonly string[];
3
4
  //# sourceMappingURL=configLocations.d.ts.map
@@ -1,4 +1,15 @@
1
- const supportedExtensions = ['.json', '.jsonc', '.yaml', '.yml', '.mjs', '.cjs', '.js', '.toml', '.mts', '.ts'];
1
+ export const supportedExtensions = [
2
+ '.json',
3
+ '.jsonc',
4
+ '.yaml',
5
+ '.yml',
6
+ '.mjs',
7
+ '.cjs',
8
+ '.js',
9
+ '.toml',
10
+ '.mts',
11
+ '.ts',
12
+ ];
2
13
  /**
3
14
  * Logic of the locations:
4
15
  * - Support backward compatibility with the VS Code Spell Checker
@@ -131,9 +131,31 @@ interface Preparations {
131
131
  localConfigFilepath: string | undefined;
132
132
  }
133
133
  interface ShouldCheckDocumentResult {
134
+ /** possible errors found while loading configuration. */
134
135
  errors: Error[];
136
+ /**
137
+ * The calculated result:
138
+ * - `false` if the document should not be checked. Based upon the settings.
139
+ * - `true` if the document should be checked.
140
+ */
135
141
  shouldCheck: boolean;
142
+ /** final settings used to determine the result. */
143
+ settings: CSpellUserSettings;
144
+ /**
145
+ * The reason the document should not be checked.
146
+ */
147
+ reason?: string | undefined;
136
148
  }
149
+ /**
150
+ * Check if a document should be checked based upon the ignorePaths and override settings.
151
+ *
152
+ * This function will search and fetch settings based upon the location of the document if `noConfigSearch` is not true.
153
+ *
154
+ * @param doc - document to check
155
+ * @param options - options to override some of the settings.
156
+ * @param settings - current settings
157
+ * @returns ShouldCheckDocumentResult
158
+ */
137
159
  export declare function shouldCheckDocument(doc: TextDocumentRef, options: DocumentValidatorOptions, settings: CSpellUserSettings): Promise<ShouldCheckDocumentResult>;
138
160
  export declare const __testing__: {
139
161
  sanitizeSuggestion: typeof sanitizeSuggestion;
@@ -81,7 +81,9 @@ export class DocumentValidator {
81
81
  : useSearchForConfig
82
82
  ? timePromise(this.perfTiming, '__searchForDocumentConfig', searchForDocumentConfig(this._document, settings, settings))
83
83
  : undefined;
84
- pLocalConfig && timePromise(this.perfTiming, '_loadConfig', pLocalConfig);
84
+ if (pLocalConfig) {
85
+ timePromise(this.perfTiming, '_loadConfig', pLocalConfig);
86
+ }
85
87
  const localConfig = (await catchPromiseError(pLocalConfig, (e) => this.addPossibleError(e))) || {};
86
88
  this.addPossibleError(localConfig?.__importRef?.error);
87
89
  const config = mergeSettings(settings, localConfig);
@@ -394,6 +396,16 @@ async function searchForDocumentConfig(document, defaultConfig, pnpSettings) {
394
396
  function mapSug(sug) {
395
397
  return { cost: 999, ...sug };
396
398
  }
399
+ /**
400
+ * Check if a document should be checked based upon the ignorePaths and override settings.
401
+ *
402
+ * This function will search and fetch settings based upon the location of the document if `noConfigSearch` is not true.
403
+ *
404
+ * @param doc - document to check
405
+ * @param options - options to override some of the settings.
406
+ * @param settings - current settings
407
+ * @returns ShouldCheckDocumentResult
408
+ */
397
409
  export async function shouldCheckDocument(doc, options, settings) {
398
410
  const errors = [];
399
411
  function addPossibleError(error) {
@@ -413,11 +425,16 @@ export async function shouldCheckDocument(doc, options, settings) {
413
425
  addPossibleError(localConfig?.__importRef?.error);
414
426
  const config = mergeSettings(settings, localConfig);
415
427
  const matcher = getGlobMatcherForExcluding(localConfig?.ignorePaths);
416
- const docSettings = await determineTextDocumentSettings(doc, config);
417
428
  // eslint-disable-next-line unicorn/prefer-regexp-test
418
- return !matcher.match(uriToFilePath(doc.uri)) && (docSettings.enabled ?? true);
429
+ if (matcher.match(uriToFilePath(doc.uri))) {
430
+ return { errors, shouldCheck: false, settings: localConfig, reason: 'Excluded by ignorePaths.' };
431
+ }
432
+ const docSettings = await determineTextDocumentSettings(doc, config);
433
+ const shouldCheck = docSettings.enabled ?? true;
434
+ const reason = shouldCheck ? undefined : 'Excluded by overrides or languageSettings.';
435
+ return { errors, shouldCheck, settings: docSettings, reason };
419
436
  }
420
- return { errors, shouldCheck: await shouldCheck() };
437
+ return await shouldCheck();
421
438
  }
422
439
  export const __testing__ = {
423
440
  sanitizeSuggestion,
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "access": "public",
5
5
  "provenance": true
6
6
  },
7
- "version": "9.3.1",
7
+ "version": "9.4.0",
8
8
  "description": "A library of useful functions used across various cspell tools.",
9
9
  "type": "module",
10
10
  "sideEffects": false,
@@ -64,21 +64,21 @@
64
64
  },
65
65
  "homepage": "https://github.com/streetsidesoftware/cspell/tree/main/packages/cspell-lib#readme",
66
66
  "dependencies": {
67
- "@cspell/cspell-bundled-dicts": "9.3.1",
68
- "@cspell/cspell-pipe": "9.3.1",
69
- "@cspell/cspell-resolver": "9.3.1",
70
- "@cspell/cspell-types": "9.3.1",
71
- "@cspell/dynamic-import": "9.3.1",
72
- "@cspell/filetypes": "9.3.1",
73
- "@cspell/strong-weak-map": "9.3.1",
74
- "@cspell/url": "9.3.1",
67
+ "@cspell/cspell-bundled-dicts": "9.4.0",
68
+ "@cspell/cspell-pipe": "9.4.0",
69
+ "@cspell/cspell-resolver": "9.4.0",
70
+ "@cspell/cspell-types": "9.4.0",
71
+ "@cspell/dynamic-import": "9.4.0",
72
+ "@cspell/filetypes": "9.4.0",
73
+ "@cspell/strong-weak-map": "9.4.0",
74
+ "@cspell/url": "9.4.0",
75
75
  "clear-module": "^4.1.2",
76
- "cspell-config-lib": "9.3.1",
77
- "cspell-dictionary": "9.3.1",
78
- "cspell-glob": "9.3.1",
79
- "cspell-grammar": "9.3.1",
80
- "cspell-io": "9.3.1",
81
- "cspell-trie-lib": "9.3.1",
76
+ "cspell-config-lib": "9.4.0",
77
+ "cspell-dictionary": "9.4.0",
78
+ "cspell-glob": "9.4.0",
79
+ "cspell-grammar": "9.4.0",
80
+ "cspell-io": "9.4.0",
81
+ "cspell-trie-lib": "9.4.0",
82
82
  "env-paths": "^3.0.0",
83
83
  "gensequence": "^8.0.8",
84
84
  "import-fresh": "^3.3.1",
@@ -91,14 +91,14 @@
91
91
  "node": ">=20"
92
92
  },
93
93
  "devDependencies": {
94
- "@cspell/dict-cpp": "^6.0.14",
94
+ "@cspell/dict-cpp": "^6.0.15",
95
95
  "@cspell/dict-csharp": "^4.0.7",
96
96
  "@cspell/dict-css": "^4.0.18",
97
97
  "@cspell/dict-fa-ir": "^4.0.5",
98
98
  "@cspell/dict-fr-fr": "^2.3.2",
99
- "@cspell/dict-html": "^4.0.12",
99
+ "@cspell/dict-html": "^4.0.13",
100
100
  "@cspell/dict-nl-nl": "^2.4.2",
101
- "@cspell/dict-python": "^4.2.21",
101
+ "@cspell/dict-python": "^4.2.23",
102
102
  "@types/configstore": "^6.0.2",
103
103
  "comment-json": "^4.4.1",
104
104
  "configstore": "^7.1.0",
@@ -107,5 +107,5 @@
107
107
  "lorem-ipsum": "^2.0.8",
108
108
  "perf-insight": "^2.0.1"
109
109
  },
110
- "gitHead": "3f8bf5c88cda393b581957b7f8efc696e432f6f1"
110
+ "gitHead": "12dba3d8b880384d1401c765cb2186647f5a266f"
111
111
  }