Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat(eslint-plugin): [strict-boolean-expressions] check array predicate functions' return statements#10106

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

ronami
Copy link
Member

@ronamironami commentedOct 5, 2024
edited
Loading

PR Checklist

Overview

This PR addresses#8016 and updatesstrict-boolean-expressions to check for array predicate return statements.

Two things to note:

Doesn't handle implicit returns

I didn't handle implicit return types from array predicates since I'm not sure if the rule should cover this:

[1,null].filter(x=>{if(x){returntrue;}// implicitly returns `undefined`});

Please let me know if you think it should.

Somewhat of a breaking change

This is a breaking change, though the issue itself isn't marked as one, and according to the docs:

A change to the plugins shall not be considered breaking if it:

  • Adds additional checks to an existing rule that causes new reports in a small-to-medium set of cases in an average codebase.

Alternatively, I can put this behind a flag, which can be removed in a later version.

kripod reacted with rocket emoji
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@ronami!

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 onhttps://opencollective.com/typescript-eslint.

@netlifyNetlify
Copy link

netlifybot commentedOct 5, 2024
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitf17a05c
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/676d2a75a34d9400096b00f1
😎 Deploy Previewhttps://deploy-preview-10106--typescript-eslint.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 98 (🟢 up 25 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 98 (no change from production)
PWA: 80 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to yourNetlify site configuration.

@nx-cloudNx Cloud
Copy link

nx-cloudbot commentedOct 5, 2024
edited
Loading

View yourCI Pipeline Execution ↗ for commitf17a05c.

CommandStatusDurationResult
nx test eslint-plugin --coverage=false✅ Succeeded7m 13sView ↗
nx test eslint-plugin✅ Succeeded6m 1sView ↗
nx test visitor-keys --coverage=false✅ Succeeded<1sView ↗
nx test utils --coverage=false✅ Succeeded<1sView ↗
nx test typescript-eslint --coverage=false✅ Succeeded8sView ↗
nx test type-utils --coverage=false✅ Succeeded<1sView ↗
nx run types:build✅ Succeeded<1sView ↗
nx run-many --target=build --exclude website --...✅ Succeeded31sView ↗
Additional runs (24)✅ Succeeded...View ↗

☁️Nx Cloud last updated this comment at2024-12-26 10:20:31 UTC

@ronamironami changed the titleStrict boolean expressions predicatesfeat(eslint-plugin): [strict-boolean-expressions] Check array predicate return statementsOct 5, 2024
@ronamironami changed the titlefeat(eslint-plugin): [strict-boolean-expressions] Check array predicate return statementsfeat(eslint-plugin): [strict-boolean-expressions] Check array predicate functions' return statementsOct 5, 2024
@ronamironami changed the titlefeat(eslint-plugin): [strict-boolean-expressions] Check array predicate functions' return statementsfeat(eslint-plugin): [strict-boolean-expressions] check array predicate functions' return statementsOct 5, 2024
@codecovCodecov
Copy link

codecovbot commentedOct 5, 2024
edited
Loading

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.86%. Comparing base(5a39e0c) to head(f17a05c).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@##             main   #10106      +/-   ##==========================================+ Coverage   86.84%   86.86%   +0.02%==========================================  Files         445      445                Lines       15427    15455      +28       Branches     4497     4507      +10     ==========================================+ Hits        13397    13425      +28  Misses       1675     1675                Partials      355      355
FlagCoverage Δ
unittest86.86% <100.00%> (+0.02%)⬆️

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

Files with missing linesCoverage Δ
...int-plugin/src/rules/strict-boolean-expressions.ts100.00% <100.00%> (ø)

@ronamironami marked this pull request as ready for reviewOctober 5, 2024 06:54
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Nice! One discussion on implicit undefined return, and some requests around testing. Direction seems great to me! 🚀

ronami reacted with heart emoji
Comment on lines 168 to 171
x.filter(t => {
return t ? 1 : 0;
});
x.filter(t => !t);

Choose a reason for hiding this comment

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

[Testing] We generally try to stick to one thing under test for each test case. For this one, it looks like two things are being tested:

  • That theallowNullableBoolean option still works...
  • ...and that general logic holds true for all three variations of something passed to.filter

I don't think the latter is necessary. We can trim the tests down a bit:

Suggested change
x.filter(t=>{
returnt ?1 :0;
});
x.filter(t=>!t);

Here and the other ones with several variations of the same, such asallowNullableString: true.

ronami reacted with thumbs up emoji
@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelOct 10, 2024
@ronami
Copy link
MemberAuthor

btw - sorry for taking so long to get around to a review on this!

No problem, I appreciate your assistance with the PR, it's been very helpful 👍

Copy link
Member

@kirkwaiblingerkirkwaiblinger left a comment

Choose a reason for hiding this comment

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

home stretch!

ronami reacted with rocket emoji
Copy link
Member

@kirkwaiblingerkirkwaiblinger left a comment

Choose a reason for hiding this comment

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

I think we're there! Great work on this! I'm excited to get to use this feature ❤️

ronami reacted with heart emoji
@kirkwaiblingerkirkwaiblinger added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 26, 2024
@kirkwaiblingerkirkwaiblinger requested review fromJoshuaKGoldberg and removed request forJoshuaKGoldbergDecember 26, 2024 10:23
@github-actionsgithub-actionsbot removed the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 26, 2024
@kirkwaiblingerkirkwaiblinger added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelDec 26, 2024
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

So thorough, love it! 🚀

ronami reacted with rocket emoji
@JoshuaKGoldbergJoshuaKGoldberg merged commit07d0e0d intotypescript-eslint:mainDec 26, 2024
68 checks passed
@ronamironami deleted the strict-boolean-expressions-predicates branchDecember 26, 2024 23:09
renovatebot added a commit to mmkal/eslint-plugin-mmkal that referenced this pull requestDec 30, 2024
##### [v8.19.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8190-2024-12-30)##### 🚀 Features-   **eslint-plugin:** \[strict-boolean-expressions] check array predicate functions' return statements ([#10106](typescript-eslint/typescript-eslint#10106))##### 🩹 Fixes-   **eslint-plugin:** \[member-ordering] ignore method overloading ([#10536](typescript-eslint/typescript-eslint#10536))-   **eslint-plugin:** \[consistent-indexed-object-style] don't report on indirect circular references ([#10537](typescript-eslint/typescript-eslint#10537))-   **eslint-plugin:** \[array-type] autofix with conditional types needs parentheses ([#10522](typescript-eslint/typescript-eslint#10522))-   **eslint-plugin:** add getConstraintInfo to handle generic constraints better ([#10496](typescript-eslint/typescript-eslint#10496))##### ❤️ Thank You-   Karl Werner-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)-   Ronen Amiel-   YeonJuan [@yeonjuan](https://github.com/yeonjuan)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
renovatebot added a commit to andrei-picus-tink/auto-renovate that referenced this pull requestDec 31, 2024
| datasource | package                          | from   | to     || ---------- | -------------------------------- | ------ | ------ || npm        | @typescript-eslint/eslint-plugin | 8.18.2 | 8.19.0 || npm        | @typescript-eslint/parser        | 8.18.2 | 8.19.0 |## [v8.19.0](https://github.com/typescript-eslint/typescript-eslint/blob/HEAD/packages/eslint-plugin/CHANGELOG.md#8190-2024-12-30)##### 🚀 Features-   **eslint-plugin:** \[strict-boolean-expressions] check array predicate functions' return statements ([#10106](typescript-eslint/typescript-eslint#10106))##### 🩹 Fixes-   **eslint-plugin:** \[member-ordering] ignore method overloading ([#10536](typescript-eslint/typescript-eslint#10536))-   **eslint-plugin:** \[consistent-indexed-object-style] don't report on indirect circular references ([#10537](typescript-eslint/typescript-eslint#10537))-   **eslint-plugin:** \[array-type] autofix with conditional types needs parentheses ([#10522](typescript-eslint/typescript-eslint#10522))-   **eslint-plugin:** add getConstraintInfo to handle generic constraints better ([#10496](typescript-eslint/typescript-eslint#10496))##### ❤️ Thank You-   Karl Werner-   Kirk Waiblinger [@kirkwaiblinger](https://github.com/kirkwaiblinger)-   Ronen Amiel-   YeonJuan [@yeonjuan](https://github.com/yeonjuan)You can read about our [versioning strategy](https://main--typescript-eslint.netlify.app/users/versioning) and [releases](https://main--typescript-eslint.netlify.app/users/releases) on our website.
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsJan 3, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

@kirkwaiblingerkirkwaiblingerkirkwaiblinger approved these changes

Assignees
No one assigned
Labels
1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

Enhancement: [strict-boolean-expressions] Check array filter/find predicate functions as boolean locations.
3 participants
@ronami@JoshuaKGoldberg@kirkwaiblinger

[8]ページ先頭

©2009-2025 Movatter.jp