-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed as not planned
Labels
enhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginwontfixThis will not be worked onThis will not be worked on
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- My proposal specifically checks TypeScript syntax, or it proposes a check that requires type information to be accurate.
- My proposal is not a "formatting rule"; meaning it does not just enforce how code is formatted (whitespace, brace placement, etc).
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Description
#9007 was closed before I could comment there. I wasn't aware that querySelector
took a generic argument. It'd be nice if there was a lint rule that caught
document.querySelector('something') as HTMLElement
and recommended changing it to
document.querySelector<HTMLElement>('something')
And maybe this could be done in a more generic way, possibly catching all functions that accept a generic but are being cast instead?
Fail Cases
document.querySelector('div') as HTMLDivElement
Pass Cases
document.querySelector<HTMLDivElement>('div')
Additional Info
It would help with these duplicates if this was enabled in the recommended ruleset
Metadata
Metadata
Assignees
Labels
enhancement: new plugin ruleNew rule request for eslint-pluginNew rule request for eslint-pluginlocked due to agePlease open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.package: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginwontfixThis will not be worked onThis will not be worked on