This repository has been archived by the owner on Mar 25, 2021. It is now read-only.
Better ban rule failure messages & allows for additional custom messages #1385
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR does 2 things.
1️⃣ Better Wording
The wording of the failure message for the
ban
rule (and theno-console
rule since it is based on theban
rule) has been updated.👎 Before
(The word "invocation" always reminded me of a wizard casting a spell... 🔮 )
👍 After
2️⃣ Optional Explanation Messages
Most TSLint rules are basically either turned on or off and they offer explanation text or it's generally understood why the rule is enabled in a project. One thing that's always bothered my and my teammates is when a function is banned it basically just says "this is banned" and it doesn't tell you why. Since I'm the one who turned on the linting rules I eventually get someone asking me "why can't I use
_.filter
? I can use in in this other project just fine..."Well, now an optional 3rd parameter for each banned function call can be added. This text could offer an explanation as to why it's banned and/or offer an alternative that could be used instead of the banned call. Here's an example of how it would be configured
And here's what the failure message would look like with the additional text appended 👏