@atelier-ui/create-workspace 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (21) hide show
  1. package/CHANGELOG.md +39 -7
  2. package/package.json +1 -1
  3. package/src/generators/preset/files/claude/skills/atelier-component/SKILL.md +7 -7
  4. package/src/generators/preset/files/storybook/angular/main.ts.template +8 -0
  5. package/src/generators/preset/files/storybook/angular/preview.ts.template +17 -0
  6. package/src/generators/preset/files/storybook/react/atl-button.stories.tsx +1 -1
  7. package/src/generators/preset/files/storybook/react/main.ts.template +8 -0
  8. package/src/generators/preset/files/storybook/react/preview.tsx +18 -1
  9. package/src/generators/preset/files/storybook/vue/atl-button.stories.ts.template +1 -1
  10. package/src/generators/preset/files/storybook/vue/main.ts.template +8 -0
  11. package/src/generators/preset/files/storybook/vue/preview.ts.template +18 -1
  12. package/src/generators/preset/files/testing/angular/test-setup.ts.template +6 -0
  13. package/src/generators/preset/files/testing/react/atl-button.spec.tsx +17 -18
  14. package/src/generators/preset/files/testing/react/test-setup-stories.ts.template +17 -0
  15. package/src/generators/preset/files/testing/react/vitest.unit.config.ts.template +1 -1
  16. package/src/generators/preset/files/testing/vue/atl-button.spec.ts.template +17 -21
  17. package/src/generators/preset/files/testing/vue/test-setup-stories.ts.template +17 -0
  18. package/src/generators/preset/files/testing/vue/vitest.unit.config.ts.template +1 -1
  19. package/src/generators/preset/files/tools/scripts/preflight.mjs +79 -0
  20. package/src/generators/preset/preset.js +487 -38
  21. package/src/generators/preset/preset.js.map +1 -1
@@ -260,6 +260,17 @@ const MCP_SDK_VERSION = '^1.29.0';
260
260
  // constant in the devDependencies write when `typescript` isn't already
261
261
  // present.
262
262
  const TYPESCRIPT_VERSION = '6.0.3';
263
+ // Strictness (ADR-0140): typescript-eslint's own meta-package, for
264
+ // `tseslint.configs.recommendedTypeChecked` (lever 5) — a defensive add, not
265
+ // the primary source, like TYPESCRIPT_VERSION above: a real generated tree
266
+ // for all three frameworks already carries it in devDependencies (each
267
+ // framework's own `@nx/{angular,react,vue}:application` generator adds it
268
+ // independently, confirmed against a real run), so the conditional add near
269
+ // the end of presetGenerator only fires if some future generator version
270
+ // stops doing that. Matches root package.json's own declared range
271
+ // (`^8.40.0`) — a caret range mirrored verbatim, like VITEST_VERSION above,
272
+ // not the exact version those generators happened to resolve on their own.
273
+ const TYPESCRIPT_ESLINT_VERSION = '^8.40.0';
263
274
  // Ported CSS-discipline stylelint rules (ADR-0130): pinned the same way
264
275
  // STORYBOOK_VERSION above is — the exact version this monorepo actually
265
276
  // runs, not the caret range root package.json declares (`^17.15.0`); the
