Skip to content

Commit

Permalink
fix(codegen): fix use of prettier.format for codegen (#2393)
Browse files Browse the repository at this point in the history
* fix(codegen): fix use of prettier.format for codegen

* chore(deps): remove unused "babel" dependency

* chore(deps): update typescript to latest (5.4.4)
  • Loading branch information
matthieusieben authored Apr 9, 2024
1 parent f5c830a commit b8f8f06
Show file tree
Hide file tree
Showing 6 changed files with 397 additions and 1,129 deletions.
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
},
"devDependencies": {
"@atproto/dev-env": "workspace:^",
"@babel/core": "^7.18.6",
"@babel/preset-env": "^7.18.6",
"@changesets/changelog-github": "^0.4.8",
"@changesets/cli": "^2.26.2",
"@swc/core": "^1.3.42",
Expand All @@ -40,7 +38,6 @@
"@types/node": "^18.19.24",
"@typescript-eslint/eslint-plugin": "^7.4.0",
"@typescript-eslint/parser": "^7.4.0",
"babel-eslint": "^10.1.0",
"dotenv": "^16.0.3",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
Expand All @@ -50,7 +47,7 @@
"pino-pretty": "^9.1.0",
"prettier": "^3.2.5",
"prettier-config-standard": "^7.0.0",
"typescript": "^5.3.3"
"typescript": "^5.4.4"
},
"workspaces": {
"packages": [
Expand Down
3 changes: 2 additions & 1 deletion packages/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"devDependencies": {
"@atproto/lex-cli": "workspace:^",
"get-port": "^6.1.2",
"jest": "^28.1.2"
"jest": "^28.1.2",
"prettier": "^3.2.5"
}
}
2 changes: 1 addition & 1 deletion packages/api/scripts/code/labels.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function gen() {
2,
)}
`,
{ semi: false, parser: 'babel', singleQuote: true },
{ semi: false, parser: 'typescript', singleQuote: true },
)
}

Expand Down
1 change: 1 addition & 0 deletions packages/lex-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@atproto/syntax": "workspace:^",
"chalk": "^4.1.2",
"commander": "^9.4.0",
"prettier": "^3.2.5",
"ts-morph": "^16.0.0",
"yesno": "^0.4.0",
"zod": "^3.21.4"
Expand Down
26 changes: 13 additions & 13 deletions packages/lex-cli/src/codegen/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import prettier from 'prettier'
import { GeneratedFile } from '../types'

const PRETTIER_OPTS = {
parser: 'babel-ts',
parser: 'typescript',
tabWidth: 2,
semi: false,
singleQuote: true,
Expand All @@ -14,17 +14,17 @@ const PRETTIER_OPTS = {
export const utilTs = (project) =>
gen(project, '/util.ts', async (file) => {
file.replaceWithText(`
export function isObj(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null
}
export function hasProp<K extends PropertyKey>(
data: object,
prop: K,
): data is Record<K, unknown> {
return prop in data
}
`)
export function isObj(v: unknown): v is Record<string, unknown> {
return typeof v === 'object' && v !== null
}
export function hasProp<K extends PropertyKey>(
data: object,
prop: K,
): data is Record<K, unknown> {
return prop in data
}
`)
})

export const lexiconsTs = (project, lexicons: LexiconDoc[]) =>
Expand Down Expand Up @@ -122,7 +122,7 @@ export async function gen(
const src = project.getFileSystem().readFileSync(path)
return {
path: path,
content: `${banner()}${prettier.format(src, PRETTIER_OPTS)}`,
content: `${banner()}${await prettier.format(src, PRETTIER_OPTS)}`,
}
}

Expand Down
Loading

0 comments on commit b8f8f06

Please sign in to comment.