-
Notifications
You must be signed in to change notification settings - Fork 1
Style Guide
We will follow a combination of Google TypeScript Style Guide and the Vue Style Guide.
Source: identifiers
-
PascalCase: every word is capitalized, no underscores.
e.g.
JustANormalClass
,Array<T>
-
Do not mark interfaces specially (NOT
IMyInterface
orMyFooInterface
). Instead give it a name that expresses why the interface exists in the first place (e.g.class TodoItem
andinterface TodoItemStorage
).
-
camelCase: first word lowercase, every other word capitalized, no underscores.
-
Private variables MUST NOT be prefixed with
_
e.g.
myFunction
,classVariable
-
UPPERCASE, words separated by underscores.
e.g.
SPECIAL_NUMBER
- PascalCase
-
Base components (app-wide reusable components like a button or a modal) should all start with the same prefix (like Base or App), e.g.
BaseButton.vue
,AppButton.vue
-
Component names should be multi-worded to prevent conflict, e.g.
TodoButton
instead of justButton
. -
Child components that are tightly coupled with their parent should include the parent name as a prefix. [source]
e.g.
TodoList.vue
,TodoListItem.vue
,TodoListItemButton.vue
Do this instead of nesting subdirectories. More detail on file structure: how to structure a large-scale Vue application
-
Component names should start with the highest-level (often most general) words and end with descriptive modifying words. [source]
SearchButtonClear.vue
instead ofClearSearchButton.vue
SearchButtonRun.vue
instead ofRunSearchButton.vue
-
Use full words over abbreviations, e.g.
StudentDashboardSettings.vue
instead ofSdSettings.vue
- Use
/* ... */
for multiline comments and//
for single-line comments.
2 spaces
-
[Skip this step if using Docker environment] Use the
npm
setup options to include JEST, ESLint, and Prettier.- This should automatically download the packages and create the necessary
.eslintrc.js
and.prettierrc
files.
- This should automatically download the packages and create the necessary
-
Install the following VS Code extensions:
-
Open your VS Code User Settings by:
- Opening the Command Palette (shift + cmd + P)
- Typing “user settings” and selecting “Preferences: Open User Settings (JSON)”
- Adding the following blocks:
"[typescript][javascript][vue]": { "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.tabSize": 2, "editor.formatOnSave": true, // runs Prettier on save "editor.codeActionsOnSave": { // lints on save "source.fixAll.eslint": true } },
-
Put the following in your
.prettierrc
:
"semi": true,
"trailingComma": "all",
"printWidth": 80,
- To fix conflicts between Prettier and ESLint, add the following under “rules” in your
.eslintrc.js
file
rules: {
indent: 0,
"prettier/prettier": ["error", { singleQuote: false }],
"@typescript-eslint/typedef": [
"error",
{
arrowParameter: true,
parameter: true,
},
],
// "@typescript-eslint/no-inferrable-types": "error",
// "@typescript-eslint/interface-name-prefix": "error",
// "@typescript-eslint/explicit-function-return-type": "error",
// "@typescript-eslint/explicit-module-boundary-types": "error",
},