interface CheckPackageApi {
    checkDirectDuplicateDependencies: (
        options?: CheckDirectDuplicateDependenciesOptions,
    ) => CheckPackageApi;
    checkDirectPeerDependencies: (
        options?: CheckDirectPeerDependenciesOptions,
    ) => CheckPackageApi;
    checkExactDevVersions: (
        options?: CheckExactVersionsOptions,
    ) => CheckPackageApi;
    checkExactVersions: (
        options?: CheckExactVersionsOptions,
    ) => CheckPackageApi;
    checkIdenticalVersions: (
        dependencies: {
            dependencies?: Record<string, string[]>;
            devDependencies?: Record<string, string[]>;
            resolutions?: Record<string, string[]>;
        },
    ) => CheckPackageApi;
    checkIdenticalVersionsThanDependency: (
        depName: string,
        dependencies: {
            dependencies?: string[];
            devDependencies?: string[];
            resolutions?: string[];
        },
    ) => CheckPackageApi;
    checkIdenticalVersionsThanDevDependencyOfDependency: (
        depName: string,
        dependencies: {
            dependencies?: string[];
            devDependencies?: string[];
            resolutions?: string[];
        },
    ) => CheckPackageApi;
    checkMinRangeDependenciesSatisfiesDevDependencies: () => CheckPackageApi;
    checkMinRangePeerDependenciesSatisfiesDependencies: () => CheckPackageApi;
    checkNoDependencies: (
        type?: DependencyTypes,
        moveToSuggestion?: DependencyTypes,
    ) => CheckPackageApi;
    checkRecommended: (options?: CheckRecommendedOptions) => CheckPackageApi;
    checkResolutionsHasExplanation: (
        checkMessage?: CheckResolutionMessage,
    ) => CheckPackageApi;
    checkResolutionsVersionsMatch: () => CheckPackageApi;
    checkSatisfiesVersions: (
        dependencies: Partial<Record<DependencyTypes, Record<string, string>>>,
    ) => CheckPackageApi;
    checkSatisfiesVersionsBetweenDependencies: (
        config: Record<
            string,
            {
                dependencies?: Record<
                    string,
                    { dependencies?: string[]; devDependencies?: string[] },
                >;
                devDependencies?: Record<
                    string,
                    { dependencies?: string[]; devDependencies?: string[] },
                >;
            },
        >,
    ) => CheckPackageApi;
    checkSatisfiesVersionsFromDependency: (
        depName: string,
        dependencies: {
            dependencies?: string[];
            devDependencies?: string[];
            resolutions?: string[];
        },
    ) => CheckPackageApi;
    checkSatisfiesVersionsInDependency: (
        depName: string,
        dependenciesRanges: Partial<
            Record<DependencyTypes, Record<string, null | string>>,
        >,
    ) => CheckPackageApi;
    checkSatisfiesVersionsInDevDependenciesOfDependency: (
        depName: string,
        dependencies: {
            dependencies?: string[];
            devDependencies?: string[];
            resolutions?: string[];
        },
    ) => CheckPackageApi;
    getDependencyPackageJson: GetDependencyPackageJson;
    isPkgLibrary: boolean;
    parsedPkg: ParsedPackageJson;
    pkg: {
        author?: Person;
        bin?: string
        | Partial<Record<string, string>>;
        browser?: string | Partial<Record<string, string | false>>;
        bugs?: BugsLocation;
        bundledDependencies?: string[];
        bundleDependencies?: string[];
        config?: JsonObject;
        contributors?: Person[];
        cpu?: LiteralUnion<
            | "arm"
            | "arm64"
            | "ia32"
            | "mips"
            | "mipsel"
            | "ppc"
            | "ppc64"
            | "s390"
            | "s390x"
            | "x32"
            | "x64"
            | "!arm"
            | "!arm64"
            | "!ia32"
            | "!mips"
            | "!mipsel"
            | "!ppc"
            | "!ppc64"
            | "!s390"
            | "!s390x"
            | "!x32"
            | "!x64",
            string,
        >[];
        dependencies?: Partial<Record<string, string>> & Record<string, string>;
        description?: string;
        devDependencies?: Partial<Record<string, string>> & Record<string, string>;
        directories?: DirectoryLocations;
        engines?: { [key: string]: undefined | string };
        engineStrict?: boolean;
        esnext?:
            | string
            | {
                browser?: string;
                main?: string;
                [moduleName: string]: undefined
                | string;
            };
        exports?: Exports;
        files?: string[];
        flat?: boolean;
        funding?: | string
        | {
            type?: LiteralUnion<
                | "github"
                | "opencollective"
                | "patreon"
                | "individual"
                | "foundation"
                | "corporation",
                string,
            >;
            url: string;
        };
        homepage?: LiteralUnion<".", string>;
        imports?: Imports;
        jspm?: PackageJson;
        keywords?: string[];
        license?: string;
        licenses?: { type?: string; url?: string }[];
        main?: string;
        maintainers?: Person[];
        man?: string | string[];
        module?: string;
        name: string;
        optionalDependencies?: Partial<Record<string, string>> & Record<
            string,
            string,
        >;
        os?: LiteralUnion<
            | "aix"
            | "darwin"
            | "freebsd"
            | "linux"
            | "openbsd"
            | "sunos"
            | "win32"
            | "!aix"
            | "!darwin"
            | "!freebsd"
            | "!linux"
            | "!openbsd"
            | "!sunos"
            | "!win32",
            string,
        >[];
        packageManager?: string;
        peerDependencies?: Partial<Record<string, string>> & Record<
            string,
            string,
        >;
        peerDependenciesMeta?: Partial<Record<string, { optional: true }>>;
        preferGlobal?: boolean;
        private?: boolean;
        publishConfig?: PublishConfig;
        repository?: string | { directory?: string; type: string; url: string };
        resolutions?: Partial<Record<string, string>> & Record<string, string>;
        resolutionsExplained?: Record<string, string>;
        scripts?: Scripts;
        sideEffects?: boolean | string[];
        type?: "module" | "commonjs";
        types?: string;
        typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
        typings?: string;
        version?: string;
        workspaces?: string[] | WorkspaceConfig;
        [key: string]:
            | null
            | (
                (string | number | boolean | JsonObject | JsonValue[] | readonly JsonValue[]) & (string | number | boolean | JsonObject | JsonValue[] | readonly JsonValue[] | undefined)
            );
    };
    pkgDirname: string;
    pkgPathName: string;
    run: (options?: CheckPackageApiRunOptions) => Promise<void>;
}

