Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions .ai/angular-patterns.md
Original file line number Diff line number Diff line change
@@ -1,76 +1,78 @@
# Angular Patterns

# Zoneless component pattern
## Zoneless component pattern

Components rely on signals for UI updates.

Example:

```ts
@Component({
selector: 'app-counter'
selector: 'app-counter',
})
export class CounterComponent {

store = inject(CounterStore);

count = this.store.count;

}
```

## NgRx Signal Store

Application state should be implemented using NgRx Signal Store.

Example pattern:

import { signalStore, withState, withMethods } from '@ngrx/signals';
```ts
import { signalStore, withMethods, withState } from '@ngrx/signals';

export const CounterStore = signalStore(
{ providedIn: 'root' },

withState({
count: 0
count: 0,
}),

withMethods((store) => ({
increment() {
store.count.update(v => v + 1);
}
}))
)
store.count.update((v) => v + 1);
},
})),
);
```

Usage in component:

```ts
@Component({
selector: 'app-counter'
selector: 'app-counter',
})
export class CounterComponent {
store = inject(CounterStore);
}
```

## UI components with optimus-ui

UI components come from `@openng/optimus-ui`, imported per-component from their subpath.

Example:

```ts
import { Component, input, output } from '@angular/core';
import { Paginator, PaginatorState } from '@openng/optimus-ui/paginator';

@Component({
selector: 'app-list',
imports: [Paginator],
template: `
<p-paginator
[first]="first()"
[rows]="rows()"
[totalRecords]="total()"
(onPageChange)="pageChange.emit($event)" />
`
<p-paginator [first]="first()" [rows]="rows()" [totalRecords]="total()" (onPageChange)="pageChange.emit($event)" />
`,
})
export class ListComponent {
first = input.required<number>();
rows = input.required<number>();
total = input.required<number>();
pageChange = output<PaginatorState>();
}
```
10 changes: 10 additions & 0 deletions .ai/dev-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,13 @@ pnpm lint
Run ESLint and automatically fix issues:

pnpm lint:fix

## Format

Format all files with Prettier (also sorts imports):

pnpm format

Check formatting without writing changes:

pnpm format:check
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ root = true

[*]
charset = utf-8
end_of_line = lf
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true
# Same as the Prettier `printWidth` (.prettierrc)
max_line_length = 120

[*.ts]
quote_type = single
Expand Down
5 changes: 5 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Generated files (Prettier also honours .gitignore)
pnpm-lock.yaml
.angular
dist
coverage
7 changes: 6 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"printWidth": 100,
"printWidth": 120,
"singleQuote": true,
"bracketSameLine": true,
"plugins": ["@ianvs/prettier-plugin-sort-imports"],
"importOrder": ["<BUILTIN_MODULES>", "<THIRD_PARTY_MODULES>", "", "^[.]"],
"importOrderParserPlugins": ["typescript", "decorators"],
"importOrderTypeScriptVersion": "6.0.3",
"overrides": [
{
"files": "*.html",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Projet pour tester Angular POC
Vous devez avoir au préalable installer pnpm sur votre système.

## Installation de bibliothèques

```bash
pnpm install
```
Expand Down
14 changes: 6 additions & 8 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
"input": "public"
}
],
"styles": [
"src/styles.scss"
]
"styles": ["src/styles.scss"]
},
"configurations": {
"production": {
Expand Down Expand Up @@ -62,11 +60,11 @@
"extractLicenses": false,
"sourceMap": true,
"fileReplacements": [
{
"replace": "src/app/app.config.ts",
"with": "src/app/app.config.mock.ts"
}
]
{
"replace": "src/app/app.config.ts",
"with": "src/app/app.config.mock.ts"
}
]
}
},
"defaultConfiguration": "production"
Expand Down
6 changes: 0 additions & 6 deletions eslint.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import eslint from '@eslint/js';
import angular from 'angular-eslint';
import { defineConfig } from 'eslint/config';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import tseslint from 'typescript-eslint';

export default defineConfig([
Expand All @@ -17,9 +16,6 @@ export default defineConfig([
angular.configs.tsRecommended,
],
processor: angular.processInlineTemplates,
plugins: {
'simple-import-sort': simpleImportSort,
},
rules: {
'@angular-eslint/directive-selector': [
'error',
Expand All @@ -37,8 +33,6 @@ export default defineConfig([
style: 'kebab-case',
},
],
'simple-import-sort/imports': 'error',
'simple-import-sort/exports': 'error',
},
},
{
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"test:watch": "vitest",
"test:coverage": "vitest run --coverage",
"lint": "eslint .",
"lint:fix": "eslint . --fix"
"lint:fix": "eslint . --fix",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"private": true,
"packageManager": "pnpm@11.22.0",
Expand All @@ -38,12 +40,12 @@
"@angular/cli": "^22.3.0",
"@angular/compiler-cli": "^22.3.0",
"@eslint/js": "^10.0.1",
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
"@tailwindcss/postcss": "^4.3.5",
"@vitest/coverage-v8": "^5.1.1",
"angular-eslint": "^22.8.0",
"baseline-browser-mapping": "^2.11.39",
"eslint": "^10.15.0",
"eslint-plugin-simple-import-sort": "^14.0.0",
"jsdom": "^31.0.1",
"postcss": "^8.5.33",
"prettier": "^3.10.1",
Expand Down
Loading