Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Module side effects #155

Closed
samhh opened this issue Sep 23, 2020 · 2 comments
Closed

Module side effects #155

samhh opened this issue Sep 23, 2020 · 2 comments
Labels
Status: Investigation Needed Issue need to be investigated further.

Comments

@samhh
Copy link

samhh commented Sep 23, 2020

This one probably can't be done, but I'm curious if anyone has any thoughts - can we lint against module side effects?

Only way I've thought of so far is to lint specifically against fp-ts and enforce that you can't call Task or IO functions in a module except within another function.

@RebeccaStevens
Copy link
Collaborator

I believe if you are using the rule no-expression-statement, this will prevent module side effects unless the side effect happens as a result of a function call.
If it becomes possible to ensure a function is pure in typescript then this could also be prevented.

@RebeccaStevens RebeccaStevens added the Status: Investigation Needed Issue need to be investigated further. label Dec 28, 2020
@jonaskello
Copy link
Collaborator

Yes, having a pure modifier for functions in typescript would be awesome :-).

I usually try to avoid having any code outside of functions in all modules. Having side-effects happen just by importing a module is IMO never wanted. Perhaps we could check if there is anything else than function definitions in a module? That check would be less specific of course but it would eliminate any side-effect that happen on import. Or would that be too restrictive?

@eslint-functional eslint-functional locked and limited conversation to collaborators Jan 8, 2022
@RebeccaStevens RebeccaStevens converted this issue into discussion #311 Jan 8, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Status: Investigation Needed Issue need to be investigated further.
Projects
None yet
Development

No branches or pull requests

3 participants