Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AirBnB Linter multiple currying in same line making it too long

I seem to have run into an AirBnB linting paradox.

I have the following line:

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

which is over 100 characters long. So I can convert it to:

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

But that violates the AirBnB arrow body style rule. Should I just disable linting for this line, or is there a better way?

like image 314
Luke Schlangen Avatar asked Sep 02 '25 16:09

Luke Schlangen


1 Answers

You can satisfy both rules. You'll see in the implicit-arrow-linebreak docs that you can wrap an implicit return in parentheses:

const pagePromiseGenerator = (graphql, createPage) => (
  (gqlNodeName, pageComponent) => new Promise((resolve, reject) => {
    // some code here
  })
);
like image 171
willlma Avatar answered Sep 05 '25 05:09

willlma