Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(eslint): fix cwd check for eslint@<6.6.0 #2848

Merged
merged 3 commits into from
Nov 30, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@ const meta: Rule.RuleMetaData = {
],
};

/**
* Normalize the value of the cwd
* Extracted from eslint
* SPDX-License-Identifier: MIT
*/
function normalizeCwd(cwd: string | undefined): string | undefined {
if (cwd) {
return cwd;
}
if (typeof process === "object") {
return process.cwd();
}

return undefined;
}

function create(context: Rule.RuleContext): Rule.RuleListener {
const { options } = context;
const allowList: Array<string> = options?.[0]?.allowList || [];
Expand All @@ -46,9 +62,11 @@ function create(context: Rule.RuleContext): Rule.RuleListener {
console.error(`Unable to convert "${allowed}" to regex`);
}
});

const cwd = normalizeCwd(context.getCwd ? context.getCwd() : undefined);
nathanhammond marked this conversation as resolved.
Show resolved Hide resolved
const turboConfig = options?.[0]?.turboConfig;
const turboVars = getEnvVarDependencies({
cwd: context.getCwd(),
cwd,
turboConfig,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function getEnvVarDependencies({
cwd,
turboConfig,
}: {
cwd: string;
cwd: string | undefined;
turboConfig?: Schema;
}): Set<string> | null {
const turboJsonContent = turboConfig || findTurboConfig({ cwd });
Expand Down