-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Rule suggestion: generalize @typescript-eslint/no-angle-bracket-type-assertion
#332
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
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
Comments
How about |
Also fine! The |
The reason I would lean against doing this is because the angle bracket assertions are kind of deprecated, and |
I personally am mostly interested in the |
I would really love to use |
@uhyo, helping your code be more safe can be accomplished via a combination of these 5 rules:
Type assertions are sometimes necessary to help typescript get it right, so banning them all together would (imo) be a terrible idea, as it would cause developers to lose faith in the linting tools. |
@bradzacher Thanks for reply. I understand your argument. IMO, however, a project which gives much weight to safety should use |
I'm not against it being built in (if someone wants to do it), but I would fight hard against it being introduced as a lint rule if I were an engineer on the codebase :) |
I would like to have a more general version of
@typescript-eslint/no-angle-bracket-type-assertion
, maybe calledtype-assertion
. It would have two options, that can be enabled independently:no-angle-bracket
: If this is enabled, angle bracket type assertions are disallowed.no-as
: If this is enabled,as
type assertions are disallowed.This would allow different use cases. Some people like to use the old assertions instead of the new ones. Personally, I would like to lint all type casting since they introduce unsafety.
The default behaviour would be
['no-angle-bracket']
to match the current situation. If no options are enabled, the lint could warn that the lint can be disabled.The text was updated successfully, but these errors were encountered: