Skip to content

Naming conventions ​

You know what’s the most annoying thing in programming? Naming things. πŸ₯² So let’s get ourselves some standards and never think about it ever again.

File names ​

A great way to quickly find things in your IDE is being searching directly by file name. A simple way to improve your experience is to suffix your components with their function.

TypeExample
typesexample.type.ts
servicesexample.service.ts
storesexample.store.ts
routesexample.routes.ts
viewsExampleView.ts

File name casing ​

  • folders: kebab-case eg. my-example-folder
  • .ts files: camelCase eg. exampleCenter.ts
  • .vue files: PascalCase eg. MyComponent.vue

Object name casing ​

TypeCasingExample
servicesPascalCaseExampleService
storesuse + PascalCaseuseExampleStore
composablesuse + PascalCaseuseExampleComposable
typesPascalCaseExampleType
routesPascalCaseExampleRoutes
variable namescamelCaseexampleVariable
function namescamelCaseexampleFunction
constantsUPPERCASE_SNAKE_CASEMY_CONSTANT
components in templatePascalCase<MyComponent />
translation keysnake_casemy_key
route pathskebab-case/example-route
booleansis/has + camelCasingisVisible

Component names ​

Two words. ​

Always. and I do mean always. Give. Your. Components. Two. Word. Names.

❌ Bad examplesβœ… Good examples
Table.vueBaseTable.vue
Button.vueAppButton.vue
Input.vueFormInput.vue

The longer the better πŸ† ​

When creating components that are tightly coupled with a view or module. Always prefix your component with the name of the module.

❌ Bad examplesβœ… Good examples
InformationStep.vueClientUpdateInformationStep.vue
Calendar.vueContractCreateCalendar.vue
DetailInformation.vueEmployeeDetailInformation.vue