remithomas / eslint-plugin-ban

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

Ban decorator functions #17

Open chriswhite199 opened 3 years ago

chriswhite199 commented 3 years ago

Would it be possible to add banning for decorators? (or maybe i'm missing it, but using either decorator name or @name in a rule doesn't seem to currently catch instances where that decorator is used).

Example use case:

I want to ban the use of @Expose from the class-transformer library:

export class MyClass {
  @Expose({ name:'my_str_field' })
  myStrField: string
}

I have tried both of the following rule configs (not that the second one should work as the function is not named with a @ prefix, that's just syntax sugar), but neither seem to work:

        "ban/ban": [
          "error",
          {
           "name": [ "Expose" ],
            "message": "Class-transformer camelCase <-> snake_case is handled by KeyCaseInterceptor"
          },
          {
           "name": [ "@Expose" ],
            "message": "Class-transformer camelCase <-> snake_case is handled by KeyCaseInterceptor"
          }
        ]
DanBoSlice commented 3 years ago

Any updates?

remithomas commented 3 years ago

Hello, @chriswhite199 this is a good idea. Will try to come back with a PR soon. thanks

remithomas commented 2 years ago

Sorry for the long delay, actually we need to move the codebase to typescript in order to address this feature before.