async function getLintConfig()

in src/lint.ts [180:206]


async function getLintConfig(
    expectedConfigPath: string,
    tsconfigPath: string,
    minVersion: TsVersion,
    maxVersion: TsVersion,
    tsLocal: string | undefined,
): Promise<IConfigurationFile> {
    const configExists = await pathExists(expectedConfigPath);
    const configPath = configExists ? expectedConfigPath : joinPaths(__dirname, "..", "dtslint.json");
    // Second param to `findConfiguration` doesn't matter, since config path is provided.
    const config = Configuration.findConfiguration(configPath, "").results;
    if (!config) {
        throw new Error(`Could not load config at ${configPath}`);
    }

    const expectRule = config.rules.get("expect");
    if (!expectRule || expectRule.ruleSeverity !== "error") {
        throw new Error("'expect' rule should be enabled, else compile errors are ignored");
    }
    if (expectRule) {
        const versionsToTest =
            range(minVersion, maxVersion).map(versionName => ({ versionName, path: typeScriptPath(versionName, tsLocal) }));
        const expectOptions: ExpectOptions = { tsconfigPath, versionsToTest };
        expectRule.ruleArguments = [expectOptions];
    }
    return config;
}