AirBnB Linter在同一条线上多次弯曲,使其过长

时间:2018-09-19 13:33:32

标签: eslint eslint-config-airbnb

我似乎遇到了AirBnB掉毛悖论。

我有以下一行:

const pagePromiseGenerator = (graphql, createPage) => (gqlNodeName, pageComponent) => new Promise((resolve, reject) => {

,超过100个字符。所以我可以将其转换为:

const pagePromiseGenerator = (graphql, createPage) => {
  return (gqlNodeName, pageComponent) => new Promise((resolve, reject) => {

但这违反了AirBnB箭头体样式规则。我应该只对此行禁用掉毛吗,还是有更好的方法?

2 个答案:

答案 0 :(得分:1)

const pagePromiseGenerator = (graphql, createPage) =>
  (gqlNodeName, pageComponent) => new Promise((resolve, reject) => {

答案 1 :(得分:1)

您可以同时满足这两个规则。您将在implicit-arrow-linebreak docs中看到可以在括号中包含一个隐式返回:

const pagePromiseGenerator = (graphql, createPage) => (
  (gqlNodeName, pageComponent) => new Promise((resolve, reject) => {
    // some code here
  })
);