|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is `@iwf-web/eslint-coding-standard`, an npm package providing standardized ESLint configurations for IWF projects. It wraps `@antfu/eslint-config` with IWF-specific customizations for TypeScript and React. |
| 8 | + |
| 9 | +## Commands |
| 10 | + |
| 11 | +```bash |
| 12 | +pnpm build # Transpile src/ to ESM in dist/ + generate .d.mts types (tsdown --clean --dts) |
| 13 | +pnpm prepack # Same as build, via @antfu/ni (`nr build`); runs automatically on publish |
| 14 | +pnpm lint # Lint the codebase (dogfoods this package's own config) |
| 15 | +pnpm lint:fix # Lint and auto-fix |
| 16 | +pnpm ts:check # Type check (tsc --noEmit) |
| 17 | +``` |
| 18 | + |
| 19 | +Note: `pnpm test` is a placeholder that errors — tests are not yet implemented. |
| 20 | + |
| 21 | +## Architecture |
| 22 | + |
| 23 | +The package exports two configs from separate entry points: |
| 24 | + |
| 25 | +- **`iwfWebStandardTs`** (`src/standard-ts.ts`) — Full config with TypeScript strict checking, React, and all style rules. Imports `baseOptions`/`baseRules` from the JS config and layers on `tsRules`. |
| 26 | +- **`iwfWebStandardJs`** (`src/standard-js.ts`) — Base config with React and style rules, without TypeScript. Defines and exports `baseOptions` and `baseRules`. |
| 27 | +- **`src/index.ts`** — Barrel re-export of both configs. |
| 28 | + |
| 29 | +Both functions accept `(options?, ...userConfigs)` — `options` shallow-merge over the IWF `baseOptions` (and override `antfu()` defaults), `userConfigs` are additional ESLint flat config objects appended after the IWF rules. Each module also exports a deprecated alias (`iwfStandardTs`/`iwfStandardJs`) kept for backward compat — slated for removal in the next major version (search `TODO: Remove`). |
| 30 | + |
| 31 | +`eslint.config.ts` at the repo root applies `iwfWebStandardTs()` to this repo itself, so linting changes here is the primary way to verify the config behaves as intended. |
| 32 | + |
| 33 | +### Consumer usage |
| 34 | + |
| 35 | +```typescript |
| 36 | +import { iwfWebStandardTs } from '@iwf-web/eslint-coding-standard'; |
| 37 | +export default iwfWebStandardTs(); |
| 38 | +// Subpath imports also available: '@iwf-web/eslint-coding-standard/standard-ts' |
| 39 | +``` |
| 40 | + |
| 41 | +## Code Style Enforced by This Config |
| 42 | + |
| 43 | +Defined in `baseRules` (`src/standard-js.ts`) and `tsRules` (`src/standard-ts.ts`); each rule carries an inline comment explaining its rationale. Highlights: |
| 44 | + |
| 45 | +- Semicolons required; curly braces required for all control statements |
| 46 | +- 120 char line length (warning; ignores comments/strings) |
| 47 | +- Single quotes, 2-space indentation, no spaces inside object braces (`{foo: bar}`) |
| 48 | +- Arrow function params always parenthesized; object props quoted only as needed |
| 49 | +- TS: relaxed `any` restrictions for third-party interop, promises allowed in event handlers |
| 50 | +- React: hooks linting on, common children-manipulation patterns allowed |
| 51 | + |
| 52 | +## Build & Release |
| 53 | + |
| 54 | +- **tsdown**: Builds ESM-only output to `dist/` with declarations. Entry points configured in `tsdown.config.ts`. `exports: true` auto-syncs `package.json` exports — do not hand-edit the `exports` field. |
| 55 | +- **pnpm**: Required package manager (version locked via `packageManager`). |
| 56 | +- **Conventional Commits**: Drive automated releases via release-please (`release-please-config.json`, `.release-please-manifest.json`). |
| 57 | +- **Node 18+** required by consumers; dev container uses Node 24. |
0 commit comments