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): [no-base-to-string] add checkArrayJoin option #10287

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

yeonjuan
Copy link
Contributor

@yeonjuan yeonjuan commented Nov 5, 2024

PR Checklist

Overview

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @yeonjuan!

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 Nov 5, 2024

Deploy Preview for typescript-eslint ready!

Name Link
🔨 Latest commit c79b0cc
🔍 Latest deploy log https://app.netlify.com/sites/typescript-eslint/deploys/67336f2543f33d0008444e39
😎 Deploy Preview https://deploy-preview-10287--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 (🔴 down 1 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 your Netlify site configuration.

Copy link

nx-cloud bot commented Nov 5, 2024

Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.61%. Comparing base (c13b6b4) to head (c79b0cc).
Report is 14 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10287      +/-   ##
==========================================
+ Coverage   86.56%   86.61%   +0.04%     
==========================================
  Files         431      432       +1     
  Lines       15188    15176      -12     
  Branches     4418     4428      +10     
==========================================
- Hits        13148    13144       -4     
+ Misses       1683     1675       -8     
  Partials      357      357              
Flag Coverage Δ
unittest 86.61% <100.00%> (+0.04%) ⬆️

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

Files with missing lines Coverage Δ
...kages/eslint-plugin/src/rules/no-base-to-string.ts 96.38% <100.00%> (+0.67%) ⬆️

... and 28 files with indirect coverage changes

@yeonjuan yeonjuan marked this pull request as ready for review November 6, 2024 17:12
@Josh-Cena
Copy link
Member

IMO: this doesn't have to be an option. I can't think of a case where someone checks all other cases but wants to allow join on purpose.

@@ -30,6 +32,8 @@ export default createRule<Options, MessageIds>({
requiresTypeChecking: true,
},
messages: {
baseArrayJoin:
"Using `join()` for {{name}} use Object's default stringification format ('[object Object]') when stringified.",
Copy link
Member

Choose a reason for hiding this comment

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

should this message have the certainty too?

Suggested change
"Using `join()` for {{name}} use Object's default stringification format ('[object Object]') when stringified.",
"Using `join()` for {{name}} {{certainty}} use Object's default stringification format ('[object Object]') when stringified.",

Otherwise "Using join() for {} use..." is ungrammatical and should be fixed?

Suggested change
"Using `join()` for {{name}} use Object's default stringification format ('[object Object]') when stringified.",
"Using `join()` for {{name}} uses Object's default stringification format ('[object Object]') when stringified.",

Copy link
Member

Choose a reason for hiding this comment

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

(test) could you add maybe one or two tests around arrays that aren't literals (eg passed in as parameters) as well as as generic parameters?

node: TSESTree.Expression,
): void {
const memberExpr = node.parent as TSESTree.MemberExpression;
const type = services.getTypeAtLocation(memberExpr.object);
Copy link
Member

Choose a reason for hiding this comment

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

wondering if we need getConstrainedTypeAtLocation here in order to handle generics nicely?

@yeonjuan
Copy link
Contributor Author

@Josh-Cena @kirkwaiblinger Thank you for your review. I've fixed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[no-base-to-string] add option to prevent usage of Array .join on non-toString things
3 participants