Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Remove any circular import references. - Move interfaces next to the supporting code.
- Loading branch information
Showing
12 changed files
with
83 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
packages/cspell/src/LinterConfiguration.ts → packages/cspell/src/lint/LintRequest.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { runLint } from './lint'; | ||
export { LintRequest } from './LintRequest'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ConfigInfo, FileResult } from '../../fileHelper'; | ||
|
||
export interface CSpellLintResultCache { | ||
/** | ||
* Retrieve cached lint results for a given file name, if present in the cache. | ||
*/ | ||
getCachedLintResults(filename: string, configInfo: ConfigInfo): Promise<FileResult | undefined>; | ||
/** | ||
* Set the cached lint results. | ||
*/ | ||
setCachedLintResults(result: FileResult, configInfo: ConfigInfo): void; | ||
/** | ||
* Persists the in-memory cache to disk. | ||
*/ | ||
reconcile(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export interface CacheOptions { | ||
/** | ||
* Store the info about processed files in order to only operate on the changed ones. | ||
*/ | ||
cache?: boolean; | ||
|
||
// cspell:word cspellcache | ||
/** | ||
* Path to the cache location. Can be a file or a directory. | ||
* If none specified .cspellcache will be used. | ||
* The file will be created in the directory where the cspell command is executed. | ||
*/ | ||
cacheLocation?: string; | ||
|
||
/** | ||
* Strategy to use for detecting changed files, default: metadata | ||
*/ | ||
cacheStrategy?: 'metadata' | 'content'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import path from 'path'; | ||
import { CacheOptions } from './CacheOptions'; | ||
import { CSpellLintResultCache } from './CSpellLintResultCache'; | ||
import { DiskCache } from './DiskCache'; | ||
import { DummyCache } from './DummyCache'; | ||
|
||
// cspell:word cspellcache | ||
export const DEFAULT_CACHE_LOCATION = '.cspellcache'; | ||
|
||
export interface CreateCacheOptions extends CacheOptions { | ||
root: string; | ||
} | ||
|
||
/** | ||
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise) | ||
*/ | ||
|
||
export function createCache(options: CreateCacheOptions): CSpellLintResultCache { | ||
const { cache, cacheLocation = DEFAULT_CACHE_LOCATION, cacheStrategy = 'metadata', root } = options; | ||
return cache ? new DiskCache(path.resolve(root, cacheLocation), cacheStrategy === 'content') : new DummyCache(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,4 @@ | ||
import path from 'path'; | ||
import type { LinterConfiguration } from '../../LinterConfiguration'; | ||
import type { ConfigInfo, FileResult } from '../../fileHelper'; | ||
import { DummyCache } from './DummyCache'; | ||
import { DiskCache } from './DiskCache'; | ||
|
||
// cspell:word cspellcache | ||
export const DEFAULT_CACHE_LOCATION = '.cspellcache'; | ||
|
||
export interface CSpellLintResultCache { | ||
/** | ||
* Retrieve cached lint results for a given file name, if present in the cache. | ||
*/ | ||
getCachedLintResults(filename: string, configInfo: ConfigInfo): Promise<FileResult | undefined>; | ||
/** | ||
* Set the cached lint results. | ||
*/ | ||
setCachedLintResults(result: FileResult, configInfo: ConfigInfo): void; | ||
/** | ||
* Persists the in-memory cache to disk. | ||
*/ | ||
reconcile(): void; | ||
} | ||
|
||
/** | ||
* Creates CSpellLintResultCache (disk cache if caching is enabled in config or dummy otherwise) | ||
*/ | ||
export function createCache(cfg: LinterConfiguration): CSpellLintResultCache { | ||
const { cache, cacheLocation = DEFAULT_CACHE_LOCATION, cacheStrategy = 'metadata' } = cfg.options; | ||
return cache ? new DiskCache(path.resolve(cfg.root, cacheLocation), cacheStrategy === 'content') : new DummyCache(); | ||
} | ||
export { createCache, DEFAULT_CACHE_LOCATION } from './createCache'; | ||
export type { CreateCacheOptions } from './createCache'; | ||
export type { CSpellLintResultCache } from './CSpellLintResultCache'; | ||
export type { CacheOptions } from './CacheOptions'; |