【问题标题】:VSCode /w. Prettier in TypeScript MonorepoVS代码/w。在 TypeScript Monorepo 中更漂亮
【发布时间】:2019-12-07 20:10:56
【问题描述】:

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

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

  • www - NextJS
  • api - 阿波罗服务器
|--- 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/*"]
    }
  }
}

【问题讨论】:

    标签: typescript visual-studio-code prettier


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2020-09-25
      • 2021-02-05
      • 2019-01-23
      • 2019-08-24
      • 2018-04-22
      • 2020-04-25
      • 2019-01-20
      • 2020-01-02
      • 1970-01-01
      相关资源
      最近更新 更多