Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

[ban] Optional explanation for banned globals #1940

Closed
vsiao opened this issue Dec 27, 2016 · 1 comment · Fixed by #2547
Closed

[ban] Optional explanation for banned globals #1940

vsiao opened this issue Dec 27, 2016 · 1 comment · Fixed by #2547

Comments

@vsiao
Copy link

vsiao commented Dec 27, 2016

#1385 added the ability to give an optional explanation for banned functions. eg. instead of just:

["_", "filter"]
// Calls to '_.filter' are not allowed.

you could provide an additional string to propose an alternative:

["_", "filter", "Use the native JavaScript 'myArray.filter' instead."]
// Calls to '_.filter' are not allowed. Use the native JavaScript 'myArray.filter' instead.

#1408 added global bans, but left out the ability to provide an optional explanation. Obviously there's the problem of input syntax (if it's an array with 2 strings "a" and "b", is that banning a.b or banning a with message b?), but I'd like to open a discussion for that.

@IllusionMH
Copy link
Contributor

@vsiao as I can see in docs examples and code - explanation isn't available for global bans.

Probably it is possible to check for characters that are not valid identifiers (spaces, special characters etc. since ElementAccessExpression aren't checked), or replace arrays with descriptive object

{
    "path": ["object", "property"],
    "explanation": "Use native"
}

P.S. Is there any reason (except linted code became less readable) why ElementAccessExpression aren't checked in ban rule?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants