diff --git a/types/duplicate-package-checker-webpack-plugin/duplicate-package-checker-webpack-plugin-tests.ts b/types/duplicate-package-checker-webpack-plugin/duplicate-package-checker-webpack-plugin-tests.ts index 0552f0e7c4..27eb651287 100644 --- a/types/duplicate-package-checker-webpack-plugin/duplicate-package-checker-webpack-plugin-tests.ts +++ b/types/duplicate-package-checker-webpack-plugin/duplicate-package-checker-webpack-plugin-tests.ts @@ -18,7 +18,12 @@ const c: webpack.Configuration = { plugins: [ new DuplicatePackageCheckerWebpackPlugin({ verbose: true, - emitError: true + emitError: true, + showHelp: false, + strict: false, + exclude(instance) { + return instance.name === "fbjs"; + } }) ] }; diff --git a/types/duplicate-package-checker-webpack-plugin/index.d.ts b/types/duplicate-package-checker-webpack-plugin/index.d.ts index 1eff56e9d5..cadb922c1a 100644 --- a/types/duplicate-package-checker-webpack-plugin/index.d.ts +++ b/types/duplicate-package-checker-webpack-plugin/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for duplicate-package-checker-webpack-plugin 1.2 +// Type definitions for duplicate-package-checker-webpack-plugin 2.1 // Project: https://github.com/darrenscerri/duplicate-package-checker-webpack-plugin#readme // Definitions by: Matt Traynham // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -13,10 +13,36 @@ declare class DuplicatePackageCheckerWebpackPlugin extends Plugin { } declare namespace DuplicatePackageCheckerWebpackPlugin { + /** The properties of the instance of a package */ + interface PackageInstanceProperties { + /** The name of the package */ + name: string; + /** The version of the package */ + version: string; + /** Absolute path to the package */ + path: string; + /** Absolute path to the module that requested the package */ + issuer?: string; + } + + /** The configurable options for the plugin */ interface Options { - // Also show module that is requiring each duplicate package + /** Also show module that is requiring each duplicate package (default: false) */ verbose?: boolean; - // Emit errors instead of warnings + /** Emit errors instead of warnings (default: false) */ emitError?: boolean; + /** Show help message if duplicate packages are found (default: true) */ + showHelp?: boolean; + /** Warn also if major versions differ (default: true) */ + strict?: boolean; + + /** + * Exclude instances of packages from the results. + * If all instances of a package are excluded, or all instances except one, + * then the package is no longer considered duplicated and won't be emitted as a warning/error. + * @param instance The instance of a package being evaluated for exclusion. + * @returns true to exclude the instance, false otherwise + */ + exclude?: (instance: PackageInstanceProperties) => boolean; } }