1.6 KiB
1.6 KiB
Code Writing Guidelines
Overview
- Code must follow the
Vue3 composition API + setup + Typescript
approach, following official documentation examples. - Direct DOM operations like
document.getElementById
are not allowed unless absolutely necessary. - Folder names should use
kebab-case
,.ts
files should usecamelCase
, and.vue
files should usePascalCase
for naming. - Packages larger than
500kb
are not allowed to be imported.
Vue3
- Functions like
defineProps
anddefineEmits
must have types declared using TypeScript, in the formatconst props = defineProps<{param: type}>()
. - When there are four or more levels of calls,
computed
must be used. Ternary operators must usecomputed
. - Component names should be in
PascalCase
, and built-in components must be imported inPascalCase
, for example,<RouterLink to="/kun" />
. - When passing props from a parent component to a child component, use
kebab-case
naming. UsecamelCase
forv-on
events.
TypeScript
- The use of
any
is not allowed. - Interfaces should be named in
PascalCase
. - Declaration files with a
.d.ts
extension should be named usingkebab-case
.
Variables and Functions
- Variables should preferably be declared using
const
, and functions should preferably be declared using arrow function syntax likeconst kun = () => {}
. - Boolean values should always start with
is
, for example,isShowToolbar
. - Functions in the
store
should be named using theuse...store
convention, for example,useKUNGalgameEditStore
. - For complex functions, use the
@param {type} paramName
format for writing comments.