Properties

checkDirectDuplicateDependencies: (
    options?: CheckDirectDuplicateDependenciesOptions,
) => CheckPackageApi
.checkDirectDuplicateDependencies({
invalidOnlyWarnsFor: { '*': 'type-fest' },
})
checkDirectPeerDependencies: (
    options?: CheckDirectPeerDependenciesOptions,
) => CheckPackageApi
.checkDirectPeerDependencies({
invalidOnlyWarnsFor: ['semver'],
})
checkExactDevVersions: (options?: CheckExactVersionsOptions) => CheckPackageApi
checkExactVersions: (options?: CheckExactVersionsOptions) => CheckPackageApi
checkIdenticalVersions: (
    dependencies: {
        dependencies?: Record<string, string[]>;
        devDependencies?: Record<string, string[]>;
        resolutions?: Record<string, string[]>;
    },
) => CheckPackageApi

Check that your package.json dependencies have the exact same version that another dependency also present in your package.json

The react-dom version should match react, so this check will ensure it does

.checkIdenticalVersions({
dependencies: {
react: {
dependencies: ['react-dom'],
devDependencies: ['react-test-renderer'],
},
},
})
checkIdenticalVersionsThanDependency: (
    depName: string,
    dependencies: {
        dependencies?: string[];
        devDependencies?: string[];
        resolutions?: string[];
    },
) => CheckPackageApi

Check that your package.json contains the same version of @babel/core than react-scripts, both in resolutions and devDependencies

.checkIdenticalVersionsThanDependency('react-scripts', {
resolutions: ['@babel/core'],
devDependencies: ['@babel/core'],
})
checkIdenticalVersionsThanDevDependencyOfDependency: (
    depName: string,
    dependencies: {
        dependencies?: string[];
        devDependencies?: string[];
        resolutions?: string[];
    },
) => CheckPackageApi
checkMinRangeDependenciesSatisfiesDevDependencies: () => CheckPackageApi
checkMinRangePeerDependenciesSatisfiesDependencies: () => CheckPackageApi
checkNoDependencies: (
    type?: DependencyTypes,
    moveToSuggestion?: DependencyTypes,
) => CheckPackageApi
checkRecommended: (options?: CheckRecommendedOptions) => CheckPackageApi
checkResolutionsHasExplanation: (
    checkMessage?: CheckResolutionMessage,
) => CheckPackageApi
checkResolutionsVersionsMatch: () => CheckPackageApi
checkSatisfiesVersions: (
    dependencies: Partial<Record<DependencyTypes, Record<string, string>>>,
) => CheckPackageApi

