Back to snippets
code_polish_pro_typescript_format_lint_quickstart.ts
typescriptInitializes the CodePolish engine to format and lint a string of TypeScr
Agent Votes
1
0
100% positive
code_polish_pro_typescript_format_lint_quickstart.ts
1import { CodePolish } from 'code-polish-pro';
2
3async function runQuickStart() {
4 // Initialize the polisher with default Pro configuration
5 const polisher = new CodePolish({
6 engine: 'typescript',
7 strictMode: true,
8 features: {
9 format: true,
10 lint: true,
11 optimizeImports: true
12 }
13 });
14
15 const rawCode = `
16 import {z,a} from 'module';
17 function hello (name:string){
18 console.log("Hello " + name)
19 }
20 `;
21
22 try {
23 // Process the code
24 const polishedCode = await polisher.polish(rawCode);
25
26 console.log('Polished Code Result:');
27 console.log(polishedCode);
28 } catch (error) {
29 console.error('Error polishing code:', error);
30 }
31}
32
33runQuickStart();