Reviewed-on: #300 Reviewed-by: Wojciech Szewczyk <szewczyw@noreply.example.com> Co-authored-by: Wojciech Mizia <miziawojciech@gmail.com> Co-committed-by: Wojciech Mizia <miziawojciech@gmail.com>
Modern frontend for Release 11 Tools
This template should help get you started developing with Vue 3 in Vite.
Recommended IDE Setup
VSCode + Volar (and disable Vetur) + TypeScript Vue Plugin (Volar).
Type Support for .vue Imports in TS
TypeScript cannot handle type information for .vue imports by default, so we replace the tsc CLI with vue-tsc for type checking. In editors, we need TypeScript Vue Plugin (Volar) to make the TypeScript language service aware of .vue types.
If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a Take Over Mode that is more performant. You can enable it by the following steps:
- Disable the built-in TypeScript Extension
- Run
Extensions: Show Built-in Extensionsfrom VSCode's command palette - Find
TypeScript and JavaScript Language Features, right click and selectDisable (Workspace)
- Run
- Reload the VSCode window by running
Developer: Reload Windowfrom the command palette.
Customize configuration
See Vite Configuration Reference.
Project Setup
npm install
Compile and Hot-Reload for Development
npm run dev
Type-Check, Compile and Minify for Production
npm run build
Lint with ESLint
npm run lint
Structure of Vuejs 3 components and views in this project
For this document's needs components and views will be named "modules" even though this is not a correct term for these files officially.
Main structure
- <script>
- <template>
- <style> - if really needed
Scripts
Elements should be placed in this order:
- Imports
- Props - constant defined by defineProps function, named "props" in code This name allows to have readable code sending data to parent module:
props.exampleProp
- Emits - constant defined by defineEmits function, named "emit" in code. This name allows to have readable code sending data to parent module:
emit("update:modelValue", exampleVariable)
- Interfaces
- Refs - constants defined by ref functions with appropriate values
- Injects - variables assigned by "inject" function
- Other variables/constants
- onFunctions - functions like onBeforeUpdate
- Other functions
Rules regarding functions:
- Functions ought to have descriptive name
- Ought to do one thing. ie. function sendRequest should send request, but not prepare request body or process response data
- In practice, if function has more than 10 SLoC, it probably should be split
- DO NOT use "any" type. Just don't. *Optional
- Function used in other function should be placed below it (if possible, as function can be called from many places in the code)
Rules regarding variables and refs:
- Variables ought to have descriptive name
In cases not covered in this convention, TypeScript, VueJS 3 conventions and good programming practices are applied