-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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): [consistent-type-assertions] add arrayLiteralTypeAssertions options #10565
base: main
Are you sure you want to change the base?
Conversation
…eAssertions options
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. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
View your CI Pipeline Execution ↗ for commit b64df60.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #10565 +/- ##
==========================================
+ Coverage 86.86% 86.92% +0.05%
==========================================
Files 445 446 +1
Lines 15455 15521 +66
Branches 4507 4524 +17
==========================================
+ Hits 13425 13491 +66
Misses 1675 1675
Partials 355 355
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lovely! The logic all makes sense and I like how the array and object checks are now mirrored. Great.
Requesting changes on some docs and testing please. 🚀
print?.(<Foo>[5]); | ||
print?.call(<Foo>[5]); | ||
print\`\${<Foo>[5]}\`; | ||
`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😬 I know this is existing code with its own pattern, but - we're trying to move away from auto-generated tests. They're much harder to statically analyze and tend to batch together a lot of redundant tests with multiple edge cases per test. Could you please keep to manually written tests for the new code?
Since all this change does functionally is add a new typed of checked assertion (arrays), I think adding a test per each of these lines should be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good,
I think adding a test per each of these lines should be fine.
Does this mean writing a test like the one below?
{
code: `
const x = [] as string[];
const x = ['a'] as string[];
const x = [] as Array<string>;
const x = ['a'] as Array<string>;
const x = [Math.random() ? 'a' : 'b'] as 'a'[];
`, options: [
{
assertionStyle: "as"
}
]
}
PR Checklist
Overview
This pr addresses #6374 and adds
arrayLiteralTypeAssertions
option to theconsistent-type-assertions
rule.It starts from #6749, which was previously closed, and adds
allow-as-parameter
to thearrayLiteralTypeAssertions
option. (#6749 (comment))Co-authored-by: @danvk