Skip to content

Commit

Permalink
docs: initial chore
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertoBasalo committed Oct 1, 2024
1 parent be95d8e commit 8c73c91
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 59 deletions.
19 changes: 0 additions & 19 deletions .ai/changes/2024-09-18.log.md

This file was deleted.

14 changes: 0 additions & 14 deletions .ai/changes/2024-09-19.log.md

This file was deleted.

40 changes: 40 additions & 0 deletions .ai/procedures/ng16/add-route.procedure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Add Route

## 1.- Generate module with routing

```bash
ng generate module routes/home --routing --module=app.module
```

## 2.- Generate page component

```bash
ng generate component routes/home/home --type=page --export=false --selector=false
```

## 3.- Add route to feature module and app module

```typescript
// home-routing.module.ts
const routes: Routes = [{ path: "", component: HomePage, title: "Home" }];

// app-routing.module.ts
const routes: Routes = [
{
path: "",
loadChildren: () => import("@app/home").then((module) => module.HomeModule),
},
];
```

## 4.- Generate service

```bash
ng generate service routes/home
```

## 5.- Generate presenter component

```bash
ng generate component routes/home/home --export=false
```
35 changes: 35 additions & 0 deletions .ai/procedures/ng16/config-schematics.procedure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Config Schematics

## Modify Angular.json

### Components

Use OnPush change detection strategy
Delay style declaration until last moment
Try to be flat
Do not test at component level

```json
"schematics": {
"@schematics/angular:component": {
"changeDetection": "OnPush",
"inlineStyle": true,
"flat": true,
"skipTests": true,
"style": "none",
}
}
```

### Services

Do not test at service level

```json
"schematics": {
"@schematics/angular:service": {
"skipTests": true,
"flat": true
}
}
```
126 changes: 100 additions & 26 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,32 @@ ng add @angular-eslint/schematics
npm i prettier prettier-eslint eslint-config-prettier eslint-plugin-prettier -D
```

- Add the following to the `eslintrc.json` file:
- Add the following, at least, to the `eslintrc.json` file:

```json
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.app.json"
},
"rules": {
"prettier/prettier": "warn",
"end-of-line": "auto"
}
"root": true,
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"project": "tsconfig.app.json"
},
"rules": {
"prettier/prettier": "warn",
"end-of-line": "auto"
}
}
]
}
```

Expand Down Expand Up @@ -144,6 +151,7 @@ npm i prettier prettier-eslint eslint-config-prettier eslint-plugin-prettier -D
- Fix an expected problem (ex. roll back a transaction, create a file, etc.)
- Add context and rethrow.
- Do not hide errors, correct or propagate them.
- Log and report them.

### Logging

Expand All @@ -170,32 +178,43 @@ npm i prettier prettier-eslint eslint-config-prettier eslint-plugin-prettier -D

## Specific to Angular Classic

### Folders structure
### Folder and Module structure

Organization principles:
Organize the code following the principles of modularity and separation of concerns.

- Eager versus lazy loading.
- Shared versus domain specific.
| **Criteria** | **Option A** | **Option B** |
| ------------ | ------------ | --------------- |
| **Loading** | Eager | Lazy |
| **Domain** | Shared | Domain-Specific |
| **Modules** | Declarative | Injectable |

- Start with the following folder/module structure:

- `src/`
- `routes/`
- `home/`
- `about/`
- `src/app/`
- `core/`
- `auth/`
- `layout/`
- `global/`
- `log/`
- `routes/`
- `home/`
- `about/`
- `shared/`
- `domain/`
- `ui/`
- `utils/`

- Add a path alias in the `tsconfig.json` file
- Add a path alias in the `tsconfig.json` file to simplify imports.

#### App Module
> Example:

```json
"paths": {
"@core/*": ["src/app/core/*"],
"@shared/*": ["src/app/shared/*"],
"@routes/*": ["src/app/routes/*"]
}
```

#### Core Module

Expand All @@ -217,12 +236,67 @@ ng generate service core/log/logger

```bash
ng generate module shared
ng generate class shared/domain/user.dto
ng generate component shared/ui/button --export
```

#### Routes Modules

```bash
ng generate module routes/home --route=home --module=app.module
ng generate service routes/home
ng generate component routes/home-banner
ng generate component routes/home-content
ng generate module routes/about --route=about --module=app.module
```

#### App Module

- Keep it as simple as possible.
- AppRoutingModule using loadChildren.

> Example:

```typescript
const routes: Routes = [
{
path: "",
loadChildren: () => import("./routes/home/home.module").then((m) => m.HomeModule),
},
{
path: "about",
loadChildren: () => import("./routes/about/about.module").then((m) => m.AboutModule),
},
];
```

### Component (Declarative) structure

Use the Container/Presentational Component pattern.

- Container:

- Logic: Events, data, business rules, etc.
- Connects the view to the model.
- Interactions with the outside world.
- Depends on injected services.

- Presentational(s):

- UI: HTML, CSS, etc.
- Only logic related to the UI .
- Receives data via `@Input()` bindings
- Raises events via `@Output()` bindings.

- Shared UI:
- Reuseable Presentational components.
- Use the `shared/ui` folder.
- Must be exported from the `shared` module.

### Service (Injectable) structure

- Use one service for each Container as a facade.
- Use the default _provided in root_ even for local services.
- Extract common business logic to shared domain services.
- Extract generic logic to shared utility functions.
- Use core domain for interceptors, guards and global services.
50 changes: 50 additions & 0 deletions AstroBookings/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"root": true,
"ignorePatterns": ["projects/**/*"],
"overrides": [
{
"files": ["*.ts"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@angular-eslint/recommended",
"plugin:@angular-eslint/template/process-inline-templates",
"plugin:prettier/recommended"
],
"rules": {
"prettier/prettier": ["none"],
"@typescript-eslint/no-unused-vars": "warn",
"@angular-eslint/directive-selector": [
"error",
{
"type": "attribute",
"prefix": "lab",
"style": "camelCase"
}
],
"@angular-eslint/component-class-suffix": [
"error",
{
"suffixes": ["Component", "Form", "Page", "Widget"]
}
],
"@angular-eslint/component-selector": [
"error",
{
"type": "element",
"prefix": "lab",
"style": "kebab-case"
}
]
}
},
{
"files": ["*.html"],
"extends": [
"plugin:@angular-eslint/template/recommended",
"plugin:@angular-eslint/template/accessibility"
],
"rules": {}
}
]
}
9 changes: 9 additions & 0 deletions AstroBookings/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"bracketSameLine": true,
"endOfLine": "auto",
"printWidth": 100,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}

0 comments on commit 8c73c91

Please sign in to comment.