我使用 JetBrains 的 IDE PhpStorm,其中還包括 WebStorm。
在撰寫 React/Next.js 應用程式時,必須解壓縮函式引數的物件屬性。
但目前 IDE 會打亂屬性的形成,如果它們位于多行中。
所需的輸出:
export default function SomeComponent({
children,
home,
}: SomeComponentProps) {
return (
<>Something...</>
);
}
但是如果我使用重新格式化,實際輸出的是:
export default function SomeComponent({
children,
home,
}: SomeComponentProps) {
return (
<>Something...</>
);
}
在 IDE 設定中,我使用 Google JavaScript Style Guide for JavaScript and TypeScript:

在 Next.js 專案中,我嘗試了 ESLint 和 prettier 的組合:
{
"extends": [
"eslint:recommended",
"google",
"next/core-web-vitals",
"prettier"
],
"rules": {
"require-jsdoc": "off"
}
}
無論如何存檔所需的輸出?
uj5u.com熱心網友回復:
請嘗試在設定 |中的函式宣告引數的多行時禁用對齊 編輯 | 代碼風格 | JavaScript | 包裝和大括號

轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/452959.html
標籤:javascript 打字稿 网络风暴 更漂亮
