8000 chore: enable unicorn/no-lonely-if by abrahamguo · Pull Request #9830 · typescript-eslint/typescript-eslint · GitHub
[go: up one dir, main page]

Skip to content

chore: enable unicorn/no-lonely-if #9830

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

Merged
merged 2 commits into from
Aug 25, 2024

Conversation

abrahamguo
Copy link
Contributor
@abrahamguo abrahamguo commented Aug 20, 2024

PR Checklist

Overview

Since we already enable no-lonely-if in #9547 (which handles else { if (a) } => else if (a) {}, this is the next logic step to enable unicorn/no-lonely-if (docs), which handles if (a) { if (b) {} } => if (a && b) {}.

Tests failed due to CI flake.

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @abrahamguo!

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.

Copy link
netlify bot commented Aug 20, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit 20c1f7b
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/66c47fc4bd0f6900086fa428
😎 Deploy Preview https://deploy-preview-9830--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: 94 (🔴 down 5 from production)
Accessibility: 100 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (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 your Netlify site configuration.

Copy link
nx-cloud bot commented Aug 20, 2024

☁️ Nx Cloud Report

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

📂 See all runs for this CI Pipeline Execution


✅ Successfully ran 2 targets

Sent with 💌 from NxCloud.

@abrahamguo
Copy link
Contributor Author

Tests failed due to CI flake.

Copy link
codecov bot commented Aug 20, 2024

Codecov Report

Attention: Patch coverage is 98.41270% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.01%. Comparing base (94f7c99) to head (20c1f7b).
Report is 19 commits behind head on main.

Files Patch % Lines
...es/no-unnecessary-parameter-property-assignment.ts 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9830      +/-   ##
==========================================
- Coverage   88.01%   88.01%   -0.01%     
==========================================
  Files         406      406              
  Lines       13879    13873       -6     
  Branches     4055     4049       -6     
==========================================
- Hits        12216    12210       -6     
  Misses       1354     1354              
  Partials      309      309              
Flag Coverage Δ
unittest 88.01% <98.41%> (-0.01%) ⬇️

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

Files Coverage Δ
...eslint-plugin/src/rules/consistent-type-imports.ts 94.73% <100.00%> (-0.05%) ⬇️
...t-plugin/src/rules/no-confusing-void-expression.ts 100.00% <100.00%> (ø)
...ages/eslint-plugin/src/rules/no-empty-interface.t 8000 s 100.00% <100.00%> (ø)
...ckages/eslint-plugin/src/rules/no-magic-numbers.ts 84.72% <100.00%> (-0.21%) ⬇️
packages/eslint-plugin/src/rules/no-misused-new.ts 100.00% <100.00%> (ø)
...ges/eslint-plugin/src/rules/no-misused-promises.ts 97.51% <100.00%> (ø)
packages/eslint-plugin/src/rules/no-type-alias.ts 100.00% <100.00%> (ø)
...efer-optional-chain-utils/gatherLogicalOperands.ts 100.00% <100.00%> (ø)
...s/eslint-plugin/src/util/collectUnusedVariables.ts 93.72% <100.00%> (-0.03%) ⬇️
...ackages/eslint-plugin/src/util/getWrappingFixer.ts 93.42% <100.00%> (ø)
... and 2 more

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.

I'm surprised how many existing violations we had... +1 from me, great rule!

@JoshuaKGoldberg JoshuaKGoldberg added the 1 approval >=1 team member has approved this PR; we're now leaving it open for more reviews before we merge label Aug 22, 2024
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.

I'm surprised how many existing violations we had

I sometimes purposely nested ifs cos I think this:

              if (
                (ref.identifier.parent.type ===
                  AST_NODE_TYPES.ExportSpecifier ||
                  ref.identifier.parent.type ===
                    AST_NODE_TYPES.ExportDefaultDeclaration ||
                  ref.identifier.parent.type ===
                    AST_NODE_TYPES.TSExportAssignment) &&
                ref.isValueReference &&
                ref.isTypeReference
              ) {
                return node.importKind === 'type';
              }

is less clear than this:

              if (
                ref.identifier.parent.type === AST_NODE_TYPES.ExportSpecifier ||
                ref.identifier.parent.type ===
                  AST_NODE_TYPES.ExportDefaultDeclaration ||
                ref.identifier.parent.type === AST_NODE_TYPES.TSExportAssignment
              ) {
                if (ref.isValueReference && ref.isTypeReference) {
                  return node.importKind === 'type';
                }
              }

But I'm not going to block this on that personal preference.

Also when reviewing it's not usually worth the review round-trip to ask someone to de-nest them unless there are other changes. So they sneak in -- cos ultimately it's just a style thing so no need to go abck and manually fix things later.

@bradzacher bradzacher merged commit 7160687 into typescript-eslint:main Aug 25, 2024
60 of 61 checks passed
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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
Development

Successfully merging this pull request may close these issues.

3 participants
0