Skip to content

Increase flexibility of --noUnusedParameters #12149

Closed
@JoshuaKGoldberg

Description

@JoshuaKGoldberg

As per #9458 (comment): relying on _ prefixes as a naming convention can be suboptimal for a few reasons:

  • Libraries such as jQuery and Knockout often provide function interfaces whose first parameter(s) aren't necessary for all usages
  • We're binding compiler logic to the variable name
  • It's easy to forget to remove the prefix, such as during refactoring
  • Prefixed names clash with some existing coding styles

I jumped the gun a bit and sent PR #12139 :) that blindly allows unused parameters before used ones. Perhaps a more complete design would be to provide configurations for --noUnusedParameters?

  • No unused parameters in any situation: tsc --noUnusedParameters
  • "---" excluding _ prefixes: tsc --noUnusedParameters allow-prefixed
  • "---" excluding those before used ones: tsc --noUnusedParameters allow-before-used
  • "---" excluding both _ prefixes and those before used ones: tsc --noUnusedParameters allow-prefixed --noUnusedParameters allow-before-used

Metadata

Metadata

Assignees

No one assigned

    Labels

    SuggestionAn idea for TypeScriptToo ComplexAn issue which adding support for may be too complex for the value it adds

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions