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): add no-redundant-type-constituents rule #4378

Merged

Conversation

JoshuaKGoldberg
Copy link
Member

PR Checklist

Overview

@nx-cloud
Copy link

nx-cloud bot commented Dec 31, 2021

☁️ Nx Cloud Report

CI ran the following commands for commit ecd559a. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 48 targets

Sent with 💌 from NxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @JoshuaKGoldberg!

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.

@netlify
Copy link

netlify bot commented Dec 31, 2021

❌ Deploy Preview for typescript-eslint failed.

🔨 Explore the source changes: ecd559a

🔍 Inspect the deploy log: https://app.netlify.com/sites/typescript-eslint/deploys/62169a537a5edf00084ea3c0

@JoshuaKGoldberg JoshuaKGoldberg force-pushed the no-redundant-type-constituents branch 2 times, most recently from 0fb2b24 to b8bc780 Compare December 31, 2021 07:31
@JoshuaKGoldberg JoshuaKGoldberg added DO NOT MERGE PRs which should not be merged yet enhancement: new plugin rule New rule request for eslint-plugin labels Dec 31, 2021
@codecov
Copy link

codecov bot commented Jan 2, 2022

Codecov Report

Merging #4378 (ecd559a) into main (0c63f26) will increase coverage by 0.34%.
The diff coverage is 94.28%.

@@            Coverage Diff             @@
##             main    #4378      +/-   ##
==========================================
+ Coverage   94.26%   94.61%   +0.34%     
==========================================
  Files         169      148      -21     
  Lines        9511     8052    -1459     
  Branches     2973     2575     -398     
==========================================
- Hits         8966     7618    -1348     
+ Misses        322      239      -83     
+ Partials      223      195      -28     
Flag Coverage Δ
unittest 94.61% <94.28%> (+0.34%) ⬆️

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

Impacted Files Coverage Δ
packages/eslint-plugin/src/configs/all.ts 100.00% <ø> (ø)
...plugin/src/rules/no-redundant-type-constituents.ts 93.89% <93.89%> (ø)
packages/eslint-plugin/src/util/misc.ts 94.44% <100.00%> (+1.11%) ⬆️
...t-estree/src/create-program/useProvidedPrograms.ts
...escript-estree/src/semantic-or-syntactic-errors.ts
...lugin-internal/src/rules/plugin-test-formatting.ts
...-estree/src/create-program/createProjectProgram.ts
packages/typescript-estree/src/ast-converter.ts
packages/typescript-estree/src/version-check.ts
...pt-estree/src/ts-estree/estree-to-ts-node-types.ts
... and 15 more

@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review January 2, 2022 20:02
@bradzacher bradzacher removed the DO NOT MERGE PRs which should not be merged yet label Jan 2, 2022
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as draft January 13, 2022 05:13
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review January 23, 2022 23:01
bradzacher
bradzacher previously approved these changes Feb 2, 2022
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.

This is looking good to me!
A few comments, but nothing blocking.
Feel free to merge when you're happy with it!

overridden: `'{{typeName}}' is overridden by other types in this {{container}} type.`,
overrides: `'{{typeName}}' overrides all other types in this {{container}} type.`,
},
schema: [],
Copy link
Member

Choose a reason for hiding this comment

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

One thing that might be nice is adding an option which allows you to ignore certain types.
I don't think we need it now, but it might be a good future addition to the rule for codebases that do "unnecessary unions" for documentation reasons.

Copy link
Member Author

Choose a reason for hiding this comment

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

Mmhh yeah that would be nice. Another example of a place where we'd want to set up a unified way to describe types...

