ptkdev / eslint-plugin-snakecasejs

:pencil2: ESLint Plugin: enforce snake_case syntax on variables and function names
https://npmjs.com/package/eslint-plugin-snakecasejs
Other
32 stars 4 forks source link

defaults and function variables #3

Closed Novaras closed 4 years ago

Novaras commented 4 years ago

Question

Two qs:

  1. have you guys considered providing some default filters somehow? It's pretty unlikely that anybody is using snake case for imports, class instantiations, functions etc. - no biggie at all here, but I was a little surprised at how extensive my filters had to get
  2. is there any solution for this:
    const myFunc = () => {}; // 'Identifiers must be snake_case: myFunc (VariableDeclarator)

    Our codebase uses camelCase for functions - this doesn't seem possible with your package as it (perhaps correctly) sees myFunc as a variable and does nothing smart regarding what it's assigned.

Thanks!

ptkdev commented 4 years ago

Hi! As default we ignore camelCase for classes and new expression.

In your example eslint detect this as VariableDeclarator. You can set filter similar as:

"snakecasejs/filter": ["ClassDeclaration", "NewExpression", "VariableDeclarator"]

On end of snakecasejs warning i added between the round brackets the expression/declaration detected by eslint and you can add this in fliters or whitelist parameter (see readme.md). Unfortunately, there aren't often specific declarations for many parts of the code: eslint provides generic values.

This aren't limit of snakecasejs plugin but is limit of eslint. Sorry.

PR Are welcome.