Skip to content

naming-convention: banned names and require minimum length #112

Description

@AndreasGassmann

I would like to disallow short variable names and certain keywords.

This should already be possible with a regex, but maybe that could still be added as an option?

Examples where this is useful:

// Short variable names
try {} catch (e) {}
[1, 2].map(n => n*2)
[1, 2].forEach(v => v)
window.addEventListener('error', (ev) => {})

// Banned words (specific names, such as `err`, `num` and `val`
try {} catch (err) {}
[1, 2].map(num => num*2)
[1, 2].forEach(val => val)

Maybe there should be a way to define exceptions, for example i:

for(let i = 0; i < 1; i++) {}

I also noticed that the rule doesn't seem to trigger for the variable used in the catch: try {} catch (e) {}. Is that intended behavior or a bug?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions