Files
release11-tools/Frontend/README.md
Adam Bem ea83e95a00 Created convention file for frontend and adjusted current project files (#277)
Reviewed-on: #277
Reviewed-by: Mikolaj Widla <widlam@noreply.example.com>
Co-authored-by: Adam Bem <adam.bem@zoho.eu>
Co-committed-by: Adam Bem <adam.bem@zoho.eu>
2024-01-04 08:17:44 +01:00

90 lines
3.3 KiB
Markdown

# Modern frontend for Release 11 Tools
This template should help get you started developing with Vue 3 in Vite.
## Recommended IDE Setup
[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).
## 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)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) 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](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:
1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.
## Customize configuration
See [Vite Configuration Reference](https://vitejs.dev/config/).
## Project Setup
```sh
npm install
```
### Compile and Hot-Reload for Development
```sh
npm run dev
```
### Type-Check, Compile and Minify for Production
```sh
npm run build
```
### Lint with [ESLint](https://eslint.org/)
```sh
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:
```TS
props.exampleProp
```
- Emits - constant defined by defineEmits function, named "emit" in code. This name allows to have readable code sending data to parent module:
```TS
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