@kubb/parser-ts
Advanced tools
Comparing version 0.0.0-canary-20241213202051 to 0.0.0-canary-20241213215524
@@ -15,6 +15,6 @@ import ts, { PrinterOptions } from 'typescript'; | ||
/** | ||
* Format the generated code based on the TypeScript printer. | ||
* Format the generated code based on Prettier | ||
*/ | ||
declare function format(source: string, options?: Omit<PrintOptions, 'source'>): string; | ||
declare function format(source: string): Promise<string>; | ||
export { format, print }; |
export { factory_exports as factory } from './chunk-RWXGFVS2.js'; | ||
import ts from 'typescript'; | ||
import { format as format$1 } from 'prettier'; | ||
import pluginTypescript from 'prettier/plugins/typescript'; | ||
@@ -28,6 +30,17 @@ var { factory } = ts; | ||
} | ||
// src/format.ts | ||
function format(source, options = {}) { | ||
return print([], { source, noEmitHelpers: false, ...options }); | ||
var formatOptions = { | ||
tabWidth: 2, | ||
printWidth: 160, | ||
parser: "typescript", | ||
singleQuote: true, | ||
semi: false, | ||
bracketSameLine: false, | ||
endOfLine: "auto", | ||
plugins: [pluginTypescript] | ||
}; | ||
async function format(source) { | ||
if (!source) { | ||
return ""; | ||
} | ||
return format$1(source, formatOptions); | ||
} | ||
@@ -34,0 +47,0 @@ |
{ | ||
"name": "@kubb/parser-ts", | ||
"version": "0.0.0-canary-20241213202051", | ||
"version": "0.0.0-canary-20241213215524", | ||
"description": "TypeScript parser", | ||
@@ -52,2 +52,3 @@ "keywords": [ | ||
"remeda": "^2.17.4", | ||
"prettier": "^3.4.2", | ||
"typescript": "^5.7.2" | ||
@@ -57,4 +58,4 @@ }, | ||
"tsup": "^8.3.5", | ||
"@kubb/config-ts": "0.0.0-canary-20241213202051", | ||
"@kubb/config-tsup": "0.0.0-canary-20241213202051" | ||
"@kubb/config-ts": "0.0.0-canary-20241213215524", | ||
"@kubb/config-tsup": "0.0.0-canary-20241213215524" | ||
}, | ||
@@ -61,0 +62,0 @@ "engines": { |
@@ -1,9 +0,27 @@ | ||
import { type PrintOptions, print } from './print.ts' | ||
import { format as prettierFormat } from 'prettier' | ||
import pluginTypescript from 'prettier/plugins/typescript' | ||
import type { Options } from 'prettier' | ||
const formatOptions: Options = { | ||
tabWidth: 2, | ||
printWidth: 160, | ||
parser: 'typescript', | ||
singleQuote: true, | ||
semi: false, | ||
bracketSameLine: false, | ||
endOfLine: 'auto', | ||
plugins: [pluginTypescript], | ||
} | ||
/** | ||
* Format the generated code based on the TypeScript printer. | ||
* Format the generated code based on Prettier | ||
*/ | ||
export function format(source: string, options: Omit<PrintOptions, 'source'> = {}) { | ||
export async function format(source: string) { | ||
// do some basic linting with the ts compiler | ||
return print([], { source, noEmitHelpers: false, ...options }) | ||
if (!source) { | ||
return '' | ||
} | ||
return prettierFormat(source, formatOptions) | ||
} |
@@ -1,2 +0,2 @@ | ||
import ts, { LanguageVariant } from 'typescript' | ||
import ts from 'typescript' | ||
@@ -3,0 +3,0 @@ import type { PrinterOptions } from 'typescript' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
158097
1867
3
+ Addedprettier@^3.4.2
+ Addedprettier@3.4.2(transitive)