Tslint: Allow exceptions to the "deprecation" rule

Created on 6 Dec 2018  ยท  6Comments  ยท  Source: palantir/tslint

Feature request

Is your feature request that we implement a new rule?
No

Is your feature request related to a problem? Please describe.
There are some deprecated web features which enjoy broad browser support, will continue to be supported for the foreseeable future, and have alternatives that cannot be quickly put into practice or are not workable. For example, event.which and event.keyCode are deprecated but certain libraries can only work with them, and event.code and event.key are either not broadly supported or not always direct replacements.

Describe the solution you'd like
I would like to designate certain values as exceptions, perhaps as a list of regular expressions, to avoid triggering the deprecation rule throughout my project.

Describe alternatives you've considered

  • Disabling the rule
  • Sprinkling // tslint:disable-next-line:deprecation throughout the code

Additional context
There are other properties I would like to turn this on for, such as performance.timing, and occasionally certain private APIs written by other teams at my org.

Rule Enhancement ๐ŸŒน R.I.P. ๐ŸŒน

Most helpful comment

Till that's implemented in TSLint directly, you could use TSLint-Filter to suppress specific warnings:
https://www.npmjs.com/package/tslint-filter

Simply install the package, add

"extends": ["tslint-filter"]

to your tslint.json, and then you can use

"___deprecation": [true, [
  "^KeyboardEvent\\.which"
]],

to filter the warnings.

All 6 comments

Another point: This would be useful in cases where a team is working on updating old legacy codebases. It would be useful to mark all old functions/classes/etc as deprecated to prevent them from being inadvertently used in new code, while ignoring cases where they are being used within the legacy code.

Any news on this?

@SDohle nothing yet - any progress will always be posted or linked to here. Waiting on someone to put forward a working proposal on how this could be added to the rule's options.

Till that's implemented in TSLint directly, you could use TSLint-Filter to suppress specific warnings:
https://www.npmjs.com/package/tslint-filter

Simply install the package, add

"extends": ["tslint-filter"]

to your tslint.json, and then you can use

"___deprecation": [true, [
  "^KeyboardEvent\\.which"
]],

to filter the warnings.

โ˜ ๏ธ TSLint's time has come! โ˜ ๏ธ

TSLint is no longer accepting most feature requests per #4534. See typescript-eslint.io for the new, shiny way to lint your TypeScript code with ESLint. โœจ

It was a pleasure open sourcing with you all!

๐Ÿค– Beep boop! ๐Ÿ‘‰ TSLint is deprecated ๐Ÿ‘ˆ _(#4534)_ and you should switch to typescript-eslint! ๐Ÿค–

๐Ÿ”’ This issue is being locked to prevent further unnecessary discussions. Thank you! ๐Ÿ‘‹

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mateiacd picture mateiacd  ยท  3Comments

jacob-robertson picture jacob-robertson  ยท  3Comments

denkomanceski picture denkomanceski  ยท  3Comments

allbto picture allbto  ยท  3Comments

zewa666 picture zewa666  ยท  3Comments