- Application has tree structure with folders for each "feature"
- Feature folders are named with lowerCamelCase → myComponentDashboard
- Feature can contain any number of components and nested features
- Components are named using UpperCamelCase → MyWidgetComponent.vue
- Component can have translation .yml file named correspondingly → MyWidgetComponent.yml
- If component requires more than 2 files: .vue and .yml file - folder is created with the same name → MyWidgetComponent
- Shared components/classes/etc can be placed under common folder
- Shared common folder is located near the topmost component that uses this commons
- If there is only one asset used in component it is stored as is near the component file
- If there are more than one asset - asset folder is created for them
- If more than one component uses the same asset - asset folder is created even if there's only one asset
- Shared asset folder is located near the topmost component that uses this asset
- TypeScript classes are named using UpperCamelCase → MyTypeScriptClass
- TypeScript class files are named the same as the class → MyTypeScriptClass.ts
- Interfaces are named using UpperCamelCase with I prefix → IMyInterface
- Single interface files are named the same as interface → IMyInterface.ts
- TypeScript files that are not classes, e.g. constants or multiple interfaces are named with lowerCamelCase → myInterfacesAndConstants.ts
- Unit tests are named the same as the class or component with .test.ts extension → MyWidgetComponent.test.ts
- Vue filters are named with .filter.ts extension → myDateTime.filter.ts
- There can be component "local" stores (if only one component and its children uses store) and "global" stores (used in different components)
- Global store is split into modules by "feature" via folders
- Local component store is named either as "feature" or just "store"
- Store modules/folders are named named with lowerCamelCase → myStoreModule
- Store module can contain one or more store files
- Store can be single file if it is relatively simple/short → index.ts
- If store has a lot of actions, mutations or getters they are extracted to separate files:
- actions → actions.ts
- mutations → mutations.ts
- getters → getters.ts
- Every action, mutation and getter name is extracted as a constant in separate file:
- actions → action-types.ts
- mutations → mutation-types.ts
- getters → getter-types.ts
- No other files should be present in the store folder
- Constants are named using UPPER_CASE → MY_STORE_ACTION
- Getters are used only if they are reused more than one time → otherwise create local computed property, use mapState
- Any state modification can happen only in mutation
- Actions are used for async operations and to compose multiple mutations, if you only need to do one mutation → commit locally, use mapMutations
- For all simple actions, mutations, getters and state access → use mapState, mapGetters, mapMutations and mapActions
- For complex operations with custom logic → use local computed properties and methods
- Don't name computed properties and getters with
get
prefix
Can you share some examples for feature/componenet names. How do you distinguish what is feature or component?