簡體   English   中英

為 Visual Studio 代碼中的每個鏈接語句添加換行符

[英]add newline for each chaining statement in visual studio code

任何人都知道在 Visual Studio 代碼中為更漂亮的擴展鏈接語句添加換行符的設置是什么? 我在 typescript 中有如下代碼

export function myfunction(myString: string) {
  cy.get(myString).find('.aaa').click();
}

我想確保它變成

export function myfunction(myString: string) {
  cy.get(myString)
    .find('.aaa')
    .click();
}


使用來自 eslint newline-per-chained-call規則: https://eslint.org/docs/rules/newline-per-chained-call

將此添加到您的 aslant 配置中(例如.eslintrc.json ):

{
  //... 
  "rules": {
    //...
    "newline-per-chained-call": "error"
  }
}

要使其在 VS Code 中工作,請安裝eslint ext並按照說明如何從 ext 頁面“保存時自動修復”。

"editor.codeActionsOnSave": {
  "source.fixAll": true
}

例如。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM