prettier
作者:互联网
prettier
Prettier is an opinionated code formatter with support for:
- JavaScript (including experimental features)
- JSX
- Angular
- Vue
- Flow
- TypeScript
- CSS, Less, and SCSS
- HTML
- JSON
- GraphQL
- Markdown, including GFM and MDX
- YAML
调用prettier的方法
let apiModule = (apiJSON) => {
let strClass = `export class ApiService {
constructor(httpClient) {
this.httpClient = httpClient
}
${transferApi(apiJSON)}}`
return prettier.format(strClass, { parser: "babel" })
}
输出
export class ApiService {
constructor(httpClient) {
this.httpClient = httpClient;
}
async postDomains(data) {
const pathname = prefixUrl("/domains");
return await this.httpClient.post(pathname, data);
}
}
不调用prettier的方法
let apiModule = (apiJSON) => {
let strClass = `export class ApiService {
constructor(httpClient) {
this.httpClient = httpClient
}
${transferApi(apiJSON)}}`
return strClass
}
export class ApiService {
constructor(httpClient) {
this.httpClient = httpClient
}
async postDomains(data) {
const pathname = prefixUrl('/domains')
return await this.httpClient.post(pathname, data)
}
}
标签:strClass,return,prettier,constructor,ApiService,httpClient 来源: https://blog.csdn.net/m0_56028305/article/details/121590133