typescript - VS代码/w。在 TypeScript Monorepo 中更漂亮

我目前在 Monorepo 设置中通过 VSCode 扩展使用 Prettier。问题是 Prettier 在我的 api 文件夹中不能完全工作。它不遵守默认的线宽,分号不会自动附加。奇怪的是,我的 www 文件夹正常工作,而且我没有丢失任何 Prettier 功能。

更漂亮的配置是通过 VSCode 中的“用户设置”全局设置的。

  • www - NextJS
  • api - Apollo 服务器
|--- api
    |--- package.json
    |--- tsconfig.json 
    |--- server.ts
|--- www
    |--- pages
         |--- index.tsx
    |--- package.json
    |--- tsconfig.json 

www/tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "allowSyntheticDefaultImports": true,
    "forceConsistentCasingInFileNames": true,
    "noUnusedLocals": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve"
  }
}

api/tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
    "target": "es6",
    "moduleResolution": "node",
    "sourceMap": true,
    "outDir": "dist",
    "baseUrl": ".",
    "paths": {
      "*": ["node_modules/*", "src/types/*"]
    }
  }
}

最佳答案

尝试添加 .prettierrc到项目的根目录,包含您想要的所有选项。

https://stackoverflow.com/questions/57271578/

相关文章:

svelte - 将选定的 Svelte 组件编译为 CustomElements

flutter - flutter 的 video_playeur 包问题

javascript - 在 Angular 2+ 上重新渲染 FullCalendar

python-3.x - 属性错误 : 'NoneType' object has no attri

spring - 让 Spring RestTemplate 使用内存中的 pem 证书(不在磁盘上

asp.net-core-2.0 - 如何在 .net 核心 web api 中将 Razor Vi

django - 自定义 Django Admin 用户密码修改表单

html - 如何修复内容安全策略错误?

python - 如何使用分类变量和数值变量绘制相关矩阵/热图

google-cloud-storage - 与 Google Cloud Storage 的连接池