更漂亮的换行符不接受规则

时间:2020-01-17 09:17:21

标签: visual-studio-code prettier

我尝试更漂亮地更改换行符,但是 vs代码为此忽略了我的设置... 我尝试放入 line-length: 140 ,但是什么也没发生。

我尝试了这个,但是没有成功

// edit your tslint.json
"max-line-length": [
     true, 
    { 
        "limit": 140, 
        "ignore-pattern": "^import |^export {(.*?)}" 
    }
],

我使用

prettier: [3.18.0]
VS code: 1.41.1

这是我的设置

{
  "workbench.editor.highlightModifiedTabs": true,
  "files.trimFinalNewlines": true,
  "window.menuBarVisibility": "default",
  "workbench.activityBar.visible": true,
  "files.autoSave": "off",
  "window.zoomLevel": 0,
  "editor.rulers": [
    140
  ],
  "editor.wordWrapColumn": 140,
  "[markdown]": {
    "editor.wordWrap": "wordWrapColumn",
    "editor.quickSuggestions": false
  },

  "diffEditor.ignoreTrimWhitespace": true,
  "vsicons.projectDetection.autoReload": true,
  "files.eol": "\n",
  "editor.formatOnSave": true,
  "editor.tabSize": 2,
  "javascript.referencesCodeLens.enabled": true,
  "cSpell.userWords": [
    "dropdown",
    "toastr"
  ],

  "typescript.updateImportsOnFileMove.enabled": "always",
  "terminal.integrated.rendererType": "dom",
  "html.format.wrapLineLength": 140,
  "editor.wordWrap": "bounded",
  "prettier.jsxBracketSameLine": true,
  "html.format.wrapAttributes": "preserve-aligned",
  "prettier.printWidth": 140
}

还有其他方法可以使它工作,因为更漂亮的总是以一种奇怪的方式格式化我的组件或html文件... 比方说 这个

languageLocale: [null, [Validators.minLength(1), Validators.maxLength(255)]],

对此

languageLocale: [
        null,
        [Validators.minLength(1), Validators.maxLength(255)]
      ],

或html

<mat-form-field>
        <input class="disabledInput" formControlName="id" matInput/>
</mat-form-field>

对此

<mat-form-field>
        <input
               class="disabledInput"
               formControlName="id"
               matInput
               />
</mat-form-field>

如果我们有多个输入字段,这将很糟糕

1 个答案:

答案 0 :(得分:0)

需要将配置放入self

在此处引用https://prettier.io/docs/en/configuration.html

package.json