3

我对 eslint + prettier 有疑问。出于某种原因,我有一些像这样的“换行符”:

var err = "jqxhr: " + jqxhr + ". Status: " + textStatus + ", " + error;

将被工具美化为:

var err =
    "jqxhr: " + jqxhr + ". Status: " + textStatus + ", " + error;

https://gyazo.com/ef44b03a25292f5e6e156c3105ef7c3b

我怎样才能防止这种行为?谢谢!

配置示例:

{
    "root": true,
    "extends": [
        "prettier",
        "prettier/standard"
    ],
    "env": {
        "browser": true,
        "jquery": true
    },
    "plugins": [
        "prettier"
    ],
    "rules": {
        "prettier/prettier": [
            "error"
        ],
        "indent": [
            "error",
            4
        ],
        "linebreak-style": [
            "error",
            "unix"
        ],
        "max-len": [
            "error",
            {"code": 120, "ignoreUrls": true}
        ]
    }
}
4

1 回答 1

2

如果您有类似的问题,请检查行 printWidth 和 operator-linebreak。我的案例与 printWidth 有关

于 2018-04-25T11:52:33.053 回答