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

fix(eslint-plugin): [consistent-indexed-object-style] convert readonly index signature to readonly record #2798

Conversation

ryym
Copy link
Contributor

@ryym ryym commented Nov 22, 2020

Fixes #2797

  • Update the rule to skip readonly index signature.
  • Update the rule document.

Update the rule to fix a readonly index signature by Readonly<Record<key, value>> type.
(#2798 (review))

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @ryym!

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.

@codecov
Copy link

codecov bot commented Nov 22, 2020

Codecov Report

Merging #2798 (ddd6011) into master (c2dde58) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master    #2798   +/-   ##
=======================================
  Coverage   92.80%   92.80%           
=======================================
  Files         300      300           
  Lines        9857     9859    +2     
  Branches     2769     2770    +1     
=======================================
+ Hits         9148     9150    +2     
  Misses        332      332           
  Partials      377      377           
Flag Coverage Δ
unittest 92.80% <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/consistent-indexed-object-style.ts 89.36% <100.00%> (+0.47%) ⬆️

@ryym ryym marked this pull request as ready for review November 22, 2020 09:17
@bradzacher bradzacher added the bug Something isn't working label Nov 22, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

Couldn't we fix this to Readonly<Record<string, unknown>> instead of just ignoring it?

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Nov 22, 2020
@ryym
Copy link
Contributor Author

ryym commented Nov 22, 2020

Good idea!
I'll try to implement it.

…adonly type to correct code examples"

This reverts commit 3212edb.
The rule should replace a readonly index signature with `Readonly<Record>`
instead of ignoring it.
…ly index signature to Readonly Record type

This replaces the fix of 816b1bb.
Instead of just ignoring the readonly index signature, replace it with
`Readonly<Record<key, value>>` type.
@ryym ryym changed the title fix(eslint-plugin): [consistent-indexed-object-style] Skip readonly index signature fix(eslint-plugin): [consistent-indexed-object-style] Convert readonly index signature correctly Nov 22, 2020
@ryym
Copy link
Contributor Author

ryym commented Nov 22, 2020

@bradzacher Thank you for your advice.
I updated the code. Could you review again?

@ryym ryym requested a review from bradzacher November 22, 2020 23:56
@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Nov 22, 2020
Copy link
Member

@bradzacher bradzacher left a comment

Choose a reason for hiding this comment

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

lgtm - thanks for working on this!

@bradzacher bradzacher changed the title fix(eslint-plugin): [consistent-indexed-object-style] Convert readonly index signature correctly fix(eslint-plugin): [consistent-indexed-object-style] convert readonly index signature to readonly record Nov 25, 2020
@bradzacher bradzacher merged commit 29428a4 into typescript-eslint:master Nov 25, 2020
@ryym ryym deleted the fix-consistent-indexed-object-style-readonly branch November 26, 2020 08:38
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[consistent-indexed-object-style] Readonly modifier is ignored
2 participants