@trackunit/eslint-plugin-trackunit 0.6.190 → 0.7.3

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,60 @@
1
+ ## 0.7.3 (2026-10-29)
2
+
3
+ ### 🧱 Updated Dependencies
4
+
5
+ - Updated css-classname-utils to 0.0.96
6
+ - Updated shared-utils to 1.22.15
7
+
8
+ ## 0.7.2 (2026-10-29)
9
+
10
+ ### 🧱 Updated Dependencies
11
+
12
+ - Updated css-classname-utils to 0.0.95
13
+ - Updated shared-utils to 1.22.14
14
+
15
+ ## 0.7.1 (2026-10-29)
16
+
17
+ ### 🚀 Features
18
+
19
+ - **eslint-plugin-trackunit:** document Vitest-only presets in README [SDK-571] ([6016a0d5ee3](https://github.com/Trackunit/manager/commit/6016a0d5ee3))
20
+ - **eslint-plugin-trackunit:** exempt eslint.config.mjs from module boundaries [SDK-571] ([e3a22ae8d51](https://github.com/Trackunit/manager/commit/e3a22ae8d51))
21
+ - **eslint-plugin-trackunit:** remove jest from published presets [SDK-571] ([533bd2ab1c4](https://github.com/Trackunit/manager/commit/533bd2ab1c4))
22
+
23
+ ### 🧱 Updated Dependencies
24
+
25
+ - Updated css-classname-utils to 0.0.94
26
+ - Updated shared-utils to 1.22.13
27
+
28
+ ### ❤️ Thank You
29
+
30
+ - Mikkel Thorbjørn Andersen
31
+
32
+ ## 0.7.0 (2026-10-29)
33
+
34
+ ### 🚀 Features
35
+
36
+ - ⚠️ **eslint-plugin-trackunit:** published presets work in Vitest workspaces [SDK-571] ([#27023](https://github.com/Trackunit/manager/pull/27023))
37
+
38
+ ### ⚠️ Breaking Changes
39
+
40
+ - **eslint-plugin-trackunit:** published presets work in Vitest workspaces [SDK-571] ([#27023](https://github.com/Trackunit/manager/pull/27023))
41
+
42
+ ### 🧱 Updated Dependencies
43
+
44
+ - Updated css-classname-utils to 0.0.93
45
+ - Updated shared-utils to 1.22.12
46
+
47
+ ### ❤️ Thank You
48
+
49
+ - Mikkel Thorbjørn Andersen @mta-trackunit
50
+
51
+ ## 0.6.191 (2026-10-29)
52
+
53
+ ### 🧱 Updated Dependencies
54
+
55
+ - Updated css-classname-utils to 0.0.92
56
+ - Updated shared-utils to 1.22.11
57
+
1
58
  ## 0.6.190 (2026-10-28)
2
59
 
3
60
  ### 🧱 Updated Dependencies
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @trackunit/eslint-plugin-trackunit
2
2
 
3
- A shared ESLint plugin and configuration preset for Trackunit projects. It bundles Trackunit-specific custom rules alongside curated third-party plugin configurations into ready-to-use flat-config presets for ESLint 9+.
3
+ A shared ESLint plugin and configuration preset for Trackunit projects. It bundles Trackunit-specific custom rules alongside curated third-party plugin configurations into ready-to-use flat-config presets for ESLint 9.
4
4
 
5
5
  ## Quick Start
6
6
 
@@ -16,13 +16,17 @@ module.exports = [...configs.base, ...configs.react];
16
16
 
17
17
  > For server, public API, and E2E presets see `@trackunit/eslint-plugin-trackunit-internal` (internal, not published to npm).
18
18
 
19
+ To set up the presets in an IrisX App workspace, see [Linting](https://developers.trackunit.com/docs/apps-and-extensions/overview/iris-app-sdk-reference/linting/) on the Developer Hub.
20
+
19
21
  ## Presets
20
22
 
21
23
 
22
- | Preset | Purpose | Includes |
23
- | --------------- | ---------------------------- | ---------------------------------------------------------------------- |
24
- | `configs.base` | Foundation for every project | TypeScript, import, module-boundary, JSDoc, and custom Trackunit rules |
25
- | `configs.react` | React / browser applications | React, React Hooks, Storybook, Jest + Testing Library overrides |
24
+ | Preset | Purpose | Includes |
25
+ | --------------- | ---------------------------- | ------------------------------------------------------------------------------------ |
26
+ | `configs.base` | Foundation for every project | TypeScript, import, module-boundary, JSDoc, and custom Trackunit rules |
27
+ | `configs.react` | React / browser applications | React, React Hooks, Storybook plugin (rules opt-in), Vitest globals, Testing Library |
28
+
29
+ Jest rules are not included: the presets target Vitest and do not configure `eslint-plugin-jest`. In `*.spec.ts(x)` files, `configs.base` turns off rules such as `no-console` and `@trackunit/no-typescript-assertion`, and `configs.react` enables Testing Library rules. `configs.react` also declares the Vitest globals (`describe`, `it`, `expect`, `vi`, …).
26
30
 
27
31
 
28
32
  ### Combining Presets
@@ -160,8 +164,8 @@ const root = findMonorepoRoot();
160
164
  ## Requirements
161
165
 
162
166
  - Node.js >= 24
163
- - ESLint 9+
164
- - TypeScript 5.9+
167
+ - ESLint 9 (9.33.0 or later; ESLint 10 is not supported yet)
168
+ - TypeScript 5.9 or 6.0
165
169
 
166
170
  For more info and a full guide on Iris App SDK Development, please visit our [Developer Hub](https://developers.trackunit.com/).
167
171
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/eslint-plugin-trackunit",
3
- "version": "0.6.190",
3
+ "version": "0.7.3",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
5
  "repository": "https://github.com/Trackunit/manager",
6
6
  "engines": {
@@ -8,12 +8,11 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@nx/eslint-plugin": "23.3.0",
11
- "@trackunit/css-classname-utils": "0.0.91",
11
+ "@trackunit/css-classname-utils": "0.0.96",
12
12
  "@typescript-eslint/eslint-plugin": "8.71.2",
13
13
  "@typescript-eslint/utils": "8.71.2",
14
14
  "eslint-config-prettier": "^10.1.8",
15
15
  "eslint-plugin-import": "2.32.0",
16
- "eslint-plugin-jest": "^29.15.2",
17
16
  "eslint-plugin-jsdoc": "^62.9.0",
18
17
  "eslint-plugin-no-null": "^1.0.2",
19
18
  "eslint-plugin-react": "7.37.5",
@@ -12,20 +12,13 @@ exports.baseJestOverrides = {
12
12
  },
13
13
  },
14
14
  plugins: {
15
- jest: plugins_1.jest,
16
15
  "testing-library": plugins_1.testingLibrary,
17
16
  },
18
17
  rules: {
19
- ...plugins_1.jest.configs.recommended.rules,
20
- ...plugins_1.jest.configs.style.rules,
21
- // Recognise vitest's `expectTypeOf` (compile-time-only type assertions) alongside `expect`,
22
- // otherwise specs that only assert types are flagged as having no assertions.
23
- "jest/expect-expect": ["error", { assertFunctionNames: ["expect", "expectTypeOf"] }],
24
18
  "@typescript-eslint/no-explicit-any": "off",
25
19
  "@typescript-eslint/no-empty-function": "off",
26
20
  "@typescript-eslint/no-non-null-assertion": "off",
27
21
  "@trackunit/no-typescript-assertion": "off",
28
- "@trackunit/no-jest-mock-trackunit-react-core-hooks": "error",
29
22
  "no-console": "off",
30
23
  "no-restricted-globals": "off",
31
24
  "no-restricted-properties": "off",
@@ -1,4 +1,3 @@
1
1
  import type { Linter } from "eslint";
2
2
  export declare const reactRules: Linter.RulesRecord;
3
3
  export declare const reactCustomRules: Linter.RulesRecord;
4
- export declare const reactTestingLibraryOverrides: Linter.Config;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.reactTestingLibraryOverrides = exports.reactCustomRules = exports.reactRules = void 0;
3
+ exports.reactCustomRules = exports.reactRules = void 0;
4
4
  exports.reactRules = {
5
5
  "react-hooks/rules-of-hooks": "error",
6
6
  "react-hooks/exhaustive-deps": "error",
@@ -135,11 +135,4 @@ exports.reactCustomRules = {
135
135
  },
136
136
  ],
137
137
  };
138
- exports.reactTestingLibraryOverrides = {
139
- files: ["**/*.spec.ts", "**/*.spec.tsx"],
140
- rules: {
141
- "jest/no-commented-out-tests": "error",
142
- "jest/expect-expect": "error",
143
- },
144
- };
145
138
  //# sourceMappingURL=react-rules.js.map
@@ -1015,7 +1015,6 @@ export declare const configs: {
1015
1015
  };
1016
1016
  };
1017
1017
  "@nx": typeof import("@nx/eslint-plugin");
1018
- jest?: undefined;
1019
1018
  };
1020
1019
  settings: {
1021
1020
  react: {
@@ -1026,6 +1025,15 @@ export declare const configs: {
1026
1025
  globals: {
1027
1026
  Text: string;
1028
1027
  screen: string;
1028
+ describe: "readonly";
1029
+ it: "readonly";
1030
+ test: "readonly";
1031
+ expect: "readonly";
1032
+ vi: "readonly";
1033
+ beforeEach: "readonly";
1034
+ afterEach: "readonly";
1035
+ beforeAll: "readonly";
1036
+ afterAll: "readonly";
1029
1037
  };
1030
1038
  parser?: undefined;
1031
1039
  ecmaVersion?: undefined;
@@ -1082,30 +1090,6 @@ export declare const configs: {
1082
1090
  } | {
1083
1091
  files: string[];
1084
1092
  plugins: {
1085
- jest: {
1086
- meta: {
1087
- name: string;
1088
- version: string;
1089
- };
1090
- environments: {
1091
- globals: {
1092
- globals: {
1093
- [key: string]: boolean;
1094
- };
1095
- };
1096
- };
1097
- configs: {
1098
- all: import("eslint").Linter.LegacyConfig;
1099
- recommended: import("eslint").Linter.LegacyConfig;
1100
- style: import("eslint").Linter.LegacyConfig;
1101
- "flat/all": import("eslint").Linter.FlatConfig;
1102
- "flat/recommended": import("eslint").Linter.FlatConfig;
1103
- "flat/style": import("eslint").Linter.FlatConfig;
1104
- };
1105
- rules: {
1106
- [key: string]: import("eslint").Rule.RuleModule;
1107
- };
1108
- };
1109
1093
  "testing-library": {
1110
1094
  readonly meta: {
1111
1095
  readonly name: string;
@@ -1139,6 +1123,15 @@ export declare const configs: {
1139
1123
  globals: {
1140
1124
  Text: string;
1141
1125
  screen: string;
1126
+ describe: "readonly";
1127
+ it: "readonly";
1128
+ test: "readonly";
1129
+ expect: "readonly";
1130
+ vi: "readonly";
1131
+ beforeEach: "readonly";
1132
+ afterEach: "readonly";
1133
+ beforeAll: "readonly";
1134
+ afterAll: "readonly";
1142
1135
  };
1143
1136
  parser: import("eslint").Linter.Parser;
1144
1137
  ecmaVersion?: undefined;
@@ -1146,8 +1139,7 @@ export declare const configs: {
1146
1139
  parserOptions?: undefined;
1147
1140
  };
1148
1141
  rules: {
1149
- "jest/no-commented-out-tests": string;
1150
- "jest/expect-expect": string;
1142
+ [rule: string]: import("eslint").Linter.RuleEntry<any[]>;
1151
1143
  "@trackunit/one-component-per-file"?: undefined;
1152
1144
  "@trackunit/component-name-matches-filename"?: undefined;
1153
1145
  "no-restricted-properties"?: undefined;
@@ -12,7 +12,6 @@ import * as typescriptEslint from "@typescript-eslint/eslint-plugin";
12
12
  import * as tsParser from "@typescript-eslint/parser";
13
13
  import eslintConfigPrettier from "eslint-config-prettier/flat";
14
14
  import * as importPlugin from "eslint-plugin-import";
15
- import * as jest from "eslint-plugin-jest";
16
15
  import * as jsdoc from "eslint-plugin-jsdoc";
17
16
  import * as noNull from "eslint-plugin-no-null";
18
17
  import * as react from "eslint-plugin-react";
@@ -143,4 +142,4 @@ export declare const storybookPlugin: {
143
142
  };
144
143
  };
145
144
  };
146
- export { eslintConfigPrettier, globals, importPlugin, jest, jsdoc, jsoncParser, noNull, nx, react, reactHooks, testingLibrary, tsParser, typescriptEslint, };
145
+ export { eslintConfigPrettier, globals, importPlugin, jsdoc, jsoncParser, noNull, nx, react, reactHooks, testingLibrary, tsParser, typescriptEslint, };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.typescriptEslint = exports.tsParser = exports.testingLibrary = exports.reactHooks = exports.react = exports.nx = exports.noNull = exports.jsoncParser = exports.jsdoc = exports.jest = exports.importPlugin = exports.globals = exports.eslintConfigPrettier = exports.storybookPlugin = exports.localRulesPlugin = void 0;
3
+ exports.typescriptEslint = exports.tsParser = exports.testingLibrary = exports.reactHooks = exports.react = exports.nx = exports.noNull = exports.jsoncParser = exports.jsdoc = exports.importPlugin = exports.globals = exports.eslintConfigPrettier = exports.storybookPlugin = exports.localRulesPlugin = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  /**
6
6
  * Shared plugin instances for ESLint flat config.
@@ -21,8 +21,6 @@ const flat_1 = tslib_1.__importDefault(require("eslint-config-prettier/flat"));
21
21
  exports.eslintConfigPrettier = flat_1.default;
22
22
  const importPlugin = tslib_1.__importStar(require("eslint-plugin-import"));
23
23
  exports.importPlugin = importPlugin;
24
- const jest = tslib_1.__importStar(require("eslint-plugin-jest"));
25
- exports.jest = jest;
26
24
  const jsdoc = tslib_1.__importStar(require("eslint-plugin-jsdoc"));
27
25
  exports.jsdoc = jsdoc;
28
26
  const noNull = tslib_1.__importStar(require("eslint-plugin-no-null"));
@@ -182,7 +182,7 @@ exports.base = [
182
182
  },
183
183
  },
184
184
  {
185
- files: ["**/eslint.config.cjs"],
185
+ files: ["**/eslint.config.{cjs,mjs}"],
186
186
  rules: {
187
187
  "@nx/enforce-module-boundaries": "off",
188
188
  },
@@ -514,7 +514,6 @@ export declare const reactPreset: (import("eslint").Linter.Config<import("eslint
514
514
  };
515
515
  };
516
516
  "@nx": typeof nx;
517
- jest?: undefined;
518
517
  };
519
518
  settings: {
520
519
  react: {
@@ -525,6 +524,15 @@ export declare const reactPreset: (import("eslint").Linter.Config<import("eslint
525
524
  globals: {
526
525
  Text: string;
527
526
  screen: string;
527
+ describe: "readonly";
528
+ it: "readonly";
529
+ test: "readonly";
530
+ expect: "readonly";
531
+ vi: "readonly";
532
+ beforeEach: "readonly";
533
+ afterEach: "readonly";
534
+ beforeAll: "readonly";
535
+ afterAll: "readonly";
528
536
  };
529
537
  parser?: undefined;
530
538
  ecmaVersion?: undefined;
@@ -581,30 +589,6 @@ export declare const reactPreset: (import("eslint").Linter.Config<import("eslint
581
589
  } | {
582
590
  files: string[];
583
591
  plugins: {
584
- jest: {
585
- meta: {
586
- name: string;
587
- version: string;
588
- };
589
- environments: {
590
- globals: {
591
- globals: {
592
- [key: string]: boolean;
593
- };
594
- };
595
- };
596
- configs: {
597
- all: import("eslint").Linter.LegacyConfig;
598
- recommended: import("eslint").Linter.LegacyConfig;
599
- style: import("eslint").Linter.LegacyConfig;
600
- "flat/all": import("eslint").Linter.FlatConfig;
601
- "flat/recommended": import("eslint").Linter.FlatConfig;
602
- "flat/style": import("eslint").Linter.FlatConfig;
603
- };
604
- rules: {
605
- [key: string]: import("eslint").Rule.RuleModule;
606
- };
607
- };
608
592
  "testing-library": {
609
593
  readonly meta: {
610
594
  readonly name: string;
@@ -638,6 +622,15 @@ export declare const reactPreset: (import("eslint").Linter.Config<import("eslint
638
622
  globals: {
639
623
  Text: string;
640
624
  screen: string;
625
+ describe: "readonly";
626
+ it: "readonly";
627
+ test: "readonly";
628
+ expect: "readonly";
629
+ vi: "readonly";
630
+ beforeEach: "readonly";
631
+ afterEach: "readonly";
632
+ beforeAll: "readonly";
633
+ afterAll: "readonly";
641
634
  };
642
635
  parser: import("eslint").Linter.Parser;
643
636
  ecmaVersion?: undefined;
@@ -645,8 +638,7 @@ export declare const reactPreset: (import("eslint").Linter.Config<import("eslint
645
638
  parserOptions?: undefined;
646
639
  };
647
640
  rules: {
648
- "jest/no-commented-out-tests": string;
649
- "jest/expect-expect": string;
641
+ [rule: string]: import("eslint").Linter.RuleEntry<any[]>;
650
642
  "@trackunit/one-component-per-file"?: undefined;
651
643
  "@trackunit/component-name-matches-filename"?: undefined;
652
644
  "no-restricted-properties"?: undefined;
@@ -16,6 +16,21 @@ const plugins_1 = require("../plugins");
16
16
  * that are linted by default keep the parser they had when it was unscoped.
17
17
  */
18
18
  const codeFiles = ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.cjs", "**/*.mjs"];
19
+ /**
20
+ * Test-runner globals for specs that rely on Vitest's `globals: true`. Spelled out because the pinned
21
+ * `globals` package has no `vitest` key.
22
+ */
23
+ const vitestGlobals = {
24
+ describe: "readonly",
25
+ it: "readonly",
26
+ test: "readonly",
27
+ expect: "readonly",
28
+ vi: "readonly",
29
+ beforeEach: "readonly",
30
+ afterEach: "readonly",
31
+ beforeAll: "readonly",
32
+ afterAll: "readonly",
33
+ };
19
34
  exports.reactPreset = [
20
35
  {
21
36
  plugins: {
@@ -39,7 +54,7 @@ exports.reactPreset = [
39
54
  languageOptions: {
40
55
  globals: {
41
56
  ...plugins_1.globals.browser,
42
- ...plugins_1.jest.environments.globals.globals,
57
+ ...vitestGlobals,
43
58
  ...plugins_1.globals.node,
44
59
  Text: "writable",
45
60
  screen: "writable",
@@ -100,13 +115,12 @@ exports.reactPreset = [
100
115
  {
101
116
  files: ["**/*.spec.ts", "**/*.spec.tsx"],
102
117
  plugins: {
103
- jest: plugins_1.jest,
104
118
  "testing-library": plugins_1.testingLibrary,
105
119
  },
106
120
  languageOptions: {
107
121
  globals: {
108
122
  ...plugins_1.globals.browser,
109
- ...plugins_1.jest.environments.globals.globals,
123
+ ...vitestGlobals,
110
124
  ...plugins_1.globals.node,
111
125
  Text: "writable",
112
126
  screen: "writable",
@@ -114,11 +128,7 @@ exports.reactPreset = [
114
128
  parser: plugins_1.tsParser,
115
129
  },
116
130
  rules: {
117
- ...plugins_1.jest.configs.recommended.rules,
118
- ...plugins_1.jest.configs.style.rules,
119
131
  ...testing_library_1.reactTestingLibraryRules,
120
- "jest/no-commented-out-tests": "error",
121
- "jest/expect-expect": "error",
122
132
  },
123
133
  },
124
134
  ];
@@ -0,0 +1,26 @@
1
+ /**
2
+ * What a project's public entrypoint(s) say about the exports of one source file.
3
+ *
4
+ * - `exportsAll` — an entrypoint re-exports the whole file (`export * from "./File"`).
5
+ * - `exportsDefault` — an entrypoint re-exports the file's default export (`export { default as X } from "./File"`,
6
+ * `import X from "./File"; export { X }`). Kept apart from `names` because the public alias says nothing about
7
+ * the local declaration name of the default export.
8
+ * - `names` — the *source* export names re-exported individually (`export { X } from "./File"`,
9
+ * `export { X as Y } from "./File"` and `import { X as Z } from "./File"; export { Z }` all contribute `X`).
10
+ */
11
+ export type PublicExportedNames = {
12
+ exportsAll: boolean;
13
+ exportsDefault: boolean;
14
+ names: Set<string>;
15
+ };
16
+ /**
17
+ * Parse the project's public entrypoint(s) and collect which exports of `filePath` they expose.
18
+ *
19
+ * Two export forms are followed: `export … from "./File"` with a relative string specifier, and local
20
+ * `export { … }` whose specifiers resolve through an `import … from "./File"` elsewhere in the entrypoint.
21
+ * Entrypoints that cannot be read, type-only exports, string-literal specifiers and specifiers that do not
22
+ * resolve to `filePath` are skipped.
23
+ */
24
+ export declare const getPublicExportedNamesForFile: (projectRoot: string, filePath: string) => PublicExportedNames;
25
+ /** Whether `filePath` is itself one of the project's public entrypoints. */
26
+ export declare const isEntrypointFile: (projectRoot: string, filePath: string) => boolean;
@@ -0,0 +1,166 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEntrypointFile = exports.getPublicExportedNamesForFile = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const ts = tslib_1.__importStar(require("typescript"));
8
+ const defaultExportName = "default";
9
+ const publicEntrypointFileNames = ["index.ts", "index.tsx"];
10
+ const normalizeFilePath = (filePath) => path.normalize(filePath);
11
+ /** Absolute paths of every file that counts as the project's public entrypoint, whether or not it exists. */
12
+ const getPublicEntrypointPaths = (projectRoot) => publicEntrypointFileNames.map(fileName => path.join(projectRoot, "src", fileName));
13
+ /** The files a relative module specifier may resolve to: as written, with a TS extension, or as a directory index. */
14
+ const getModulePathCandidates = (fromFilePath, moduleSpecifier) => {
15
+ const modulePath = path.resolve(path.dirname(fromFilePath), moduleSpecifier);
16
+ return [
17
+ modulePath,
18
+ `${modulePath}.ts`,
19
+ `${modulePath}.tsx`,
20
+ path.join(modulePath, "index.ts"),
21
+ path.join(modulePath, "index.tsx"),
22
+ ];
23
+ };
24
+ const moduleSpecifierTargetsFile = (fromFilePath, moduleSpecifier, targetFilePath) => {
25
+ if (!moduleSpecifier.startsWith(".")) {
26
+ return false;
27
+ }
28
+ const normalizedTargetFilePath = normalizeFilePath(targetFilePath);
29
+ return getModulePathCandidates(fromFilePath, moduleSpecifier).some(candidatePath => normalizeFilePath(candidatePath) === normalizedTargetFilePath);
30
+ };
31
+ /**
32
+ * The name on the left of `as` in an export specifier, or its only name: the *source* export name for
33
+ * `export { … } from "./File"`, the *local* binding name for a module-local `export { … }`.
34
+ * String-literal names (`export { "weird" as X }`) cannot name a component declaration and yield `null`.
35
+ */
36
+ const getSpecifierSourceName = (specifier) => {
37
+ const sourceName = specifier.propertyName ?? specifier.name;
38
+ return ts.isStringLiteral(sourceName) ? null : sourceName.text;
39
+ };
40
+ /** Record one resolved re-export of `filePath`: the default export as a flag, anything else as a source name. */
41
+ const addPublicExport = (result, sourceExportName) => {
42
+ if (sourceExportName === defaultExportName) {
43
+ result.exportsDefault = true;
44
+ return;
45
+ }
46
+ result.names.add(sourceExportName);
47
+ };
48
+ const isTypeOnlyImportClause = (importClause) => importClause.phaseModifier === ts.SyntaxKind.TypeKeyword;
49
+ /**
50
+ * Map every value binding the entrypoint imports (local name → source) over the whole file, so a later
51
+ * `export { local }` can be resolved regardless of whether the import precedes or follows it.
52
+ * Namespace imports and type-only imports are skipped: neither can re-export a component value.
53
+ */
54
+ const collectImportBindings = (sourceFile) => {
55
+ const bindings = new Map();
56
+ for (const statement of sourceFile.statements) {
57
+ if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {
58
+ continue;
59
+ }
60
+ const { importClause } = statement;
61
+ if (!importClause || isTypeOnlyImportClause(importClause)) {
62
+ continue;
63
+ }
64
+ const moduleSpecifier = statement.moduleSpecifier.text;
65
+ if (importClause.name) {
66
+ bindings.set(importClause.name.text, { moduleSpecifier, importedName: defaultExportName });
67
+ }
68
+ if (importClause.namedBindings && ts.isNamedImports(importClause.namedBindings)) {
69
+ for (const element of importClause.namedBindings.elements) {
70
+ if (element.isTypeOnly) {
71
+ continue;
72
+ }
73
+ bindings.set(element.name.text, {
74
+ moduleSpecifier,
75
+ importedName: element.propertyName?.text ?? element.name.text,
76
+ });
77
+ }
78
+ }
79
+ }
80
+ return bindings;
81
+ };
82
+ /**
83
+ * Collect the exports of `filePath` that a local `export { A, B as C }` statement exposes by resolving each
84
+ * specifier's local name through the entrypoint's import bindings.
85
+ *
86
+ * Specifiers without a matching import (locally declared values) and bindings that do not target `filePath`
87
+ * contribute nothing. A re-exported default import (`import X from "./File"; export { X }`) sets `exportsDefault`.
88
+ */
89
+ const collectLocallyReExportedNames = (statement, importBindings, entrypointPath, filePath, result) => {
90
+ if (statement.isTypeOnly || !statement.exportClause || !ts.isNamedExports(statement.exportClause)) {
91
+ return;
92
+ }
93
+ for (const specifier of statement.exportClause.elements) {
94
+ if (specifier.isTypeOnly) {
95
+ continue;
96
+ }
97
+ const localName = getSpecifierSourceName(specifier);
98
+ const binding = localName === null ? undefined : importBindings.get(localName);
99
+ if (binding && moduleSpecifierTargetsFile(entrypointPath, binding.moduleSpecifier, filePath)) {
100
+ addPublicExport(result, binding.importedName);
101
+ }
102
+ }
103
+ };
104
+ /**
105
+ * Parse the project's public entrypoint(s) and collect which exports of `filePath` they expose.
106
+ *
107
+ * Two export forms are followed: `export … from "./File"` with a relative string specifier, and local
108
+ * `export { … }` whose specifiers resolve through an `import … from "./File"` elsewhere in the entrypoint.
109
+ * Entrypoints that cannot be read, type-only exports, string-literal specifiers and specifiers that do not
110
+ * resolve to `filePath` are skipped.
111
+ */
112
+ const getPublicExportedNamesForFile = (projectRoot, filePath) => {
113
+ const result = {
114
+ exportsAll: false,
115
+ exportsDefault: false,
116
+ names: new Set(),
117
+ };
118
+ for (const entrypointPath of getPublicEntrypointPaths(projectRoot)) {
119
+ let sourceText;
120
+ try {
121
+ sourceText = fs.readFileSync(entrypointPath, "utf8");
122
+ }
123
+ catch {
124
+ continue;
125
+ }
126
+ const sourceFile = ts.createSourceFile(entrypointPath, sourceText, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
127
+ const importBindings = collectImportBindings(sourceFile);
128
+ for (const statement of sourceFile.statements) {
129
+ if (!ts.isExportDeclaration(statement)) {
130
+ continue;
131
+ }
132
+ if (!statement.moduleSpecifier) {
133
+ collectLocallyReExportedNames(statement, importBindings, entrypointPath, filePath, result);
134
+ continue;
135
+ }
136
+ // `export type … from` re-exports types only; a component value is never reachable through it.
137
+ if (statement.isTypeOnly || !ts.isStringLiteral(statement.moduleSpecifier)) {
138
+ continue;
139
+ }
140
+ if (!moduleSpecifierTargetsFile(entrypointPath, statement.moduleSpecifier.text, filePath)) {
141
+ continue;
142
+ }
143
+ if (!statement.exportClause) {
144
+ result.exportsAll = true;
145
+ continue;
146
+ }
147
+ if (ts.isNamedExports(statement.exportClause)) {
148
+ for (const specifier of statement.exportClause.elements) {
149
+ const sourceExportName = specifier.isTypeOnly ? null : getSpecifierSourceName(specifier);
150
+ if (sourceExportName !== null) {
151
+ addPublicExport(result, sourceExportName);
152
+ }
153
+ }
154
+ }
155
+ }
156
+ }
157
+ return result;
158
+ };
159
+ exports.getPublicExportedNamesForFile = getPublicExportedNamesForFile;
160
+ /** Whether `filePath` is itself one of the project's public entrypoints. */
161
+ const isEntrypointFile = (projectRoot, filePath) => {
162
+ const normalizedFilePath = normalizeFilePath(filePath);
163
+ return getPublicEntrypointPaths(projectRoot).some(entrypointPath => normalizeFilePath(entrypointPath) === normalizedFilePath);
164
+ };
165
+ exports.isEntrypointFile = isEntrypointFile;
166
+ //# sourceMappingURL=entrypoint-exports.js.map
@@ -7,7 +7,33 @@ type Options = [
7
7
  restrictToComponentsWithJsxReturn?: boolean;
8
8
  }
9
9
  ];
10
- export declare const checkerTypeHasRequiredInterface: (type: ts.Type, requiredInterface: string, checker: ts.TypeChecker, visitedTypeNames?: Set<string>) => boolean;
10
+ /** The contracts every public component's props must satisfy. */
11
+ type ContractOptions = {
12
+ requiredProps: ReadonlyArray<string>;
13
+ requiredInterfaces: ReadonlyArray<string>;
14
+ };
15
+ /**
16
+ * Whether `type` satisfies `requiredInterface`. `exposureRoot` is the *resulting* props type the structural check
17
+ * compares against; it stays fixed while the walk descends into intersection parts, base types and heritage clauses,
18
+ * and defaults to the type the check started on.
19
+ *
20
+ * Bug fix (SDK-564): the comparison used to run against the alias-carrying member itself, so
21
+ * `interface Props extends Omit<CommonProps, "id">, … { id?: string }` was reported even though the resulting props
22
+ * type exposes every `CommonProps` member: the base alone does not, but the interface body re-adds `id`. A contract's
23
+ * members may come from any part of the props type, so the comparison always targets the whole of it.
24
+ */
25
+ export declare const checkerTypeHasRequiredInterface: (type: ts.Type, requiredInterface: string, checker: ts.TypeChecker, visited?: Set<ts.Type>, exposureRoot?: ts.Type) => boolean;
26
+ /**
27
+ * The contract names a resolved props type is missing, required props first, then required interfaces, in the
28
+ * configured order. Exported so checker-backed candidates can be judged without an annotation node (SDK-565).
29
+ */
30
+ export declare const getMissingContractsForCheckerType: (type: ts.Type, { requiredProps, requiredInterfaces }: ContractOptions, checker: ts.TypeChecker) => Array<string>;
31
+ /**
32
+ * The contracts missing from *every* one of several props types, in the configured order: for an overloaded
33
+ * component each overload's props type is a candidate, and a contract carried by any of them is satisfied
34
+ * (SDK-565). An empty list of types misses nothing; callers skip such candidates before getting here.
35
+ */
36
+ export declare const getMissingContractsForCheckerTypes: (types: ReadonlyArray<ts.Type>, contractOptions: ContractOptions, checker: ts.TypeChecker) => Array<string>;
11
37
  export declare const requireComponentPropContracts: ESLintUtils.RuleModule<"missingPropContracts", Options, unknown, ESLintUtils.RuleListener> & {
12
38
  name: string;
13
39
  };