arrow-body-style

箭头函数体周围需要大括号

一些该规则报告的问题可以通过 --fix 命令行选项 自动修复

箭头函数的函数体有两种语法形式。它们可以用块体(用大括号表示)() => { ... } 或用单个表达式 () => ... 定义,其值被隐式返回。

规则详情

此规则可以强制或禁止在箭头函数体周围使用大括号。

选项

该规则有一个或两个选项。第一个是字符串,可以是:

    /5jpztV5zik8Wxbn1EHnKFxSRhFjnjTn1IkFTO+4Qzh6gTi4V2iVmnH/awkQDjAb7g5qoEyfGENFjbaTHbI9JrAerTsxdS4Xjzz5Z78+MUnh2P4gK+Nn4K1kSTkAzH00gKWjkcO+YkrCF8qXNq91H9I8Qphnb7r4R4MHVBEIKZ9AIrFjunsWAwieG/CgF3iEsJbVOwPeclXCpxnx04g5Dqn82/L/B9FCidJBBDbjDBZK+/X8Zrwe7FOn092bjGsoVWIOj2KXKKEVYb6hW2FfjzYrEKVrSVlOmVUZscOXNmD4lCbUJ0itufNDrZMF6rtLBbUHfzLmnlXIWQ4qA4mwcX7lHQpuOtj7pXcFbz7SnCix9AiVP1/GsCLWhsuNugT/

MPS7Vp161eBvBUUpgxiBaNrA8+u1GF40U5k8T/4LcZwkMWFZ8xKXP4saRTLrrdXK8kJqqyugZY1YxqEFovjg2jnHcojo2OJ5iBtRBvmGeYUG+Ip8DhFuQLtfvglp31lNTKmfkgQt2HbvXDQ00g3ed0dk67G14gNMcZjd4BvNiPFz59CiMIuPc0z9bsD7YR5KliIn/sxLrErIWBKU/KyhYCxkQFOfUPB1DJISM9poZ3/ru14gheosaqHWo9OkrllhVYQZrZUxY/uGnUK7qZiJbnl0yPSMqjGKWth9MDSHiRV7eoSSjAgqISll95Fgy85BLLaMmIWFJHvm3704YRUDprkYVW9a3caywacNeP5TfEdBdcpQeZrCsgifoJhfakyDFrTI+/RzEP9vxt6ZdR9esB1UUxD/vHS0SeX+jzIyCOAOIdJq9d8ACoDBKs1v42WD

"arrow-body-style": ["error", "always"]

always

ACbGoO0F0WET2g6e840uzKYqnmQ3LNJQ9dHR4+xUOgIghddPdtYEPdKoOtIGiAMk/oB5qgkF2ZhqYmfUnGwytdLUC/7BRrEk62EcVTqkCrw=

/*eslint arrow-body-style: ["error", "always"]*/
/*eslint-env es6*/
let foo = () => 0;

ACbGoO0F0WET2g6e840uzKYqnmQ3LNJQ9dHR4+xUOgLhIz6E3IVpny1LxEpwle4XSJJfGZdi2taOpwm0Eqy5oSM4qZqt7Jo+BR+kUbjoCIA=

let foo = () => {
    return 0;
};
let foo = (retv, name) => {
    retv[name] = true;
    return retv;
};

as-needed

voYhZHfetX7RFbEmc5BGw3qJ8NTBNtwUlUrMyNwolZC5luqwxRuN1bmfOY3ye3Og7J+39Yf0pxUaF2By0LejdF/MK4gunt3//q7kfydnta4=

/*eslint arrow-body-style: ["error", "as-needed"]*/
/*eslint-env es6*/

let foo = () => {
    return 0;
};
let foo = () => {
    return {
       bar: {
            foo: 1,
            bar: 2,
        }
    };
};

voYhZHfetX7RFbEmc5BGw3qJ8NTBNtwUlUrMyNwolZC5luqwxRuN1bmfOY3ye3OgQELdiwlkgMUZx3vWRdRfJVhDUJiJV/MmxzzYky3VKeA=

/*eslint arrow-body-style: ["error", "as-needed"]*/
/*eslint-env es6*/

let foo = () => 0;
let foo = (retv, name) => {
    retv[name] = true;
    return retv;
};
let foo = () => ({
    bar: {
        foo: 1,
        bar: 2,
    }
});
let foo = () => { bar(); };
let foo = () => {};
let foo = () => { /* do nothing */ };
let foo = () => {
    // do nothing.
};
let foo = () => ({ bar: 0 });

requireReturnForObjectLiteral

9up4KYnYm34pq8ypiEXyq9w/lXVnyiIx9MgzL3Fmrewo7YhpfKNXgsG5Ge1i0Id7HNVjH5takrhHPnneW4erKz4XSdu9LC1ru2F13C2+sx0=

ACbGoO0F0WET2g6e840uzBpKdHckvAGhP42fTFBn1qRcArIURfH4xMPyaT8fIOPtJx3PXJMCNJ1bX53txOkFotSoVSvYJWNYLnXcHZTdk4oiQMbi+H5cZyeEK3kUvzi38+2+4StuhwowMEfH9fcgFg==

/*eslint arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
/*eslint-env es6*/
let foo = () => ({});
let foo = () => ({ bar: 0 });

ACbGoO0F0WET2g6e840uzBpKdHckvAGhP42fTFBn1qRcArIURfH4xMPyaT8fIOPtJx3PXJMCNJ1bX53txOkFotSoVSvYJWNYLnXcHZTdk4orgy5urzW5261u5jpWRB5/vPbuXyV84DMhr9AK+zXcgQ==

/*eslint arrow-body-style: ["error", "as-needed", { "requireReturnForObjectLiteral": true }]*/
/*eslint-env es6*/

let foo = () => {};
let foo = () => { return { bar: 0 }; };

never

ACbGoO0F0WET2g6e840uzDishvYNNfr59Rbq40OWp80njxP3fILX8l9NdhaiYCK3beOG2Y4GWluzIb7SQ3UI5AEpzgtA2h1eEJCXaOmkmo0=

/*eslint arrow-body-style: ["error", "never"]*/
/*eslint-env es6*/

let foo = () => {
    return 0;
};
let foo = (retv, name) => {
    retv[name] = true;
    return retv;
};

ACbGoO0F0WET2g6e840uzDishvYNNfr59Rbq40OWp81Nsrj0mRjbgsSTcjW3q6v2eek+TpQ6Pz+0r589uDLpGoLfgWwG+H/EzVJMKbAsRZk=

/*eslint arrow-body-style: ["error", "never"]*/
/*eslint-env es6*/

let foo = () => 0;
let foo = () => ({ foo: 0 });