Skip to content

Commit 85d3642

Browse files
authored
chore: add check:format script and CI formatting step (#569)
Add formatting check to catch unformatted code in CI and locally: - New script: check:format (prettier --check .) - Added to the check script (runs format → lint → types → deps) - New CI step in lint.yml: Format Check (runs before Lint) - Fix 7 files with existing formatting issues Co-Authored-By: Claude
1 parent 67229b5 commit 85d3642

File tree

9 files changed

+15
-23
lines changed

9 files changed

+15
-23
lines changed

.github/workflows/lint.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
if: github.run_attempt > 1
3131
run: echo "TURBO_FORCE=true" >> $GITHUB_ENV
3232

33+
- name: Format Check
34+
run: pnpm check:format
35+
3336
- name: Lint
3437
run: pnpm check:lint
3538

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
"scripts": {
2222
"build": "turbo run build build:types",
2323
"build:cli": "turbo run build build:types --filter=./packages/**",
24-
"check": "npm run check:lint && npm run check:types && npm run check:deps",
24+
"check": "npm run check:format && npm run check:lint && npm run check:types && npm run check:deps",
2525
"check:deps": "knip",
26+
"check:format": "prettier --check .",
2627
"check:lint": "turbo run lint -- --fix",
2728
"check:types": "turbo run check:types --filter=@sanity/cli --filter=@sanity/cli-core",
2829
"clean": "rimraf packages/@sanity/*/lib packages/*/lib packages/@sanity/*/dist packages/*/dist",

packages/@repo/coverage-delta/src/lib.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ function isCoverageMetric(value: unknown): value is {pct: number} {
88
)
99
}
1010

11-
function isFileCoverageData(
12-
value: unknown,
13-
): value is {
11+
function isFileCoverageData(value: unknown): value is {
1412
branches: {pct: number}
1513
functions: {pct: number}
1614
lines: {pct: number}

packages/@sanity/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,8 @@
155155
"@types/lodash-es": "^4.17.12",
156156
"@types/minimist": "^1.2.5",
157157
"@types/node": "catalog:",
158-
"@types/react": "^19.2.14",
159158
"@types/picomatch": "^4.0.2",
159+
"@types/react": "^19.2.14",
160160
"@types/react-dom": "^19.2.3",
161161
"@types/react-is": "^19.2.0",
162162
"@types/semver": "^7.7.1",

packages/@sanity/cli/src/commands/documents/__tests__/validate.flags.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ describe('#documents:validate flag passthrough', () => {
116116
])
117117

118118
if (error) throw error
119-
expect(mocks.validateDocuments).toHaveBeenCalledWith(
120-
expect.objectContaining({level: 'error'}),
121-
)
119+
expect(mocks.validateDocuments).toHaveBeenCalledWith(expect.objectContaining({level: 'error'}))
122120
})
123121

124122
test('passes --max-custom-validation-concurrency to validateDocuments action', async () => {

packages/@sanity/cli/src/commands/documents/query.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,7 @@ export class QueryDocumentCommand extends SanityCommand<typeof QueryDocumentComm
6464
public async run(): Promise<void> {
6565
const {args, flags} = await this.parse(QueryDocumentCommand)
6666
const {query} = args
67-
const {
68-
anonymous,
69-
'api-version': apiVersion,
70-
dataset,
71-
pretty,
72-
} = flags
67+
const {anonymous, 'api-version': apiVersion, dataset, pretty} = flags
7368

7469
const cliConfig = await this.getCliConfig()
7570
const projectId = await this.getProjectId({

packages/@sanity/cli/src/commands/documents/validate.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export class ValidateDocumentsCommand extends SanityCommand<typeof ValidateDocum
3939

4040
static flags = {
4141
...getProjectIdFlag({
42-
description: 'Override the project ID used. By default, this is derived from the given workspace',
42+
description:
43+
'Override the project ID used. By default, this is derived from the given workspace',
4344
}),
4445
...getDatasetFlag({
4546
description:

packages/@sanity/cli/src/commands/graphql/__tests__/undeploy.test.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -246,11 +246,9 @@ describe('graphql undeploy', () => {
246246
})
247247

248248
test('errors when both --api and --project-id are specified', async () => {
249-
const {error} = await testCommand(
250-
Undeploy,
251-
['--api', 'ios', '--project-id', 'test-project'],
252-
{mocks: defaultMocks},
253-
)
249+
const {error} = await testCommand(Undeploy, ['--api', 'ios', '--project-id', 'test-project'], {
250+
mocks: defaultMocks,
251+
})
254252

255253
expect(error).toBeInstanceOf(Error)
256254
expect(error?.message).toContain('cannot also be provided when using --api')

packages/@sanity/cli/src/services/__tests__/grants.test.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ describe('getUserGrants', () => {
3838
organizations: {},
3939
projects: {
4040
'project-a': {
41-
'sanity.project.datasets': [
42-
{grants: [{name: 'read', params: {}}]},
43-
],
41+
'sanity.project.datasets': [{grants: [{name: 'read', params: {}}]}],
4442
},
4543
},
4644
}

0 commit comments

Comments
 (0)