remithomas / eslint-plugin-ban

Ban some methods and functions
ISC License
31 stars 3 forks source link

Extend wildcard functionality #28

Open oriooctopus opened 2 years ago

oriooctopus commented 2 years ago

Right now we would support the wildcard operator in the following situation:

"rules": {
    "ban/ban": [
        "error",
    {
        name: ["api", "*"],
        message: "Some message",
    },
     ]
}

The following is another situation which is not supported but I think we should support:

"rules": {
    "ban/ban": [
        "error",
    {
        name: ["api", "getAllBy*"],
        message: "Some message",
    },
     ]
}

Basically, the first situation shows the wildcard being used to match everything, the second shows it in combination with a precursor. Additionally, something like *text should be supported where the wildcard is first.

I would be happy to put up a diff supporting this if you tell me that you would be okay with it

remithomas commented 2 years ago

Hello @oriooctopus, this could be a good feature. It should be easy to implement, feel free to push a MR.

Thanks for the idea !!

DerZyklop commented 1 year ago

Our case is probably related…

We want to ban this this.routerService.navigate() as well as routerService.navigate()

["pRouterService", "navigate"] does not catch this.routerService.navigate() ["*", "pRouterService", "navigate"] does not catch anything ["this.routerService", "navigate"] does not catch anything

["*", "navigate"] is our workaround but would also catch somethingElse.navigate()