Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion integration-tests/src/reporter/reportGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@ function tabToSpace(text: string, tabWidth = 4): string {
return result;
}

export const __testing__ = {
export const __testing__: {
padLines: typeof padLines;
} = {
padLines,
};
2 changes: 1 addition & 1 deletion integration-tests/src/repositoryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { Logger } from './types.js';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

export const repositoryDir = Path.resolve(Path.join(__dirname, '../repositories/temp'));
export const repositoryDir: string = Path.resolve(Path.join(__dirname, '../repositories/temp'));

function mkdirp(p: string) {
return fs.promises.mkdir(p, { recursive: true });
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/snapshots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { Repository } from './configDef.js';

const __dirname = fileURLToPath(new URL('.', import.meta.url));

export const snapshotDir = Path.resolve(Path.join(__dirname, '..', 'snapshots'));
export const snapshotDir: string = Path.resolve(Path.join(__dirname, '..', 'snapshots'));
const snapshotFileName = 'snapshot.txt';
const reportFileName = 'report.yaml';

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^12.1.2",
"@swc-node/register": "^1.10.10",
"@tsconfig/node18": "^18.2.4",
"@tsconfig/node20": "^20.1.5",
"@types/node": "^20.19.0",
"@vitest/coverage-istanbul": "~3.2.2",
"conventional-changelog-conventionalcommits": "^9.0.0",
Expand Down
3 changes: 3 additions & 0 deletions packages/cspell-bundled-dicts/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Things to ignore.

*.d.ts
*.map
1 change: 1 addition & 0 deletions packages/cspell-bundled-dicts/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"declaration": false,
"isolatedDeclarations": false,
"declarationMap": false,
"sourceMap": false
},
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-config-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"isolatedDeclarations": false, // make this true
"types": ["node"],
"outDir": "dist"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export function createCachingDictionary(
return cached;
}

export function enableLogging(enabled = !logRequests): void {
export function enableLogging(enabled: boolean = !logRequests): void {
logRequests = enabled;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,10 @@ export function isSpellingDictionaryCollection(dict: SpellingDictionary): dict i
return dict instanceof SpellingDictionaryCollectionImpl;
}

export const __testing__ = {
export const __testing__: {
isWordInAnyDictionary: typeof isWordInAnyDictionary;
isWordForbiddenInAnyDictionary: typeof isWordForbiddenInAnyDictionary;
} = {
isWordInAnyDictionary,
isWordForbiddenInAnyDictionary,
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import type { SuggestOptions } from './SuggestOptions.js';

export class SpellingDictionaryFromTrie implements SpellingDictionary {
private _size = 0;
readonly knownWords = new Set<string>();
readonly unknownWords = new Set<string>();
readonly knownWords: Set<string> = new Set<string>();
readonly unknownWords: Set<string> = new Set<string>();
readonly mapWord: (word: string) => string;
readonly remapWord: (word: string) => string[];
readonly type = 'SpellingDictionaryFromTrie';
Expand Down Expand Up @@ -254,4 +254,6 @@ function* outerWordForms(word: string, mapWord: (word: string) => string[]): Ite
return;
}

export const __testing__ = { outerWordForms };
export const __testing__: {
outerWordForms: typeof outerWordForms;
} = { outerWordForms };
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ export function createWeightMapFromDictionaryInformation(di: DictionaryInformati
return di ? mapDictionaryInformationToWeightMap(di) : undefined;
}

export const __testMethods__ = {
export const __testMethods__: {
wordSearchForms: typeof wordSearchForms;
wordSearchFormsArray: typeof wordSearchFormsArray;
} = {
wordSearchForms,
wordSearchFormsArray,
};
5 changes: 4 additions & 1 deletion packages/cspell-dictionary/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export {
/**
* Debugging utilities.
*/
export const _debug = {
export const _debug: {
cacheDictionaryEnableLogging: typeof cacheDictionaryEnableLogging;
cacheDictionaryGetLog: typeof cacheDictionaryGetLog;
} = {
cacheDictionaryEnableLogging,
cacheDictionaryGetLog,
};
2 changes: 1 addition & 1 deletion packages/cspell-dictionary/src/util/AutoCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export function createCache01<R>(size: number): Cache01<R> {
return new Cache01Map(size);
}

export function autoCache<R>(fn: (p: string) => R, size = CACHE_SIZE): AutoCache<R> {
export function autoCache<R>(fn: (p: string) => R, size: number = CACHE_SIZE): AutoCache<R> {
const cache = createCache01<R>(size);

const ac: AutoCache<R> = get as AutoCache<R>;
Expand Down
4 changes: 2 additions & 2 deletions packages/cspell-dictionary/src/util/AutoResolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function autoResolve<K, V>(map: Map<K, V>, key: K, resolve: (k: K) => V):
}

export class AutoResolveCache<K, V> {
readonly map = new Map<K, V>();
readonly map: Map<K, V> = new Map<K, V>();

get(k: K): V | undefined;
get(k: K, resolve: (k: K) => V): V;
Expand Down Expand Up @@ -39,7 +39,7 @@ export function autoResolveWeak<K extends object, V>(map: WeakMap<K, V>, key: K,
}

export class AutoResolveWeakCache<K extends object, V> {
readonly map = new WeakMap<K, V>();
readonly map: WeakMap<K, V> = new WeakMap<K, V>();

get(k: K): V | undefined;
get(k: K, resolve: (k: K) => V): V;
Expand Down
8 changes: 7 additions & 1 deletion packages/cspell-dictionary/src/util/repMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,13 @@ function addToTrie(node: RepTrieNode, match: string, replaceWith: string) {
node.rep = [...s];
}

export const __testing__ = {
export const __testing__: {
charsetToRepMap: typeof charsetToRepMapRegEx;
createMapperRegExp: typeof createMapperRegExp;
createTrie: typeof createTrie;
calcAllEdits: typeof calcAllEdits;
applyEdits: typeof applyEdits;
} = {
charsetToRepMap: charsetToRepMapRegEx,
createMapperRegExp,
createTrie,
Expand Down
4 changes: 2 additions & 2 deletions packages/cspell-dictionary/src/util/simpleCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class SimpleWeakCache<K extends object, T> {
return undefined;
}

set(key: K, value: T) {
set(key: K, value: T): void {
this._set(key, { v: value });
}

Expand Down Expand Up @@ -110,7 +110,7 @@ export class SimpleCache<K, T> {
return undefined;
}

set(key: K, value: T) {
set(key: K, value: T): void {
this._set(key, { v: value });
}

Expand Down
3 changes: 1 addition & 2 deletions packages/cspell-eslint-plugin/fixtures/simple/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"extends": "@tsconfig/node20/tsconfig.json",
"compilerOptions": {
"allowJs": true,
"rootDir": ".",
"outDir": "dist"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,13 @@ async function run() {

await writeFile(
new URL(outFileTs, rootUrl),
'// NOTICE: This file is autogenerated.\nexport const optionsSchema = ' + schemaString,
`\
// NOTICE: This file is autogenerated.

import type { Rule } from 'eslint';

export const optionsSchema: Rule.RuleMetaData['schema'] = ${schemaString}\
`,
);
}

Expand Down
4 changes: 3 additions & 1 deletion packages/cspell-eslint-plugin/src/common/logger.cts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export interface LoggerOptions {
useAsync?: boolean;
}

type Log = (...p: Parameters<typeof console.log>) => void;

export class Logger {
readonly logFile: string;
readonly cwd: string;
Expand All @@ -39,7 +41,7 @@ export class Logger {
: fs.appendFileSync(this.logFile, message);
}

log = this._log.bind(this);
log: Log = this._log.bind(this);
}

let logger: Logger | undefined;
Expand Down
5 changes: 4 additions & 1 deletion packages/cspell-eslint-plugin/src/generated/schema.cts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// NOTICE: This file is autogenerated.
export const optionsSchema = {

import type { Rule } from 'eslint';

export const optionsSchema: Rule.RuleMetaData['schema'] = {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"definitions": {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,4 @@ export const configs: ESlintPlugin['configs'] = {
'recommended-legacy': recommended,
};

export const plugin = { rules, configs, meta } satisfies ESlintPlugin;
export const plugin: ESlintPlugin = { rules, configs, meta } satisfies ESlintPlugin;
4 changes: 2 additions & 2 deletions packages/cspell-eslint-plugin/src/plugin/recommended.cts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ const config: Linter.Config = {
},
};

export const plugins = config.plugins;
export const rules = config.rules;
export const plugins: Linter.Config['plugins'] = config.plugins;
export const rules: Linter.Config['rules'] = config.rules;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { ASTPath, ASTPathElement, Key } from './ASTPath.js' with { 'resolut

const debugMode = false;

export function walkTree(node: ASTNode, enter: (path: ASTPath) => void) {
export function walkTree(node: ASTNode, enter: (path: ASTPath) => void): void {
const visited = new Set<object>();

let pathNode: ASTPath | undefined = undefined;
Expand Down
4 changes: 2 additions & 2 deletions packages/cspell-filetypes/src/filetypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ type ExtensionToFileTypeIdMap = Map<string, string[]>;

const binaryFormatIds = definitions.filter((d) => d.format === 'Binary').map((d) => d.id);

export const binaryLanguages = new Set(['binary', 'image', 'video', 'fonts', ...binaryFormatIds]);
export const binaryLanguages: Set<string> = new Set(['binary', 'image', 'video', 'fonts', ...binaryFormatIds]);

export const generatedFiles = new Set([
export const generatedFiles: Set<string> = new Set([
...binaryLanguages,
'map',
'lock',
Expand Down
4 changes: 3 additions & 1 deletion packages/cspell-gitignore/src/GitIgnoreFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ function globToString(glob: GlobPatternWithRoot, relativeToDir: string | URL): s
return (base ? base + '/' : '') + glob.glob;
}

export const __testing__ = {
export const __testing__: {
mustBeHierarchical: typeof mustBeHierarchical;
} = {
mustBeHierarchical,
};
10 changes: 5 additions & 5 deletions packages/cspell-gitignore/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const defaultHelper = factoryPathHelper(path);
* @returns root directory
* @deprecated to be removed in the next major version.
*/
export const directoryRoot = defaultHelper.directoryRoot;
export const directoryRoot: (directory: string) => string = defaultHelper.directoryRoot;

/**
* Checks to see if the child directory is nested under the parent directory.
Expand All @@ -139,7 +139,7 @@ export const directoryRoot = defaultHelper.directoryRoot;
* @returns true iff child is a child of parent.
* @deprecated to be removed in the next major version.
*/
export const isParentOf = defaultHelper.isParentOf;
export const isParentOf: (parent: string, child: string) => boolean = defaultHelper.isParentOf;

/**
* Check to see if a parent directory contains a child directory.
Expand All @@ -148,7 +148,7 @@ export const isParentOf = defaultHelper.isParentOf;
* @returns true iff child is the same as the parent or nested in the parent.
* @deprecated to be removed in the next major version.
*/
export const contains = defaultHelper.contains;
export const contains: (parent: string, child: string) => boolean = defaultHelper.contains;

/**
* Make a path relative to another if the other is a parent.
Expand All @@ -157,15 +157,15 @@ export const contains = defaultHelper.contains;
* @returns the normalized relative path or undefined if rootPath is not a parent.
* @deprecated to be removed in the next major version.
*/
export const makeRelativeTo = defaultHelper.makeRelativeTo;
export const makeRelativeTo: (path: string, rootPath: string) => string | undefined = defaultHelper.makeRelativeTo;

/**
* Normalize a path to have only forward slashes.
* @param path - path to normalize
* @returns a normalized string.
* @deprecated to be removed in the next major version.
*/
export const normalizePath = defaultHelper.normalizePath;
export const normalizePath: (path: string) => string = defaultHelper.normalizePath;

export const DefaultPathHelper: PathHelper = {
directoryRoot,
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-glob/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"isolatedDeclarations": false, // make this true
"rootDir": "src",
"outDir": "dist",
"types": ["node"]
Expand Down
4 changes: 2 additions & 2 deletions packages/cspell-grammar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@
],
"scripts": {
"clean": "shx rm -rf dist temp coverage \"*.tsbuildInfo\"",
"build": "tsc -b . -f",
"build": "tsc -p .",
"clean-build": "pnpm run clean && pnpm run build",
"coverage": "vitest run --coverage",
"test:watch": "vitest",
"test": "vitest run",
"watch": "tsc -b . -w -f"
"watch": "tsc -p . -w"
},
"repository": {
"type": "git",
Expand Down
11 changes: 0 additions & 11 deletions packages/cspell-grammar/tsconfig.esm.json

This file was deleted.

10 changes: 8 additions & 2 deletions packages/cspell-grammar/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"files": [],
"references": [{ "path": "./tsconfig.esm.json" }]
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"isolatedDeclarations": false, // make this true
"rootDir": "src",
"outDir": "dist",
"types": ["node"]
},
"include": ["src"]
}
1 change: 1 addition & 0 deletions packages/cspell-lib/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"isolatedDeclarations": false, // make this true
"rootDir": "src",
"outDir": "dist",
"types": ["node"]
Expand Down
1 change: 1 addition & 0 deletions packages/cspell-pipe/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"isolatedDeclarations": false, // make this true
"rootDir": "src",
"outDir": "dist",
"types": ["node"]
Expand Down
3 changes: 2 additions & 1 deletion packages/cspell-tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig.esm.json",
"compilerOptions": {
"exactOptionalPropertyTypes": false, // make this true
"declaration": true,
"isolatedDeclarations": false,
"types": ["node"],
"outDir": "dist"
},
Expand Down
Loading
Loading