- Always refer to
home-assistant-js-websocketlibrary for types and functions to interact with the Home Assistant API. - When interaction with Home Assistant API is needed, use
custom-card-helperslibrary for helper utilities for the card lifecycle and events.
src/: TypeScript source for the custom Lovelace card (entry:src/purifier-card.ts).dist/: Build output (bundled card JS). This is generated by Rollup.rollup.config.mjs: Build pipeline and asset handling.eslint.config.mjs: Lint configuration.package.json: Scripts, dependencies, and release config.
npm install: Install dependencies.npm run start: Watch mode build (Rollup) for local development.npm run build: Production bundle todist/.npm run lint: Run ESLint onsrc/.npm run lint:fix: Auto-fix lint issues insrc/.npm run format: Format with Prettier (respects.prettiersettings inpackage.json).npm test: Runslintthenbuild(no separate test suite).
- Language: TypeScript, ES modules (
"type": "module"). - Formatting: Prettier with single quotes (
"singleQuote": true). - Linting: ESLint (see
eslint.config.mjs) using@typescript-eslintandeslint-plugin-import. - Match existing patterns in
src/for file naming and exports; prefer descriptive, kebab-case filenames for components.
- UI is a Home Assistant Lovelace custom card implemented as a Web Component with Lit (
LitElement, decorators,htmltemplates). - Home Assistant integrations use
custom-card-helpersfor card lifecycle/events andhome-assistant-js-websockettypes for entities/services. - Template rendering uses
ha-templatefor dynamic text in the card. - Localization is handled via JSON translation files in
src/translations/and thelocalizehelper. - Build tooling is Rollup with TypeScript (
rollup-plugin-typescript2), Babel transforms, and asset handling for JSON, images, CSS, and SVG. - Styling uses PostCSS (
postcss-preset-env) androllup-plugin-postcss-litto process component CSS. - Production optimizations include HTML literal minification and Terser.
- Utility helpers include Lodash (
get). - Developer tooling includes ESLint, Prettier, Husky, and lint-staged.
- This card uses the custom-card-helpers library with helper utilities for the card lifecycle and events. Always refer to the documentation for useful functions and utilities.
- Use the home-assistant-js-websocket library for types and functions to interact with the Home Assistant API.
- No dedicated test framework is configured.
- Use
npm testto validate linting and the production build. - Keep changes buildable; avoid introducing new build-time warnings.
- Commit messages follow Conventional Commits (Angular preset), e.g.
feat: ...,fix: ...,chore(deps): .... - Dependency updates should use
chore(deps): ...to align with release rules. - PRs should include: a concise description, what changed, and how it was validated (commands run). If UI changes are visible, include a screenshot or GIF.
- Releases are handled by semantic-release on
mainwith assets fromdist/purifier-card.js. - Ensure build output remains stable when changing dependencies or build config.