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): [ban-types] update message to suggest object instead of Record<string, unknown> #6079

Merged
merged 19 commits into from Dec 7, 2022

Conversation

kmin-jeong
Copy link
Contributor

@kmin-jeong kmin-jeong commented Nov 24, 2022

PR Checklist

Overview

Updates the report message to mention object first instead of Record<string, never>.

Co-authored-by: @RyanCavanaugh

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @kmin-jeong!

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.

@nx-cloud
Copy link

nx-cloud bot commented Nov 24, 2022

☁️ Nx Cloud Report

CI is running/has finished running commands for commit 6a22bef. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 47 targets

Sent with 💌 from NxCloud.

@netlify
Copy link

netlify bot commented Nov 24, 2022

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 6a22bef
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/638a171a28d6e60008c9ded3
😎 Deploy Preview https://deploy-preview-6079--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@Josh-Cena
Copy link
Member

Are we un-suggesting Record<string, never> or Record<string, unknown>? To me the former is more problematic, but this PR is not changing the right thing.

@kmin-jeong
Copy link
Contributor Author

@Josh-Cena @JoshuaKGoldberg I changed the part of the message according to the proposal in the issue and sent a pr draft. I saw the issue and understood that the object was used instead of 'Record<string, unknown>'. Did I get it wrong? I haven't worked on the code and the test code yet.

@bradzacher
Copy link
Member

This is the correct fix (it's just a re-creation of #5018).

@kmin-jeong kmin-jeong marked this pull request as ready for review November 29, 2022 08:06
@kmin-jeong kmin-jeong changed the title fix(eslint-plugin): suggest object, not Record<string, never> fix(eslint-plugin): use object instead of Record<string, never> Nov 29, 2022
@kmin-jeong
Copy link
Contributor Author

@bradzacher @Josh-Cena @JoshuaKGoldberg
I fixed the part in the record. I add the short test code, and converted the draft into a pr. If I understand something wrong or there is something wrong with the code, I will correct it.

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.

looks like you've introduced some type errors

@kmin-jeong
Copy link
Contributor Author

@bradzacher I add type Types and type checkrequiredTypes to fix lint errors.

@kmin-jeong
Copy link
Contributor Author

kmin-jeong commented Dec 1, 2022

After looking at this issue and the discussion mentioned in the issue, I added the test code and requested the pr. I don't know the range where I shouldn't use type Record <string, never>. if I just need to modify the message to 'use object instead', or if I need to modify the code in the type Record <string, never> and let the message 'use object instead' come out. @JoshuaKGoldberg and @bradzacher, Are there any other issues or discursions that mention the scope of use of Record?
If think it's unnecessary pr, I'll close it.

  • There was a misspelling part, so I modified it.
  • there was a vague part I was correct it.

@bradzacher
Copy link
Member

@kmin-jeong the fix we're looking for here is to update the message so that it suggests using object.
You're first commit (f679c99) was the correct fix!

@bradzacher bradzacher added the awaiting response Issues waiting for a reply from the OP or another party label Dec 2, 2022
@kmin-jeong
Copy link
Contributor Author

@bradzacher I vaguely thought I should fix the code, too. I modified ban-types.ts again like Commit (f679c99).

@JoshuaKGoldberg
Copy link
Member

Psst - you don't have to keep @ tagging us. We'll see the updates come in and reply when we can. 🙂

JoshuaKGoldberg
JoshuaKGoldberg previously approved these changes Dec 2, 2022
Copy link
Member

@JoshuaKGoldberg JoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

The code changes look good, thanks! I'll take care of the test revert.

I also filled out the Overview in the PR.

packages/eslint-plugin/tests/rules/ban-types.test.ts Outdated Show resolved Hide resolved
@JoshuaKGoldberg JoshuaKGoldberg enabled auto-merge (squash) December 2, 2022 15:19
@Josh-Cena
Copy link
Member

Josh-Cena commented Dec 2, 2022

Shouldn't the PR title say "instead of Record<string, unknown> then? Also, there's minor difference between a Record and an object (the latter has no index signatures and you can access nothing on it directly), but maybe that doesn't matter much, and it's probably safer to suggest object anyway.

@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(eslint-plugin): use object instead of Record<string, never> fix(eslint-plugin): use object instead of Record<string, unknown> Dec 2, 2022
@JoshuaKGoldberg
Copy link
Member

Ah thanks, good catch on the title - updated.

And yeah they're not quite the same but object is close enough for most cases.

@bradzacher bradzacher removed the awaiting response Issues waiting for a reply from the OP or another party label Dec 7, 2022
@bradzacher bradzacher changed the title fix(eslint-plugin): use object instead of Record<string, unknown> fix(eslint-plugin): [ban-types] update message to suggest object instead of Record<string, unknown> Dec 7, 2022
@bradzacher bradzacher merged commit d91a5fc into typescript-eslint:main Dec 7, 2022
@kmin-jeong kmin-jeong deleted the feat/5949 branch December 10, 2022 06:26
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Dec 13, 2022
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@typescript-eslint/eslint-plugin](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`5.44.0` -> `5.46.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/5.44.0/5.46.0) |
| [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`5.44.0` -> `5.46.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/5.44.0/5.46.0) |