@@ -509,6 +520,13 @@ function presetGenerator(tree, options) {
509
520
  '@storybook/addon-mcp': STORYBOOK_VERSION,
510
521
  '@storybook/addon-a11y': STORYBOOK_VERSION,
511
522
  '@storybook/addon-docs': STORYBOOK_VERSION,
523
+ // Manual dark-mode toolbar: tokens.css ships dark mode but nothing let a
524
+ // scaffolded workspace preview it before (only the OS-level
525
+ // prefers-color-scheme fallback). Previewing is all this adds — the a11y
526
+ // axe check still only runs against each story's default (light) render,
527
+ // same as before (see plan/adr/0142 in the monorepo this is scaffolded
528
+ // from).
529
+ '@storybook/addon-themes': STORYBOOK_VERSION,
512
530
  // Browser-mode Storybook tests (owner correction 2026-09-10 to ADR-0123) —
513
531
  // written unconditionally, independent of which framework is selected; the
514
532
  // framework-specific Vite plugin is added conditionally, further below,
@@ -517,6 +535,12 @@ function presetGenerator(tree, options) {
517
535
  vitest: VITEST_VERSION,
518
536
  '@vitest/browser-playwright': VITEST_BROWSER_PLAYWRIGHT_VERSION,
519
537
  playwright: PLAYWRIGHT_VERSION,
538
+ // Lever 4 (ADR-0140): "the stories are the claims" (ADR-0121) and nothing
539
+ // lints them today — wired into each app's eslint.config.mjs below, the
540
+ // same `flat/recommended` this monorepo's own libs/{angular,react,vue}
541
+ // already use. Pinned to STORYBOOK_VERSION like every other Storybook
542
+ // devDependency above, not a separate range.
543
+ 'eslint-plugin-storybook': STORYBOOK_VERSION,
520
544
  };
521
545
  const appName = `workshop-${framework}`;
522
546
  if (framework === 'angular') {
@@ -558,8 +582,30 @@ function presetGenerator(tree, options) {
558
582
  // React and Vue below already pass this explicitly; Angular didn't,
559
583
  // which was the actual defect, not merely a posture gap.
560
584
  linter: 'eslint',
585
+ // Lever 2 (ADR-0140): explicit, not relied-upon-as-default.
586
+ // `@nx/angular:application`'s own schema already defaults `strict` to
587
+ // `true` (`normalize-options.js`), and that default is what already
588
+ // writes `compilerOptions.strict: true` plus the three
589
+ // `angularCompilerOptions` flags below into `${appName}/tsconfig.json`
590
+ // today — verified against the real generator's source
591
+ // (`enable-strict-type-checking.js`) and a real generated tree, not
592
+ // assumed. Passing it explicitly stops that outcome from depending on
593
+ // an upstream default this repo does not control; the `updateJson`
594
+ // backstop below makes it certain either way.
595
+ strict: true,
561
596
  });
562
597
  deps['@atelier-ui/angular'] = componentPackageVersion;
598
+ // Lever 2 (ADR-0140) backstop: `angularAppGenerator`'s own `strict: true`
599
+ // above already writes these three flags (see its comment), but this
600
+ // preset's OWN generation of the outcome shouldn't depend on an nx
601
+ // default it does not control — same posture as
602
+ // `appendToFlatEslintConfig`'s throw-if-missing below. `updateJson`
603
+ // throws if `${appName}/tsconfig.json` is missing, which the application
604
+ // generator above always writes.
605
+ (0, devkit_1.updateJson)(tree, `${appName}/tsconfig.json`, (json) => {
606
+ json.angularCompilerOptions = Object.assign(Object.assign({}, json.angularCompilerOptions), { strictTemplates: true, strictInjectionParameters: true, strictInputAccessModifiers: true });
607
+ return json;
608
+ });
563
609
  // `flat/angular-template` above (written into workshop-angular's own
564
610
  // eslint.config.mjs by the application generator, confirmed by a real
565
611
  // run) already carries angular-eslint's `templateAccessibility` preset
@@ -568,6 +614,39 @@ function presetGenerator(tree, options) {
568
614
  // tagged in angular-eslint's README): WCAG 2.4.3, positive tabindex
569
615
  // fights natural DOM tab order. Same addition libs/angular's own config
570
616
  // makes on top of the identical preset.
617
+ //
618
+ // Levers 3/4/5 (ADR-0140) follow, all appended to the same file:
619
+ // - lever 3: promotes this framework's four warning-only rules that are
620
+ // genuine correctness bugs — matching this repo's OWN
621
+ // libs/angular/eslint.config.mjs, which already sets exactly these
622
+ // four to 'error' (verified: a real generated Angular app's eslint
623
+ // config leaves exactly these four, and no others, at 'warn').
624
+ // - lever 4: wires eslint-plugin-storybook's `flat/recommended` plus the
625
+ // `no-uninstalled-addons` rule, mirroring libs/angular/eslint.config.mjs
626
+ // (packageJsonLocation is one level up here — Storybook addons install
627
+ // at the scaffold's own root, not two levels up the way this
628
+ // monorepo's own libs/ nests).
629
+ // - lever 5: type-aware linting (`recommendedTypeChecked`), scoped to
630
+ // `src/**/*.ts` — exactly what `tsconfig.app.json`/`tsconfig.spec.json`
631
+ // both include, verified against a real generated tree so every file
632
+ // this matches already resolves inside one of the two referenced
633
+ // projects. The `**/*.js`/`.jsx`/`.cjs`/`.mjs` block below is a
634
+ // necessary companion, not an extra feature: `nx.configs['flat/typescript']`
635
+ // (in baseConfig) already assigns typescript-eslint's parser to
636
+ // `.ts`/`.tsx`/`.cts`/`.mts` files WITH an explicit `tsconfigRootDir`
637
+ // (the workspace root, where `nx lint` actually runs from) but its
638
+ // `.js`/`.jsx`/`.cjs`/`.mjs` sibling block assigns the same parser with
639
+ // none at all — harmless on its own, but once ANY block anywhere in
640
+ // this config enables `projectService` (as lever 5 does), typescript-
641
+ // eslint's parser service scans the whole run for tsconfig roots and
642
+ // refuses to guess a default for a file with none of its own, once more
643
+ // than one distinct root exists anywhere in the run. `eslint.config.mjs`
644
+ // itself (an `.mjs` file, linted like any other file in this project)
645
+ // hits this immediately. Verified against a real generated workspace:
646
+ // without this block, `eslint.config.mjs` fails to lint with "No
647
+ // tsconfigRootDir was set, and multiple candidate TSConfigRootDirs are
648
+ // present". Giving these files the same root nx's own block already
649
+ // uses closes the gap.
571
650
  appendToFlatEslintConfig(tree, `${appName}/eslint.config.mjs`, `,
572
651
  {
573
652
  // Not covered by \`flat/angular-template\` above (angular-eslint's own
@@ -579,7 +658,50 @@ function presetGenerator(tree, options) {
579
658
  '@angular-eslint/template/no-positive-tabindex': 'error',
580
659
  },
581
660
  },
582
- `);
661
+ ...tseslint.configs.recommendedTypeChecked.map((cfg) =>
662
+ cfg.files ? cfg : { ...cfg, files: ['src/**/*.ts'] },
663
+ ),
664
+ {
665
+ files: ['src/**/*.ts'],
666
+ languageOptions: {
667
+ parserOptions: {
668
+ projectService: true,
669
+ tsconfigRootDir: import.meta.dirname,
670
+ },
671
+ },
672
+ },
673
+ {
674
+ files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
675
+ languageOptions: {
676
+ parserOptions: {
677
+ tsconfigRootDir: dirname(import.meta.dirname),
678
+ },
679
+ },
680
+ },
681
+ {
682
+ files: ['**/*.ts'],
683
+ rules: {
684
+ '@angular-eslint/use-lifecycle-interface': 'error',
685
+ '@typescript-eslint/no-explicit-any': 'error',
686
+ '@typescript-eslint/no-non-null-assertion': 'error',
687
+ '@typescript-eslint/no-unused-vars': 'error',
688
+ },
689
+ },
690
+ ...storybook.configs['flat/recommended'],
691
+ {
692
+ files: ['.storybook/main.ts'],
693
+ rules: {
694
+ 'storybook/no-uninstalled-addons': [
695
+ 'error',
696
+ { packageJsonLocation: '../package.json' },
697
+ ],
698
+ },
699
+ },
700
+ `, [
701
+ `import { dirname } from 'node:path';`,
702
+ `import tseslint from 'typescript-eslint';`,
703
+ `import storybook from 'eslint-plugin-storybook';`,
704
+ ]);
583
705
  }
584
706
  if (framework === 'react') {
585
707
  console.log(`\n◇ Generating React workshop app…`);
@@ -597,11 +719,110 @@ function presetGenerator(tree, options) {
597
719
  skipFormat: true,
598
720
  });
599
721
  deps['@atelier-ui/react'] = componentPackageVersion;
600
- // Deliberately nothing added here. `flat/react` above (written into
601
- // workshop-react's own eslint.config.mjs by the application generator,
602
- // confirmed by a real run) already carries jsx-a11y's full 18-rule
603
- // active set — the same rule set libs/react/eslint.config.mjs relies on
604
- // without adding anything of its own either.
722
+ // `flat/react` above (written into workshop-react's own eslint.config.mjs
723
+ // by the application generator, confirmed by a real run) already carries
724
+ // jsx-a11y's full 18-rule active set — the same rule set
725
+ // libs/react/eslint.config.mjs relies on without adding anything of its
726
+ // own either. None of jsx-a11y's own warning-only rules are touched
727
+ // below: a11y stays enforced by axe in check:stories (storybook-test), a
728
+ // stronger runtime check than these static heuristics.
729
+ //
730
+ // Levers 3/4/5 (ADR-0140), all appended below — see the identical
731
+ // structure's comment in the Angular branch above for lever 5's
732
+ // `.js`/`.jsx`/`.cjs`/`.mjs` companion block; the reasoning is the same
733
+ // for every framework, not repeated here.
734
+ //
735
+ // Lever 3: the correctness/security family of React's own warning-only
736
+ // rules. Verified against a real generated tree's own
737
+ // `eslint --print-config` for a `.tsx` file: 68 rules sit at 'warn'; the
738
+ // 26 below are the ones that flag a behavioural bug or a real security
739
+ // footgun (e.g. `react/jsx-no-target-blank`'s reverse-tabnabbing), not a
740
+ // style preference — the rest (unicode-bom, no-extra-bind,
741
+ // react/jsx-pascal-case, …) stay warnings. `react-hooks/exhaustive-deps`
742
+ // is deliberately NOT promoted: this repo's own
743
+ // libs/react/eslint.config.mjs makes the identical call (leaves it
744
+ // untouched at 'warn', the only rule this whole file doesn't already
745
+ // decide on) — a missing dependency is a real bug worth flagging, but the
746
+ // rule has a well-known false-positive rate around intentionally-omitted
747
+ // stable references (a `dispatch`, a `setState` function, a ref) and
748
+ // "run once" effects — a strict rule that fires on legitimate code
749
+ // teaches the wrong fix (suppress the warning) to a beginner audience of
750
+ // attendees and LLM agents, the one failure mode this whole change is
751
+ // built to avoid (ADR-0140).
752
+ appendToFlatEslintConfig(tree, `${appName}/eslint.config.mjs`, `,
753
+ ...tseslint.configs.recommendedTypeChecked.map((cfg) =>
754
+ cfg.files
755
+ ? cfg
756
+ : {
757
+ ...cfg,
758
+ files: ['src/**/*.ts', 'src/**/*.tsx'],
759
+ ignores: ['src/**/*.spec.ts', 'src/**/*.spec.tsx'],
760
+ },
761
+ ),
762
+ {
763
+ files: ['src/**/*.ts', 'src/**/*.tsx'],
764
+ ignores: ['src/**/*.spec.ts', 'src/**/*.spec.tsx'],
765
+ languageOptions: {
766
+ parserOptions: {
767
+ projectService: true,
768
+ tsconfigRootDir: import.meta.dirname,
769
+ },
770
+ },
771
+ },
772
+ {
773
+ files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
774
+ languageOptions: {
775
+ parserOptions: {
776
+ tsconfigRootDir: dirname(import.meta.dirname),
777
+ },
778
+ },
779
+ },
780
+ {
781
+ files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
782
+ rules: {
783
+ eqeqeq: 'error',
784
+ 'no-eval': 'error',
785
+ 'no-implied-eval': 'error',
786
+ 'array-callback-return': 'error',
787
+ 'no-new-func': 'error',
788
+ 'no-script-url': 'error',
789
+ 'no-caller': 'error',
790
+ 'no-extend-native': 'error',
791
+ 'no-iterator': 'error',
792
+ 'no-label-var': 'error',
793
+ 'no-loop-func': 'error',
794
+ 'no-native-reassign': 'error',
795
+ 'no-negated-in-lhs': 'error',
796
+ 'no-new-wrappers': 'error',
797
+ 'no-octal-escape': 'error',
798
+ 'no-self-compare': 'error',
799
+ 'no-sequences': 'error',
800
+ 'no-template-curly-in-string': 'error',
801
+ 'no-throw-literal': 'error',
802
+ 'react/jsx-no-target-blank': 'error',
803
+ 'react/jsx-no-duplicate-props': 'error',
804
+ 'react/jsx-no-comment-textnodes': 'error',
805
+ 'react/no-direct-mutation-state': 'error',
806
+ 'react/no-is-mounted': 'error',
807
+ 'react/no-danger-with-children': 'error',
808
+ 'react/style-prop-object': 'error',
809
+ },
810
+ },
811
+ ...storybook.configs['flat/recommended'],
812
+ {
813
+ files: ['.storybook/main.ts'],
814
+ rules: {
815
+ 'storybook/no-uninstalled-addons': [
816
+ 'error',
817
+ { packageJsonLocation: '../package.json' },
818
+ ],
819
+ },
820
+ },
821
+ `, [
822
+ `import { dirname } from 'node:path';`,
823
+ `import tseslint from 'typescript-eslint';`,
824
+ `import storybook from 'eslint-plugin-storybook';`,
825
+ ]);
605
826
  }
606
827
  if (framework === 'vue') {
607
828
  console.log(`\n◇ Generating Vue workshop app…`);
@@ -653,6 +874,40 @@ function presetGenerator(tree, options) {
653
874
  // the generator, and @nx/vue already turns off the rule most likely to
654
875
  // misfire on plain .ts — vue/multi-word-component-names — project-wide
655
876
  // on its own). Recorded here rather than silently left unmentioned.
877
+ // Levers 3/4/5 (ADR-0140), appended below alongside the two blocks above.
878
+ //
879
+ // Lever 3: four of the ~30 `vue/*` rules Vue's own warning tier carries
880
+ // are genuine correctness/security bugs, not the layout/whitespace style
881
+ // rules the eslintConfigPrettier block above already neutralises —
882
+ // `no-v-html` is this framework's `dangerouslySetInnerHTML` (an XSS
883
+ // vector, the same security family as `no-eval`), `no-required-prop-with-default`
884
+ // and `no-template-shadow` catch real logic bugs, and
885
+ // `require-explicit-emits` is the emitted-event counterpart to the
886
+ // already-promoted `no-unused-properties` (declare what you actually
887
+ // emit, the same way you declare what you actually read). The rest —
888
+ // attribute ordering, html-indent, component-name casing, and every
889
+ // other rule eslintConfigPrettier.rules doesn't already turn off — stay
890
+ // warnings: this repo's own libs/vue/eslint.config.mjs makes the
891
+ // identical call (it doesn't touch a single one of them either).
892
+ //
893
+ // Lever 4: eslint-plugin-storybook's `flat/recommended`, mirroring
894
+ // libs/vue/eslint.config.mjs (packageJsonLocation is one level up here).
895
+ //
896
+ // Lever 5: type-aware linting, including `.vue` SFCs — most Vue
897
+ // component code lives in `.vue` files, not `.ts`, so a `.ts`-only scope
898
+ // would miss the majority of what an attendee actually writes. The
899
+ // `.vue`-scoped block below re-specifies `parser` alongside
900
+ // `projectService`/`tsconfigRootDir`/`extraFileExtensions` in ONE
901
+ // object, not split across two — verified against a real generated
902
+ // workspace that splitting them (a second, later block adding only
903
+ // `projectService`+`tsconfigRootDir` next to the app generator's own
904
+ // parser-only block above) reproduces the exact "No tsconfigRootDir was
905
+ // set, and multiple candidate TSConfigRootDirs are present" failure
906
+ // lever 5's own `.js`/`.jsx`/`.cjs`/`.mjs` companion block (see the
907
+ // identical block's comment in the Angular branch above) exists to avoid
908
+ // for plain files — vue-eslint-parser's delegate-parsing does not pick
909
+ // up a later block's parserOptions the same way ESLint's own
910
+ // language-options merge does for every other file type in this preset.
656
911
  appendToFlatEslintConfig(tree, `${appName}/eslint.config.mjs`, `,
657
912
  {
658
913
  // eslint-plugin-vue's flat/recommended (spread above by @nx/vue's own
@@ -670,8 +925,106 @@ function presetGenerator(tree, options) {
670
925
  'vue/no-unused-properties': ['error', { groups: ['props'] }],
671
926
  },
672
927
  },
673
- `, [`import eslintConfigPrettier from 'eslint-config-prettier';`]);
928
+ ...tseslint.configs.recommendedTypeChecked.map((cfg) =>
929
+ cfg.files
930
+ ? cfg
931
+ : {
932
+ ...cfg,
933
+ files: ['src/**/*.ts', 'src/**/*.vue'],
934
+ ignores: ['src/**/*.spec.ts'],
935
+ },
936
+ ),
937
+ {
938
+ // Re-specifies \`parser\` alongside the type-aware options in one block —
939
+ // see this branch's comment above for why splitting them fails.
940
+ files: ['**/*.vue'],
941
+ languageOptions: {
942
+ parserOptions: {
943
+ parser: await import('@typescript-eslint/parser'),
944
+ projectService: true,
945
+ tsconfigRootDir: import.meta.dirname,
946
+ extraFileExtensions: ['.vue'],
947
+ },
948
+ },
949
+ },
950
+ {
951
+ files: ['src/**/*.ts'],
952
+ ignores: ['src/**/*.spec.ts'],
953
+ languageOptions: {
954
+ parserOptions: {
955
+ projectService: true,
956
+ tsconfigRootDir: import.meta.dirname,
957
+ },
958
+ },
959
+ },
960
+ {
961
+ files: ['**/*.js', '**/*.jsx', '**/*.cjs', '**/*.mjs'],
962
+ languageOptions: {
963
+ parserOptions: {
964
+ tsconfigRootDir: dirname(import.meta.dirname),
965
+ },
966
+ },
967
+ },
968
+ {
969
+ files: ['**/*.vue'],
970
+ rules: {
971
+ 'vue/no-v-html': 'error',
972
+ 'vue/no-required-prop-with-default': 'error',
973
+ 'vue/no-template-shadow': 'error',
974
+ 'vue/require-explicit-emits': 'error',
975
+ },
976
+ },
977
+ ...storybook.configs['flat/recommended'],
978
+ {
979
+ files: ['.storybook/main.ts'],
980
+ rules: {
981
+ 'storybook/no-uninstalled-addons': [
982
+ 'error',
983
+ { packageJsonLocation: '../package.json' },
984
+ ],
985
+ },
986
+ },
987
+ `, [
988
+ `import eslintConfigPrettier from 'eslint-config-prettier';`,
989
+ `import { dirname } from 'node:path';`,
990
+ `import tseslint from 'typescript-eslint';`,
991
+ `import storybook from 'eslint-plugin-storybook';`,
992
+ ]);
674
993
  }
994
+ // ─── Strictness (lever 1, ADR-0140) ──────────────────────────────────────
995
+ // `tsconfig.base.json` does NOT exist yet at the top of this function —
996
+ // measured directly against a real `create-nx-workspace` run (not assumed
997
+ // from reading `@nx/js`'s source): `create-nx-workspace` writes only
998
+ // package.json/nx.json/.gitignore before invoking this preset, and
999
+ // `tsconfig.base.json` is written for the first time by whichever
1000
+ // framework's own `@nx/{angular,react,vue}:application` generator just ran
1001
+ // above — confirmed for all three by running each real (unmocked)
1002
+ // generator against a tree with the file deliberately absent beforehand.
1003
+ // Placing this write any earlier reproduced exactly the failure this
1004
+ // comment now guards against: `updateJson` throwing `Cannot find
1005
+ // tsconfig.base.json` at scaffold time, before a single check could run.
1006
+ // `createTreeWithEmptyWorkspace()` (used by this file's own tests)
1007
+ // pre-seeds a bare `{ compilerOptions: { paths: {} } }` tsconfig.base.json
1008
+ // regardless of generator order, which is exactly why that in-memory-tree
1009
+ // testing setup could not have caught the ordering bug on its own — see
1010
+ // this preset's mocked app generators, which now also write
1011
+ // tsconfig.base.json themselves (dedicated tests below cover the ordering
1012
+ // directly instead).
1013
+ //
1014
+ // `tsConfigBaseOptions` (`@nx/js`'s own default, written by the framework
1015
+ // generator above) pins `strict: false` deliberately — "TS 6.0 flips the
1016
+ // `strict` default to true; pin false to keep this base config's behavior
1017
+ // identical on TS 5.8 and 6.0" (that package's own comment). Measured
1018
+ // against a real generated tree, all three frameworks: `strict: false`
1019
+ // there, and the app itself already builds clean with `strict: true` —
1020
+ // nobody has fixed code for this, so flipping it costs no migration.
1021
+ console.log(`\n◇ Wiring strict TypeScript…`);
1022
+ (0, devkit_1.updateJson)(tree, 'tsconfig.base.json', (json) => {
1023
+ var _a;
1024
+ json.compilerOptions = (_a = json.compilerOptions) !== null && _a !== void 0 ? _a : {};
1025
+ json.compilerOptions.strict = true;
1026
+ return json;
1027
+ });
675
1028
  // Copy design tokens into the scaffolded app so attendees can edit them
