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

fix(eslint-plugin): [no-unnecessary-boolean-literal-compare] fixer should handle parentheses#6569

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

@armano2
Copy link
Collaborator

@armano2armano2 commentedMar 4, 2023
edited
Loading

PR Checklist

Overview

Add missing handling for removal and adding parenthesis in rule fixer

new cases covered:

if((xinstanceofError)===false){}if(false===(xinstanceofError)){}if(xinstanceofError===false){}

old fixer result

if(!(xinstanceofError){}if(!xinstanceofError)){}if(!xinstanceofError){}

new fixer result

if(!(xinstanceofError)){}if(!(xinstanceofError)){}if(!(xinstanceofError)){}

initially i was planning to extend range of fixer to include)( but after further investigation this started generating to many edge cases

eg.(false) === x instanceof Error

@nx-cloud
Copy link

nx-cloudbot commentedMar 4, 2023
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit79de5c2. 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 46 targets

Sent with 💌 fromNxCloud.

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@armano2!

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.

@netlify
Copy link

netlifybot commentedMar 4, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commit79de5c2
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/6403a01a1f961b0008db9ab8
😎 Deploy Previewhttps://deploy-preview-6569--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 yourNetlify site settings.

@armano2armano2 marked this pull request as draftMarch 4, 2023 19:04
@codecov
Copy link

codecovbot commentedMar 4, 2023
edited
Loading

Codecov Report

Merging#6569 (79de5c2) intomain (9427b7c) willincrease coverage by0.04%.
The diff coverage is100.00%.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #6569      +/-   ##==========================================+ Coverage   90.66%   90.71%   +0.04%==========================================  Files         376      376                Lines       12851    12855       +4       Branches     3783     3783              ==========================================+ Hits        11651    11661      +10+ Misses        856      850       -6  Partials      344      344
FlagCoverage Δ
unittest90.71% <100.00%> (+0.04%)⬆️

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

Impacted FilesCoverage Δ
...rc/rules/no-unnecessary-boolean-literal-compare.ts97.67% <100.00%> (+7.31%)⬆️
...ackages/eslint-plugin/src/util/getWrappingFixer.ts100.00% <100.00%> (ø)

@armano2armano2 marked this pull request as ready for reviewMarch 4, 2023 19:49
);

// if the expression `exp` isn't nullable, or we're comparing to `true`,
// we can just replace the entire comparison with `exp` or `!exp`
Copy link
CollaboratorAuthor

@armano2armano2Mar 5, 2023
edited
Loading

Choose a reason for hiding this comment

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

after further investigation we could simplify this fixer to

          fix:function*(fixer){constisUnaryNegation=node.parent!=null&&nodeIsUnaryNegation(node.parent);constmutatedNode=isUnaryNegation ?node.parent! :node;yieldfixer.replaceText(mutatedNode,sourceCode.getText(comparison.expression),);constshouldNegate=comparison.literalBooleanInComparison              ?!comparison.negated              :comparison.negated;if(isUnaryNegation===shouldNegate){yieldfixer.insertTextBefore(mutatedNode,'!');if(!util.isStrongPrecedenceNode(comparison.expression)){yieldfixer.insertTextBefore(mutatedNode,'(');yieldfixer.insertTextAfter(mutatedNode,')');}}// if the expression `exp` is nullable, and we're not comparing to `true`,// we can just replace the entire comparison with `exp` or `!exp`if(comparison.expressionIsNullableBoolean&&!comparison.literalBooleanInComparison){// provide the default `true`yieldfixer.insertTextBefore(mutatedNode,'(');yieldfixer.insertTextAfter(mutatedNode,' ?? true)');}}

that should allow us to provide better fixer for

// sourceif(!(varBoolean===false)){}// currentif(!(!varBoolean)){}// newif(varBoolean){}

i'm not sure if we should push this with this fix

Choose a reason for hiding this comment

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

I like it 😄 +1 to including it here. Also a +1 to filing a followup if you want to get this in sooner.

bradzacher reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I'm going to land this as-is for now, just so we can get this fix out with the next release.
We can follow-up next week with the changes to simplify this fixer later

JoshuaKGoldberg and armano2 reacted with thumbs up emoji
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.

💯

);

// if the expression `exp` isn't nullable, or we're comparing to `true`,
// we can just replace the entire comparison with `exp` or `!exp`

Choose a reason for hiding this comment

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

I like it 😄 +1 to including it here. Also a +1 to filing a followup if you want to get this in sooner.

bradzacher reacted with thumbs up emoji
@JoshuaKGoldbergJoshuaKGoldberg added the 1 approval>=1 team member has approved this PR; we're now leaving it open for more reviews before we merge labelMar 8, 2023
@bradzacherbradzacher added awaiting responseIssues waiting for a reply from the OP or another party and removed awaiting responseIssues waiting for a reply from the OP or another party labelsMar 13, 2023
@bradzacherbradzacher added this pull request to the merge queueMar 13, 2023
@bradzacherbradzacher added the bugSomething isn't working labelMar 13, 2023
@github-merge-queuegithub-merge-queuebot removed this pull request from the merge queue due to no response for status checksMar 13, 2023
@JoshuaKGoldbergJoshuaKGoldberg merged commit2d8c196 intomainMar 13, 2023
@JoshuaKGoldbergJoshuaKGoldberg deleted the fix/no-unnecessary-boolean-literal-compare-braces branchMarch 13, 2023 04:25
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsMar 21, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@bradzacherbradzacherbradzacher left review comments

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg 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 mergebugSomething isn't working

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Bug: [no-unnecessary-boolean-literal-compare] Quick Fix generates bug withinstanceof

4 participants

@armano2@JoshuaKGoldberg@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp