jshint / fixmyjs

Automatically fix silly lint errors.
http://fixmyjs.com
Other
972 stars 78 forks source link

do not remove new if it is inside a function call #116

Closed lejenome closed 10 years ago

lejenome commented 10 years ago

this pull request fix this wrong rewrite c(new Foo()); => c(Foo()); it just checks if parent.expression.type === 'CallExpression' in case parent.type === 'ExpressionStatement' I'm not sure if there are other expression types inside ExpressionStatement that should be ignored too on newSideEffects rule

goatslacker commented 10 years ago

What is the rationale for this?

newcap is supposed to complain regardless of context.

lejenome commented 10 years ago

c(new Foo()); should not be rewritten to c(Foo()); this PR will fix the error for example, on my app, fixmyjs rewrittes

document.body.dispatchEvent(new CustomEvent("blog-post-loaded"));

to

document.body.dispatchEvent(CustomEvent());

which is wrong

hope that explain what this PR is for, it has nothing to do with newcap

goatslacker commented 10 years ago

LGTM