Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

naming-conventions: question - recognize if variable is primitive #125

Open
bartekleon opened this issue Jul 17, 2019 · 1 comment
Open

Comments

@bartekleon
Copy link

bartekleon commented Jul 17, 2019

I would like to have different styles for exported primitives and objects. It is possible to be done?

It should look like:

export const PRIMITIVE_VARIABLE = 12;
export const objectVariable = {
   someProps: 12
   .
   .
   .
}
export const functionVariable = () => {}

I would be grateful for any idea about it

my current config looks like:

"naming-convention": [
  true,
  { "type": "default", "format": "camelCase", "leadingUnderscore": "forbid", "trailingUnderscore": "forbid" },
  { "type": "variable", "modifiers": ["global", "const"], "format": ["camelCase"] },
  { "type": "variable", "modifiers": ["export", "const"], "format": "UPPER_CASE" },
  { "type": "functionVariable", "modifiers": ["export", "const"], "format": "camelCase" },
  { "type": "parameter", "modifiers": "unused", "leadingUnderscore": "allow" },
  { "type": "member", "modifiers": "private", "leadingUnderscore": "forbid" },
  { "type": "member", "modifiers": "protected", "leadingUnderscore": "forbid" },
  { "type": "method", "filter": "^toJSON$", "format": null },
  { "type": "property", "modifiers": ["public", "static", "const"], "format": "camelCase" },
  { "type": "type", "format": "PascalCase" },
  { "type": "class", "modifiers": "abstract", "prefix": "" },
  { "type": "interface", "prefix": "" },
  { "type": "genericTypeParameter", "prefix": "" },
  { "type": "enumMember", "format": "PascalCase" }
]
@ajafff
Copy link
Owner

ajafff commented Jul 17, 2019

This is not possible to achieve at the moment. The rule doesn't use type information and is therefore not able to tell whether a variable has a primitive type.
There are several other issues that need a similar change: #1, #2, #49

I definitely think that type information would be a great addition to this rule. However, I currently have other priorities and not enough spare time to invest into this project. I'm happy to review a PR with the necessary changes if someone wants to give it a shot.

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

No branches or pull requests

2 participants