---

### Release Notes

<details>
<summary>typescript-eslint/typescript-eslint (@&#8203;typescript-eslint/eslint-plugin)</summary>

### [`v5.46.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#&#8203;5460-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5451v5460-2022-12-08)

[Compare Source](typescript-eslint/typescript-eslint@v5.45.1...v5.46.0)

##### Bug Fixes

-   **eslint-plugin:** \[ban-types] update message to suggest `object` instead of `Record<string, unknown>` ([#&#8203;6079](typescript-eslint/typescript-eslint#6079)) ([d91a5fc](typescript-eslint/typescript-eslint@d91a5fc))

##### Features

-   **eslint-plugin:** \[prefer-nullish-coalescing] logic and test for strict null checks ([#&#8203;6174](typescript-eslint/typescript-eslint#6174)) ([8a91cbd](typescript-eslint/typescript-eslint@8a91cbd))

#### [5.45.1](typescript-eslint/typescript-eslint@v5.45.0...v5.45.1) (2022-12-05)

##### Bug Fixes

-   **eslint-plugin:** \[keyword-spacing] unexpected space before/after in `import type` ([#&#8203;6095](typescript-eslint/typescript-eslint#6095)) ([98caa92](typescript-eslint/typescript-eslint@98caa92))
-   **eslint-plugin:** \[no-shadow] add call and method signatures to `ignoreFunctionTypeParameterNameValueShadow` ([#&#8203;6129](typescript-eslint/typescript-eslint#6129)) ([9d58b6b](typescript-eslint/typescript-eslint@9d58b6b))
-   **eslint-plugin:** \[prefer-optional-chain] collect MetaProperty type ([#&#8203;6083](typescript-eslint/typescript-eslint#6083)) ([d7114d3](typescript-eslint/typescript-eslint@d7114d3))
-   **eslint-plugin:** \[sort-type-constituents, sort-type-union-intersection-members] handle some required parentheses cases in the fixer ([#&#8203;6118](typescript-eslint/typescript-eslint#6118)) ([5d49d5d](typescript-eslint/typescript-eslint@5d49d5d))

### [`v5.45.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#&#8203;5451-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5450v5451-2022-12-05)

[Compare Source](typescript-eslint/typescript-eslint@v5.45.0...v5.45.1)

##### Bug Fixes

-   **eslint-plugin:** \[keyword-spacing] unexpected space before/after in `import type` ([#&#8203;6095](typescript-eslint/typescript-eslint#6095)) ([98caa92](typescript-eslint/typescript-eslint@98caa92))
-   **eslint-plugin:** \[no-shadow] add call and method signatures to `ignoreFunctionTypeParameterNameValueShadow` ([#&#8203;6129](typescript-eslint/typescript-eslint#6129)) ([9d58b6b](typescript-eslint/typescript-eslint@9d58b6b))
-   **eslint-plugin:** \[prefer-optional-chain] collect MetaProperty type ([#&#8203;6083](typescript-eslint/typescript-eslint#6083)) ([d7114d3](typescript-eslint/typescript-eslint@d7114d3))
-   **eslint-plugin:** \[sort-type-constituents, sort-type-union-intersection-members] handle some required parentheses cases in the fixer ([#&#8203;6118](typescript-eslint/typescript-eslint#6118)) ([5d49d5d](typescript-eslint/typescript-eslint@5d49d5d))

### [`v5.45.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#&#8203;5450-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5440v5450-2022-11-28)

[Compare Source](typescript-eslint/typescript-eslint@v5.44.0...v5.45.0)

##### Bug Fixes

-   **eslint-plugin:** \[array-type] --fix flag removes parentheses from type ([#&#8203;5997](typescript-eslint/typescript-eslint#5997)) ([42b33af](typescript-eslint/typescript-eslint@42b33af))
-   **eslint-plugin:** \[keyword-spacing] prevent crash on no options ([#&#8203;6073](typescript-eslint/typescript-eslint#6073)) ([1f19998](typescript-eslint/typescript-eslint@1f19998))
-   **eslint-plugin:** \[member-ordering] support private fields ([#&#8203;5859](typescript-eslint/typescript-eslint#5859)) ([f02761a](typescript-eslint/typescript-eslint@f02761a))
-   **eslint-plugin:** \[prefer-readonly] report if a member's property is reassigned ([#&#8203;6043](typescript-eslint/typescript-eslint#6043)) ([6e079eb](typescript-eslint/typescript-eslint@6e079eb))

##### Features

-   **eslint-plugin:** \[member-ordering] add a required option for required vs. optional member ordering ([#&#8203;5965](typescript-eslint/typescript-eslint#5965)) ([2abadc6](typescript-eslint/typescript-eslint@2abadc6))

</details>

<details>
<summary>typescript-eslint/typescript-eslint (@&#8203;typescript-eslint/parser)</summary>

### [`v5.46.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#&#8203;5460-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5451v5460-2022-12-08)

[Compare Source](typescript-eslint/typescript-eslint@v5.45.1...v5.46.0)

**Note:** Version bump only for package [@&#8203;typescript-eslint/parser](https://github.com/typescript-eslint/parser)

#### [5.45.1](typescript-eslint/typescript-eslint@v5.45.0...v5.45.1) (2022-12-05)

##### Bug Fixes

-   **parser:** remove the jsx option requirement for automatic jsx pragma resolution ([#&#8203;6134](typescript-eslint/typescript-eslint#6134)) ([e777f5e](typescript-eslint/typescript-eslint@e777f5e))

### [`v5.45.1`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#&#8203;5451-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5450v5451-2022-12-05)

[Compare Source](typescript-eslint/typescript-eslint@v5.45.0...v5.45.1)

##### Bug Fixes

-   **parser:** remove the jsx option requirement for automatic jsx pragma resolution ([#&#8203;6134](typescript-eslint/typescript-eslint#6134)) ([e777f5e](typescript-eslint/typescript-eslint@e777f5e))

### [`v5.45.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#&#8203;5450-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5440v5450-2022-11-28)

[Compare Source](typescript-eslint/typescript-eslint@v5.44.0...v5.45.0)

**Note:** Version bump only for package [@&#8203;typescript-eslint/parser](https://github.com/typescript-eslint/parser)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNC40Mi4wIiwidXBkYXRlZEluVmVyIjoiMzQuNTEuMCJ9-->

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1666
Reviewed-by: Epsilon_02 <epsilon_02@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: [ban-types] Should suggest object, not Record<string, never>
4 participants