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(lint): update @vercel/style-guide to latest #5832

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"devDependencies": {
"@taplo/cli": "^0.5.2",
"@types/react": "18.2.0",
"eslint": "^8.47.0",
"eslint": "^8.48.0",
"husky": "^8.0.0",
"lint-staged": "^13.1.0",
"next": "^13.0.6",
Expand Down
9 changes: 3 additions & 6 deletions packages/create-turbo/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,10 @@ createTurboCli
.parseAsync()
.then(notifyUpdate)
.catch(async (reason) => {
// eslint-disable-next-line no-console
console.log();
logger.log();
logger.error("Unexpected error. Please report it as a bug:");
// eslint-disable-next-line no-console
console.log(reason);
// eslint-disable-next-line no-console
console.log();
logger.log(reason);
logger.log();
await notifyUpdate();
process.exit(1);
});
77 changes: 30 additions & 47 deletions packages/create-turbo/src/commands/create/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ export async function create(
opts: CreateCommandOptions
) {
const { skipInstall, skipTransforms } = opts;
// eslint-disable-next-line no-console
console.log(chalk.bold(turboGradient(`\n>>> TURBOREPO\n`)));
logger.log(chalk.bold(turboGradient(`\n>>> TURBOREPO\n`)));
info(`Welcome to Turborepo! Let's get you set up with a new codebase.`);
// eslint-disable-next-line no-console
console.log();
logger.log();

const [online, availablePackageManagers] = await Promise.all([
isOnline(),
Expand Down Expand Up @@ -109,7 +107,7 @@ export async function create(
if (!skipTransforms) {
for (const transform of transforms) {
try {
// eslint-disable-next-line no-await-in-loop
// eslint-disable-next-line no-await-in-loop -- we need to run transforms sequentially
const transformResult = await transform({
example: {
repo: repoInfo,
Expand Down Expand Up @@ -144,8 +142,7 @@ export async function create(
: selectedPackageManagerDetails;

info("Created a new Turborepo with the following:");
// eslint-disable-next-line no-console
console.log();
logger.log();
if (project.workspaceData.workspaces.length > 0) {
const workspacesForDisplay = project.workspaceData.workspaces
.map((w) => ({
Expand All @@ -158,25 +155,20 @@ export async function create(
let lastGroup: string | undefined;
workspacesForDisplay.forEach(({ group, title, description }, idx) => {
if (idx === 0 || group !== lastGroup) {
// eslint-disable-next-line no-console
console.log(chalk.cyan(group));
logger.log(chalk.cyan(group));
}
// eslint-disable-next-line no-console
console.log(
logger.log(
` - ${chalk.bold(title)}${description ? `: ${description}` : ""}`
);
lastGroup = group;
});
} else {
// eslint-disable-next-line no-console
console.log(chalk.cyan("apps"));
// eslint-disable-next-line no-console
console.log(` - ${chalk.bold(projectName)}`);
logger.log(chalk.cyan("apps"));
logger.log(` - ${chalk.bold(projectName)}`);
}

// run install
// eslint-disable-next-line no-console
console.log();
logger.log();
if (hasPackageJson && !skipInstall) {
// in the case when the user opted out of transforms, but not install, we need to make sure the package manager is available
// before we attempt an install
Expand All @@ -190,13 +182,10 @@ export async function create(
warn(
`Try running without "--skip-transforms" to convert "${exampleName}" to a package manager that is available on your system.`
);
// eslint-disable-next-line no-console
console.log();
logger.log();
} else if (projectPackageManager.version) {
// eslint-disable-next-line no-console
console.log("Installing packages. This might take a couple of minutes.");
// eslint-disable-next-line no-console
console.log();
logger.log("Installing packages. This might take a couple of minutes.");
logger.log();

const loader = turboLoader("Installing dependencies...").start();
await install({
Expand All @@ -213,15 +202,13 @@ export async function create(
}

if (projectDirIsCurrentDir) {
// eslint-disable-next-line no-console
console.log(
logger.log(
`${chalk.bold(
turboGradient(">>> Success!")
)} Your new Turborepo is ready.`
);
} else {
// eslint-disable-next-line no-console
console.log(
logger.log(
`${chalk.bold(
turboGradient(">>> Success!")
)} Created a new Turborepo at "${relativeProjectDir}".`
Expand All @@ -230,36 +217,32 @@ export async function create(

// get the package manager details so we display the right commands to the user in log messages
const packageManagerMeta = getPackageManagerMeta(projectPackageManager);
/* eslint-disable no-console */
if (packageManagerMeta && hasPackageJson) {
console.log(
logger.log(
`Inside ${
projectDirIsCurrentDir ? "this" : "that"
} directory, you can run several commands:`
);
console.log();
logger.log();
availableScripts
.filter((script) => SCRIPTS_TO_DISPLAY[script])
.forEach((script) => {
console.log(
chalk.cyan(` ${packageManagerMeta.command} run ${script}`)
);
console.log(` ${SCRIPTS_TO_DISPLAY[script]} all apps and packages`);
console.log();
logger.log(chalk.cyan(` ${packageManagerMeta.command} run ${script}`));
logger.log(` ${SCRIPTS_TO_DISPLAY[script]} all apps and packages`);
logger.log();
});
console.log(`Turborepo will cache locally by default. For an additional`);
console.log(`speed boost, enable Remote Caching with Vercel by`);
console.log(`entering the following command:`);
console.log();
console.log(chalk.cyan(` ${packageManagerMeta.executable} turbo login`));
console.log();
console.log(`We suggest that you begin by typing:`);
console.log();
logger.log(`Turborepo will cache locally by default. For an additional`);
logger.log(`speed boost, enable Remote Caching with Vercel by`);
logger.log(`entering the following command:`);
logger.log();
logger.log(chalk.cyan(` ${packageManagerMeta.executable} turbo login`));
logger.log();
logger.log(`We suggest that you begin by typing:`);
logger.log();
if (!projectDirIsCurrentDir) {
console.log(` ${chalk.cyan("cd")} ${relativeProjectDir}`);
logger.log(` ${chalk.cyan("cd")} ${relativeProjectDir}`);
}
console.log(chalk.cyan(` ${packageManagerMeta.executable} turbo login`));
console.log();
logger.log(chalk.cyan(` ${packageManagerMeta.executable} turbo login`));
logger.log();
}
/* eslint-enable no-console */
}
2 changes: 1 addition & 1 deletion packages/create-turbo/src/commands/create/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export async function directory({ dir }: { dir: CreateCommandArgument }) {
filter: (d: string) => d.trim(),
});

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- we know it's defined because of the `when` condition above
const { projectDirectory: selectedProjectDirectory = dir! } =
projectDirectoryAnswer;

Expand Down
2 changes: 1 addition & 1 deletion packages/create-turbo/src/transforms/git-ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const meta = {
name: "git-ignore",
};

// eslint-disable-next-line @typescript-eslint/require-await
// eslint-disable-next-line @typescript-eslint/require-await -- must match transform function signature
export async function transform(args: TransformInput): TransformResult {
const { prompts } = args;
const ignorePath = path.join(prompts.root, ".gitignore");
Expand Down
7 changes: 5 additions & 2 deletions packages/create-turbo/src/transforms/official-starter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ const meta = {
name: "official-starter",
};

// applied to "official starter" examples (those hosted within vercel/turbo/examples)
// eslint-disable-next-line @typescript-eslint/require-await
/**
* Transform applied to "official starter" examples (those hosted within vercel/turbo/examples)
**/

// eslint-disable-next-line @typescript-eslint/require-await -- must match transform function signature
export async function transform(args: TransformInput): TransformResult {
const { prompts, example, opts } = args;

Expand Down
9 changes: 6 additions & 3 deletions packages/create-turbo/src/utils/isOnline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,20 @@ export function isOnline(): Promise<boolean> {
return new Promise((resolve) => {
dns.lookup("registry.yarnpkg.com", (registryErr) => {
if (!registryErr) {
return resolve(true);
resolve(true);
return;
}

const proxy = getProxy();
if (!proxy) {
return resolve(false);
resolve(false);
return;
}

const { hostname } = url.parse(proxy);
if (!hostname) {
return resolve(false);
resolve(false);
return;
}

dns.lookup(hostname, (proxyErr) => {
Expand Down
10 changes: 4 additions & 6 deletions packages/create-turbo/src/utils/notifyUpdate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import chalk from "chalk";
import checkForUpdate from "update-check";
import { logger } from "@turbo/utils";
import cliPkgJson from "../../package.json";

const update = checkForUpdate(cliPkgJson).catch(() => null);
Expand All @@ -8,14 +9,11 @@ export async function notifyUpdate(): Promise<void> {
try {
const res = await update;
if (res?.latest) {
// eslint-disable-next-line no-console
console.log();
// eslint-disable-next-line no-console
console.log(
logger.log();
logger.log(
chalk.yellow.bold("A new version of `create-turbo` is available!")
);
// eslint-disable-next-line no-console
console.log();
logger.log();
}
process.exit();
} catch (_) {
Expand Down
2 changes: 1 addition & 1 deletion packages/eslint-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "0.0.0",
"private": true,
"devDependencies": {
"@vercel/style-guide": "^4.0.2"
"@vercel/style-guide": "^5.0.0"
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "node:path";
import type { Rule } from "eslint";
import type { Node, MemberExpression } from "estree";
import { logger } from "@turbo/utils";
import { RULES } from "../constants";
import { Project, getWorkspaceFromFilePath } from "../utils/calculate-inputs";

Expand Down Expand Up @@ -76,13 +77,12 @@ function create(context: RuleContextWithOptions): Rule.RuleListener {
regexAllowList.push(new RegExp(allowed));
} catch (err) {
// log the error, but just move on without this allowList entry
// eslint-disable-next-line no-console
console.error(`Unable to convert "${allowed}" to regex`);
logger.error(`Unable to convert "${allowed}" to regex`);
}
});

const cwd = normalizeCwd(
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- needed to support older eslint versions
context.getCwd ? context.getCwd() : undefined,
options
);
Expand Down
7 changes: 3 additions & 4 deletions packages/turbo-ignore/src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
skipWorkspaceCommits,
forceWorkspaceCommits,
} from "./checkCommit";
import { log } from "./logger";

export const help = `
turbo-ignore
Expand Down Expand Up @@ -53,14 +54,12 @@ export function parseArgs({ argv }: { argv: Array<string> }): TurboIgnoreArgs {

// handle help flag and exit
if (flags.has("help") || flags.has("h")) {
// eslint-disable-next-line no-console
console.log(help);
log(help);
process.exit(0);
}
// handle version flag and exit
if (flags.has("version") || flags.has("v")) {
// eslint-disable-next-line no-console
console.log(pkg.version);
log(pkg.version);
process.exit(0);
}

Expand Down
8 changes: 3 additions & 5 deletions packages/turbo-ignore/src/ignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,18 @@ import type { DryRun } from "@turbo/types";
import { getComparison } from "./getComparison";
import { getTask } from "./getTask";
import { getWorkspace } from "./getWorkspace";
import { info, warn, error } from "./logger";
import { log, info, warn, error } from "./logger";
import { shouldWarn } from "./errors";
import type { TurboIgnoreArgs } from "./types";
import { checkCommit } from "./checkCommit";

function ignoreBuild() {
// eslint-disable-next-line no-console
console.log("⏭ Ignoring the change");
log("⏭ Ignoring the change");
return process.exit(0);
}

function continueBuild() {
// eslint-disable-next-line no-console
console.log("✓ Proceeding with deployment");
log("✓ Proceeding with deployment");
return process.exit(1);
}

Expand Down
13 changes: 9 additions & 4 deletions packages/turbo-ignore/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,23 @@
const TURBO_IGNORE_PREFIX = "\u226B ";

function info(...args: Array<unknown>) {
// eslint-disable-next-line no-console
// eslint-disable-next-line no-console -- logger
console.log(TURBO_IGNORE_PREFIX, ...args);
}

function error(...args: Array<unknown>) {
// eslint-disable-next-line no-console
// eslint-disable-next-line no-console -- logger
console.error(TURBO_IGNORE_PREFIX, ...args);
}

function warn(...args: Array<unknown>) {
// eslint-disable-next-line no-console
// eslint-disable-next-line no-console -- logger
console.warn(TURBO_IGNORE_PREFIX, ...args);
}

export { info, warn, error };
function log(...args: Array<unknown>) {
// eslint-disable-next-line no-console -- logger
console.log(...args);
}

export { log, info, warn, error };
2 changes: 1 addition & 1 deletion packages/turbo-types/src/types/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface BaseSchema {
*
* @defaultValue `{}`
*/
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style
// eslint-disable-next-line @typescript-eslint/consistent-indexed-object-style -- it's more readable to specify a name for the key
pipeline: {
/**
* The name of a task that can be executed by turbo. If turbo finds a workspace
Expand Down
Loading
Loading