欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vscode中prettier和eslint換行縮進(jìn)沖突的問(wèn)題

 更新時(shí)間:2023年10月20日 10:17:12   作者:Simorel  
這篇文章主要介紹了vscode中prettier和eslint換行縮進(jìn)沖突的問(wèn)題及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教

prettier

Javascript

// Input
const example1 =
    someValue === 'a' ? 'hello world, branch a'
  : someValue === 'b' ? 'hello world, branch a && b'
  : someValue === 'c' ? 'hello world, branch a && b && c'
  : someValue === 'd' ? 'hello world, branch a && b && c && d'
  : null;

const example2 =
  someValue === 'a'
    ? someValue === 'b'
      ? someValue === 'c'
        ? 'hello world, branch a && b && c'
        : 'hello world, branch a && b && !c'
      : 'hello world, branch a && !b' 
    : null;

// Output (Prettier 1.14)
const example1 =
  someValue === "a"
    ? "hello world, branch a"
    : someValue === "b"
      ? "hello world, branch a && b"
      : someValue === "c"
        ? "hello world, branch a && b && c"
        : someValue === "d"
          ? "hello world, branch a && b && c && d"
          : null;

const example2 =
  someValue === "a"
    ? someValue === "b"
      ? someValue === "c"
        ? "hello world, branch a && b && c"
        : "hello world, branch a && b && !c"
      : "hello world, branch a && !b"
    : null;

// Output (Prettier 1.15)
const example1 =
  someValue === "a"
    ? "hello world, branch a"
    : someValue === "b"
    ? "hello world, branch a && b"
    : someValue === "c"
    ? "hello world, branch a && b && c"
    : someValue === "d"
    ? "hello world, branch a && b && c && d"
    : null;

const example2 =
  someValue === "a"
    ? someValue === "b"
      ? someValue === "c"
        ? "hello world, branch a && b && c"
        : "hello world, branch a && b && !c"
      : "hello world, branch a && !b"
    : null;

異常展示

prettier 格式化后輸出結(jié)果

<div
  v-if="
    statusSetting.a === element.status ||
    statusSetting.b === element.status
  "
  class="ticket__background"
/>

eslint沖突輸出結(jié)果

<div
  v-if="
    statusSetting.a === element.status ||
   	  statusSetting.b === element.status
  "
  class="ticket__background"
/>

解決方案

方案一

工作區(qū)禁用eslint

方案二

修改 vscode 配置

/** 保存文檔時(shí)自動(dòng)格式化 */
"editor.formatOnSave": false,
/** 保存時(shí)按照哪個(gè)規(guī)則進(jìn)行格式化(上面的保存文檔時(shí)自動(dòng)格式化必須關(guān)閉否則會(huì)有沖突) */
"editor.codeActionsOnSave": {
  "source.fixAll": true,
},

總結(jié)

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論