Skip to content

Commit

Permalink
[tests] Add prettier check (#9664)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
styfle committed Mar 13, 2023
1 parent 7ec3777 commit bada86b
Show file tree
Hide file tree
Showing 38 changed files with 172 additions and 140 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/label-feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
issue-number: ${{ github.event.issue.number }}
body: |
Thank you for taking the time to created this request!
We added it to our backlog but need to discuss design/architecture before we can accept a PR.
Please let us know if you would be interested in sending a PR once we approve the design.
6 changes: 3 additions & 3 deletions .github/workflows/label-support.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
issue-number: ${{ github.event.issue.number }}
comment: |
Thank you so much for filing this issue.
We do try to keep issues in this repository focused on the vercel command line and related code.
At this point we think that this issue is best handled by our friendly Vercel support team. They can be found by contacting them at: https://vercel.com/help#issues
If you think closing of this is a mistake, then please re-open this issue and we'll take another look :bow:
6 changes: 3 additions & 3 deletions .github/workflows/label-triaged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
issue-number: ${{ github.event.issue.number }}
body: |
Thank you for taking the time to file this issue!
We have confirmed this is a bug and added it to our backlog.
We don't have a timeline for when this issue will be fixed, but we will accept a Pull Request with a fix and a test.
See the [contributing guidelines](https://github.com/vercel/vercel/blob/main/.github/CONTRIBUTING.md) for more info.
96 changes: 48 additions & 48 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Publish
on:
push:
branches:
- main
- main
tags:
- '!*'
- '!*'

env:
TURBO_REMOTE_ONLY: 'true'
Expand All @@ -17,50 +17,50 @@ jobs:
name: Publish
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Release
id: check-release
run: |
tag="$(git describe --tags --exact-match 2> /dev/null || :)"
if [[ -z "$tag" ]];
then
echo "IS_RELEASE=false" >> $GITHUB_OUTPUT
else
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
fi
- name: Setup Go
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
uses: actions/setup-go@v3
with:
go-version: '1.13.15'
- name: Setup Node
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
uses: actions/setup-node@v3
with:
node-version: 16
- name: install npm@9
run: npm i -g npm@9
- name: install pnpm@7.24.2
run: npm i -g pnpm@7.24.2
- name: Install
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm install
- name: Build
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm build
env:
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Publish
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm publish-from-github
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Check Release
id: check-release
run: |
tag="$(git describe --tags --exact-match 2> /dev/null || :)"
if [[ -z "$tag" ]];
then
echo "IS_RELEASE=false" >> $GITHUB_OUTPUT
else
echo "IS_RELEASE=true" >> $GITHUB_OUTPUT
fi
- name: Setup Go
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
uses: actions/setup-go@v3
with:
go-version: '1.13.15'
- name: Setup Node
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
uses: actions/setup-node@v3
with:
node-version: 16
- name: install npm@9
run: npm i -g npm@9
- name: install pnpm@7.24.2
run: npm i -g pnpm@7.24.2
- name: Install
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm install
- name: Build
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm build
env:
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
- name: Publish
if: ${{ steps.check-release.outputs.IS_RELEASE == 'true' }}
run: pnpm publish-from-github
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN_ELEVATED }}
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
4 changes: 2 additions & 2 deletions .github/workflows/test-integration-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: CLI
on:
push:
branches:
- main
- main
tags:
- '!*'
- '!*'
pull_request:

env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/test-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Lint
on:
push:
branches:
- main
- main
tags:
- '!*'
- '!*'
pull_request:

env:
Expand All @@ -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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ name: Tests
on:
push:
branches:
- main
- main
tags:
- '!*'
- '!*'
pull_request:

env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-remix-run-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
25 changes: 25 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -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

5 changes: 4 additions & 1 deletion DEVELOPING_A_RUNTIME.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 5 additions & 2 deletions api/_lib/examples/github-repo-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
10 changes: 0 additions & 10 deletions codecov.yml

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 1 addition & 3 deletions packages/cli/scripts/compile-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/commands/env/add.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
6 changes: 5 additions & 1 deletion packages/cli/src/commands/env/ls.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
5 changes: 1 addition & 4 deletions packages/cli/src/util/certs/get-wildcard-cns-for-alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/create-polling-fn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function createPollingFn<R>(
future: (...args: any[]) => Promise<R>,
sleepTime: number
) {
return async function*(...args: any[]) {
return async function* (...args: any[]) {
while (true) {
yield await future(...args);
await sleep(sleepTime);
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/dns/delete-dns-record-by-id.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default async function deleteDNSRecordById(
return client.fetch(
`/v3/domains/${encodeURIComponent(domain)}/records/${recordId}`,
{
method: 'DELETE'
method: 'DELETE',
}
);
}
14 changes: 7 additions & 7 deletions packages/cli/src/util/dns/parse-add-dns-record-args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default function parseAddArgs(
if (domain && rest.length === 0) {
return {
domain,
data: null
data: null,
};
}

Expand All @@ -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]) },
};
}

Expand All @@ -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],
},
},
};
}

Expand All @@ -52,8 +52,8 @@ export default function parseAddArgs(
data: {
name,
type,
value
}
value,
},
};
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/domains/get-auth-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default async function getAuthCode(code?: string) {
}
return textInput({
label: `- Transfer auth code: `,
validateValue: isValidAuthCode
validateValue: isValidAuthCode,
});
}

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/util/format-dns-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
Loading

0 comments on commit bada86b

Please sign in to comment.