676
1029
  // directly. They're not imported from the @atelier-ui/<fw> npm package
677
1030
  // because (a) those published packages don't ship tokens.css, and (b) a
@@ -718,6 +1071,17 @@ function presetGenerator(tree, options) {
718
1071
  // app, same purpose as atl-button.stories.*: the pattern that gets copied.
719
1072
  tree.write(`${appName}/vitest.unit.config.ts`, readTemplate(testingTemplateName(framework, 'vitest.unit.config')));
720
1073
  tree.write(`${appName}/src/test-setup.ts`, readTemplate(testingTemplateName(framework, 'test-setup')));
1074
+ // Portable stories (composeStories) let a jsdom unit test import a
1075
+ // *.stories.* file directly instead of hand-duplicating what its stories
1076
+ // already claim (ADR-0121, ADR-0141). React and Vue only:
1077
+ // @storybook/angular(-vite)@10.6.0 exports setProjectAnnotations but not
1078
+ // composeStories/composeStory (verified against the installed dist;
1079
+ // tracked upstream as storybookjs/storybook#28897) — wiring
1080
+ // setProjectAnnotations alone would register project config nothing in
1081
+ // this workspace could yet consume. See ADR-0141.
1082
+ if (framework !== 'angular') {
1083
+ tree.write(`${appName}/src/test-setup-stories.ts`, readTemplate(testingTemplateName(framework, 'test-setup-stories')));
1084
+ }
721
1085
  tree.write(`${appName}/src/atl-button.spec.${storybookOutputExt(framework)}`, readTemplate(testingTemplateName(framework, 'atl-button.spec')));
722
1086
  // The application generator (@nx/{angular,react,vue}:application, above)
723
1087
  // guarantees `${appName}/project.json` exists at this point — updateJson
@@ -788,19 +1152,30 @@ function presetGenerator(tree, options) {
788
1152
  return config;
789
1153
  });
790
1154
  storybookDevDeps[STORYBOOK_FRAMEWORK_PACKAGE[framework]] = STORYBOOK_VERSION;
791
- // @storybook/react-vite and @storybook/vue3-vite each carry their
792
- // non-vite renderer counterpart as a plain (non-peer) `dependency`, not
793
- // something npm/pnpm is told the app needs directly — but the story and
794
- // preview templates import straight from '@storybook/react' /
795
- // '@storybook/vue3' for the `Meta`/`StoryObj`/`Preview` types. That
796
- // resolves today only because npm hoists it; pnpm's stricter, non-hoisted
797
- // layout would leave the import unresolved. Angular has no matching case:
1155
+ // @storybook/react-vite and @storybook/vue3-vite each carry their non-vite
1156
+ // renderer counterpart as a plain (non-peer) `dependency` regardless of
1157
+ // whether it's declared explicitly here. It used to also be load-bearing
1158
+ // for a type import: the story and preview templates imported
1159
+ // `Meta`/`StoryObj`/`Preview` straight from '@storybook/react' /
1160
+ // '@storybook/vue3', which resolved only because npm hoists it (pnpm's
1161
+ // stricter, non-hoisted layout would have left it unresolved). ADR-0140
1162
+ // (lever 4, eslint-plugin-storybook) moved both templates to import those
1163
+ // same types from '@storybook/react-vite' / '@storybook/vue3-vite' instead
1164
+ // — the same types are re-exported there (confirmed: this monorepo's own
1165
+ // libs/react and libs/vue stories already import them from the `-vite`
1166
+ // packages) — because eslint-plugin-storybook's `no-renderer-packages` rule
1167
+ // flags importing the renderer package directly, and the scaffold's own
1168
+ // example must pass its own new linter. The explicit devDependency below
1169
+ // stays anyway: harmless (the vite package already pulls it in
1170
+ // transitively), and it remains available for anyone who wants the
1171
+ // renderer package's own types directly. Angular has no matching case:
798
1172
  // '@storybook/angular-vite' has no such counterpart to hoist, and the
799
- // angular templates import their types from '@storybook/angular-vite'
800
- // itself (see files/storybook/angular/*.template) — adding
801
- // '@storybook/angular' back here would reintroduce exactly the ERESOLVE
802
- // this generator now avoids (its peer on @angular-devkit/build-angular is
803
- // not satisfiable by a freshly scaffolded Angular 22 app).
1173
+ // angular templates already imported their types from
1174
+ // '@storybook/angular-vite' itself (see files/storybook/angular/*.template)
1175
+ // — adding '@storybook/angular' back here would reintroduce exactly the
1176
+ // ERESOLVE this generator now avoids (its peer on
1177
+ // @angular-devkit/build-angular is not satisfiable by a freshly scaffolded
1178
+ // Angular 22 app).
804
1179
  if (framework === 'react') {
805
1180
  storybookDevDeps['@storybook/react'] = STORYBOOK_VERSION;
806
1181
  }
@@ -1001,7 +1376,14 @@ Full API reference: ${SITE_URL}/llms-full.txt
1001
1376
 
1002
1377
  ## MCP Servers
1003
1378
 
1004
- The servers are pre-configured in \`.mcp.json\` and connect automatically.
1379
+ The servers are pre-configured in \`.mcp.json\` and connect automatically —
1380
+ **but only once you've trusted this folder.** The first time you open this
1381
+ workspace in Claude Code, accept the "do you trust the files in this folder?"
1382
+ prompt; until then, \`.mcp.json\` and everything in \`.claude/settings.json\`
1383
+ (the permissions allowlist, \`enableAllProjectMcpServers\`, the format-on-save
1384
+ hook) are silently ignored, and every server below has to be approved by hand
1385
+ instead. \`npm run preflight\` (see Troubleshooting) flags this if it's still
1386
+ outstanding.
1005
1387
 
1006
1388
  ${mcpSection}${angularCliMcpSection}
1007
1389
 
@@ -1049,15 +1431,15 @@ scaffold itself is already Prettier-clean — \`check:format\` passes right afte
1049
1431
 
1050
1432
  ## Apps
1051
1433
 
1052
- - \`${appName}\` — run with \`npx nx serve ${appName}\`
1434
+ - \`${appName}\` — run with \`npm start\`
1053
1435
 
1054
1436
  ## Storybook
1055
1437
 
1056
1438
  The app has its own local Storybook:
1057
1439
 
1058
- - \`${appName}\` — \`npx nx storybook ${appName}\` — http://localhost:6006
1440
+ - \`${appName}\` — \`npm run storybook\` — http://localhost:6006
1059
1441
 
1060
- Build a static Storybook (CI, hosting) with \`npx nx build-storybook ${appName}\`.
1442
+ Build a static Storybook (CI, hosting) with \`npm run build:storybook\`.
1061
1443
 
1062
1444
  Every story is also a browser-mode test (\`@storybook/addon-vitest\`). One-time setup
1063
1445
  after \`npm install\`:
@@ -1109,7 +1491,7 @@ instead come from \`@storybook/addon-mcp\` inside a *running local* Storybook
1109
1491
  deliberately not wired into \`.mcp.json\` by default, the same as this repo's own
1110
1492
  root \`.mcp.json\`, because a fixed \`localhost\` entry would fail to connect on
1111
1493
  every Claude Code session started without that Storybook already running. To use
1112
- the \`dev\` toolset: start \`npx nx storybook workshop-<fw>\` (see Storybook below),
1494
+ the \`dev\` toolset: start \`npm run storybook\` (see Storybook below),
1113
1495
  then add this to \`.mcp.json\`'s \`mcpServers\` (only while that Storybook is up):
1114
1496
 
1115
1497
  \`\`\`json
@@ -1178,6 +1560,14 @@ once after \`npm install\` — see Storybook below.
1178
1560
 
1179
1561
  ## Definition of Done
1180
1562
 
1563
+ This workspace is strict, not lenient-by-default: \`tsconfig.base.json\` has
1564
+ \`strict: true\`, and \`npm run lint\` promotes the correctness/security family of rules
1565
+ (\`eqeqeq\`, \`no-eval\`, and their kin — see \`eslint.config.mjs\` for the exact set) plus
1566
+ type-aware checks (\`no-floating-promises\`, \`no-misused-promises\`, \`await-thenable\`)
1567
+ to errors. That is the feedback loop this workspace hands an LLM, not friction to prompt
1568
+ around: code Claude Code (or you) writes has to satisfy \`npm run lint\` and \`npm run
1569
+ build\` before it is done, the same way it has to satisfy the five checks below.
1570
+
1181
1571
  A change here is done when all five of these pass:
1182
1572
 
1183
1573
  - \`npm run check:format\` — Prettier
@@ -1236,6 +1626,16 @@ file exports). The Desktop Bridge covers creation and inspection without a token
1236
1626
  if (!hasTypescript) {
1237
1627
  contractLoopDevDeps.typescript = TYPESCRIPT_VERSION;
1238
1628
  }
1629
+ // Lever 5 (ADR-0140): `typescript-eslint`, imported by each framework's own
1630
+ // eslint.config.mjs addition above (`tseslint.configs.recommendedTypeChecked`).
1631
+ // Defensive add, not the primary source — see TYPESCRIPT_ESLINT_VERSION's own
1632
+ // comment: a real generated tree for all three frameworks already carries
1633
+ // this in devDependencies, added independently by each framework's own
1634
+ // application generator.
1635
+ const typeAwareLintDevDeps = {};
1636
+ if (!existingDeps['typescript-eslint']) {
1637
+ typeAwareLintDevDeps['typescript-eslint'] = TYPESCRIPT_ESLINT_VERSION;
1638
+ }
1239
1639
  // Browser-mode Storybook tests (owner correction 2026-09-10 to ADR-0123):
1240
1640
  // the selected framework needs its own Vite plugin for the vitest browser
1241
1641
  // pipeline, added only when the framework's own application generator
@@ -1302,7 +1702,7 @@ file exports). The Desktop Bridge covers creation and inspection without a token
1302
1702
  // the contract loop's own tools + the vitest browser-mode tooling + the
1303
1703
  // unit test runner's own tooling (S5) + stylelint + prettier
1304
1704
  // (devDependencies, exact pins — see the *_VERSION constants above)
1305
- const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, deps, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, storybookDevDeps), contractLoopDevDeps), viteFrameworkDevDeps), unitTestDevDeps), stylelintDevDeps), prettierDevDeps));
1705
+ const installTask = (0, devkit_1.addDependenciesToPackageJson)(tree, deps, Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, storybookDevDeps), contractLoopDevDeps), viteFrameworkDevDeps), unitTestDevDeps), stylelintDevDeps), prettierDevDeps), typeAwareLintDevDeps));
1306
1706
  // Remove the preset package itself — create-nx-workspace adds it automatically
1307
1707
  // but it's a build-time tool and should not be in the workspace's dependencies
1308
1708
  const removePresetTask = (0, devkit_1.removeDependenciesFromPackageJson)(tree, ['@atelier-ui/create-workspace'], []);
@@ -1369,6 +1769,31 @@ file exports). The Desktop Bridge covers creation and inspection without a token
1369
1769
  // an attendee runs unmodified should not depend on remembering `--all`.
1370
1770
  pkg.scripts.format = 'prettier --write .';
1371
1771
  pkg.scripts['check:format'] = 'prettier --check .';
1772
+ // The names a JS developer already expects — no Nx knowledge required to
1773
+ // serve, build, lint, or run Storybook (owner requirement: everything
1774
+ // startable through `npm run`). The preset scaffolds exactly one app
1775
+ // (`${appName}`, ADR-0134), so these can name it literally — there is no
1776
+ // second app to disambiguate against and no placeholder for anyone to
1777
+ // fill in. `start` and `test` (below) are npm's own bare-word aliases
1778
+ // for the `start`/`test` script keys, so `npm start`/`npm test` work
1779
+ // without `run`.
1780
+ pkg.scripts.start = `nx serve ${appName}`;
1781
+ pkg.scripts.build = `nx build ${appName}`;
1782
+ pkg.scripts.lint = `nx lint ${appName}`;
1783
+ pkg.scripts.storybook = `nx storybook ${appName}`;
1784
+ pkg.scripts['build:storybook'] = `nx build-storybook ${appName}`;
1785
+ // `npm test` runs the jsdom unit tests ONLY — never the browser suite
1786
+ // (`check:stories` stays the separate, slower gate; a `test` script that
1787
+ // boots Chromium on every run is a script people stop running). This
1788
+ // delegates to `check:unit` rather than respelling `nx run-many -t test`
1789
+ // a second time: `check:unit` is already the one CLAUDE.md's Definition
1790
+ // of Done, `/verify`, and the atelier-component skill name, so it stays
1791
+ // the single source of truth for what "run the unit tests" actually
1792
+ // does, and `test` (the name `npm test` needs) just calls it. Keeping
1793
+ // `check:unit` on `run-many` rather than narrowing it to `nx test
1794
+ // ${appName}` also means it keeps working unchanged if this
1795
+ // single-app workspace ever grows a second test-bearing project.
1796
+ pkg.scripts.test = 'npm run check:unit';
1372
1797
  return pkg;
1373
1798
  });
1374
1799
  // Write .mcp.json with MCP servers for the selected framework
@@ -1433,7 +1858,7 @@ not \`latest\`, so the workshop behaves the same for everyone. Upgrade deliberat
1433
1858
  \`\`\`bash
1434
1859
  npm install
1435
1860
  npx playwright install chromium # one-time — needed by npm run check:stories
1436
- npx nx serve ${appName}
1861
+ npm start
1437
1862
  \`\`\`
1438
1863
 
1439
1864
  ## Formatting
@@ -1444,7 +1869,7 @@ Prettier-clean out of the box — \`check:format\` passes right after \`npm inst
1444
1869
 
1445
1870
  ## Storybook
1446
1871
 
1447
- - \`${appName}\` — \`npx nx storybook ${appName}\` — http://localhost:6006
1872
+ - \`${appName}\` — \`npm run storybook\` — http://localhost:6006
1448
1873
 
1449
1874
  Every story is also a browser-mode test — run them all headless in Chromium with
1450
1875
  \`npm run check:stories\`.
@@ -1472,7 +1897,10 @@ ${SKILLS_ADD_COMMAND_FOR_HUMANS}
1472
1897
 
1473
1898
  ## MCP
1474
1899
 
1475
- Claude Code MCP servers are pre-configured in \`.mcp.json\`.
1900
+ Claude Code MCP servers are pre-configured in \`.mcp.json\`. They — and the
1901
+ permissions/hooks in \`.claude/settings.json\` — only take effect once you've
1902
+ accepted Claude Code's folder-trust prompt in your first session here; run
1903
+ \`npm run preflight\` if you're not sure whether that's happened yet.
1476
1904
  Browse components at ${SITE_URL}
1477
1905
  `);
1478
1906
  // ─── Claude Code project setup ────────────────────────────────────────────
@@ -1502,20 +1930,41 @@ Browse components at ${SITE_URL}
1502
1930
  enableAllProjectMcpServers: true,
1503
1931
  permissions: {
1504
1932
  allow: [
1505
- // The Nx CLI — `npx nx serve/storybook/build-storybook <app>`, all
1506
- // named in the CLAUDE.md this preset writes above.
1933
+ // The Nx CLI directly. CLAUDE.md no longer tells an attendee to type
1934
+ // `npx nx serve/storybook/build-storybook <app>` by hand — those are
1935
+ // now the `start`/`storybook`/`build:storybook` npm scripts below —
1936
+ // but the wildcard stays for the exploratory/diagnostic `nx`
1937
+ // subcommands the docs still do use directly (e.g. `nx show
1938
+ // projects`, troubleshooting.astro's "which environment am I in"
1939
+ // check) and anything an attendee or agent reaches for beyond the
1940
+ // fixed script set.
1507
1941
  'Bash(npx nx *)',
1508
- // The eight npm scripts this preset writes to package.json
1942
+ // The fourteen npm scripts this preset writes to package.json
1509
1943
  // (preflight, check:contracts, figma:snapshot, check:unit,
1510
- // check:stories, check:stylelint, format, check:format) — one
1511
- // wildcard entry rather than eight separate ones, since this
1512
- // workspace's package.json carries exactly this fixed,
1513
- // generator-written script set (a workshop attendee adding a script
1514
- // of their own opts into this same allowance by definition, having
1515
- // already edited package.json by hand).
1944
+ // check:stories, check:stylelint, format, check:format, start,
1945
+ // build, lint, storybook, build:storybook, test) — one wildcard
1946
+ // entry rather than fourteen separate ones, since this workspace's
1947
+ // package.json carries exactly this fixed, generator-written script
1948
+ // set (a workshop attendee adding a script of their own opts into
1949
+ // this same allowance by definition, having already edited
1950
+ // package.json by hand).
1516
1951
  'Bash(npm run *)',
1952
+ // `npm run *` above does not match npm's own bare-word aliases —
1953
+ // `npm start` and `npm test` are literally different argv than `npm
1954
+ // run start` / `npm run test`, even though they resolve to the same
1955
+ // script. CLAUDE.md and README tell an attendee to type the bare
1956
+ // form for exactly these two (the names a JS developer already
1957
+ // reaches for without `run`), so both need their own entry or every
1958
+ // first `npm start`/`npm test` would stop for approval regardless of
1959
+ // the wildcard above.
1960
+ 'Bash(npm start)',
1961
+ 'Bash(npm test)',
1517
1962
  // The Storybook CLI itself — `dev`/`build` only, the two
1518
- // subcommands CLAUDE.md/README actually tell an attendee to run.
1963
+ // subcommands the `storybook`/`build:storybook` npm scripts above
1964
+ // shell out to under the hood (each app's own project.json target
1965
+ // is a literal `npx storybook dev|build ...` `nx:run-commands`
1966
+ // string) — kept allowed directly too, for anyone who bypasses the
1967
+ // npm script to pass an extra flag by hand.
1519
1968
  // Deliberately NOT a bare `Bash(npx storybook *)`: this repo's own
1520
1969
  // AGENTS.md warns against running `storybook automigrate`/`upgrade`
1521
1970
  // against the pinned 10.6.0 setup (it silently proposes bumping