sindresorhus/eslint-plugin-unicorn

Rule proposal: `max-nested-calls`

Closed

#1,274 opened on May 14, 2021

 (3 comments) (7 reactions) (0 assignees)JavaScript (468 forks)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

Got the idea from this line.

Fail

mergeReports(await pMap(await mergeWithFileConfigs(uniq(paths), inputOptions, configFiles), async ({files, options, prettierOptions}) => runEslint(files, buildConfig(options, prettierOptions), {isQuiet: options.quiet})));

Pass

const uniqPaths = uniq(paths);
const mergedConfigs = await mergeWithFileConfigs(
  uniqPaths,
  inputOptions,
  configFiles
);
const reports = await pMap(
  mergedConfigs,
  async ({ files, options, prettierOptions }) =>
    runEslint(
      files, 
      buildConfig(options, prettierOptions),
      {isQuiet: options.quiet}
    )
);

mergeReports(reports);

Maybe with a configurable depth option.

These should all considered as "call"

  • CallExpression
  • ChainExpression > CallExpression
  • NewExpression
  • AwaitExpression > NodeTypesListedAbove.argument

Contributor guide