@hublo/sentinel 1.7.0-alpha.2 → 1.7.0-alpha.4

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.
@@ -12,12 +12,13 @@ import {
12
12
  presetNotInstalledYet,
13
13
  registerAdapters,
14
14
  resolve
15
- } from "../chunk-EETHWJBF.js";
15
+ } from "../chunk-CTSBAGVM.js";
16
+ import "../chunk-ETVNZUU4.js";
16
17
  import {
17
18
  resolveContext,
18
19
  separateToolArgs
19
- } from "../chunk-Z3JI7ZWX.js";
20
- import "../chunk-4UUL4SEW.js";
20
+ } from "../chunk-P6KTBQ2Q.js";
21
+ import "../chunk-ZFG6P27V.js";
21
22
  import {
22
23
  ensureWorkspacePrep,
23
24
  findWorkspaceRoot,
@@ -593,7 +594,7 @@ async function runMigrate(ctx) {
593
594
  );
594
595
  }
595
596
  if (!ctx.targets.includes("typescript")) return 1;
596
- const { migrateModule } = await import("../migrate-NI33SXZD.js");
597
+ const { migrateModule } = await import("../migrate-W5VLHDT5.js");
597
598
  const migration = migrateModule(module.root, {
598
599
  write: !ctx.dryRun,
599
600
  workspaceRoot: findWorkspaceRoot(module.root) ?? module.root
@@ -646,7 +647,7 @@ async function runValidate(ctx) {
646
647
  );
647
648
  }
648
649
  if (!ctx.targets.includes("test")) return 1;
649
- const { validateModuleTests } = await import("../validate-LRHF63AW.js");
650
+ const { validateModuleTests } = await import("../validate-4V3EGTXN.js");
650
651
  const outcomes = modules.flatMap(
651
652
  (module) => validateModuleTests(module.name, module.root)
652
653
  );
@@ -698,7 +699,15 @@ var RULE_BLOCKS = [
698
699
  // The other direction, and listed for the same reason: a rule a module adds to its lint
699
700
  // preset is not drift, so nothing else on the row would ever show it was there.
700
701
  { key: "added", label: "added by the module (kept by --init, not drift):" },
701
- { key: "addedConfig", label: "config added by the module (kept by --init, not drift):" }
702
+ { key: "addedConfig", label: "config added by the module (kept by --init, not drift):" },
703
+ // TypeScript's two: an option the preset took over from the base, set to another value by the
704
+ // module (kept, so `conformant` cannot show it), and the debt a migrated module takes from
705
+ // `legacy`. Both are this module departing from the standard, named.
706
+ {
707
+ key: "standardOverrides",
708
+ label: "differs from the repo standard (kept by --init, not drift):"
709
+ },
710
+ { key: "legacyCompromises", label: "inherited compromises (debt to remove):" }
702
711
  ];
703
712
  var MAX_INLINE_WIDTH = 60;
704
713
  function renderValue(key, value, p) {
@@ -1,20 +1,23 @@
1
1
  import {
2
- ALWAYS_LOCAL_KEYS,
2
+ DEFERRED_RULES,
3
+ LEGACY_ENTRY,
4
+ SHIPPED_PRESETS,
5
+ appliedOptions,
6
+ extendsList,
7
+ hasShippedPreset,
8
+ raisedFromBase,
9
+ tsLegacyLayer,
10
+ tsPresetFor
11
+ } from "./chunk-ETVNZUU4.js";
12
+ import {
3
13
  BaseAdapter,
4
14
  ESLINT_CONFIG_FILES,
5
- FORMAT_CONFIG_FILE,
6
- FORMAT_DEFAULT_IGNORES,
7
- FORMAT_SCRIPT_NAME,
8
15
  LINT_BASELINE_FILE,
9
16
  LINT_BASELINE_SPECIFIER,
10
17
  LINT_CONFIG_FILE,
11
18
  LINT_MEASURE_FILE,
12
19
  LINT_PRESETS,
13
20
  LINT_SCRIPT_NAME,
14
- OWNED_WHEN_SET_KEYS,
15
- PERMITTED_LOCAL_KEYS,
16
- PRETTIER_CONFIG_FILES,
17
- PROVENANCE_KEY,
18
21
  RESOLVABLE_EXTENSIONS,
19
22
  VitestAdapter,
20
23
  adoptedPackageName,
@@ -26,9 +29,6 @@ import {
26
29
  downgradedFor,
27
30
  extendsWithBaseline,
28
31
  extendsWithPreset,
29
- formatPresetFor,
30
- formatPresetName,
31
- formatTargets,
32
32
  governedRules,
33
33
  hasLintPreset,
34
34
  heldRules,
@@ -42,7 +42,6 @@ import {
42
42
  moduleOwnBlocks,
43
43
  moduleScripts,
44
44
  nxTargetOperations,
45
- oxfmtRejects,
46
45
  oxlintPath,
47
46
  oxlintSearchPath,
48
47
  presetNameFromPath,
@@ -52,26 +51,38 @@ import {
52
51
  presetVariant,
53
52
  projectTargets,
54
53
  readAdoption,
55
- readFormatAdoption,
56
54
  readLintAdoption,
57
55
  readModuleAdditions,
58
56
  renderBaseline,
59
57
  resolveConfigTarget,
60
- resolveOxfmt,
61
58
  resolveOxlint,
62
59
  rewriteToolchainImports,
63
60
  selfCommand,
64
61
  splitToolArgs,
65
62
  uncoveredFor,
66
- walk,
67
- writtenFileFormatter
68
- } from "./chunk-Z3JI7ZWX.js";
63
+ walk
64
+ } from "./chunk-P6KTBQ2Q.js";
69
65
  import {
66
+ ALWAYS_LOCAL_KEYS,
67
+ FORMAT_CONFIG_FILE,
68
+ FORMAT_DEFAULT_IGNORES,
69
+ FORMAT_SCRIPT_NAME,
70
+ OWNED_WHEN_SET_KEYS,
71
+ PERMITTED_LOCAL_KEYS,
72
+ PRETTIER_CONFIG_FILES,
73
+ PROVENANCE_KEY,
70
74
  binFromOwnInstall,
71
75
  binSearchPath,
76
+ formatPresetFor,
77
+ formatPresetName,
78
+ formatTargets,
79
+ oxfmtRejects,
80
+ readFormatAdoption,
72
81
  resolveBin,
73
- scriptPath
74
- } from "./chunk-4UUL4SEW.js";
82
+ resolveOxfmt,
83
+ scriptPath,
84
+ writtenFileFormatter
85
+ } from "./chunk-ZFG6P27V.js";
75
86
  import {
76
87
  DEFAULT_MAX_DIAGNOSTICS,
77
88
  WORKSPACE_ROOT_MARKER,
@@ -3122,7 +3133,7 @@ var OxfmtAdapter = class extends BaseAdapter {
3122
3133
  const adoption = readFormatAdoption(ctx.cwd);
3123
3134
  const preset = formatPresetFor(adoption.preset ?? DEFAULT_PRESET);
3124
3135
  const options = { ...preset, ...adoption.local };
3125
- const describe2 = (value) => typeof value === "string" ? value : JSON.stringify(value);
3136
+ const describe3 = (value) => typeof value === "string" ? value : JSON.stringify(value);
3126
3137
  return {
3127
3138
  runner: "oxfmt",
3128
3139
  configFile: adoption.configFile,
@@ -3131,7 +3142,7 @@ var OxfmtAdapter = class extends BaseAdapter {
3131
3142
  options,
3132
3143
  overrides: Object.entries(adoption.local).filter(([key]) => !ALWAYS_LOCAL_KEYS.includes(key)).map(([key, value]) => ({
3133
3144
  rule: key,
3134
- reason: key in preset ? `${describe2(value)}, where the ${adoption.preset ?? DEFAULT_PRESET} preset says ${describe2(preset[key])}` : `${describe2(value)}, which the preset does not set`
3145
+ reason: key in preset ? `${describe3(value)}, where the ${adoption.preset ?? DEFAULT_PRESET} preset says ${describe3(preset[key])}` : `${describe3(value)}, which the preset does not set`
3135
3146
  })),
3136
3147
  // Which files this module does not format at all. A long list here is worth a look:
3137
3148
  // it is the quiet way a module stops being covered.
@@ -3377,8 +3388,8 @@ function ruleCount(cwd, specifier) {
3377
3388
  return void 0;
3378
3389
  }
3379
3390
  }
3380
- function extraLayers(cwd, extendsList) {
3381
- return extendsList.filter((entry) => !isSentinelPreset(entry) && entry !== LINT_BASELINE_SPECIFIER).map((entry) => {
3391
+ function extraLayers(cwd, extendsList2) {
3392
+ return extendsList2.filter((entry) => !isSentinelPreset(entry) && entry !== LINT_BASELINE_SPECIFIER).map((entry) => {
3382
3393
  const count = ruleCount(cwd, entry);
3383
3394
  return {
3384
3395
  rule: entry,
@@ -8332,161 +8343,6 @@ import { existsSync as existsSync21, readFileSync as readFileSync23 } from "node
8332
8343
  import { createRequire } from "node:module";
8333
8344
  import { join as join33 } from "node:path";
8334
8345
 
8335
- // src/roles/typescript/presets/nest.json
8336
- var nest_default = {
8337
- compilerOptions: {
8338
- module: "esnext",
8339
- moduleResolution: "bundler",
8340
- types: ["node"],
8341
- experimentalDecorators: true,
8342
- emitDecoratorMetadata: true,
8343
- declaration: true,
8344
- sourceMap: true,
8345
- importHelpers: true,
8346
- target: "es2021",
8347
- lib: ["es2023", "dom"]
8348
- },
8349
- notes: {
8350
- module: "the backends are webpack-bundled and tsc only typechecks, so the module format is the bundler's concern; `bundler` resolution is what the repo already uses, and the only Node-friendly option TS7 still accepts since it removed classic `node`",
8351
- target: "raised from tsconfig.base.json (sentinel#147) with the value every nest module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
8352
- lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
8353
- importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base"
8354
- },
8355
- fromBase: ["importHelpers", "target", "lib"]
8356
- };
8357
-
8358
- // src/roles/typescript/presets/node.json
8359
- var node_default = {
8360
- compilerOptions: {
8361
- module: "esnext",
8362
- moduleResolution: "bundler",
8363
- types: ["node"],
8364
- declaration: true,
8365
- importHelpers: true,
8366
- target: "es2021",
8367
- lib: ["es2023", "dom"],
8368
- sourceMap: true
8369
- },
8370
- notes: {
8371
- module: "esnext/bundler like the react and nest presets, matching a monorepo whose libs are bundler-resolved in practice. NOT NodeNext: that would force its stricter ESM rules onto libs the repo resolves through a bundler",
8372
- target: "raised from tsconfig.base.json (sentinel#147) with the value every node module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
8373
- lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
8374
- importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base",
8375
- sourceMap: "raised from tsconfig.base.json (sentinel#147): `true` in every node module, through the base; nest already set it"
8376
- },
8377
- fromBase: ["importHelpers", "target", "lib", "sourceMap"]
8378
- };
8379
-
8380
- // src/roles/typescript/presets/react.json
8381
- var react_default = {
8382
- compilerOptions: {
8383
- target: "ES2023",
8384
- lib: ["ES2023", "DOM", "DOM.Iterable"],
8385
- module: "ESNext",
8386
- moduleResolution: "bundler",
8387
- jsx: "react-jsx",
8388
- useDefineForClassFields: true,
8389
- isolatedModules: true,
8390
- moduleDetection: "force",
8391
- noEmit: true,
8392
- noUncheckedSideEffectImports: true
8393
- },
8394
- notes: {
8395
- noEmit: "vite owns the build; tsc only typechecks here"
8396
- }
8397
- };
8398
-
8399
- // src/roles/typescript/presets/shared.json
8400
- var shared_default2 = {
8401
- $schema: "https://json.schemastore.org/tsconfig",
8402
- compilerOptions: {
8403
- strict: true,
8404
- noFallthroughCasesInSwitch: true,
8405
- forceConsistentCasingInFileNames: true,
8406
- esModuleInterop: true,
8407
- skipLibCheck: true,
8408
- verbatimModuleSyntax: true,
8409
- resolveJsonModule: true,
8410
- skipDefaultLibCheck: true
8411
- },
8412
- deferred: {
8413
- noImplicitAny: {
8414
- phase: 2,
8415
- reason: "the implicit-any migration (TS70xx)"
8416
- },
8417
- noUnusedLocals: {
8418
- phase: 2,
8419
- reason: "unused-local cleanup (TS6133)"
8420
- },
8421
- noUnusedParameters: {
8422
- phase: 2,
8423
- reason: "unused-parameter cleanup (TS6133)"
8424
- }
8425
- },
8426
- notes: {
8427
- verbatimModuleSyntax: "raised from tsconfig.base.json (HUB-43866, sentinel#147): every sentinel module applied `true` through the base, so a module that stops extending it keeps it. A module that sets `false` itself keeps its own value, and `--init` does not strip it (see fromBase)",
8428
- resolveJsonModule: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base",
8429
- skipDefaultLibCheck: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base"
8430
- },
8431
- fromBase: ["verbatimModuleSyntax", "resolveJsonModule", "skipDefaultLibCheck"]
8432
- };
8433
-
8434
- // src/roles/typescript/preset-data.ts
8435
- var SHARED = shared_default2;
8436
- var LAYERS = {
8437
- nest: nest_default,
8438
- node: node_default,
8439
- react: react_default
8440
- };
8441
- var SHIPPED_PRESETS = Object.keys(LAYERS).sort();
8442
- var DEFERRED_RULES = Object.entries(SHARED.deferred ?? {}).map(([rule, entry]) => ({ rule, phase: entry.phase, reason: entry.reason })).sort((left, right) => left.rule.localeCompare(right.rule));
8443
- function validate() {
8444
- for (const { rule, phase, reason } of DEFERRED_RULES) {
8445
- if (!Number.isInteger(phase) || phase < 2) {
8446
- throw new Error(
8447
- `deferred rule "${rule}" has phase ${phase}; a deferred rule is scheduled for phase 2 or later`
8448
- );
8449
- }
8450
- if (reason.trim() === "") {
8451
- throw new Error(
8452
- `deferred rule "${rule}" has no reason; --inspect reports it and would say nothing`
8453
- );
8454
- }
8455
- if (rule in SHARED.compilerOptions) {
8456
- throw new Error(
8457
- `"${rule}" is deferred and also set by the shared layer; it would be announced as not enforced while being enforced`
8458
- );
8459
- }
8460
- for (const [preset, layer] of Object.entries(LAYERS)) {
8461
- if (layer && rule in layer.compilerOptions) {
8462
- throw new Error(
8463
- `"${rule}" is deferred and also set by the ${preset} preset; it would be announced as not enforced while being enforced`
8464
- );
8465
- }
8466
- }
8467
- }
8468
- }
8469
- validate();
8470
- function raisedFromBase(preset) {
8471
- return [...SHARED.fromBase ?? [], ...LAYERS[preset]?.fromBase ?? []];
8472
- }
8473
- function hasShippedPreset(preset) {
8474
- return preset in LAYERS;
8475
- }
8476
- function tsPresetFor(preset) {
8477
- const layer = LAYERS[preset];
8478
- if (!layer) throw new Error(`no TypeScript preset ships for preset "${preset}"`);
8479
- return {
8480
- ...SHARED.$schema === void 0 ? {} : { $schema: SHARED.$schema },
8481
- compilerOptions: { ...SHARED.compilerOptions, ...layer.compilerOptions }
8482
- };
8483
- }
8484
-
8485
- // src/roles/typescript/phased-rules.ts
8486
- function deferredRuleNames2() {
8487
- return deferredRuleNames(DEFERRED_RULES);
8488
- }
8489
-
8490
8346
  // src/roles/typescript/config-policy.ts
8491
8347
  var PERMITTED_COMPILER_OPTIONS = [
8492
8348
  "paths",
@@ -8524,6 +8380,39 @@ function localOnlyCompilerOptions(compilerOptions, preset) {
8524
8380
  );
8525
8381
  return [...localOnlyKeys(compilerOptions, PERMITTED_COMPILER_OPTIONS, sets), ...keptOverrides];
8526
8382
  }
8383
+ var describe2 = (value) => typeof value === "string" ? value : JSON.stringify(value);
8384
+ function standardOverrides(compilerOptions, preset) {
8385
+ if (preset === void 0 || !hasShippedPreset(preset)) return [];
8386
+ const presetOptions = tsPresetFor(preset).compilerOptions;
8387
+ return raisedFromBase(preset).filter(
8388
+ (key) => compilerOptions !== void 0 && key in compilerOptions && !sameOptionValue(compilerOptions[key], presetOptions[key])
8389
+ ).map((key) => ({
8390
+ rule: key,
8391
+ value: compilerOptions?.[key],
8392
+ standard: presetOptions[key],
8393
+ reason: `${describe2(compilerOptions?.[key])}, where the ${preset} preset says ${describe2(presetOptions[key])}`
8394
+ }));
8395
+ }
8396
+ function legacyCompromises(compilerOptions, preset) {
8397
+ const stack = preset !== void 0 && hasShippedPreset(preset) ? tsPresetFor(preset).compilerOptions : {};
8398
+ const applied = appliedOptions({ compilerOptions: stack });
8399
+ return Object.entries(tsLegacyLayer().compilerOptions).filter(
8400
+ ([key]) => !(key in stack) && !(compilerOptions !== void 0 && key in compilerOptions)
8401
+ ).map(([key, value]) => {
8402
+ const standard = applied.has(key) ? JSON.parse(applied.get(key) ?? "null") : null;
8403
+ return {
8404
+ rule: key,
8405
+ value,
8406
+ standard,
8407
+ reason: `${describe2(value)}, ${standard === null ? "which the standard leaves to tsc" : `where the standard says ${describe2(standard)}`}, inherited from ${LEGACY_ENTRY}`
8408
+ };
8409
+ });
8410
+ }
8411
+
8412
+ // src/roles/typescript/phased-rules.ts
8413
+ function deferredRuleNames2() {
8414
+ return deferredRuleNames(DEFERRED_RULES);
8415
+ }
8527
8416
 
8528
8417
  // src/roles/typescript/resolve-tsconfig-target.ts
8529
8418
  var TSCONFIG_CANDIDATES = ["tsconfig.app.json", "tsconfig.json"];
@@ -8936,14 +8825,31 @@ var TscAdapter = class _TscAdapter extends BaseAdapter {
8936
8825
  */
8937
8826
  async inspect(ctx) {
8938
8827
  const target = resolveTsconfigTarget(ctx.cwd);
8828
+ const { preset } = readTsconfigAdoption(ctx.cwd);
8829
+ const stack = preset === null ? void 0 : preset.slice(preset.lastIndexOf("/") + 1);
8830
+ const config = this.readConfig(join33(ctx.cwd, target.path));
8831
+ const options = config?.compilerOptions;
8832
+ const overrides = standardOverrides(options, stack);
8833
+ const legacy = config !== void 0 && extendsList(config).includes(LEGACY_ENTRY) ? legacyCompromises(options, stack) : [];
8939
8834
  return {
8940
8835
  runner: "tsc",
8941
8836
  configFile: target.path,
8942
8837
  configState: target.reason,
8943
8838
  phase: 1,
8944
- deferred: DEFERRED_RULES
8839
+ deferred: DEFERRED_RULES,
8840
+ ...overrides.length > 0 ? { standardOverrides: overrides } : {},
8841
+ ...legacy.length > 0 ? { legacyCompromises: legacy } : {}
8945
8842
  };
8946
8843
  }
8844
+ /** A tsconfig as written, or undefined when it is missing or not readable as JSONC. */
8845
+ readConfig(file) {
8846
+ if (!existsSync21(file)) return void 0;
8847
+ try {
8848
+ return parseJsonc(readFileSync23(file, "utf8"), file);
8849
+ } catch {
8850
+ return void 0;
8851
+ }
8852
+ }
8947
8853
  /**
8948
8854
  * Adoption + conformity from the committed tsconfig, for `--status`. No tsc run and
8949
8855
  * no preset guessing: reads the actual `extends` chain, so a workspace-wide scan is
@@ -0,0 +1,288 @@
1
+ // src/roles/typescript/compare.ts
2
+ var STRICT_FAMILY = [
3
+ "alwaysStrict",
4
+ "noImplicitAny",
5
+ "noImplicitThis",
6
+ "strictBindCallApply",
7
+ "strictBuiltinIteratorReturn",
8
+ "strictFunctionTypes",
9
+ "strictNullChecks",
10
+ "strictPropertyInitialization",
11
+ "useUnknownInCatchVariables"
12
+ ];
13
+ var CASE_INSENSITIVE = /* @__PURE__ */ new Set([
14
+ "jsx",
15
+ "lib",
16
+ "module",
17
+ "moduleDetection",
18
+ "moduleResolution",
19
+ "target"
20
+ ]);
21
+ function targetYear(target) {
22
+ const name = typeof target === "string" ? target.toLowerCase() : "es5";
23
+ if (name === "esnext") return Number.MAX_SAFE_INTEGER;
24
+ const year = Number(name.replace(/^es/, ""));
25
+ return Number.isFinite(year) ? year : 5;
26
+ }
27
+ function comparable(key, value) {
28
+ const json = JSON.stringify(value) ?? "undefined";
29
+ return CASE_INSENSITIVE.has(key) ? json.toLowerCase() : json;
30
+ }
31
+ function appliedOptions(config) {
32
+ const options = new Map(Object.entries(config.compilerOptions ?? {}));
33
+ options.delete("paths");
34
+ const derive = (key, value) => {
35
+ if (!options.has(key)) options.set(key, value);
36
+ };
37
+ if (options.get("strict") === true) for (const key of STRICT_FAMILY) derive(key, true);
38
+ derive("allowJs", false);
39
+ if (options.get("esModuleInterop") === true) derive("allowSyntheticDefaultImports", true);
40
+ if (options.get("verbatimModuleSyntax") === true) derive("isolatedModules", true);
41
+ if (options.get("isolatedModules") === true) derive("preserveConstEnums", true);
42
+ derive("useDefineForClassFields", targetYear(options.get("target")) >= 2022);
43
+ return new Map([...options].map(([key, value]) => [key, comparable(key, value)]));
44
+ }
45
+ function diffConfigs(before, after) {
46
+ const was = appliedOptions(before);
47
+ const now = appliedOptions(after);
48
+ const differences = [];
49
+ for (const key of /* @__PURE__ */ new Set([...was.keys(), ...now.keys()])) {
50
+ if (was.get(key) !== now.get(key)) {
51
+ differences.push({ key: `compilerOptions.${key}`, before: was.get(key), after: now.get(key) });
52
+ }
53
+ }
54
+ for (const key of /* @__PURE__ */ new Set([...Object.keys(before), ...Object.keys(after)])) {
55
+ if (key === "compilerOptions") continue;
56
+ const left = JSON.stringify(before[key]);
57
+ const right = JSON.stringify(after[key]);
58
+ if (left !== right) differences.push({ key, before: left, after: right });
59
+ }
60
+ return differences;
61
+ }
62
+ function remainder(effective, layers, ownKeys) {
63
+ const applied = appliedOptions(effective);
64
+ const given = appliedOptions(layers);
65
+ const written = [];
66
+ for (const [key, value] of applied) {
67
+ if (ownKeys.has(key) || given.get(key) === value) continue;
68
+ written.push({ key, value: effective.compilerOptions?.[key] ?? JSON.parse(value) });
69
+ }
70
+ return written;
71
+ }
72
+
73
+ // src/roles/typescript/presets/legacy.json
74
+ var legacy_default = {
75
+ $schema: "https://json.schemastore.org/tsconfig",
76
+ compilerOptions: {
77
+ noImplicitAny: false,
78
+ noImplicitThis: false,
79
+ strictBindCallApply: false,
80
+ strictFunctionTypes: false,
81
+ strictPropertyInitialization: false,
82
+ useUnknownInCatchVariables: false,
83
+ ignoreDeprecations: "6.0",
84
+ experimentalDecorators: true,
85
+ emitDecoratorMetadata: true,
86
+ declaration: false,
87
+ types: ["vite/client", "@types/segment-analytics"],
88
+ importHelpers: true,
89
+ sourceMap: true
90
+ },
91
+ notes: {
92
+ purpose: "the compromises tsconfig.base.json applied to every module, kept in one place so a module that stops extending the base loses nothing (sentinel#147). Placed LEFT of the stack preset, where the base was, so the stack preset keeps winning wherever both set an option",
93
+ who: "added only by `--migrate --typescript`, never by `--init`: a new module is born with the full strict set, and a module that has paid this debt removes one `extends` line",
94
+ strict: "the six opt-outs below turn off parts of `strict`, which the shared layer sets; the base had them for every module",
95
+ ignoreDeprecations: "temporary by nature: it silences the TypeScript 6 deprecations the base still relies on",
96
+ react: "`declaration`, `types`, the decorator flags, `importHelpers` and `sourceMap` are what the base gave react modules that the react preset does not set. `types` moves whole: an array is replaced, never merged, so splitting it between two presets would lose an entry",
97
+ types: "`vite/client` and `@types/segment-analytics` are the base's, kept as they were: on react they apply, on nest and node the stack preset's `types: [node]` wins, exactly as it did over the base. Not a choice for a backend, a copy of the debt, to clean up with it"
98
+ }
99
+ };
100
+
101
+ // src/roles/typescript/presets/nest.json
102
+ var nest_default = {
103
+ compilerOptions: {
104
+ module: "esnext",
105
+ moduleResolution: "bundler",
106
+ types: ["node"],
107
+ experimentalDecorators: true,
108
+ emitDecoratorMetadata: true,
109
+ declaration: true,
110
+ sourceMap: true,
111
+ importHelpers: true,
112
+ target: "es2021",
113
+ lib: ["es2023", "dom"]
114
+ },
115
+ notes: {
116
+ module: "the backends are webpack-bundled and tsc only typechecks, so the module format is the bundler's concern; `bundler` resolution is what the repo already uses, and the only Node-friendly option TS7 still accepts since it removed classic `node`",
117
+ target: "raised from tsconfig.base.json (sentinel#147) with the value every nest module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
118
+ lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
119
+ importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base"
120
+ },
121
+ fromBase: ["importHelpers", "target", "lib"]
122
+ };
123
+
124
+ // src/roles/typescript/presets/node.json
125
+ var node_default = {
126
+ compilerOptions: {
127
+ module: "esnext",
128
+ moduleResolution: "bundler",
129
+ types: ["node"],
130
+ declaration: true,
131
+ importHelpers: true,
132
+ target: "es2021",
133
+ lib: ["es2023", "dom"],
134
+ sourceMap: true
135
+ },
136
+ notes: {
137
+ module: "esnext/bundler like the react and nest presets, matching a monorepo whose libs are bundler-resolved in practice. NOT NodeNext: that would force its stricter ESM rules onto libs the repo resolves through a bundler",
138
+ target: "raised from tsconfig.base.json (sentinel#147) with the value every node module already applied: `es2021`. Same value, so `useDefineForClassFields` does not flip (TS2612), which is why it was left to the base before. Moving it to a newer target is its own change, measured on its own",
139
+ lib: "raised from tsconfig.base.json (sentinel#147) as the base had it, DOM included: narrowing `lib` drops DOM types some modules use (GLfloat), so that is its own change",
140
+ importHelpers: "raised from tsconfig.base.json (sentinel#147): `true` in every module of this stack, through the base",
141
+ sourceMap: "raised from tsconfig.base.json (sentinel#147): `true` in every node module, through the base; nest already set it"
142
+ },
143
+ fromBase: ["importHelpers", "target", "lib", "sourceMap"]
144
+ };
145
+
146
+ // src/roles/typescript/presets/react.json
147
+ var react_default = {
148
+ compilerOptions: {
149
+ target: "ES2023",
150
+ lib: ["ES2023", "DOM", "DOM.Iterable"],
151
+ module: "ESNext",
152
+ moduleResolution: "bundler",
153
+ jsx: "react-jsx",
154
+ useDefineForClassFields: true,
155
+ isolatedModules: true,
156
+ moduleDetection: "force",
157
+ noEmit: true,
158
+ noUncheckedSideEffectImports: true
159
+ },
160
+ notes: {
161
+ noEmit: "vite owns the build; tsc only typechecks here"
162
+ }
163
+ };
164
+
165
+ // src/roles/typescript/presets/shared.json
166
+ var shared_default = {
167
+ $schema: "https://json.schemastore.org/tsconfig",
168
+ compilerOptions: {
169
+ strict: true,
170
+ noFallthroughCasesInSwitch: true,
171
+ forceConsistentCasingInFileNames: true,
172
+ esModuleInterop: true,
173
+ skipLibCheck: true,
174
+ verbatimModuleSyntax: true,
175
+ resolveJsonModule: true,
176
+ skipDefaultLibCheck: true
177
+ },
178
+ deferred: {
179
+ noImplicitAny: {
180
+ phase: 2,
181
+ reason: "the implicit-any migration (TS70xx)"
182
+ },
183
+ noUnusedLocals: {
184
+ phase: 2,
185
+ reason: "unused-local cleanup (TS6133)"
186
+ },
187
+ noUnusedParameters: {
188
+ phase: 2,
189
+ reason: "unused-parameter cleanup (TS6133)"
190
+ }
191
+ },
192
+ notes: {
193
+ verbatimModuleSyntax: "raised from tsconfig.base.json (HUB-43866, sentinel#147): every sentinel module applied `true` through the base, so a module that stops extending it keeps it. A module that sets `false` itself keeps its own value, and `--init` does not strip it (see fromBase)",
194
+ resolveJsonModule: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base",
195
+ skipDefaultLibCheck: "raised from tsconfig.base.json (sentinel#147): `true` in all 113 sentinel modules, through the base"
196
+ },
197
+ fromBase: ["verbatimModuleSyntax", "resolveJsonModule", "skipDefaultLibCheck"]
198
+ };
199
+
200
+ // src/roles/typescript/preset-data.ts
201
+ var SHARED = shared_default;
202
+ var LAYERS = {
203
+ nest: nest_default,
204
+ node: node_default,
205
+ react: react_default
206
+ };
207
+ var LEGACY = legacy_default;
208
+ var LEGACY_LAYER = "legacy";
209
+ var SHIPPED_PRESETS = Object.keys(LAYERS).sort();
210
+ var DEFERRED_RULES = Object.entries(SHARED.deferred ?? {}).map(([rule, entry]) => ({ rule, phase: entry.phase, reason: entry.reason })).sort((left, right) => left.rule.localeCompare(right.rule));
211
+ function validate() {
212
+ for (const { rule, phase, reason } of DEFERRED_RULES) {
213
+ if (!Number.isInteger(phase) || phase < 2) {
214
+ throw new Error(
215
+ `deferred rule "${rule}" has phase ${phase}; a deferred rule is scheduled for phase 2 or later`
216
+ );
217
+ }
218
+ if (reason.trim() === "") {
219
+ throw new Error(
220
+ `deferred rule "${rule}" has no reason; --inspect reports it and would say nothing`
221
+ );
222
+ }
223
+ if (rule in SHARED.compilerOptions) {
224
+ throw new Error(
225
+ `"${rule}" is deferred and also set by the shared layer; it would be announced as not enforced while being enforced`
226
+ );
227
+ }
228
+ for (const [preset, layer] of Object.entries(LAYERS)) {
229
+ if (layer && rule in layer.compilerOptions) {
230
+ throw new Error(
231
+ `"${rule}" is deferred and also set by the ${preset} preset; it would be announced as not enforced while being enforced`
232
+ );
233
+ }
234
+ }
235
+ }
236
+ }
237
+ validate();
238
+ function tsLegacyLayer() {
239
+ return {
240
+ ...LEGACY.$schema === void 0 ? {} : { $schema: LEGACY.$schema },
241
+ compilerOptions: { ...LEGACY.compilerOptions }
242
+ };
243
+ }
244
+ function raisedFromBase(preset) {
245
+ return [...SHARED.fromBase ?? [], ...LAYERS[preset]?.fromBase ?? []];
246
+ }
247
+ function hasShippedPreset(preset) {
248
+ return preset in LAYERS;
249
+ }
250
+ function tsPresetFor(preset) {
251
+ const layer = LAYERS[preset];
252
+ if (!layer) throw new Error(`no TypeScript preset ships for preset "${preset}"`);
253
+ return {
254
+ ...SHARED.$schema === void 0 ? {} : { $schema: SHARED.$schema },
255
+ compilerOptions: { ...SHARED.compilerOptions, ...layer.compilerOptions }
256
+ };
257
+ }
258
+
259
+ // src/roles/typescript/legacy.ts
260
+ var BASE_FILE = "tsconfig.base.json";
261
+ var LEGACY_ENTRY = `@hublo/sentinel/typescript/${LEGACY_LAYER}`;
262
+ function isBaseEntry(entry) {
263
+ return entry === BASE_FILE || entry.endsWith(`/${BASE_FILE}`);
264
+ }
265
+ function isStackPresetEntry(entry) {
266
+ return /^@hublo\/sentinel\/(?:typescript|tsconfig)\/[a-z-]+$/.test(entry) && !entry.endsWith(`/${LEGACY_LAYER}`);
267
+ }
268
+ function extendsList(config) {
269
+ const value = config.extends;
270
+ if (typeof value === "string") return [value];
271
+ return Array.isArray(value) ? value.filter((entry) => typeof entry === "string") : [];
272
+ }
273
+
274
+ export {
275
+ appliedOptions,
276
+ diffConfigs,
277
+ remainder,
278
+ SHIPPED_PRESETS,
279
+ DEFERRED_RULES,
280
+ tsLegacyLayer,
281
+ raisedFromBase,
282
+ hasShippedPreset,
283
+ tsPresetFor,
284
+ LEGACY_ENTRY,
285
+ isBaseEntry,
286
+ isStackPresetEntry,
287
+ extendsList
288
+ };