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

feat(eslint-plugin): [prefer-readonly-parameter-types] add `ignoreInferredTypes` option #2668

Conversation

@eyelidlessness
Copy link
Contributor

@eyelidlessness eyelidlessness commented Oct 12, 2020

This PR addresses part of #2079. I'm not sure whether I should mark this as fixes, since there's discussion of other wants. So I'll leave that determination up to the reporter and maintainers).

This introduces an ignoreInferredTypes option for prefer-readonly-parameter-types, which if true ignores errors on parameters with no explicit type parameter. This may be useful for cases where an external dependency specifies mutable parameter types, e.g. for parameters in callbacks.

…Types option

Allows `prefer-readonly-parameter-types` users to specify an `ignoreInferredTypes` option, which if true will ignroe errors on parameters with no explicit type parameter. This may be useful for cases where an external dependency specifies mutable parameter types, e.g. for parameters in callbacks.
@typescript-eslint
Copy link

@typescript-eslint typescript-eslint bot commented Oct 12, 2020

Thanks for the PR, @eyelidlessness!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

@eyelidlessness
Copy link
Contributor Author

@eyelidlessness eyelidlessness commented Oct 12, 2020

Dang, I knew it was risky for me to make that second commit without rerunning lint etc locally. Fixes incoming!

@codecov
Copy link

@codecov codecov bot commented Oct 12, 2020

Codecov Report

Merging #2668 into master will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2668   +/-   ##
=======================================
  Coverage   92.83%   92.83%           
=======================================
  Files         294      294           
  Lines        9666     9669    +3     
  Branches     2711     2712    +1     
=======================================
+ Hits         8973     8976    +3     
  Misses        327      327           
  Partials      366      366           
Flag Coverage Δ
#unittest 92.83% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...lugin/src/rules/prefer-readonly-parameter-types.ts 100.00% <100.00%> (ø)
@eyelidlessness
Copy link
Contributor Author

@eyelidlessness eyelidlessness commented Oct 12, 2020

Okay, so I was looking at the code coverage report to try to see why it was such a significant reduction, and... discovered that not only had I implemented this incorrectly... I also had gotten false positives in the tests because apparently eslint-disable is infectious. So that's probably not the right approach here, and I'm unsure how to proceed, because the setup requires an erroneous precondition. I think what I'll probably do is put this PR into draft mode for now and spend some time looking through the codebase for prior art.

@eyelidlessness eyelidlessness marked this pull request as draft Oct 12, 2020
@eyelidlessness eyelidlessness marked this pull request as ready for review Oct 13, 2020
Copy link
Member

@bradzacher bradzacher left a comment

nice and simple - thanks for this option, should save people a lot of pain.

@bradzacher bradzacher changed the title feat(eslint-plugin): [prefer-readonly-parameter-types] ignoreInferredTypes option feat(eslint-plugin): [prefer-readonly-parameter-types] add `ignoreInferredTypes` option Oct 18, 2020
@bradzacher bradzacher merged commit 91010e8 into typescript-eslint:master Oct 18, 2020
8 checks passed
8 checks passed
Typecheck
Details
Unit tests Unit tests
Details
Code style and lint
Details
Run integration tests on primary Node.js version
Details
Run unit tests on other Node.js versions (10.x)
Details
Run unit tests on other Node.js versions (14.x)
Details
Publish the latest code as a canary version
Details
Semantic Pull Request ready to be squashed
Details
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.