Skip to content

Commit

Permalink
chore: remove prettier dependency (#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
ymc9 authored Mar 24, 2024
1 parent c13a1fd commit a0ca15d
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 33 deletions.
1 change: 0 additions & 1 deletion packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"@zenstackhq/runtime": "workspace:*",
"langium": "1.3.1",
"lower-case-first": "^2.0.2",
"prettier": "^2.8.3 || 3.x",
"semver": "^7.5.2",
"ts-morph": "^16.0.0",
"ts-pattern": "^4.3.0",
Expand Down
31 changes: 2 additions & 29 deletions packages/sdk/src/code-gen.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
import prettier from 'prettier';
import { CompilerOptions, DiagnosticCategory, ModuleKind, Project, ScriptTarget, SourceFile } from 'ts-morph';
import { CompilerOptions, DiagnosticCategory, ModuleKind, Project, ScriptTarget } from 'ts-morph';
import { PluginError } from './types';

const formatOptions = {
trailingComma: 'all',
tabWidth: 4,
printWidth: 120,
bracketSpacing: true,
semi: true,
singleQuote: true,
useTabs: false,
parser: 'typescript',
} as const;

async function formatFile(sourceFile: SourceFile) {
try {
const content = sourceFile.getFullText();
const formatted = await prettier.format(content, formatOptions);
sourceFile.replaceWithText(formatted);
await sourceFile.save();
} catch {
/* empty */
}
}

/**
* Creates a TS code generation project
*/
Expand All @@ -46,11 +23,7 @@ export function createProject(options?: CompilerOptions) {
* Persists a TS project to disk.
*/
export async function saveProject(project: Project) {
await Promise.all(
project.getSourceFiles().map(async (sf) => {
await formatFile(sf);
})
);
project.getSourceFiles().forEach((sf) => sf.formatText());
await project.save();
}

Expand Down
3 changes: 0 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a0ca15d

Please sign in to comment.