@bradzacher bradzacher added the 1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready label Feb 2, 2022
@bradzacher bradzacher merged commit 63d051e into typescript-eslint:main Feb 23, 2022
@JoshuaKGoldberg JoshuaKGoldberg deleted the no-redundant-type-constituents branch February 23, 2022 23:59
JoshuaKGoldberg added a commit to JoshuaKGoldberg/typescript-eslint that referenced this pull request Feb 27, 2022
crapStone pushed a commit to Calciumdibromid/CaBr2 that referenced this pull request Mar 8, 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.12.1` -> `5.13.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2feslint-plugin/5.12.1/5.13.0) |
| [@typescript-eslint/parser](https://github.com/typescript-eslint/typescript-eslint) | devDependencies | minor | [`5.12.1` -> `5.13.0`](https://renovatebot.com/diffs/npm/@typescript-eslint%2fparser/5.12.1/5.13.0) |

---

### Release Notes

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

### [`v5.13.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#&#8203;5130-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5121v5130-2022-02-28)

[Compare Source](typescript-eslint/typescript-eslint@v5.12.1...v5.13.0)

##### Bug Fixes

-   **eslint-plugin:** \[sort-type-union-intersection-members] Wrap the constructorType in parentheses ([#&#8203;4590](typescript-eslint/typescript-eslint#4590)) ([851bb90](typescript-eslint/typescript-eslint@851bb90))

##### Features

-   **eslint-plugin:** \[no-misused-promises] check more places for checksVoidReturn ([#&#8203;4541](typescript-eslint/typescript-eslint#4541)) ([052cf51](typescript-eslint/typescript-eslint@052cf51))
-   **eslint-plugin:** add `no-redundant-type-constituents` rule ([#&#8203;4378](typescript-eslint/typescript-eslint#4378)) ([63d051e](typescript-eslint/typescript-eslint@63d051e))
-   **eslint-plugin:** add `no-useless-empty-export` rule ([#&#8203;4380](typescript-eslint/typescript-eslint#4380)) ([823b945](typescript-eslint/typescript-eslint@823b945))
-   **eslint-plugin:** add extension rule `space-before-blocks` ([#&#8203;1606](typescript-eslint/typescript-eslint#1606)) ([#&#8203;4184](typescript-eslint/typescript-eslint#4184)) ([208b6d0](typescript-eslint/typescript-eslint@208b6d0))
-   **eslint-plugin:** added member group support to member-ordering rule ([#&#8203;4538](typescript-eslint/typescript-eslint#4538)) ([6afcaea](typescript-eslint/typescript-eslint@6afcaea))

#### [5.12.1](typescript-eslint/typescript-eslint@v5.12.0...v5.12.1) (2022-02-21)

##### Bug Fixes

-   **eslint-plugin:** \[no-unnecessary-type-arguments] fix comparison of types ([#&#8203;4555](typescript-eslint/typescript-eslint#4555)) ([fc3936e](typescript-eslint/typescript-eslint@fc3936e))

</details>

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

### [`v5.13.0`](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/parser/CHANGELOG.md#&#8203;5130-httpsgithubcomtypescript-eslinttypescript-eslintcomparev5121v5130-2022-02-28)

[Compare Source](typescript-eslint/typescript-eslint@v5.12.1...v5.13.0)

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

#### [5.12.1](typescript-eslint/typescript-eslint@v5.12.0...v5.12.1) (2022-02-21)

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

</details>

---

### Configuration

📅 **Schedule**: At any time (no schedule defined).

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

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

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

---

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

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).

Co-authored-by: cabr2-bot <cabr2.help@gmail.com>
Co-authored-by: 6543 <6543@noreply.codeberg.org>
Reviewed-on: https://codeberg.org/Calciumdibromid/CaBr2/pulls/1192
Reviewed-by: 6543 <6543@noreply.codeberg.org>
Co-authored-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
Co-committed-by: Calciumdibromid Bot <cabr2_bot@noreply.codeberg.org>
@fregante
Copy link
Contributor

fregante commented May 22, 2022

💚

I just started using this (via XO) and it already found a few bugs around. For whatever reason, some types weren't resolving so any was being propagated throughout the code. TypeScript is gladly letting this happen, but this rule caught it.

Seen on this commit and further comment: refined-github/refined-github@f298b56 (#5654)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
1 approval PR that a maintainer has LGTM'd - any maintainer can merge this when ready enhancement: new plugin rule New rule request for eslint-plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rule proposal: Disallow unions with unknown or any
3 participants