question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Useless function call is not removed by plugin-remove-useless-functions

See original GitHub issue

Hi there 👋
It could be that the plugin I’m looking for exists, but I can’t find the one. I have the next statement:

const test = (fn, value) => {
  return (a => fn(a))(value);
}

const test(console.log, 42);

I want it to be transformed to

const test = (fn, value) => {
  return fn(value);
}

const test(console.log, 42);

I expected that plugin-remove-useless-functions does the thing, but it doesn’t.

What’s the best way I can solve the issue?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
mrkosimacommented, Sep 14, 2022

Just checked how the remove-iife plugin works. Here some extra cases I checked:

  1. Unused params
((a) => fn(42))(value);

Result: fn(value) Expected: fn(42) or noTransform().

  1. The previous example can be extended with:
((a) => fn(a, 42))(value);

Result: fn(value) Expected: fn(value, 42) or noTransform().

  1. Used variables within a function body
((a) => fn({customProp: a.x}))(value);

Result: fn(value) Expected: fn({customProp: value.x}) or noTransform()

What do you think?

1reaction
coderaisercommented, Sep 12, 2022

Just landed to @putout/plugin-remove-iife, it’s more related 😃.

You can try it in 🐊Putout v27.8.0 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

putout/README.md at master - GitHub
Perfection is finally attained not when there is no longer anything to add, ... remove console.log calls ... @putout/plugin-remove-useless-functions · npm.
Read more >
putout - npm Package Health Analysis - Snyk
The npm package putout was scanned for known vulnerabilities and missing license, and no issues were found. Thus the package was deemed as...
Read more >
no-useless-call - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
Compare Versions | putout | npm - Open Source Insights
Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json.
Read more >
putout/ChangeLog - UNPKG
66, - feature(@putout/plugin-remove-useless-await) add suppoort of not async functions. 67, - feature(putout) bin: disable remove-empty/import, ESM: disable ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found