bryanrsmith / eslint-plugin-sort-class-members

An ESLint rule for enforcing consistent ES6 class member order
119 stars 21 forks source link

noDecorator option #89

Closed dospunk closed 1 year ago

dospunk commented 1 year ago

Adds an option to match class members that have no decorator. It can also be used to match members that have any decorator by setting noDecorator: false

dospunk commented 1 year ago

This would solve #86

bryanrsmith commented 1 year ago

Thanks for the pr! I am traveling at the moment, but will take a look when I'm back next week.

bryanrsmith commented 1 year ago

I think it would be better to roll this into the existing groupByDecorator config. You've already expanded support for that matcher in your other PR; I think we could also make it support a boolean, where true would match any decorator, and false would match no decorators.

As a tangent, the name "groupByDecorator" is also a bit inconsistent with the rest of the options. As long as we're improving it we could alias it as simply "decorator". So, { decorator: true }, or { decorator: 'bind' }.

What do you think?

dospunk commented 1 year ago

I think it would be better to roll this into the existing groupByDecorator config. You've already expanded support for that matcher in your other PR; I think we could also make it support a boolean, where true would match any decorator, and false would match no decorators.

As far as I can find, the JSON Schema format doesn't support multiple types so we couldn't have groupByDecorator take a boolean or a string. We could have it check for the strings "true" and "false" to get the same functionality since they aren't valid names for decorators.

bryanrsmith commented 1 year ago

I think oneOf should do the trick. Something like groupByDecorator: { oneOf: [{ type: 'string' }, { type: 'boolean' }] }