Skip to content

myosotisgit/coding-standards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 

Repository files navigation

Coding standards Myosotis

Coding standards and naming conventions used by Myosotis. These standards are based on the PHP, Laravel and Vue3 recommendations.

INDEX

Folders

Project (root) folders: lowercase

Laravel

app/
config/
resources/js/
storage/logs/

child folders : PascalCase or lowercase

Laravel

When a folder is referring to a component/model/class it uses PascalCase

app/Actions/
app/Console/
resources/js/components/Modals/

For other folders, not referring to model/class it uses lowercase

database/factories/
resources/js/components/

Files

File names: PascalCase / lowercase

Laravel

When a file is referring to a model/class it uses PascalCase

app/Actions/CreateNewUser.php
app/Console/Kernel.php

For other folders, not referring to model/classes it uses lowercase

config/broadcasting.php

Components

Components - PascalCase

Filenames of Single-File Components should either be always PascalCase or always kebab-case.

ALERT: Component names MUST BE multi-worded. This is to avoid possible confusion with html elements, which are always single-worded

Bad: <Modal />
Good: <ConfirmModal />

Base Componentns

Base components (a.k.a. presentational, dumb, or pure components) that apply app-specific styling and conventions should all begin with a specific prefix, such as Base, App, or V.

<BaseModal />

Tightly coupled component names​

Child components that are tightly coupled with their parent should include the parent component name as a prefix.

components/TodoList/
- TodoList.vue
- TodoListItem.vue
- TodoListItemButton.vue

Order of words in component names​

Component names should start with the highest-level (often most general) words and end with descriptive modifying words.

- BaseModal
- ModalConfirm
- ModalConfirmButtons

Self-closing components​

Components with no content should be self-closing in Single-File Components, string templates, and JSX - but never in in-DOM templates.

<ModalConfirm />
<!-- In in-DOM templates -->
<my-component></my-component>

Props

Use detailed prop definitions​

In committed code, prop definitions should always be as detailed as possible, specifying at least type(s).

const props = defineProps({
  status: String
})

Prop names

Prop names should always use camelCase during declaration. When used inside in-DOM templates, props should be kebab-cased. Single-File Components templates and JSX can use either kebab-case or camelCase props.

const props = defineProps({
  greetingText: String
})

// for SFC - use consistent casing
<WelcomeMessage greeting-text="hi"/>
// or
<WelcomeMessage greetingText="hi"/>

Multi-attribute elements​

Elements with multiple attributes should span multiple lines, with one attribute per line.

Use prettier in VS Code

<MyComponent
  foo="a"
  bar="b"
  baz="c"
/>

Variables

Javascript

JS: camelCase
.env : SCREAMING_SNAKE_CASE

Boostrap / CSS id, classes: kebab-case

class="custom-control-label my-auto"

About

Coding standards Myosotis

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published