Check that your package.json dependencies specifically satisfies the range passed in config

.checkSatisfiesVersions({
devDependencies: {
eslint: '^8.0.0'
},
})
checkSatisfiesVersionsBetweenDependencies: (
    config: Record<
        string,
        {
            dependencies?: Record<
                string,
                { dependencies?: string[]; devDependencies?: string[] },
            >;
            devDependencies?: Record<
                string,
                { dependencies?: string[]; devDependencies?: string[] },
            >;
        },
    >,
) => CheckPackageApi
checkSatisfiesVersionsFromDependency: (
    depName: string,
    dependencies: {
        dependencies?: string[];
        devDependencies?: string[];
        resolutions?: string[];
    },
) => CheckPackageApi

Check that your package.json dependencies specifically satisfies the range set in another dependencies

.checkSatisfiesVersionsFromDependency('@pob/eslint-config-typescript', {
devDependencies: [
'@typescript-eslint/eslint-plugin',
'@typescript-eslint/parser',
],
})
checkSatisfiesVersionsInDependency: (
    depName: string,
    dependenciesRanges: Partial<
        Record<DependencyTypes, Record<string, null | string>>,
    >,
) => CheckPackageApi

Check versions in a dependency Also useable to check if a dependency is not present

Checking if @lerna/version has no dependency @nrwl/devkit

.checkSatisfiesVersionsInDependency('@lerna/version', {
dependencies: {
'@nrwl/devkit': null,
},
})
checkSatisfiesVersionsInDevDependenciesOfDependency: (
    depName: string,
    dependencies: {
        dependencies?: string[];
        devDependencies?: string[];
        resolutions?: string[];
    },
) => CheckPackageApi
getDependencyPackageJson: GetDependencyPackageJson
isPkgLibrary: boolean
parsedPkg: ParsedPackageJson
pkg: {
    author?: Person;
    bin?: string | Partial<Record<string, string>>;
    browser?: string | Partial<Record<string, string | false>>;
    bugs?: BugsLocation;
    bundledDependencies?: string[];
    bundleDependencies?: string[];
    config?: JsonObject;
    contributors?: Person[];
    cpu?: LiteralUnion<
        | "arm"
        | "arm64"
        | "ia32"
        | "mips"
        | "mipsel"
        | "ppc"
        | "ppc64"
        | "s390"
        | "s390x"
        | "x32"
        | "x64"
        | "!arm"
        | "!arm64"
        | "!ia32"
        | "!mips"
        | "!mipsel"
        | "!ppc"
        | "!ppc64"
        | "!s390"
        | "!s390x"
        | "!x32"
        | "!x64",
        string,
    >[];
    dependencies?: Partial<Record<string, string>> & Record<string, string>;
    description?: string;
    devDependencies?: Partial<Record<string, string>> & Record<string, string>;
    directories?: DirectoryLocations;
    engines?: { [key: string]: undefined | string };
    engineStrict?: boolean;
    esnext?:
        | string
        | {
            browser?: string;
            main?: string;
            [moduleName: string]: undefined
            | string;
        };
    exports?: Exports;
    files?: string[];
    flat?: boolean;
    funding?: | string
    | {
        type?: LiteralUnion<
            | "github"
            | "opencollective"
            | "patreon"
            | "individual"
            | "foundation"
            | "corporation",
            string,
        >;
        url: string;
    };
    homepage?: LiteralUnion<".", string>;
    imports?: Imports;
    jspm?: PackageJson;
    keywords?: string[];
    license?: string;
    licenses?: { type?: string; url?: string }[];
    main?: string;
    maintainers?: Person[];
    man?: string | string[];
    module?: string;
    name: string;
    optionalDependencies?: Partial<Record<string, string>> & Record<
        string,
        string,
    >;
    os?: LiteralUnion<
        | "aix"
        | "darwin"
        | "freebsd"
        | "linux"
        | "openbsd"
        | "sunos"
        | "win32"
        | "!aix"
        | "!darwin"
        | "!freebsd"
        | "!linux"
        | "!openbsd"
        | "!sunos"
        | "!win32",
        string,
    >[];
    packageManager?: string;
    peerDependencies?: Partial<Record<string, string>> & Record<string, string>;
    peerDependenciesMeta?: Partial<Record<string, { optional: true }>>;
    preferGlobal?: boolean;
    private?: boolean;
    publishConfig?: PublishConfig;
    repository?: string | { directory?: string; type: string; url: string };
    resolutions?: Partial<Record<string, string>> & Record<string, string>;
    resolutionsExplained?: Record<string, string>;
    scripts?: Scripts;
    sideEffects?: boolean | string[];
    type?: "module" | "commonjs";
    types?: string;
    typesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>;
    typings?: string;
    version?: string;
    workspaces?: string[] | WorkspaceConfig;
    [key: string]:
        | null
        | (
            (string | number | boolean | JsonObject | JsonValue[] | readonly JsonValue[]) & (string | number | boolean | JsonObject | JsonValue[] | readonly JsonValue[] | undefined)
        );
}

