cspell 8.15.1 → 8.15.2

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.
@@ -1,5 +1,5 @@
1
1
  import type { Issue } from '@cspell/cspell-types';
2
- import type { LinterCliOptions, LinterOptions } from '../options.js';
2
+ import type { CSpellConfigFile, LinterCliOptions, LinterOptions } from '../options.js';
3
3
  import type { GlobSrcInfo } from '../util/glob.js';
4
4
  import type { FinalizedReporter } from '../util/reporters.js';
5
5
  interface Deprecated {
@@ -12,7 +12,7 @@ export declare class LintRequest {
12
12
  readonly reporter: FinalizedReporter;
13
13
  readonly uniqueFilter: (issue: Issue) => boolean;
14
14
  readonly locale: string;
15
- readonly configFile: string | undefined;
15
+ readonly configFile: string | CSpellConfigFile | undefined;
16
16
  readonly excludes: GlobSrcInfo[];
17
17
  readonly root: string;
18
18
  readonly showContext: number;
@@ -1,5 +1,6 @@
1
+ import { CSpellSettings } from '@cspell/cspell-types';
1
2
  import type { CacheOptions } from './util/cache/index.js';
2
- export interface LinterOptions extends BaseOptions, Omit<CacheOptions, 'version'> {
3
+ export interface LinterOptions extends Omit<BaseOptions, 'config'>, Omit<CacheOptions, 'version'> {
3
4
  /**
4
5
  * Display verbose information
5
6
  */
@@ -87,6 +88,10 @@ export interface LinterOptions extends BaseOptions, Omit<CacheOptions, 'version'
87
88
  * Load and parse documents, but do not spell check.
88
89
  */
89
90
  skipValidation?: boolean;
91
+ /**
92
+ * Path to configuration file.
93
+ */
94
+ config?: string | CSpellConfigFile;
90
95
  }
91
96
  export interface TraceOptions extends BaseOptions {
92
97
  stdin?: boolean;
@@ -134,6 +139,7 @@ export interface SuggestionOptions extends BaseOptions {
134
139
  export interface LegacyOptions {
135
140
  local?: string;
136
141
  }
142
+ export type LegacyFixes = Pick<BaseOptions, 'locale'>;
137
143
  export interface BaseOptions {
138
144
  /**
139
145
  * Path to configuration file.
@@ -236,5 +242,9 @@ export interface LinterCliOptions extends LinterOptions {
236
242
  */
237
243
  issueTemplate?: string;
238
244
  }
239
- export declare function fixLegacy<T extends BaseOptions>(opts: T & LegacyOptions): Omit<T & LegacyOptions, 'local'>;
245
+ export declare function fixLegacy<T extends LegacyFixes>(opts: T & LegacyOptions): Omit<T & LegacyOptions, 'local'>;
246
+ export interface CSpellConfigFile {
247
+ url: URL;
248
+ settings: CSpellSettings;
249
+ }
240
250
  //# sourceMappingURL=options.d.ts.map
@@ -1,6 +1,6 @@
1
1
  export { pkgDir } from './dirname.js';
2
2
  export declare const name = "cspell";
3
- export declare const version = "8.15.1";
3
+ export declare const version = "8.15.2";
4
4
  export declare const engines: {
5
5
  node: string;
6
6
  };
@@ -1,7 +1,7 @@
1
1
  // This file is generated by tools/patch-version.mjs
2
2
  export { pkgDir } from './dirname.js';
3
3
  export const name = 'cspell';
4
- export const version = '8.15.1';
4
+ export const version = '8.15.2';
5
5
  export const engines = { node: '>=18' };
6
6
  export const npmPackage = { name, version, engines };
7
7
  //# sourceMappingURL=pkgInfo.js.map
@@ -1,6 +1,7 @@
1
1
  import type { BufferEncoding } from 'cspell-io';
2
2
  import type { CSpellUserSettings, Document, Issue } from 'cspell-lib';
3
3
  import * as cspell from 'cspell-lib';
4
+ import { CSpellConfigFile } from '../options.js';
4
5
  import type { GlobOptions } from './glob.js';
5
6
  export interface ConfigInfo {
6
7
  source: string;
@@ -12,7 +13,8 @@ export interface FileConfigInfo {
12
13
  text: string;
13
14
  languageIds: string[];
14
15
  }
15
- export declare function readConfig(configFile: string | undefined, root: string | undefined): Promise<ConfigInfo>;
16
+ export declare function readConfig(configFile: string | CSpellConfigFile | undefined, root: string | undefined): Promise<ConfigInfo>;
17
+ export declare function readConfigFile(filename: string | URL): Promise<CSpellConfigFile>;
16
18
  export interface FileInfo {
17
19
  filename: string;
18
20
  text?: string;
@@ -30,7 +32,7 @@ export interface FileResult {
30
32
  cached?: boolean;
31
33
  }
32
34
  export declare function fileInfoToDocument(fileInfo: FileInfo, languageId: string | undefined, locale: string | undefined): Document;
33
- export declare function filenameToUrl(filename: string, cwd?: string): URL;
35
+ export declare function filenameToUrl(filename: string | URL, cwd?: string): URL;
34
36
  export declare function filenameToUri(filename: string, cwd?: string): URL;
35
37
  export declare function isBinaryFile(filename: string, cwd?: string): boolean;
36
38
  export interface ReadFileInfoResult extends FileInfo {
@@ -1,7 +1,7 @@
1
1
  import { promises as fsp } from 'node:fs';
2
2
  import * as path from 'node:path';
3
3
  import { fileURLToPath, pathToFileURL } from 'node:url';
4
- import { toFileDirURL, toFileURL } from '@cspell/url';
4
+ import { toFileDirURL, toFilePathOrHref, toFileURL } from '@cspell/url';
5
5
  import { readFileText as cioReadFile, toURL } from 'cspell-io';
6
6
  import * as cspell from 'cspell-lib';
7
7
  import { fileToDocument, isBinaryFile as isUriBinaryFile } from 'cspell-lib';
@@ -15,12 +15,31 @@ import { isStdinUrl, resolveStdinUrl } from './stdinUrl.js';
15
15
  import { clean } from './util.js';
16
16
  export async function readConfig(configFile, root) {
17
17
  if (configFile) {
18
- const config = (await cspell.loadConfig(configFile)) || {};
19
- return { source: configFile, config };
18
+ const cfgFile = typeof configFile === 'string' ? await readConfigHandleError(configFile) : configFile;
19
+ const config = await cspell.resolveConfigFileImports(cfgFile);
20
+ const source = toFilePathOrHref(cfgFile.url);
21
+ return { source, config };
20
22
  }
21
23
  const config = await cspell.searchForConfig(root);
22
24
  return { source: config?.__importRef?.filename || 'None found', config: config || {} };
23
25
  }
26
+ export function readConfigFile(filename) {
27
+ return cspell.readConfigFile(filename);
28
+ }
29
+ async function readConfigHandleError(filename) {
30
+ try {
31
+ return await readConfigFile(filename);
32
+ }
33
+ catch (e) {
34
+ const settings = {
35
+ __importRef: {
36
+ filename: filename.toString(),
37
+ error: e,
38
+ },
39
+ };
40
+ return { url: filenameToUrl(filename), settings };
41
+ }
42
+ }
24
43
  export function fileInfoToDocument(fileInfo, languageId, locale) {
25
44
  const { filename, text } = fileInfo;
26
45
  languageId = languageId || undefined;
@@ -37,6 +56,8 @@ export function fileInfoToDocument(fileInfo, languageId, locale) {
37
56
  return fileToDocument(uri.href, text, languageId, locale);
38
57
  }
39
58
  export function filenameToUrl(filename, cwd = '.') {
59
+ if (filename instanceof URL)
60
+ return filename;
40
61
  const cwdURL = toFileDirURL(cwd);
41
62
  if (filename === STDIN)
42
63
  return new URL('stdin:///');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "8.15.1",
3
+ "version": "8.15.2",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "bin": {
@@ -81,19 +81,19 @@
81
81
  },
82
82
  "homepage": "https://cspell.org/",
83
83
  "dependencies": {
84
- "@cspell/cspell-json-reporter": "8.15.1",
85
- "@cspell/cspell-pipe": "8.15.1",
86
- "@cspell/cspell-types": "8.15.1",
87
- "@cspell/dynamic-import": "8.15.1",
88
- "@cspell/url": "8.15.1",
84
+ "@cspell/cspell-json-reporter": "8.15.2",
85
+ "@cspell/cspell-pipe": "8.15.2",
86
+ "@cspell/cspell-types": "8.15.2",
87
+ "@cspell/dynamic-import": "8.15.2",
88
+ "@cspell/url": "8.15.2",
89
89
  "chalk": "^5.3.0",
90
90
  "chalk-template": "^1.1.0",
91
91
  "commander": "^12.1.0",
92
- "cspell-dictionary": "8.15.1",
93
- "cspell-gitignore": "8.15.1",
94
- "cspell-glob": "8.15.1",
95
- "cspell-io": "8.15.1",
96
- "cspell-lib": "8.15.1",
92
+ "cspell-dictionary": "8.15.2",
93
+ "cspell-gitignore": "8.15.2",
94
+ "cspell-glob": "8.15.2",
95
+ "cspell-io": "8.15.2",
96
+ "cspell-lib": "8.15.2",
97
97
  "fast-json-stable-stringify": "^2.1.0",
98
98
  "file-entry-cache": "^9.1.0",
99
99
  "get-stdin": "^9.0.0",
@@ -111,5 +111,5 @@
111
111
  "micromatch": "^4.0.8",
112
112
  "minimatch": "^9.0.5"
113
113
  },
114
- "gitHead": "6a99d22627f0e360fcfc5b98afa670464ec763f6"
114
+ "gitHead": "63f8b976a0711780646f63283cf4f0457db740ee"
115
115
  }