coderaiser / putout

🐊 Pluggable and configurable JavaScript Linter, code transformer and formatter, drop-in ESLint superpower replacement 💪 with built-in support for js, jsx, typescript, flow, markdown, yaml and json. Write declarative codemods in a simplest possible way 😏
https://putout.cloudcmd.io/
MIT License
698 stars 40 forks source link

Incorrect removing of an expression #198

Closed sirenkovladd closed 8 months ago

sirenkovladd commented 8 months ago
import {
    parse,
    transform,
} from 'putout';
import {print} from '@putout/printer';
import removeUnusedExpressions from '@putout/plugin-remove-unused-expressions';

const js = `a();!(function (s) {console.log(s);})();b()`;

const ast = parse(js);
transform(ast, js, {plugins: [
    ['remove-unused-expressions', removeUnusedExpressions],
]});
const min = print(ast);

console.log(min);

result

❯ node v.js
a();
b();

removed immediate function execution

coderaiser commented 8 months ago

Just fixed, is it works for you?

sirenkovladd commented 8 months ago

Yes, thank you so much)