eslint-plugin-ban icon indicating copy to clipboard operation
eslint-plugin-ban copied to clipboard

Ban decorator functions

Open chriswhite199 opened this issue 3 years ago • 3 comments

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"
          }
        ]

chriswhite199 avatar Feb 24 '21 17:02 chriswhite199

Any updates?

DanBoSlice avatar May 08 '21 16:05 DanBoSlice

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

remithomas avatar May 10 '21 21:05 remithomas

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

remithomas avatar Jun 25 '22 23:06 remithomas