升级webstorm版本后,格式化代码后,代码风格可能与之前会有区别,导致看着别扭,eslint还飘红。
解决方式是启用自定义的code style设置。截图如下:
如果设置里没有这个选项,则可以在项目根目录下添加.editorconfig文件,示例内容如下:
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
该文件的作用就是说明项目的编码、换行、缩进、空格等规定,保证在不同的ide下使用相同的代码风格进行开发。