Guest User

Untitled

a guest
May 27th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.93 KB | None | 0 0
  1. # Application structure
  2.  
  3. ## General
  4.  
  5. 1. Application has tree structure with folders for each "feature"
  6. 2. Feature folders are named with lowerCamelCase → myComponentDashboard
  7. 3. Feature can contain any number of components and nested features
  8. 4. Components are named using UpperCamelCase → MyWidgetComponent.vue
  9. 5. Component can have translation .yml file named correspondingly → MyWidgetComponent.yml
  10. 6. If component requires more than 2 files: .vue and .yml file - folder is created with the same name → MyWidgetComponent
  11. 7. Shared components/classes/etc can be placed under common folder
  12. 8. Shared common folder is located near the topmost component that uses this commons
  13.  
  14. ## Assets
  15.  
  16. 1. If there is only one asset used in component it is stored as is near the component file
  17. 2. If there are more than one asset - asset folder is created for them
  18. 3. If more than one component uses the same asset - asset folder is created even if there's only one asset
  19. 4. Shared asset folder is located near the topmost component that uses this asset
  20.  
  21. # Code style
  22.  
  23. ## Naming conventions
  24. 1. TypeScript classes are named using UpperCamelCase → MyTypeScriptClass
  25. 2. TypeScript class files are named the same as the class → MyTypeScriptClass.ts
  26. 3. Interfaces are named using UpperCamelCase with I prefix → IMyInterface
  27. 4. Single interface files are named the same as interface → IMyInterface.ts
  28. 5. TypeScript files that are not classes, e.g. constants or multiple interfaces are named with lowerCamelCase → myInterfacesAndConstants.ts
  29. 6. Unit tests are named the same as the class or component with .test.ts extension → MyWidgetComponent.test.ts
  30. 7. Vue filters are named with .filter.ts extension → myDateTime.filter.ts
  31.  
  32. # Vuex store
  33.  
  34. ## Structure
  35.  
  36. 1. Store is split into modules by "feature" via folders
  37. 2. Store modules/folders are named named with lowerCamelCase → myStoreModule
  38. 3. Store module can contain one or more store files
  39. 4. Store can be single file if it is relatively simple/short → index.ts
  40. 5. If store has a lot of actions, mutations or getters they are extracted to separate files:
  41. - actions → actions.ts
  42. - mutations → mutations.ts
  43. - getters → getters.ts
  44. 6. Every action, mutation and getter name is extracted as a constant in separate file:
  45. - actions → action-types.ts
  46. - mutations → mutation-types.ts
  47. - getters → getter-types.ts
  48.  
  49. ## Conventions
  50.  
  51. 1. Constants are named using UPPER_CASE → MY_STORE_ACTION
  52. 2. Getters are used only if they are reused more than one time → otherwise create local computed property, use mapState
  53. 3. Any state modification can happen only in mutation
  54. 4. Actions are used for async operations and to compose multiple mutations, if you only need to do one mutation → commit locally, use mapMutations
  55. 5. For all simple actions, mutations, getters and state access → use mapState, mapGetters, mapMutations and mapActions
  56. 6. For complex operations with custom logic → use local computed properties and methods
Add Comment
Please, Sign In to add comment