V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
meloncc
V2EX  ›  问与答

vscode 对 eslint-js 的格式化问题

  •  
  •   meloncc · Apr 26, 2020 · 2407 views
    This topic created in 2201 days ago, the information mentioned may be changed or developed.

    背景:团队使用 eslint 格式化,保存自动 eslint-fix,大部分的人都正常,一个小伙子 js(项目使用 vue,在.vue 中的 js 可以正常格式化缩进)文件保存时会把缩进变成 8 个“Expected indentation of 4 spaces but found 8.”,系统环境是 windows 。

    现象:ctrl+s 触发而 elint 自动格式化有很明显的两次格式改变,第一次格式正常,紧接着会闪一下,由把格式变成 8 个 spaces 。

    看了他的 eslint 、.editconfig 、setting.json 配置和大家是一样,且格式化的操作代码格式正常,把语言选择为 javascriptreact 能正常使用 eslint 的自动格式化。有没有兄弟姐妹叔叔阿姨遇到过!

    4 replies    2020-05-12 09:29:51 +08:00
    red2dog
        1
    red2dog  
       Apr 26, 2020
    看看他有没有装其他的格式化插件吧。 根据 你这个描述
    oreo
        2
    oreo  
       May 10, 2020
    Please also note that if you use ESLint as your default formatter you should turn off editor.formatOnSave when you have turned on editor.codeActionsOnSave. Otherwise you file gets fixed twice which in unnecessary.

    vscode-eslint 插件文档里写着,试试
    meloncc
        3
    meloncc  
    OP
       May 12, 2020
    @oreo 已经解决了,原因是这个小伙子装了其他插件,并且有默认配置,所以在配置文件没看出来(口区)
    meloncc
        4
    meloncc  
    OP
       May 12, 2020
    @red2dog 已经解决了,原因是这个小伙子装了其他插件,并且有默认配置,所以在配置文件没看出来(口区)
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5691 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 08:40 · PVG 16:40 · LAX 01:40 · JFK 04:40
    ♥ Do have faith in what you're doing.