# Frontend lint pack — Generalized Style Guide v1.1, Part 2

Build-time enforcement for the 62 frontend rules, mirroring the .NET pack:
REQUIRED rules are errors, DEFAULT rules are warnings, and CI runs with
`--max-warnings=0` so both fail the build.

## Adopt

Copy `eslint.config.mjs`, `tsconfig.json`, `tsconfig.base.json`,
`tsconfig.app.json`, `tsconfig.spec.json`, `.stylelintrc.json`,
`.prettierrc.json` to the workspace root and merge the `devDependencies`
and scripts from `package.json`. Set the selector prefix in
`eslint.config.mjs` to the app prefix (libraries keep `zh`, SG-FE-NG-02).
Enable `@angular-eslint/template/i18n` once the app's i18n is wired
(SG-FE-I18N-03).

## Rule mapping (selection)

| Guide rule | Enforcement |
|---|---|
| SG-FE-TS-01 strict TS | tsconfig.base.json flags |
| SG-FE-TS-02 no any | no-explicit-any, no-non-null-assertion |
| SG-FE-TS-03 naming | naming-convention (no I-prefix types) |
| SG-FE-TS-04 no Dto suffix | no-restricted-syntax selectors |
| SG-FE-TS-05 observables end in $ | rxjs-x/finnish |
| SG-FE-TS-06 no enum | no-restricted-syntax TSEnumDeclaration |
| SG-FE-TS-08 no default exports | no-restricted-syntax |
| SG-FE-API-05 no web-storage tokens | no-restricted-syntax MemberExpression |
| SG-FE-API-07 never swallow stream errors | rxjs-x/no-ignored-error |
| SG-FE-SEC-03 no eval | no-eval, no-new-func, no-implied-eval |
| SG-FE-SEC-05 npm audit gate | `npm run audit` in CI |
| SG-FE-FMT-01 Prettier 120/single | .prettierrc.json |
| SG-FE-FMT-02 ESLint correctness | no-floating-promises, eqeqeq, no-console, import-x/order |
| SG-FE-NG-03 OnPush | prefer-on-push (explicit pre-v22; v22 defaults) |
| SG-FE-NG-04 signal inputs/outputs | prefer-signals + decorator ban |
| SG-FE-NG-05 built-in control flow | template/prefer-control-flow |
| SG-FE-NG-07 subscribe discipline | rxjs-x/no-unsafe-takeuntil, no-floating-observables |
| SG-FE-NG-08 inject() | prefer-inject |
| SG-FE-A11Y-01..03 | templateAccessibility config |
| SG-FE-I18N-02 logical properties | Stylelint property/value disallowed lists |
| SG-FE-STYLE-01 tokens, no raw hex | color-no-hex (tokens folder exempt) |
| SG-FE-STYLE-03 no !important | declaration-no-important |
| SG-FE-STYLE-02 kebab classes, --zh-* | selector/custom-property patterns |

Review-only (no lint rule exists): envelope unwrapping (SG-FE-API-02),
generated API types (SG-FE-API-01 — enforce by generating into
`*.generated.ts`, which the config ignores), sanitizer bypass comments
(SG-FE-NG-13), CWV budgets (SG-FE-PERF-01 — Lighthouse CI in the wiring
pack).

## Pins and the health gate (checked 2026-12-02)

eslint 10.16.0, typescript-eslint 8.74.0, angular-eslint 22.8.0,
eslint-plugin-import-x 4.18.1, eslint-plugin-rxjs-x 1.0.7,
stylelint 18.1.0, stylelint-config-standard-scss 18.0.0,
prettier 3.10.1, typescript 5.9.3 (typescript-eslint supports <6.1;
revisit when it allows TS 7). Two originals failed the gate and were
replaced: eslint-plugin-import (no ESLint 10 peer) and
eslint-plugin-rxjs (unmaintained since 2023) — import-x and rxjs-x are
the maintained forks. All MIT/Apache-2.0.

Verified 2026-12-02 on scratch samples: violating TS/component/template/
SCSS failed with the mapped rules; clean samples passed ESLint, Stylelint
and `tsc --noEmit`.
