Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ignore-prefix option to no-expression-statement rule #39

Closed
algesten opened this issue Sep 2, 2017 · 2 comments
Closed

Add ignore-prefix option to no-expression-statement rule #39

algesten opened this issue Sep 2, 2017 · 2 comments

Comments

@algesten
Copy link
Contributor

algesten commented Sep 2, 2017

Would you consider a ignore-prefix for the no-expression-statement.

My use case is logging, which pretty much per definition is a side effect, yet something that a server can't really live without. It would clean up my code a lot, since I now have a lot of this going on.

    // tslint:disable-next-line:no-expression-statement
    logSys.error('startup failed', err)

Happy to put a PR together, if you would consider accepting it.

@jonaskello
Copy link
Owner

jonaskello commented Sep 2, 2017

Just to clarify you mean that if we configure it like this:

"no-expression-statement": [true, {"ignore-prefix": "sideEffect"}]

Then this would be ignored:

sideEffectFoo("bar")

I think that makes sense and would welcome a PR for it :-).

If the call is a method on an object, I guess then the prefix would apply to the method name and not the object name:

myObj.sideEffectFoo("bar"); // This will be ignored
sideEffectObj.myMethod("bar"); // This will **not** be ignored

Or should both object names and method name be considered?

@algesten
Copy link
Contributor Author

algesten commented Sep 9, 2017

If the call is a method on an object, I guess then the prefix would apply to the method name and not the object name
...
Or should both object names and method name be considered?

Maybe both? I mean for console.log, would it perhaps be more natural to ignore the whole thing, not just log?

algesten added a commit to algesten/tslint-immutable that referenced this issue Sep 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants