Skip to content

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

@bartekleon

Description

@bartekleon

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" }
]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions