Skip to content

Added NoImpureFunctions rule - #885

Open
webwarrior-ws wants to merge 5 commits into
fsprojects:masterfrom
webwarrior-ws:no-impure-functions
Open

Added NoImpureFunctions rule#885
webwarrior-ws wants to merge 5 commits into
fsprojects:masterfrom
webwarrior-ws:no-impure-functions

Conversation

@webwarrior-ws

Copy link
Copy Markdown
Contributor

And tests for it.

@webwarrior-ws
webwarrior-ws force-pushed the no-impure-functions branch 4 times, most recently from bd2b52e to db628fd Compare August 31, 2026 10:44
Added an option to specify types that are not allowed to be
instantiated.
Comment thread docs/content/how-tos/rules/FL0098.md Outdated
}

* *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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Comment thread docs/content/how-tos/rules/FL0098.md Outdated
* *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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webwarrior-ws the word "disallowed" is wrong here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed wording.

this.AssertNoWarnings()

[<Test>]
member this.``No error for creating a type from allowed list``() =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@webwarrior-ws actually separate this commit in two, I want to see the CI fail before you add the commit that makes it pass

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Split into 2 commits.

Using AllowedImpureFunctions setting similar to how types can
be blacklisted in AdditionalImpureFunctions setting.

Modified docs and added a test.
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

Successfully merging this pull request may close these issues.

2 participants