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): [consistent-type-assertions] addarrayLiteralTypeAssertions option#6749

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

danvk
Copy link
Collaborator

@danvkdanvk commentedMar 23, 2023
edited by Josh-Cena
Loading

PR Checklist

Overview

This PR adds anarrayLiteralTypeAssertions option to theconsistent-type-assertions rule as described in the linked issue. This uses the same auto-fixer as theobjectLiteralTypeAssertions option.

I didn't include an equivalent of the"allow-as-parameter" option but I can do so if there's a need.

If I may step on my soapbox for a moment:

  1. TheobjectLiteralTypeAssertions option (and this new one) are an awkward fit for theconsistent-type-assertions, which you would expect to just enforce consistency betweenx as T and<T>x. Both options would make more sense in a distinct rule that bans type assertions (rather than enforcing a consistent style).
  2. I'm not sure why you'd ever want to enableobjectLiteralTypeAssertions but notarrayLiteralTypeAssertions, or vice versa. It also feels odd that we're singling out these two types but allowing constructs with other types such asconst x = 'foo' as string;

@typescript-eslint
Copy link
Contributor

Thanks for the PR,@danvk!

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 23, 2023
edited
Loading

Deploy Preview fortypescript-eslint ready!

NameLink
🔨 Latest commitfd20281
🔍 Latest deploy loghttps://app.netlify.com/sites/typescript-eslint/deploys/641ccf88ba6eac0008050326
😎 Deploy Previewhttps://deploy-preview-6749--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.

@danvkdanvk changed the titlefeat(consistent-type-assertions): Add arrayLiteralTypeAssertions option to consistent-type-assertions rulefeat(eslint-plugin): AddarrayLiteralTypeAssertions option toconsistent-type-assertions ruleMar 23, 2023
@danvkdanvk changed the titlefeat(eslint-plugin): AddarrayLiteralTypeAssertions option toconsistent-type-assertions rulefeat(eslint-plugin): [consistent-type-assertions] addarrayLiteralTypeAssertions optionMar 23, 2023
@nx-cloud
Copy link

nx-cloudbot commentedMar 23, 2023
edited
Loading

☁️ Nx Cloud Report

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

Sent with 💌 fromNxCloud.

@codecov
Copy link

codecovbot commentedMar 23, 2023

Codecov Report

Merging#6749 (fd20281) intomain (c166cc9) willincrease coverage by0.01%.
The diff coverage is95.23%.

Additional details and impacted files
@@            Coverage Diff             @@##             main    #6749      +/-   ##==========================================+ Coverage   87.24%   87.25%   +0.01%==========================================  Files         383      383                Lines       13080    13091      +11       Branches     3845     3849       +4     ==========================================+ Hits        11411    11422      +11  Misses       1302     1302                Partials      367      367
FlagCoverage Δ
unittest87.25% <95.23%> (+0.01%)⬆️

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

Impacted FilesCoverage Δ
...int-plugin/src/rules/consistent-type-assertions.ts93.84% <95.23%> (+1.25%)⬆️

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.

Sorry this took so long to get to@danvk - the implementation looks very clean and the tests are thorough. Thanks for sending it in!

Just requesting changes on the missing"allow-as-parameter" equivalent.

type OptUnion =
| {
assertionStyle: 'as' | 'angle-bracket';
objectLiteralTypeAssertions?: 'allow' | 'allow-as-parameter' | 'never';
arrayLiteralTypeAssertions?: 'allow' | 'never';

Choose a reason for hiding this comment

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

I didn't include an equivalent of the"allow-as-parameter" option but I can do so if there's a need.

Yeah it feels weird to have one without the other... Could you please?

@JoshuaKGoldberg
Copy link
Member

If I may step on my soapbox for a moment

You most certainly may 😄 I agree with your points. It does seem odd to be so specific, especially since it means the exception doesn't cover'foo' as string & co. Could I ask you to file a new issue with your proposed changes? It might end up being a breaking change, so we might have to wait until v7 to get it in.

@JoshuaKGoldbergJoshuaKGoldberg added the awaiting responseIssues waiting for a reply from the OP or another party labelApr 8, 2023
@bradzacherbradzacher added the enhancement: plugin rule optionNew rule option for an existing eslint-plugin rule labelApr 10, 2023
@JoshuaKGoldbergJoshuaKGoldberg added the stalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period labelJul 16, 2023
@JoshuaKGoldberg
Copy link
Member

👋 Hey@danvk! Just checking in, is this still something you have time for? No worries if not - I just don't want to leave it hanging.

@JoshuaKGoldberg
Copy link
Member

Closing this PR as it's been stale for a few months without activity. Feel free to reopen@danvk if you have time - but no worries if not! If anybody wants to drive it forward, please do post your own PR - and if you use this as a start, consider addingCo-authored-by: @danvk at the end of your PR description. Thanks! 😊

@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsOct 25, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg requested changes

Assignees
No one assigned
Labels
awaiting responseIssues waiting for a reply from the OP or another partyenhancement: plugin rule optionNew rule option for an existing eslint-plugin rulestalePRs or Issues that are at risk of being or have been closed due to inactivity for a prolonged period
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@danvk@JoshuaKGoldberg@bradzacher

[8]ページ先頭

©2009-2025 Movatter.jp