Files
nocobase/ui-library/eslint.config.js
T
Zeke ZhangandClaude Opus 5.5 9e8fc3edd3 fix(ui-library): sync auth-ui, check items as plugins compile them, and document the library (#399)
* fix(ui-library): sync auth-ui, check items as plugins compile them, and document the library

Bring the auth-ui item up to date with the copies the templates ship.
Those gained translations in #264 while the registry source kept
hard-coded English, so `shadcn add @nocobase/auth-ui` installed an older
version than any template carried. The item now declares @nocobase/i18n.

- Relative imports inside items carry the .js extension. A plugin
  compiles installed source with NodeNext, which rejects an extensionless
  import; an application's bundler resolves either form.
- tsconfig.registry.json compiles the registry sources with NodeNext
  against the real workspace packages. tsconfig.json no longer maps the
  authentication plugin's actions to the preview's mock, so both programs
  check the items against the plugin's real exports and the mock is
  typed from them; only the Vite build swaps it in. A plugin change that
  breaks an item now fails typecheck in that plugin's pull request.
- The package is linted with the rules a plugin uses. The preview's
  shadcn primitives get the relaxations the Portal configuration gives an
  application's, and the two problems the rules found in the preview, a
  synchronous setState in an effect and a fetch that was never aborted,
  are fixed. The UI Library workflow lints before it publishes, and the
  pre-commit hook lints the directory with its own configuration.
- The preview mounts an i18n runtime, as an application does, so the
  translated items render without react-i18next warnings.
- MAINTAINING.md and USAGE.md document maintaining the library and
  installing its items into applications and plugins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* feat(ui-library): ship auth-ui's translations with the item

The item's strings were translatable, but the translations lived only in
the templates' own locale files, so any other consumer had to copy the
keys by hand and could not tell when an upgrade added one.

- auth-ui ships locales/en-US.ts and locales/zh-CN.ts, listed in its
  files. en-US exports its shape as a type and zh-CN is annotated with
  it, so typecheck fails on a key either one lacks or adds.
- The item's docs, README and the usage guide describe merging the files
  into the consumer's locale resources, which installing does not do,
  and MAINTAINING.md makes shipping every key a rule for items.
- i18n:check also scans ui-library/registry/.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* revert(ui-library): leave the i18n:check scan to #400

The change that adds ui-library/registry/ to i18n:check now lives in
#400, next to the parser fix that makes it effective, so the two pull
requests no longer edit the same lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(ui-library): address review findings

- The documented merge of an item's locales into a plugin's en-US.ts
  failed the plugin's declaration build with TS9015, because
  isolatedDeclarations cannot infer an object built with a spread. The
  item README now shows en-US annotated as
  `typeof authUi & typeof messages`, and USAGE.md says the merged file
  needs it.
- The preview's theme effect toggled only the `dark` class, leaving the
  inline color-scheme index.html sets on load stale after a toggle; it
  now updates both.
- ESLint relaxed only the first of dev-config's two shadcn registry
  blocks, so adding the chart primitive the documented way failed lint.
  dev-config now exports createShadcnRegistryConfig(root), which the
  Portal factory uses for client/ and ui-library uses for website/, so
  the list is no longer copied.
- tsconfig.registry.json compiled items with the ESNext library and
  without noUnusedLocals, unlike the plugins that install them; it now
  uses the create-plugin template's lib and noUnusedLocals.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 21:37:41 +08:00

13 lines
535 B
JavaScript

import {
createClientLibraryConfig,
createShadcnRegistryConfig,
} from '@nocobase/dev-config/eslint';
export default createClientLibraryConfig({
tsconfigRootDir: import.meta.dirname,
// The preview's shadcn primitives stay as `shadcn add` generated them, so they get the relaxations the Portal
// configuration gives an application's `client/components/ui/`, scoped to `website/`. The registry sources and the
// rest of the preview are held to the full rule set.
environment: createShadcnRegistryConfig('website'),
});