Type declaration

  • [key: string]:
        | null
        | (
            (string | number | boolean | JsonObject | JsonValue[] | readonly JsonValue[]) & (string | number | boolean | JsonObject | JsonValue[] | readonly JsonValue[] | undefined)
        )
  • Optionalauthor?: Person
  • Optionalbin?: string | Partial<Record<string, string>>

    The executable files that should be installed into the PATH.

  • Optionalbrowser?: string | Partial<Record<string, string | false>>

    A hint to JavaScript bundlers or component tools when packaging modules for client side use.

  • Optionalbugs?: BugsLocation

    The URL to the package's issue tracker and/or the email address to which issues should be reported.

  • OptionalbundledDependencies?: string[]

    Package names that are bundled when the package is published.

  • OptionalbundleDependencies?: string[]

    Alias of bundledDependencies.

  • Optionalconfig?: JsonObject

    Is used to set configuration parameters used in package scripts that persist across upgrades.

  • Optionalcontributors?: Person[]

    A list of people who contributed to the package.

  • Optionalcpu?: LiteralUnion<
        | "arm"
        | "arm64"
        | "ia32"
        | "mips"
        | "mipsel"
        | "ppc"
        | "ppc64"
        | "s390"
        | "s390x"
        | "x32"
        | "x64"
        | "!arm"
        | "!arm64"
        | "!ia32"
        | "!mips"
        | "!mipsel"
        | "!ppc"
        | "!ppc64"
        | "!s390"
        | "!s390x"
        | "!x32"
        | "!x64",
        string,
    >[]

    CPU architectures the module runs on.

  • Optionaldependencies?: Partial<Record<string, string>> & Record<string, string>

    The dependencies of the package.

  • Optionaldescription?: string

    Package description, listed in npm search.

  • OptionaldevDependencies?: Partial<Record<string, string>> & Record<string, string>

    Additional tooling dependencies that are not required for the package to work. Usually test, build, or documentation tooling.

  • Optionaldirectories?: DirectoryLocations

    Indicates the structure of the package.

  • Optionalengines?: { [key: string]: undefined | string }

    Engines that this package runs on.

  • OptionalengineStrict?: boolean
  • Optionalesnext?:
        | string
        | {
            browser?: string;
            main?: string;
            [moduleName: string]: undefined
            | string;
        }

    A module ID with untranspiled code that is the primary entry point to the program.

  • Optionalexports?: Exports

    Subpath exports to define entry points of the package.

    Read more.

  • Optionalfiles?: string[]

    The files included in the package.

  • Optionalflat?: boolean

    If your package only allows one version of a given dependency, and you’d like to enforce the same behavior as yarn install --flat on the command-line, set this to true.

    Note that if your package.json contains "flat": true and other packages depend on yours (e.g. you are building a library rather than an app), those other packages will also need "flat": true in their package.json or be installed with yarn install --flat on the command-line.

  • Optionalfunding?:
        | string
        | {
            type?: LiteralUnion<
                | "github"
                | "opencollective"
                | "patreon"
                | "individual"
                | "foundation"
                | "corporation",
                string,
            >;
            url: string;
        }

    Describes and notifies consumers of a package's monetary support information.

    Read more.

  • Optionalhomepage?: LiteralUnion<".", string>

    The URL to the package's homepage.

  • Optionalimports?: Imports

    Subpath imports to define internal package import maps that only apply to import specifiers from within the package itself.

    Read more.

  • Optionaljspm?: PackageJson

    JSPM configuration.

  • Optionalkeywords?: string[]

    Keywords associated with package, listed in npm search.

  • Optionallicense?: string

    The license for the package.

  • Optionallicenses?: { type?: string; url?: string }[]

    The licenses for the package.

  • Optionalmain?: string

    The module ID that is the primary entry point to the program.

  • Optionalmaintainers?: Person[]

    A list of people who maintain the package.

  • Optionalman?: string | string[]

    Filenames to put in place for the man program to find.

  • Optionalmodule?: string

    An ECMAScript module ID that is the primary entry point to the program.

  • name: string

    The name of the package.

  • OptionaloptionalDependencies?: Partial<Record<string, string>> & Record<string, string>

    Dependencies that are skipped if they fail to install.

  • Optionalos?: LiteralUnion<
        | "aix"
        | "darwin"
        | "freebsd"
        | "linux"
        | "openbsd"
        | "sunos"
        | "win32"
        | "!aix"
        | "!darwin"
        | "!freebsd"
        | "!linux"
        | "!openbsd"
        | "!sunos"
        | "!win32",
        string,
    >[]

    Operating systems the module runs on.

  • OptionalpackageManager?: string

    Defines which package manager is expected to be used when working on the current project. It can set to any of the supported package managers, and will ensure that your teams use the exact same package manager versions without having to install anything else than Node.js.

    This field is currently experimental and needs to be opted-in; check the Corepack page for details about the procedure.

    {
    "packageManager": "<package manager name>@<version>"
    }
  • OptionalpeerDependencies?: Partial<Record<string, string>> & Record<string, string>

    Dependencies that will usually be required by the package user directly or via another dependency.

  • OptionalpeerDependenciesMeta?: Partial<Record<string, { optional: true }>>

    Indicate peer dependencies that are optional.

  • OptionalpreferGlobal?: boolean

    If set to true, a warning will be shown if package is installed locally. Useful if the package is primarily a command-line application that should be installed globally.

  • Optionalprivate?: boolean

    If set to true, then npm will refuse to publish it.

  • OptionalpublishConfig?: PublishConfig

    A set of config values that will be used at publish-time. It's especially handy to set the tag, registry or access, to ensure that a given package is not tagged with 'latest', published to the global public registry or that a scoped module is private by default.

  • Optionalrepository?: string | { directory?: string; type: string; url: string }

    Location for the code repository.

  • Optionalresolutions?: Partial<Record<string, string>> & Record<string, string>

    Selective version resolutions. Allows the definition of custom package versions inside dependencies without manual edits in the yarn.lock file.

  • OptionalresolutionsExplained?: Record<string, string>
  • Optionalscripts?: Scripts

    Script commands that are run at various times in the lifecycle of the package. The key is the lifecycle event, and the value is the command to run at that point.

  • OptionalsideEffects?: boolean | string[]

    Denote which files in your project are "pure" and therefore safe for Webpack to prune if unused.

    Read more.

  • Optionaltype?: "module" | "commonjs"

    Resolution algorithm for importing ".js" files from the package's scope.

    Read more.

  • Optionaltypes?: string

    Location of the bundled TypeScript declaration file.

  • OptionaltypesVersions?: Partial<Record<string, Partial<Record<string, string[]>>>>

    Version selection map of TypeScript.

  • Optionaltypings?: string

    Location of the bundled TypeScript declaration file. Alias of types.

  • Optionalversion?: string

    Package version, parseable by node-semver.

  • Optionalworkspaces?: string[] | WorkspaceConfig

    Used to configure npm workspaces / Yarn workspaces.

    Workspaces allow you to manage multiple packages within the same repository in such a way that you only need to run your install command once in order to install all of them in a single pass.

    Please note that the top-level private property of package.json must be set to true in order to use workspaces.

pkgDirname: string
pkgPathName: string
run: (options?: CheckPackageApiRunOptions) => Promise<void>