Closed seanblonien closed 2 years ago
Finally figured out you can just use the built-in eslint no-restricted-syntax
command to ban any arbitrary javascript structure whatsoever, and that is how I'll be banning the switch statement
'no-restricted-syntax': [
'error',
{
selector: 'SwitchStatement',
message: 'Switch statements are banned. Use object literal mapping instead.',
},
]
I was wondering if it would be possible to allow banning of built-in code structures, for example, the
switch
statement.In my experience, most switch statements could be converted to an object mappings (where properties are either values of functions that produce values/perform some action), and I prefer this style over switch statements.
Can this plugin support a config like this?
Other examples I think of are
for-loops
with a comment about saying you can use forEach/filter/map/reduce instead.If this is out-of-scope of this project, totally fine, was just curious