Skip to content
Open
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
50 changes: 50 additions & 0 deletions .ai/angular-patterns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Angular Patterns

# Zoneless component pattern

Components rely on signals for UI updates.

Example:

@Component({
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush
})
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';

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

withState({
count: 0
}),

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

Usage in component:

@Component({
standalone: true
})
export class CounterComponent {
store = inject(CounterStore)
}
72 changes: 72 additions & 0 deletions .ai/angular-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Angular Rules

Framework version: Angular 21

## Core rules

- Use standalone components only.
- Do not introduce NgModules.
- Prefer Angular Signals for local state.
- Avoid RxJS when Signals are sufficient.
- Use strict TypeScript typing.

## Component design

- Components must remain small and focused on UI.
- Business logic should not live inside components.
- Move reusable logic to services or pure functions.

## Change detection

- Use OnPush change detection by default.

Example:

@Component({
standalone: true,
changeDetection: ChangeDetectionStrategy.OnPush
})

## Dependency injection

- Avoid unnecessary services.
- Prefer simple utility functions when Angular DI is not needed.

## State management

State management rules:

1. Local component state → Angular Signals
2. Application state → NgRx Signal Store

Use:

- @ngrx/signals
- signalStore
- withState
- withMethods
- withComputed
- signalStoreFeature

Do not use:

- NgRx Store (createReducer, createEffect)
- BehaviorSubject stores
- custom RxJS state services

## Code quality

- Avoid the use of `any`.
- Prefer explicit types.
- Keep functions small and testable.

## Zoneless mode

This project runs without Zone.js.

Rules:

- Do not rely on zone-based change detection.
- Prefer Angular Signals to trigger updates.
- Avoid patterns requiring `NgZone`.
- Do not introduce `zone.js` dependencies.
58 changes: 58 additions & 0 deletions .ai/dev-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Development Commands

These are the official commands for working with this repository.
LLM tools should prefer these commands instead of inventing new ones.

## Install dependencies

npm install

## Development server

Start the Angular development server:

npm run serve

## Compile assets

Compile css tailwind style files:

npm run build-css

## Build

Build the Angular library project:

ng build @rero/ng-core

Build the Angular testing application project:

ng build ng-core-tester

## Tests

Run Angular library tests with Vitest:

ng test @rero/ng-core --watch=false --headless

Run Angular testing application tests with Vitest:

ng test ng-core-tester --watch=false --headless

## Lint

Run ESLint:

npm run lint

## Format

Run Prettier:

npm run format

## Full quality check

Run all quality checks:

./run-tests.sh
58 changes: 58 additions & 0 deletions .ai/project-context.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Project Context

## Stack

- Angular 21
- Standalone components
- TypeScript strict mode
- Zoneless change detection (Zone.js disabled)
- NgRx Signal Store for application state
- Signals preferred over RxJS
- Vitest for testing
- Node 20+

## Architecture principles

- Business logic should be isolated from Angular when possible.
- Prefer pure functions for reusable logic.
- Angular components should remain thin and focused on UI.

## Folder conventions

src/app/
components/
services/
stores/
utils/

- components: UI components
- services: Angular services and API access
- stores: signal-based state management
- utils: framework-independent helpers

## Testing philosophy

- Prefer unit tests without Angular when possible.
- Use TestBed only when Angular integration is required.
- Tests must run with Vitest.

## State management

State management uses **NgRx Signal Store**.

Rules:

- Application state must use NgRx Signal Store.
- Component-local state should use Angular Signals.
- Do not use NgRx reducers/effects/store module.
- Do not introduce BehaviorSubject-based stores.

## Change detection

The application runs in **zoneless mode**.

Rules:

- Zone.js is not used.
- Change detection must rely on Angular Signals.
- Avoid patterns depending on automatic zone-based updates.
57 changes: 57 additions & 0 deletions .ai/prompts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Prompt Templates

These prompt templates help guide the LLM when performing common tasks in this repository.

---

## Fix Angular test

Goal: migrate this test to Vitest.

Constraints:

- do not change business logic
- replace Jasmine APIs with Vitest equivalents
- replace `jasmine.createSpy` with `vi.fn`
- replace `spyOn` with `vi.spyOn`
- keep TestBed only if Angular integration is required

---

## Refactor Angular component

Goal: simplify this component.

Constraints:

- Angular 21
- standalone components only
- do not introduce NgModules
- move business logic outside components when possible
- avoid RxJS if Angular Signals are sufficient
- keep change detection strategy OnPush

---

## Improve typing

Goal: improve TypeScript typing.

Constraints:

- do not introduce `any`
- prefer explicit types
- keep code compatible with strict TypeScript mode

---

## Write unit test

Goal: write a unit test for the provided code.

Constraints:

- use Vitest
- prefer pure function testing
- avoid TestBed unless Angular integration is required
- keep the test minimal and readable
85 changes: 85 additions & 0 deletions .ai/testing-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Testing Rules

Testing framework: Vitest

## Allowed testing APIs

Use the Vitest testing API:

- describe()
- it()
- expect()
- beforeEach()
- afterEach()

Spies and mocks:

- vi.fn()
- vi.spyOn()

## Do not use

The following tools must not be introduced:

- Karma
- Jasmine
- jasmine.createSpy
- jasmine.clock

## Angular testing

Prefer tests that do not require Angular.

Priority order:

1. Pure function tests
2. Service tests without TestBed
3. Angular integration tests using TestBed

Use TestBed only when Angular features are required:

- dependency injection
- component rendering
- directives/pipes

## Component tests

When testing components:

- import standalone components directly
- avoid large testing modules
- mock dependencies with simple objects when possible

Example pattern:

describe('MyComponent', () => {

it('should compute value', () => {
const result = computeSomething(2)
expect(result).toBe(4)
})

})

## Test performance

Tests must:

- run with Vitest
- support watch mode
- remain fast and isolated

## Zoneless testing

The application runs without Zone.js.

Do not use:

- fakeAsync
- tick
- flush

Prefer:

- async/await
- Promise-based testing
Loading