Skip to content

WIP: feat(eslint-plugin): [consistent-type-assertion] add allowAsReturn option #1628

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

Closed

Conversation

mbrowne
Copy link
Contributor

@mbrowne mbrowne commented Feb 21, 2020

This PR adds an option to consistent-type-assertion to allow type assertions as part of a return statement (but otherwise preferring const x: T format).

I'm not sure of the best way to add this new option while preserving backward compatibility. Once one of the maintainers points me in the right direction, I can adjust and complete this PR.

For more details, see this issue:
#1629

(Resolves #1629)

@typescript-eslint
Copy link
Contributor

Thanks for the PR, @mbrowne!

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. As a thank you, your profile/company logo will be added to our main README which receives thousands of unique visitors per day.

Comment on lines +15 to +16
objectLiteralTypeAssertions?: 'allow' | 'allow-as-parameter' | 'never';
allowAsReturn?: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

this shouldn't be a separate boolean flag.
It would be better to accept an array of strings, i.e.:

type Options = 
  | {
    assertionStyle: 'as' | 'angle-bracket';
    objectLiteralTypeAssertions?:
      | 'allow'
      | 'allow-as-parameter'
      | 'allow-as-return'
      | 'never'
      | ('allow-as-parameter' | 'allow-as-return')[];
  }
  | {
    assertionStyle: 'never';
  }

@bradzacher
Copy link
Member

note for next time - if you've got a WIP PR, you should open it as a draft PR in github.

@bradzacher bradzacher added the enhancement: plugin rule option New rule option for an existing eslint-plugin rule label Feb 24, 2020
@mbrowne
Copy link
Contributor Author

mbrowne commented Feb 28, 2020

Closed in favor of #1651

@mbrowne mbrowne closed this Feb 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement: plugin rule option New rule option for an existing eslint-plugin rule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[consistent-type-assertions] Type assertions in return statements
2 participants