-
-
Notifications
You must be signed in to change notification settings - Fork 28
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
type-declaration-immutability: ignorePattern doesn't work on member name #599
Comments
The If we were to add support for ignoring members, we'd likely need do it in a new option. |
The example above was taken verbatim from your own documentation, so maybe this page should be deleted, or edited? |
I think the prefer-readonly-type worked according to the docs. However it is now superseded by type-declaration-immutability. The original intent of field level mutability for prefer-readonly-type was to mimic the approach some immutable-first languages takes to mutability. They usually have a I guess the reason for having anything mutable is performance, and to be honest I seldom use this ignore feature of eslint-functional myself. However since it has been available before I think it would be interesting to know how widely used it is so I'll re-open so we can collect some opinions on this. Of course, it would be nice if typescript could be compiled with a |
Yeah, I should have re-written that file with the release of v5. The reasoning behind my last comment and closing this issue was based off the fact that with v5, the rules |
Note: Once @typescript-eslint/type-utils v6 comes out, I'll be making some improvements to is-immutable-type using the new functionality coming (#575 and #577 are waiting for this). |
So let's say I have a class (or object). Is there any way to do this? class Hey {
mut_array = []
}
const hey = new Hey()
hey.mut_array.push(1) // currently, it complains with "Modifying an array is not allowed." |
@rickmed I think you replied to the wrong thread. #691 (comment) |
@RebeccaStevens don't think so. The other issue is about const/let functionality. |
Ahh, sorry. I thought this was just a follow up question for over there. I'll move my reply here. |
You can use the This should do what you want: {
"ignoreAccessorPattern": "**.mut_*.**"
} |
🎉 This issue has been resolved in version 6.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Bug Report
ignorePattern
option of type-declaration-immutability doesn't work on member names, contrary to what is advertised hereExpected behavior
given following config:
there should be no linter error for the following code:
Actual behavior
The following error is raised:
Note that the following does not cause an error, which means that the
ignorePattern
is in force, but only matches the type name, not it's members.Steps to reproduce
Run eslint on the above code using the above config.
Proposed changes
Mutability checks for members which names match
ignorePattern
should be skippedThe text was updated successfully, but these errors were encountered: