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
2 changes: 1 addition & 1 deletion src/api/style-rules-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export class StyleRulesClient extends HttpClient {
const wire = await this.makeJsonRequest<StyleRuleWireShape>(
'PUT',
`/v3/style_rules/${encodeURIComponent(styleId)}/configured_rules`,
rules as unknown as Record<string, unknown>,
rules,
);
return mapStyleRuleDetailed(wire);
}
Expand Down
4 changes: 2 additions & 2 deletions src/cli/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ConfigCommand {
}
return value;
}
return this.maskSensitiveValues(this.config.get() as unknown as Record<string, unknown>);
return this.maskSensitiveValues(this.config.get());
}

/**
Expand All @@ -57,7 +57,7 @@ export class ConfigCommand {
const config = this.config.get();

// Mask sensitive values
return this.maskSensitiveValues(config as unknown as Record<string, unknown>);
return this.maskSensitiveValues(config);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/cli/commands/sync/register-sync-audit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,6 @@ async function handleSyncAudit(
if (options.format === 'json') {
emitJsonErrorAndExit(error);
}
deps.handleError(error as Error);
deps.handleError(error);
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/sync/register-sync-export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ async function handleSyncExport(
if (options.format === 'json') {
emitJsonErrorAndExit(error);
}
deps.handleError(error as Error);
deps.handleError(error);
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/sync/register-sync-init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,6 @@ async function handleSyncInit(
if (options.format === 'json') {
emitJsonErrorAndExit(error);
}
handleError(error as Error);
handleError(error);
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/sync/register-sync-push.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ async function handleSyncPush(
if (options.format === 'json') {
emitJsonErrorAndExit(error);
}
deps.handleError(error as Error);
deps.handleError(error);
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/sync/register-sync-resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ async function handleSyncResolve(
if (options.format === 'json') {
emitJsonErrorAndExit(error);
}
deps.handleError(error as Error);
deps.handleError(error);
}
}
4 changes: 2 additions & 2 deletions src/cli/commands/sync/register-sync-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ async function handleSyncRoot(
}
}
const syncCommand = await createSyncCommand(deps);
const result = await syncCommand.run(options as Parameters<typeof syncCommand.run>[0]);
const result = await syncCommand.run(options);
if (result.driftDetected) {
// Soft exit — set exitCode and return so in-flight writes / auto-commit
// steps / the --watch event loop drain cleanly instead of being killed
Expand All @@ -154,6 +154,6 @@ async function handleSyncRoot(
if (options['format'] === 'json') {
emitJsonErrorAndExit(error);
}
handleError(error as Error);
handleError(error);
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/sync/register-sync-status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ async function handleSyncStatus(
if (options.format === 'json') {
emitJsonErrorAndExit(error);
}
deps.handleError(error as Error);
deps.handleError(error);
}
}
2 changes: 1 addition & 1 deletion src/cli/commands/sync/register-sync-validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ async function handleSyncValidate(
if (options.format === 'json') {
emitJsonErrorAndExit(error);
}
deps.handleError(error as Error);
deps.handleError(error);
}
}
2 changes: 1 addition & 1 deletion src/formats/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export class JsonFormatParser implements FormatParser {
}
} else if (typeof val === 'object' && val !== null && !Array.isArray(val)) {
this.removeDeletedKeys(val, key, translations, flatKeyInfo);
if (Object.keys(val as Record<string, unknown>).length === 0) {
if (Object.keys(val).length === 0) {
delete record[prop];
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/services/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class DetectService {
}

const result = await this.client.translate(text, {
targetLang: 'en' as Language,
targetLang: 'en',
});

if (!result.detectedSourceLang) {
Expand Down
2 changes: 1 addition & 1 deletion src/services/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ export class WatchService {
await this.fileTranslationService.translateFile(
filePath,
outputPath,
{ ...baseOptions, targetLang } as TranslationOptions,
{ ...baseOptions, targetLang },
{ preserveCode }
);

Expand Down
2 changes: 1 addition & 1 deletion src/sync/sync-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ export function validateSyncConfig(raw: unknown): SyncConfig {
}

return {
version: obj['version'] as number,
version: obj['version'],
source_locale: obj['source_locale'],
target_locales: obj['target_locales'] as string[],
buckets: obj['buckets'] as Record<string, SyncBucketConfig>,
Expand Down
2 changes: 1 addition & 1 deletion src/sync/tms-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function sanitizePullKeysResponse(raw: unknown): Record<string, string> {
'Check that your TMS server returns the documented shape: {"<key>": "<translation>", ...}.',
);
}
const keys = Object.keys(raw as Record<string, unknown>);
const keys = Object.keys(raw);
if (keys.length > MAX_PULL_KEY_COUNT) {
throw new ValidationError(
`TMS pull response exceeds MAX_PULL_KEY_COUNT (${MAX_PULL_KEY_COUNT})`,
Expand Down
2 changes: 1 addition & 1 deletion src/types/glossary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function normalizeGlossaryInfo(response: GlossaryApiResponse): GlossaryIn
source_lang = Array.from(sourceLangs)[0]!;
} else {
Logger.warn('Glossary has empty dictionaries; defaulting source language to "en"');
source_lang = 'en' as Language;
source_lang = 'en';
}

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import type { ServiceDeps } from '../../src/cli/commands/service-factory';
function makeDeps(): ServiceDeps {
const handleError = jest.fn();
return {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: handleError as unknown as ServiceDeps['handleError'],
};
}
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/sync.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2078,8 +2078,8 @@ describe('Sync Integration — translation memory', () => {
const tmThresholdRaw = parsed['translation_memory_threshold'];
capture.push({
targetLang,
tmId: Array.isArray(tmIdRaw) ? tmIdRaw[0] : (tmIdRaw as string | undefined),
tmThreshold: Array.isArray(tmThresholdRaw) ? tmThresholdRaw[0] : (tmThresholdRaw as string | undefined),
tmId: Array.isArray(tmIdRaw) ? tmIdRaw[0] : (tmIdRaw),
tmThreshold: Array.isArray(tmThresholdRaw) ? tmThresholdRaw[0] : (tmThresholdRaw),
body: parsed,
});
const texts = getTexts(rawBody);
Expand Down
11 changes: 5 additions & 6 deletions tests/unit/cli-translate-workflow.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { FileTranslationService } from '../../src/services/file-translation.js';
import { DeepLClient, LanguageInfo } from '../../src/api/deepl-client.js';
import { ConfigService } from '../../src/storage/config.js';
import { CacheService } from '../../src/storage/cache.js';
import { Language } from '../../src/types/index.js';
import { TEST_API_KEY, createMockConfigService, createMockCacheService } from '../helpers';

describe('Translation Workflow Integration', () => {
Expand Down Expand Up @@ -450,8 +449,8 @@ describe('Translation Workflow Integration', () => {

it('should get supported source languages', async () => {
const mockLanguages: LanguageInfo[] = [
{ language: 'en' as Language, name: 'English' },
{ language: 'de' as Language, name: 'German' },
{ language: 'en', name: 'English' },
{ language: 'de', name: 'German' },
];

jest.spyOn(client, 'getSupportedLanguages').mockResolvedValue(mockLanguages);
Expand All @@ -463,8 +462,8 @@ describe('Translation Workflow Integration', () => {

it('should get supported target languages', async () => {
const mockLanguages: LanguageInfo[] = [
{ language: 'es' as Language, name: 'Spanish' },
{ language: 'fr' as Language, name: 'French' },
{ language: 'es', name: 'Spanish' },
{ language: 'fr', name: 'French' },
];

jest.spyOn(client, 'getSupportedLanguages').mockResolvedValue(mockLanguages);
Expand All @@ -475,7 +474,7 @@ describe('Translation Workflow Integration', () => {
});

it('should cache language results for 24 hours', async () => {
const mockLanguages: LanguageInfo[] = [{ language: 'en' as Language, name: 'English' }];
const mockLanguages: LanguageInfo[] = [{ language: 'en', name: 'English' }];

const getSpy = jest.spyOn(client, 'getSupportedLanguages').mockResolvedValue(mockLanguages);

Expand Down
8 changes: 4 additions & 4 deletions tests/unit/cli/register-sync-force-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ import type { ServiceDeps } from '../../../src/cli/commands/service-factory';

function makeDeps(): ServiceDeps {
return {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: jest.fn() as unknown as ServiceDeps['handleError'],
};
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/cli/register-sync-init.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import type { ServiceDeps } from '../../../src/cli/commands/service-factory';

function makeDeps(handleError: jest.Mock): ServiceDeps {
return {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: handleError as unknown as ServiceDeps['handleError'],
};
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/cli/register-sync-root.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ const { createSyncCommand: mockCreateSyncCommand } =

function makeDeps(handleError: jest.Mock): ServiceDeps {
return {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: handleError as unknown as ServiceDeps['handleError'],
};
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/cli/register-sync-scan-context-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import type { ServiceDeps } from '../../../src/cli/commands/service-factory';

function makeDeps(): ServiceDeps {
return {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: jest.fn() as unknown as ServiceDeps['handleError'],
};
}
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/cli/register-sync-tms-help.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import type { ServiceDeps } from '../../../src/cli/commands/service-factory';

function makeDeps(): ServiceDeps {
return {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: jest.fn() as unknown as ServiceDeps['handleError'],
};
}
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/cli/register-sync.commander-snapshot.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@ function snapshotCommand(cmd: Command): CommandSnapshot {
function buildSyncTree(): CommandSnapshot {
const program = new Command();
const deps: ServiceDeps = {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: jest.fn() as unknown as ServiceDeps['handleError'],
};
registerSync(program, deps);
Expand Down Expand Up @@ -101,10 +101,10 @@ describe('register-sync commander tree', () => {
it('keeps the hidden glossary-report rejector registered', () => {
const program = new Command();
const deps: ServiceDeps = {
createDeepLClient: jest.fn() as unknown as ServiceDeps['createDeepLClient'],
getApiKeyAndOptions: jest.fn() as unknown as ServiceDeps['getApiKeyAndOptions'],
getConfigService: jest.fn() as unknown as ServiceDeps['getConfigService'],
getCacheService: jest.fn() as unknown as ServiceDeps['getCacheService'],
createDeepLClient: jest.fn(),
getApiKeyAndOptions: jest.fn(),
getConfigService: jest.fn(),
getCacheService: jest.fn(),
handleError: jest.fn() as unknown as ServiceDeps['handleError'],
};
registerSync(program, deps);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/config-service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ describe('ConfigService', () => {
it('should validate boolean values', () => {
expect(() => {

configService.set('cache.enabled', 'yes' as any);
configService.set('cache.enabled', 'yes');
}).toThrow(/Expected boolean for "cache\.enabled"\. Use true or false\./);
});
});
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/detect-command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ describe('DetectCommand', () => {

it('should produce pretty-printed JSON', () => {
const output = detectCommand.formatJson({
detectedLanguage: 'ja' as any,
detectedLanguage: 'ja',
languageName: 'Japanese',
});

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/document-translation-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ describe('DocumentTranslationHandler', () => {
mocks.documentTranslationService.translateDocument.mockResolvedValue({
success: true,
outputPath: '/tmp/output.pdf',
} as any);
});

const result = await handler.translateDocument('/tmp/doc.pdf', defaultOptions());

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/dry-run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ describe('--dry-run flag', () => {
handleError: jest.fn() as jest.Mock & ((error: unknown) => never),
};

registerGlossary(program, mockDeps as any);
registerGlossary(program, mockDeps);

await program.parseAsync([
'node', 'deepl', 'glossary', 'delete', 'my-glossary',
Expand Down
Loading