mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 04:22:12 +00:00
[tests] Add prettier check (#9664)
This PR fixes the formatting on several files that were never run through `prettier`. It also makes sure to run `prettier` in CI to to [fail fast](https://github.com/vercel/vercel/actions/runs/4408442998/jobs/7723453978) when the incorrect formatting is attempted.
This commit is contained in:
1
.github/workflows/test-lint.yml
vendored
1
.github/workflows/test-lint.yml
vendored
@@ -32,3 +32,4 @@ jobs:
|
||||
run: npm i -g pnpm@7.24.2
|
||||
- run: pnpm install
|
||||
- run: pnpm run lint
|
||||
- run: pnpm run prettier-check
|
||||
|
||||
2
.github/workflows/update-remix-run-dev.yml
vendored
2
.github/workflows/update-remix-run-dev.yml
vendored
@@ -5,7 +5,7 @@ on:
|
||||
inputs:
|
||||
new-version:
|
||||
type: string
|
||||
description: "Optional version to update @remix-run/dev to inside of @vercel/remix"
|
||||
description: 'Optional version to update @remix-run/dev to inside of @vercel/remix'
|
||||
|
||||
jobs:
|
||||
update-remix-run-dev:
|
||||
|
||||
@@ -7,3 +7,28 @@ examples/sveltekit-1
|
||||
|
||||
# gatsby-plugin-vercel-analytics
|
||||
packages/gatsby-plugin-vercel-analytics
|
||||
|
||||
# ignore directories that are not source code
|
||||
node_modules
|
||||
dist
|
||||
pnpm-lock.yaml
|
||||
.vscode
|
||||
.DS_Store
|
||||
.next
|
||||
.vercel
|
||||
.turbo
|
||||
.eslintcache
|
||||
.output
|
||||
.vercel_build_output
|
||||
.vercel
|
||||
coverage
|
||||
turbo-cache-key.json
|
||||
/examples
|
||||
/public
|
||||
packages/*/dist
|
||||
packages/*/node_modules
|
||||
packages/**/test/fixtures
|
||||
packages/**/test/dev/fixtures
|
||||
packages/**/test/build-fixtures
|
||||
packages/**/test/cache-fixtures
|
||||
|
||||
|
||||
@@ -87,7 +87,10 @@ future builds.
|
||||
import { relative } from 'path';
|
||||
import { glob, PrepareCache } from '@vercel/build-utils';
|
||||
|
||||
export const prepareCache: PrepareCache = async ({ workPath, repoRootPath }) => {
|
||||
export const prepareCache: PrepareCache = async ({
|
||||
workPath,
|
||||
repoRootPath,
|
||||
}) => {
|
||||
// Create a mapping of file names and `File` object instances to cache here…
|
||||
const rootDirectory = relative(repoRootPath, workPath);
|
||||
const cache = await glob(`${rootDirectory}/some/dir/**`, repoRootPath);
|
||||
|
||||
@@ -51,8 +51,11 @@ export async function getGitHubRepoInfo(repo: Repo) {
|
||||
data.subdir = repo.path.slice(subdirPath.length).split('/');
|
||||
}
|
||||
|
||||
if (data.id === 'vercel/vercel' && data.subdir && data.subdir[0] === 'examples') {
|
||||
|
||||
if (
|
||||
data.id === 'vercel/vercel' &&
|
||||
data.subdir &&
|
||||
data.subdir[0] === 'examples'
|
||||
) {
|
||||
// from our examples, add `homepage` and `description` fields
|
||||
const example = data.subdir[1];
|
||||
const exampleList = await getExampleList();
|
||||
|
||||
10
codecov.yml
10
codecov.yml
@@ -1,10 +0,0 @@
|
||||
codecov:
|
||||
require_ci_to_pass: yes
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project: off
|
||||
patch: off
|
||||
|
||||
fixes:
|
||||
- "::packages/cli/" # move root e.g., "path/" => "after/path/"
|
||||
@@ -51,6 +51,7 @@
|
||||
"test-e2e": "node utils/gen.js && turbo run test-e2e",
|
||||
"test-dev": "node utils/gen.js && turbo run test-dev",
|
||||
"lint": "eslint . --cache --ext .ts,.js",
|
||||
"prettier-check": "prettier --check .",
|
||||
"prepare": "husky install",
|
||||
"pack": "cd utils && node -r ts-eager/register ./pack.ts"
|
||||
},
|
||||
|
||||
@@ -36,9 +36,7 @@ async function main() {
|
||||
const def = await readFile(fnPath.replace(/\.js$/, '.tsdef'), 'utf8');
|
||||
const interfaceName = def.match(/interface (\w+)/)[1];
|
||||
|
||||
const lines = require(fnPath)
|
||||
.toString()
|
||||
.split('\n');
|
||||
const lines = require(fnPath).toString().split('\n');
|
||||
let errorHtmlStart = -1;
|
||||
let errorHtmlEnd = -1;
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
|
||||
6
packages/cli/src/commands/env/add.ts
vendored
6
packages/cli/src/commands/env/add.ts
vendored
@@ -1,5 +1,9 @@
|
||||
import chalk from 'chalk';
|
||||
import { ProjectEnvTarget, Project, ProjectEnvType } from '@vercel-internals/types';
|
||||
import {
|
||||
ProjectEnvTarget,
|
||||
Project,
|
||||
ProjectEnvType,
|
||||
} from '@vercel-internals/types';
|
||||
import { Output } from '../../util/output';
|
||||
import Client from '../../util/client';
|
||||
import stamp from '../../util/output/stamp';
|
||||
|
||||
6
packages/cli/src/commands/env/ls.ts
vendored
6
packages/cli/src/commands/env/ls.ts
vendored
@@ -1,7 +1,11 @@
|
||||
import chalk from 'chalk';
|
||||
import ms from 'ms';
|
||||
import { Output } from '../../util/output';
|
||||
import { Project, ProjectEnvVariable, ProjectEnvType } from '@vercel-internals/types';
|
||||
import {
|
||||
Project,
|
||||
ProjectEnvVariable,
|
||||
ProjectEnvType,
|
||||
} from '@vercel-internals/types';
|
||||
import Client from '../../util/client';
|
||||
import formatTable from '../../util/format-table';
|
||||
import getEnvRecords from '../../util/env/get-env-records';
|
||||
|
||||
@@ -20,10 +20,7 @@ export default function getWildcardCNSForAlias(alias: string) {
|
||||
|
||||
const secondLevel =
|
||||
subdomain && subdomain.includes('.')
|
||||
? subdomain
|
||||
.split('.')
|
||||
.slice(1)
|
||||
.join('.')
|
||||
? subdomain.split('.').slice(1).join('.')
|
||||
: null;
|
||||
|
||||
const root = secondLevel ? `${secondLevel}.${domain}` : domain;
|
||||
|
||||
@@ -8,7 +8,7 @@ export default async function deleteDNSRecordById(
|
||||
return client.fetch(
|
||||
`/v3/domains/${encodeURIComponent(domain)}/records/${recordId}`,
|
||||
{
|
||||
method: 'DELETE'
|
||||
method: 'DELETE',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ export default function parseAddArgs(
|
||||
if (domain && rest.length === 0) {
|
||||
return {
|
||||
domain,
|
||||
data: null
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export default function parseAddArgs(
|
||||
if (type === 'MX' && args.length === 5) {
|
||||
return {
|
||||
domain,
|
||||
data: { name, type, value, mxPriority: Number(args[4]) }
|
||||
data: { name, type, value, mxPriority: Number(args[4]) },
|
||||
};
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ export default function parseAddArgs(
|
||||
priority: Number(value),
|
||||
weight: Number(args[4]),
|
||||
port: Number(args[5]),
|
||||
target: args[6]
|
||||
}
|
||||
}
|
||||
target: args[6],
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@ export default function parseAddArgs(
|
||||
data: {
|
||||
name,
|
||||
type,
|
||||
value
|
||||
}
|
||||
value,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export default async function getAuthCode(code?: string) {
|
||||
}
|
||||
return textInput({
|
||||
label: `- Transfer auth code: `,
|
||||
validateValue: isValidAuthCode
|
||||
validateValue: isValidAuthCode,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,6 @@ export default function formatDNSTable(
|
||||
return table([HEADER, ...rows], {
|
||||
align: ['l', 'l', 'l'],
|
||||
hsep: ' '.repeat(8),
|
||||
stringLength: strlen
|
||||
stringLength: strlen,
|
||||
}).replace(/^(.*)/gm, `${extraSpace}$1`);
|
||||
}
|
||||
|
||||
@@ -22,19 +22,23 @@ export default function formatNSTable(
|
||||
sortedCurrent[i] || chalk.gray('-'),
|
||||
sortedIntended[i] === sortedCurrent[i]
|
||||
? chalk.green(chars.tick)
|
||||
: chalk.red(chars.cross)
|
||||
: chalk.red(chars.cross),
|
||||
]);
|
||||
}
|
||||
|
||||
return table(
|
||||
[
|
||||
[chalk.gray('Intended Nameservers'), chalk.gray('Current Nameservers'), ''],
|
||||
...rows
|
||||
[
|
||||
chalk.gray('Intended Nameservers'),
|
||||
chalk.gray('Current Nameservers'),
|
||||
'',
|
||||
],
|
||||
...rows,
|
||||
],
|
||||
{
|
||||
align: ['l', 'l', 'l', 'l'],
|
||||
hsep: ' '.repeat(4),
|
||||
stringLength: strlen
|
||||
stringLength: strlen,
|
||||
}
|
||||
).replace(/^(.*)/gm, `${extraSpace}$1`);
|
||||
}
|
||||
|
||||
@@ -7,4 +7,3 @@ export function getDistTag(version: string): string {
|
||||
}
|
||||
return 'latest';
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ export function getPaginationOpts(opts: PaginationOptions) {
|
||||
typeof limit === 'number' &&
|
||||
(!Number.isInteger(limit) || limit > 100 || limit < 1)
|
||||
) {
|
||||
throw new Error('Please provide an integer from 1 to 100 for option --limit');
|
||||
throw new Error(
|
||||
'Please provide an integer from 1 to 100 for option --limit'
|
||||
);
|
||||
}
|
||||
|
||||
return [nextTimestamp, limit];
|
||||
|
||||
@@ -14,6 +14,6 @@ export default function getSubcommand(
|
||||
}
|
||||
return {
|
||||
subcommand: config.default,
|
||||
args: cliArgs
|
||||
args: cliArgs,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ function didYouMean(input: string, list: string[], threshold: number = 0.5) {
|
||||
const found = rated.filter(item => item[0] > threshold);
|
||||
if (found.length) {
|
||||
const highestRated = found.reduce((accu, curr) => {
|
||||
return accu[0] > curr[0] ? accu : curr
|
||||
return accu[0] > curr[0] ? accu : curr;
|
||||
});
|
||||
return highestRated[1];
|
||||
}
|
||||
@@ -23,6 +23,7 @@ function didYouMean(input: string, list: string[], threshold: number = 0.5) {
|
||||
function dashAwareDistance(word: string, dashWord: string) {
|
||||
const fullDistance = distance(word, dashWord);
|
||||
const distances = dashWord.split('-').map(w => distance(w, word));
|
||||
const meanDistance = distances.reduce((accu, curr) => accu + curr) / distances.length;
|
||||
const meanDistance =
|
||||
distances.reduce((accu, curr) => accu + curr) / distances.length;
|
||||
return fullDistance > meanDistance ? fullDistance : meanDistance;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ export class NowError<C, Meta> extends Error {
|
||||
constructor({
|
||||
code,
|
||||
message,
|
||||
meta
|
||||
meta,
|
||||
}: {
|
||||
code: C;
|
||||
message: string;
|
||||
|
||||
@@ -6,7 +6,7 @@ export default async function* raceAsyncGenerators(...args: any[]) {
|
||||
yield new Promise(resolve => {
|
||||
let resolved = false;
|
||||
nextPromises.forEach((nextPromise, idx) => {
|
||||
nextPromise.then(({ value, done }: { value: any, done: boolean }) => {
|
||||
nextPromise.then(({ value, done }: { value: any; done: boolean }) => {
|
||||
if (!resolved) {
|
||||
resolved = true;
|
||||
resolve(value);
|
||||
@@ -15,7 +15,7 @@ export default async function* raceAsyncGenerators(...args: any[]) {
|
||||
} else {
|
||||
nextPromises = [
|
||||
...nextPromises.slice(0, idx),
|
||||
...nextPromises.slice(idx + 1)
|
||||
...nextPromises.slice(idx + 1),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ export async function readConfigFile<T>(
|
||||
if (name.endsWith('.json')) {
|
||||
return JSON.parse(str) as T;
|
||||
} else if (name.endsWith('.toml')) {
|
||||
return (toml.parse(str) as unknown) as T;
|
||||
return toml.parse(str) as unknown as T;
|
||||
} else if (name.endsWith('.yaml') || name.endsWith('.yml')) {
|
||||
return yaml.safeLoad(str, { filename: name }) as T;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
import type { NextPage } from 'next'
|
||||
import type { NextPage } from 'next';
|
||||
|
||||
const Home: NextPage = () => {
|
||||
return (
|
||||
<div>
|
||||
Home
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default Home
|
||||
return <div>Home</div>;
|
||||
};
|
||||
|
||||
export default Home;
|
||||
|
||||
export const config = {
|
||||
runtime: 'experimental-edge',
|
||||
}
|
||||
};
|
||||
|
||||
@@ -22,9 +22,11 @@ function getBuilderRoutesMapping(builds: Build[]) {
|
||||
return builderRoutes;
|
||||
}
|
||||
|
||||
function getCheckAndContinue(
|
||||
routes: Route[]
|
||||
): { checks: Route[]; continues: Route[]; others: Route[] } {
|
||||
function getCheckAndContinue(routes: Route[]): {
|
||||
checks: Route[];
|
||||
continues: Route[];
|
||||
others: Route[];
|
||||
} {
|
||||
const checks: Route[] = [];
|
||||
const continues: Route[] = [];
|
||||
const others: Route[] = [];
|
||||
|
||||
@@ -3,7 +3,10 @@ import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
const ajv = new Ajv();
|
||||
|
||||
export function validate<T extends JSONSchema>(schema: T, data: any): FromSchema<T> {
|
||||
export function validate<T extends JSONSchema>(
|
||||
schema: T,
|
||||
data: any
|
||||
): FromSchema<T> {
|
||||
const isValid = ajv.compile(schema);
|
||||
if (!isValid(data)) {
|
||||
// TODO: better error message
|
||||
|
||||
Reference in New Issue
Block a user