Added NoImpureFunctions rule - #885
Open
webwarrior-ws wants to merge 5 commits into
Open
Conversation
And tests for it.
webwarrior-ws
force-pushed
the
no-impure-functions
branch
4 times, most recently
from
August 31, 2026 10:44
bd2b52e to
db628fd
Compare
webwarrior-ws
force-pushed
the
no-impure-functions
branch
from
August 31, 2026 11:36
db628fd to
354f5e6
Compare
Added an option to specify types that are not allowed to be instantiated.
webwarrior-ws
force-pushed
the
no-impure-functions
branch
from
August 31, 2026 12:11
e402e44 to
9c2d5f7
Compare
knocte
reviewed
Sep 1, 2026
| } | ||
|
|
||
| * *allowedImpureFunctions* - list of strings representing impure functions to allow (e.g. `"Array.set"`). | ||
| * *additionalImpureFunctions* - list of strings representing additional impure functions to disallow. If a string ends in `.*` (e.g. `Foo.Bar.Baz.*`), then it is treated as type `Foo.Bar.Baz` (without type parameters), using constructors of which is disallowed. |
Collaborator
There was a problem hiding this comment.
@webwarrior-ws the * comment should apply to allowedImpureFunctions too (e.g. to allow Dictionary even if the rule blacklists it), let's add a 4th commit that covers this and tweaks the docs to move this comment about asterisks to apply to both settings
knocte
reviewed
Sep 1, 2026
| * *additionalImpureFunctions* - list of strings representing additional impure functions to disallow. If a string ends in `.*` (e.g. `Foo.Bar.Baz.*`), then it is treated as type `Foo.Bar.Baz` (without type parameters), using constructors of which is disallowed. | ||
| * *additionalImpureFunctions* - list of strings representing additional impure functions to disallow. | ||
|
|
||
| If a string in either of those settings ends in `.*` (e.g. `Foo.Bar.Baz.*`), then it is treated as type `Foo.Bar.Baz` (without type parameters), using constructors of which is disallowed. |
Collaborator
There was a problem hiding this comment.
@webwarrior-ws the word "disallowed" is wrong here
Contributor
Author
There was a problem hiding this comment.
Changed wording.
knocte
reviewed
Sep 1, 2026
| this.AssertNoWarnings() | ||
|
|
||
| [<Test>] | ||
| member this.``No error for creating a type from allowed list``() = |
Collaborator
There was a problem hiding this comment.
@webwarrior-ws actually separate this commit in two, I want to see the CI fail before you add the commit that makes it pass
Contributor
Author
There was a problem hiding this comment.
Split into 2 commits.
webwarrior-ws
force-pushed
the
no-impure-functions
branch
from
September 1, 2026 10:37
8961c40 to
6015677
Compare
Using AllowedImpureFunctions setting similar to how types can be blacklisted in AdditionalImpureFunctions setting. Modified docs and added a test.
webwarrior-ws
force-pushed
the
no-impure-functions
branch
from
September 1, 2026 10:46
6015677 to
c3ce173
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
And tests for it.