deslop-js 0.0.11 → 0.0.13

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.
package/dist/index.d.cts CHANGED
@@ -216,6 +216,154 @@ interface DuplicateConstant {
216
216
  confidence: SemanticConfidence;
217
217
  reason: string;
218
218
  }
219
+ interface CrossFileDuplicateExportLocation {
220
+ path: string;
221
+ line: number;
222
+ column: number;
223
+ isTypeOnly: boolean;
224
+ }
225
+ interface CrossFileDuplicateExport {
226
+ name: string;
227
+ locations: CrossFileDuplicateExportLocation[];
228
+ confidence: SemanticConfidence;
229
+ reason: string;
230
+ }
231
+ type DuplicateBlockDetectionMode = "strict" | "semantic";
232
+ interface DuplicateBlockOccurrence {
233
+ path: string;
234
+ startLine: number;
235
+ endLine: number;
236
+ startColumn: number;
237
+ endColumn: number;
238
+ }
239
+ interface DuplicateBlock {
240
+ instances: DuplicateBlockOccurrence[];
241
+ tokenCount: number;
242
+ lineCount: number;
243
+ confidence: SemanticConfidence;
244
+ reason: string;
245
+ }
246
+ type DuplicateBlockRefactoringKind = "extract-function" | "extract-module";
247
+ interface DuplicateBlockRefactoringHint {
248
+ kind: DuplicateBlockRefactoringKind;
249
+ description: string;
250
+ estimatedSavings: number;
251
+ }
252
+ interface DuplicateBlockCluster {
253
+ files: string[];
254
+ groups: DuplicateBlock[];
255
+ totalDuplicatedLines: number;
256
+ totalDuplicatedTokens: number;
257
+ suggestions: DuplicateBlockRefactoringHint[];
258
+ }
259
+ interface ShadowedDirectoryPair {
260
+ directoryA: string;
261
+ directoryB: string;
262
+ sharedFiles: string[];
263
+ totalDuplicatedLines: number;
264
+ }
265
+ interface DuplicateBlocksConfig {
266
+ enabled: boolean;
267
+ mode: DuplicateBlockDetectionMode;
268
+ minTokens: number;
269
+ minLines: number;
270
+ minOccurrences: number;
271
+ skipLocal: boolean;
272
+ }
273
+ type ReExportCycleKind = "self-loop" | "multi-node";
274
+ interface ReExportCycle {
275
+ files: string[];
276
+ kind: ReExportCycleKind;
277
+ confidence: SemanticConfidence;
278
+ reason: string;
279
+ }
280
+ type FeatureFlagKind = "env-var" | "sdk-call" | "config-object";
281
+ interface FeatureFlag {
282
+ path: string;
283
+ name: string;
284
+ kind: FeatureFlagKind;
285
+ line: number;
286
+ column: number;
287
+ sdkProvider?: string;
288
+ guardLineStart?: number;
289
+ guardLineEnd?: number;
290
+ guardsDeadCode: boolean;
291
+ }
292
+ interface FeatureFlagsConfig {
293
+ enabled: boolean;
294
+ extraEnvPrefixes: string[];
295
+ extraSdkFunctionNames: string[];
296
+ detectConfigObjects: boolean;
297
+ }
298
+ interface FunctionComplexity {
299
+ path: string;
300
+ functionName: string;
301
+ line: number;
302
+ column: number;
303
+ cyclomatic: number;
304
+ cognitive: number;
305
+ lineCount: number;
306
+ paramCount: number;
307
+ confidence: SemanticConfidence;
308
+ reason: string;
309
+ }
310
+ interface ComplexityConfig {
311
+ enabled: boolean;
312
+ cyclomaticThreshold: number;
313
+ cognitiveThreshold: number;
314
+ paramCountThreshold: number;
315
+ functionLineThreshold: number;
316
+ }
317
+ interface PrivateTypeLeak {
318
+ path: string;
319
+ exportName: string;
320
+ typeName: string;
321
+ line: number;
322
+ column: number;
323
+ confidence: SemanticConfidence;
324
+ reason: string;
325
+ }
326
+ type UnnecessaryAssertionKind = "redundant-double-assertion" | "assertion-to-any" | "redundant-non-null-on-literal" | "double-non-null" | "angle-bracket-assertion";
327
+ interface UnnecessaryAssertion {
328
+ path: string;
329
+ kind: UnnecessaryAssertionKind;
330
+ snippet: string;
331
+ line: number;
332
+ column: number;
333
+ confidence: SemanticConfidence;
334
+ reason: string;
335
+ suggestion: string;
336
+ }
337
+ type LazyImportKind = "top-level-await-import" | "top-level-then-import";
338
+ interface LazyImportAtTopLevel {
339
+ path: string;
340
+ specifier: string;
341
+ kind: LazyImportKind;
342
+ line: number;
343
+ column: number;
344
+ confidence: SemanticConfidence;
345
+ reason: string;
346
+ }
347
+ type CommonjsInEsmKind = "require" | "module-exports" | "exports-assignment";
348
+ interface CommonjsInEsm {
349
+ path: string;
350
+ kind: CommonjsInEsmKind;
351
+ line: number;
352
+ column: number;
353
+ confidence: SemanticConfidence;
354
+ reason: string;
355
+ snippet: string;
356
+ }
357
+ type TypeScriptEscapeHatchKind = "ts-ignore" | "ts-nocheck" | "ts-expect-error-without-explanation";
358
+ interface TypeScriptEscapeHatch {
359
+ path: string;
360
+ kind: TypeScriptEscapeHatchKind;
361
+ line: number;
362
+ column: number;
363
+ confidence: SemanticConfidence;
364
+ reason: string;
365
+ suggestion: string;
366
+ }
219
367
  interface ScanResult {
220
368
  unusedFiles: UnusedFile[];
221
369
  unusedExports: UnusedExport[];
@@ -235,6 +383,18 @@ interface ScanResult {
235
383
  simplifiableFunctions: SimplifiableFunction[];
236
384
  simplifiableExpressions: SimplifiableExpression[];
237
385
  duplicateConstants: DuplicateConstant[];
386
+ crossFileDuplicateExports: CrossFileDuplicateExport[];
387
+ duplicateBlocks: DuplicateBlock[];
388
+ duplicateBlockClusters: DuplicateBlockCluster[];
389
+ shadowedDirectoryPairs: ShadowedDirectoryPair[];
390
+ reExportCycles: ReExportCycle[];
391
+ featureFlags: FeatureFlag[];
392
+ complexFunctions: FunctionComplexity[];
393
+ privateTypeLeaks: PrivateTypeLeak[];
394
+ unnecessaryAssertions: UnnecessaryAssertion[];
395
+ lazyImportsAtTopLevel: LazyImportAtTopLevel[];
396
+ commonjsInEsm: CommonjsInEsm[];
397
+ typeScriptEscapeHatches: TypeScriptEscapeHatch[];
238
398
  analysisErrors: DeslopError[];
239
399
  totalFiles: number;
240
400
  totalExports: number;
@@ -260,6 +420,9 @@ interface DeslopConfig {
260
420
  includeEntryExports: boolean;
261
421
  reportRedundancy: boolean;
262
422
  semantic: SemanticConfig | undefined;
423
+ duplicateBlocks: DuplicateBlocksConfig | undefined;
424
+ featureFlags: FeatureFlagsConfig | undefined;
425
+ complexity: ComplexityConfig | undefined;
263
426
  }
264
427
  //#endregion
265
428
  //#region src/index.d.ts
@@ -268,4 +431,4 @@ declare const defineConfig: (options: Partial<DeslopConfig> & {
268
431
  }) => DeslopConfig;
269
432
  declare const analyze: (config: DeslopConfig) => Promise<ScanResult>;
270
433
  //#endregion
271
- export { type CircularDependency, type ClassMemberKind, type DependencyDeclaredAs, type DeslopConfig, type DeslopError, type DeslopErrorCode, type DeslopErrorModule, type DeslopErrorSeverity, type DuplicateConstant, type DuplicateConstantOccurrence, type DuplicateExport, type DuplicateExportOccurrence, type DuplicateImport, type DuplicateImportOccurrence, type DuplicateInlineType, type DuplicateTypeDefinition, type DuplicateTypeDefinitionInstance, type IdentityWrapper, type InlineTypeContext, type InlineTypeOccurrence, type MisclassifiedDependency, type RedundantAlias, type RedundantAliasKind, type RedundantTypePattern, type RedundantTypePatternKind, type ScanResult, type SemanticConfidence, type SemanticConfig, type SimplifiableExpression, type SimplifiableExpressionKind, type SimplifiableFunction, type SimplifiableFunctionKind, type UnusedClassMember, type UnusedDependency, type UnusedEnumMember, type UnusedExport, type UnusedFile, type UnusedType, type UnusedTypeKind, analyze, defineConfig };
434
+ export { type CircularDependency, type ClassMemberKind, type CommonjsInEsm, type CommonjsInEsmKind, type ComplexityConfig, type CrossFileDuplicateExport, type CrossFileDuplicateExportLocation, type DependencyDeclaredAs, type DeslopConfig, type DeslopError, type DeslopErrorCode, type DeslopErrorModule, type DeslopErrorSeverity, type DuplicateBlock, type DuplicateBlockCluster, type DuplicateBlockDetectionMode, type DuplicateBlockOccurrence, type DuplicateBlockRefactoringHint, type DuplicateBlockRefactoringKind, type DuplicateBlocksConfig, type DuplicateConstant, type DuplicateConstantOccurrence, type DuplicateExport, type DuplicateExportOccurrence, type DuplicateImport, type DuplicateImportOccurrence, type DuplicateInlineType, type DuplicateTypeDefinition, type DuplicateTypeDefinitionInstance, type FeatureFlag, type FeatureFlagKind, type FeatureFlagsConfig, type FunctionComplexity, type IdentityWrapper, type InlineTypeContext, type InlineTypeOccurrence, type LazyImportAtTopLevel, type LazyImportKind, type MisclassifiedDependency, type PrivateTypeLeak, type ReExportCycle, type ReExportCycleKind, type RedundantAlias, type RedundantAliasKind, type RedundantTypePattern, type RedundantTypePatternKind, type ScanResult, type SemanticConfidence, type SemanticConfig, type ShadowedDirectoryPair, type SimplifiableExpression, type SimplifiableExpressionKind, type SimplifiableFunction, type SimplifiableFunctionKind, type TypeScriptEscapeHatch, type TypeScriptEscapeHatchKind, type UnnecessaryAssertion, type UnnecessaryAssertionKind, type UnusedClassMember, type UnusedDependency, type UnusedEnumMember, type UnusedExport, type UnusedFile, type UnusedType, type UnusedTypeKind, analyze, defineConfig };
package/dist/index.d.mts CHANGED
@@ -216,6 +216,154 @@ interface DuplicateConstant {
216
216
  confidence: SemanticConfidence;
217
217
  reason: string;
218
218
  }
219
+ interface CrossFileDuplicateExportLocation {
220
+ path: string;
221
+ line: number;
222
+ column: number;
223
+ isTypeOnly: boolean;
224
+ }
225
+ interface CrossFileDuplicateExport {
226
+ name: string;
227
+ locations: CrossFileDuplicateExportLocation[];
228
+ confidence: SemanticConfidence;
229
+ reason: string;
230
+ }
231
+ type DuplicateBlockDetectionMode = "strict" | "semantic";
232
+ interface DuplicateBlockOccurrence {
233
+ path: string;
234
+ startLine: number;
235
+ endLine: number;
236
+ startColumn: number;
237
+ endColumn: number;
238
+ }
239
+ interface DuplicateBlock {
240
+ instances: DuplicateBlockOccurrence[];
241
+ tokenCount: number;
242
+ lineCount: number;
243
+ confidence: SemanticConfidence;
244
+ reason: string;
245
+ }
246
+ type DuplicateBlockRefactoringKind = "extract-function" | "extract-module";
247
+ interface DuplicateBlockRefactoringHint {
248
+ kind: DuplicateBlockRefactoringKind;
249
+ description: string;
250
+ estimatedSavings: number;
251
+ }
252
+ interface DuplicateBlockCluster {
253
+ files: string[];
254
+ groups: DuplicateBlock[];
255
+ totalDuplicatedLines: number;
256
+ totalDuplicatedTokens: number;
257
+ suggestions: DuplicateBlockRefactoringHint[];
258
+ }
259
+ interface ShadowedDirectoryPair {
260
+ directoryA: string;
261
+ directoryB: string;
262
+ sharedFiles: string[];
263
+ totalDuplicatedLines: number;
264
+ }
265
+ interface DuplicateBlocksConfig {
266
+ enabled: boolean;
267
+ mode: DuplicateBlockDetectionMode;
268
+ minTokens: number;
269
+ minLines: number;
270
+ minOccurrences: number;
271
+ skipLocal: boolean;
272
+ }
273
+ type ReExportCycleKind = "self-loop" | "multi-node";
274
+ interface ReExportCycle {
275
+ files: string[];
276
+ kind: ReExportCycleKind;
277
+ confidence: SemanticConfidence;
278
+ reason: string;
279
+ }
280
+ type FeatureFlagKind = "env-var" | "sdk-call" | "config-object";
281
+ interface FeatureFlag {
282
+ path: string;
283
+ name: string;
284
+ kind: FeatureFlagKind;
285
+ line: number;
286
+ column: number;
287
+ sdkProvider?: string;
288
+ guardLineStart?: number;
289
+ guardLineEnd?: number;
290
+ guardsDeadCode: boolean;
291
+ }
292
+ interface FeatureFlagsConfig {
293
+ enabled: boolean;
294
+ extraEnvPrefixes: string[];
295
+ extraSdkFunctionNames: string[];
296
+ detectConfigObjects: boolean;
297
+ }
298
+ interface FunctionComplexity {
299
+ path: string;
300
+ functionName: string;
301
+ line: number;
302
+ column: number;
303
+ cyclomatic: number;
304
+ cognitive: number;
305
+ lineCount: number;
306
+ paramCount: number;
307
+ confidence: SemanticConfidence;
308
+ reason: string;
309
+ }
310
+ interface ComplexityConfig {
311
+ enabled: boolean;
312
+ cyclomaticThreshold: number;
313
+ cognitiveThreshold: number;
314
+ paramCountThreshold: number;
315
+ functionLineThreshold: number;
316
+ }
317
+ interface PrivateTypeLeak {
318
+ path: string;
319
+ exportName: string;
320
+ typeName: string;
321
+ line: number;
322
+ column: number;
323
+ confidence: SemanticConfidence;
324
+ reason: string;
325
+ }
326
+ type UnnecessaryAssertionKind = "redundant-double-assertion" | "assertion-to-any" | "redundant-non-null-on-literal" | "double-non-null" | "angle-bracket-assertion";
327
+ interface UnnecessaryAssertion {
328
+ path: string;
329
+ kind: UnnecessaryAssertionKind;
330
+ snippet: string;
331
+ line: number;
332
+ column: number;
333
+ confidence: SemanticConfidence;
334
+ reason: string;
335
+ suggestion: string;
336
+ }
337
+ type LazyImportKind = "top-level-await-import" | "top-level-then-import";
338
+ interface LazyImportAtTopLevel {
339
+ path: string;
340
+ specifier: string;
341
+ kind: LazyImportKind;
342
+ line: number;
343
+ column: number;
344
+ confidence: SemanticConfidence;
345
+ reason: string;
346
+ }
347
+ type CommonjsInEsmKind = "require" | "module-exports" | "exports-assignment";
348
+ interface CommonjsInEsm {
349
+ path: string;
350
+ kind: CommonjsInEsmKind;
351
+ line: number;
352
+ column: number;
353
+ confidence: SemanticConfidence;
354
+ reason: string;
355
+ snippet: string;
356
+ }
357
+ type TypeScriptEscapeHatchKind = "ts-ignore" | "ts-nocheck" | "ts-expect-error-without-explanation";
358
+ interface TypeScriptEscapeHatch {
359
+ path: string;
360
+ kind: TypeScriptEscapeHatchKind;
361
+ line: number;
362
+ column: number;
363
+ confidence: SemanticConfidence;
364
+ reason: string;
365
+ suggestion: string;
366
+ }
219
367
  interface ScanResult {
220
368
  unusedFiles: UnusedFile[];
221
369
  unusedExports: UnusedExport[];
@@ -235,6 +383,18 @@ interface ScanResult {
235
383
  simplifiableFunctions: SimplifiableFunction[];
236
384
  simplifiableExpressions: SimplifiableExpression[];
237
385
  duplicateConstants: DuplicateConstant[];
386
+ crossFileDuplicateExports: CrossFileDuplicateExport[];
387
+ duplicateBlocks: DuplicateBlock[];
388
+ duplicateBlockClusters: DuplicateBlockCluster[];
389
+ shadowedDirectoryPairs: ShadowedDirectoryPair[];
390
+ reExportCycles: ReExportCycle[];
391
+ featureFlags: FeatureFlag[];
392
+ complexFunctions: FunctionComplexity[];
393
+ privateTypeLeaks: PrivateTypeLeak[];
394
+ unnecessaryAssertions: UnnecessaryAssertion[];
395
+ lazyImportsAtTopLevel: LazyImportAtTopLevel[];
396
+ commonjsInEsm: CommonjsInEsm[];
397
+ typeScriptEscapeHatches: TypeScriptEscapeHatch[];
238
398
  analysisErrors: DeslopError[];
239
399
  totalFiles: number;
240
400
  totalExports: number;
@@ -260,6 +420,9 @@ interface DeslopConfig {
260
420
  includeEntryExports: boolean;
261
421
  reportRedundancy: boolean;
262
422
  semantic: SemanticConfig | undefined;
423
+ duplicateBlocks: DuplicateBlocksConfig | undefined;
424
+ featureFlags: FeatureFlagsConfig | undefined;
425
+ complexity: ComplexityConfig | undefined;
263
426
  }
264
427
  //#endregion
265
428
  //#region src/index.d.ts
@@ -268,4 +431,4 @@ declare const defineConfig: (options: Partial<DeslopConfig> & {
268
431
  }) => DeslopConfig;
269
432
  declare const analyze: (config: DeslopConfig) => Promise<ScanResult>;
270
433
  //#endregion
271
- export { type CircularDependency, type ClassMemberKind, type DependencyDeclaredAs, type DeslopConfig, type DeslopError, type DeslopErrorCode, type DeslopErrorModule, type DeslopErrorSeverity, type DuplicateConstant, type DuplicateConstantOccurrence, type DuplicateExport, type DuplicateExportOccurrence, type DuplicateImport, type DuplicateImportOccurrence, type DuplicateInlineType, type DuplicateTypeDefinition, type DuplicateTypeDefinitionInstance, type IdentityWrapper, type InlineTypeContext, type InlineTypeOccurrence, type MisclassifiedDependency, type RedundantAlias, type RedundantAliasKind, type RedundantTypePattern, type RedundantTypePatternKind, type ScanResult, type SemanticConfidence, type SemanticConfig, type SimplifiableExpression, type SimplifiableExpressionKind, type SimplifiableFunction, type SimplifiableFunctionKind, type UnusedClassMember, type UnusedDependency, type UnusedEnumMember, type UnusedExport, type UnusedFile, type UnusedType, type UnusedTypeKind, analyze, defineConfig };
434
+ export { type CircularDependency, type ClassMemberKind, type CommonjsInEsm, type CommonjsInEsmKind, type ComplexityConfig, type CrossFileDuplicateExport, type CrossFileDuplicateExportLocation, type DependencyDeclaredAs, type DeslopConfig, type DeslopError, type DeslopErrorCode, type DeslopErrorModule, type DeslopErrorSeverity, type DuplicateBlock, type DuplicateBlockCluster, type DuplicateBlockDetectionMode, type DuplicateBlockOccurrence, type DuplicateBlockRefactoringHint, type DuplicateBlockRefactoringKind, type DuplicateBlocksConfig, type DuplicateConstant, type DuplicateConstantOccurrence, type DuplicateExport, type DuplicateExportOccurrence, type DuplicateImport, type DuplicateImportOccurrence, type DuplicateInlineType, type DuplicateTypeDefinition, type DuplicateTypeDefinitionInstance, type FeatureFlag, type FeatureFlagKind, type FeatureFlagsConfig, type FunctionComplexity, type IdentityWrapper, type InlineTypeContext, type InlineTypeOccurrence, type LazyImportAtTopLevel, type LazyImportKind, type MisclassifiedDependency, type PrivateTypeLeak, type ReExportCycle, type ReExportCycleKind, type RedundantAlias, type RedundantAliasKind, type RedundantTypePattern, type RedundantTypePatternKind, type ScanResult, type SemanticConfidence, type SemanticConfig, type ShadowedDirectoryPair, type SimplifiableExpression, type SimplifiableExpressionKind, type SimplifiableFunction, type SimplifiableFunctionKind, type TypeScriptEscapeHatch, type TypeScriptEscapeHatchKind, type UnnecessaryAssertion, type UnnecessaryAssertionKind, type UnusedClassMember, type UnusedDependency, type UnusedEnumMember, type UnusedExport, type UnusedFile, type UnusedType, type UnusedTypeKind, analyze, defineConfig };