@atlaskit/eslint-plugin-platform 2.7.2 → 2.8.0

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 (75) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/cjs/index.js +14 -3
  3. package/dist/cjs/rules/feature-gating/valid-gate-name/index.js +60 -0
  4. package/dist/cjs/rules/import/no-barrel-entry-imports/index.js +871 -0
  5. package/dist/cjs/rules/import/no-barrel-entry-jest-mock/index.js +1384 -0
  6. package/dist/cjs/rules/import/no-conversation-assistant-barrel-imports/index.js +43 -0
  7. package/dist/cjs/rules/import/no-jest-mock-barrel-files/index.js +1401 -0
  8. package/dist/cjs/rules/import/no-relative-barrel-file-imports/index.js +777 -0
  9. package/dist/cjs/rules/import/shared/barrel-parsing.js +511 -0
  10. package/dist/cjs/rules/import/shared/file-system.js +186 -0
  11. package/dist/cjs/rules/import/shared/jest-utils.js +191 -0
  12. package/dist/cjs/rules/import/shared/package-registry.js +263 -0
  13. package/dist/cjs/rules/import/shared/package-resolution.js +185 -0
  14. package/dist/cjs/rules/import/shared/perf.js +89 -0
  15. package/dist/cjs/rules/import/shared/types.js +67 -0
  16. package/dist/es2019/index.js +14 -3
  17. package/dist/es2019/rules/feature-gating/valid-gate-name/index.js +52 -0
  18. package/dist/es2019/rules/import/no-barrel-entry-imports/index.js +801 -0
  19. package/dist/es2019/rules/import/no-barrel-entry-jest-mock/index.js +1113 -0
  20. package/dist/es2019/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
  21. package/dist/es2019/rules/import/no-jest-mock-barrel-files/index.js +1179 -0
  22. package/dist/es2019/rules/import/no-relative-barrel-file-imports/index.js +738 -0
  23. package/dist/es2019/rules/import/shared/barrel-parsing.js +433 -0
  24. package/dist/es2019/rules/import/shared/file-system.js +174 -0
  25. package/dist/es2019/rules/import/shared/jest-utils.js +159 -0
  26. package/dist/es2019/rules/import/shared/package-registry.js +240 -0
  27. package/dist/es2019/rules/import/shared/package-resolution.js +161 -0
  28. package/dist/es2019/rules/import/shared/perf.js +83 -0
  29. package/dist/es2019/rules/import/shared/types.js +57 -0
  30. package/dist/esm/index.js +14 -3
  31. package/dist/esm/rules/feature-gating/valid-gate-name/index.js +53 -0
  32. package/dist/esm/rules/import/no-barrel-entry-imports/index.js +864 -0
  33. package/dist/esm/rules/import/no-barrel-entry-jest-mock/index.js +1375 -0
  34. package/dist/esm/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
  35. package/dist/esm/rules/import/no-jest-mock-barrel-files/index.js +1391 -0
  36. package/dist/esm/rules/import/no-relative-barrel-file-imports/index.js +770 -0
  37. package/dist/esm/rules/import/shared/barrel-parsing.js +500 -0
  38. package/dist/esm/rules/import/shared/file-system.js +176 -0
  39. package/dist/esm/rules/import/shared/jest-utils.js +179 -0
  40. package/dist/esm/rules/import/shared/package-registry.js +256 -0
  41. package/dist/esm/rules/import/shared/package-resolution.js +175 -0
  42. package/dist/esm/rules/import/shared/perf.js +80 -0
  43. package/dist/esm/rules/import/shared/types.js +61 -0
  44. package/dist/types/index.d.ts +16 -2
  45. package/dist/types/rules/feature-gating/valid-gate-name/index.d.ts +3 -0
  46. package/dist/types/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
  47. package/dist/types/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
  48. package/dist/types/rules/import/no-conversation-assistant-barrel-imports/index.d.ts +3 -0
  49. package/dist/types/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
  50. package/dist/types/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
  51. package/dist/types/rules/import/shared/barrel-parsing.d.ts +30 -0
  52. package/dist/types/rules/import/shared/file-system.d.ts +38 -0
  53. package/dist/types/rules/import/shared/jest-utils.d.ts +47 -0
  54. package/dist/types/rules/import/shared/package-registry.d.ts +26 -0
  55. package/dist/types/rules/import/shared/package-resolution.d.ts +38 -0
  56. package/dist/types/rules/import/shared/perf.d.ts +13 -0
  57. package/dist/types/rules/import/shared/types.d.ts +131 -0
  58. package/dist/types-ts4.5/index.d.ts +16 -2
  59. package/dist/types-ts4.5/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
  60. package/dist/types-ts4.5/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
  61. package/dist/types-ts4.5/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
  62. package/dist/types-ts4.5/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
  63. package/dist/types-ts4.5/rules/import/shared/barrel-parsing.d.ts +30 -0
  64. package/dist/types-ts4.5/rules/import/shared/file-system.d.ts +38 -0
  65. package/dist/types-ts4.5/rules/import/shared/jest-utils.d.ts +47 -0
  66. package/dist/types-ts4.5/rules/import/shared/package-registry.d.ts +26 -0
  67. package/dist/types-ts4.5/rules/import/shared/package-resolution.d.ts +38 -0
  68. package/dist/types-ts4.5/rules/import/shared/perf.d.ts +13 -0
  69. package/dist/types-ts4.5/rules/import/shared/types.d.ts +131 -0
  70. package/package.json +4 -2
  71. package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +0 -158
  72. package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +0 -146
  73. package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +0 -151
  74. /package/dist/types-ts4.5/rules/{ensure-native-and-af-exports-synced → feature-gating/valid-gate-name}/index.d.ts +0 -0
  75. /package/dist/{types/rules/ensure-native-and-af-exports-synced → types-ts4.5/rules/import/no-conversation-assistant-barrel-imports}/index.d.ts +0 -0
@@ -0,0 +1,61 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { execSync as _execSync } from 'child_process';
5
+ import { existsSync, readdirSync as _readdirSync, readFileSync, realpathSync, statSync } from 'fs';
6
+
7
+ /**
8
+ * Directory entry returned by readdirSync with withFileTypes option.
9
+ */
10
+
11
+ /**
12
+ * State for the package registry cache.
13
+ * This is used to cache package name to directory mappings for efficient lookups.
14
+ */
15
+
16
+ /**
17
+ * Cache structure for file system operations.
18
+ * Contains both package registry cache and workspace root cache.
19
+ */
20
+
21
+ /**
22
+ * File system abstraction for testability.
23
+ * This interface allows the core logic to be tested with mock file systems.
24
+ * The cache property holds package resolution state and can be passed as an empty
25
+ * object for tests to ensure fresh state for each test case.
26
+ */
27
+
28
+ /**
29
+ * Real file system implementation using Node.js fs module.
30
+ */
31
+ export var realFileSystem = {
32
+ existsSync: existsSync,
33
+ readFileSync: readFileSync,
34
+ realpathSync: realpathSync,
35
+ statSync: statSync,
36
+ readdirSync: function readdirSync(path, options) {
37
+ return _readdirSync(path, options);
38
+ },
39
+ execSync: function execSync(command, options) {
40
+ try {
41
+ return _execSync(command, _objectSpread(_objectSpread({}, options), {}, {
42
+ encoding: 'utf-8'
43
+ })).trim();
44
+ } catch (_unused) {
45
+ return null;
46
+ }
47
+ },
48
+ cache: {}
49
+ };
50
+
51
+ /**
52
+ * Information about cross-package re-export origin.
53
+ */
54
+
55
+ /**
56
+ * Information about where an export originates.
57
+ */
58
+
59
+ /**
60
+ * Context for package resolution operations.
61
+ */
@@ -15,7 +15,6 @@ declare const rules: {
15
15
  'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
16
16
  'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
17
17
  'ensure-publish-valid': import("eslint").Rule.RuleModule;
18
- 'ensure-native-and-af-exports-synced': import("eslint").Rule.RuleModule;
19
18
  'no-module-level-eval': import("eslint").Rule.RuleModule;
20
19
  'no-module-level-eval-nav4': import("eslint").Rule.RuleModule;
21
20
  'static-feature-flags': import("eslint").Rule.RuleModule;
@@ -25,10 +24,16 @@ declare const rules: {
25
24
  'no-alias': import("eslint").Rule.RuleModule;
26
25
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
27
26
  'use-recommended-utils': import("eslint").Rule.RuleModule;
27
+ 'valid-gate-name': import("eslint").Rule.RuleModule;
28
28
  'no-sparse-checkout': import("eslint").Rule.RuleModule;
29
29
  'no-direct-document-usage': import("eslint").Rule.RuleModule;
30
30
  'no-set-immediate': import("eslint").Rule.RuleModule;
31
31
  'prefer-crypto-random-uuid': import("eslint").Rule.RuleModule;
32
+ 'no-barrel-entry-imports': import("eslint").Rule.RuleModule;
33
+ 'no-barrel-entry-jest-mock': import("eslint").Rule.RuleModule;
34
+ 'no-jest-mock-barrel-files': import("eslint").Rule.RuleModule;
35
+ 'no-relative-barrel-file-imports': import("eslint").Rule.RuleModule;
36
+ 'no-conversation-assistant-barrel-imports': import("eslint").Rule.RuleModule;
32
37
  };
33
38
  declare const plugin: {
34
39
  meta: {
@@ -51,7 +56,6 @@ declare const plugin: {
51
56
  'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
52
57
  'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
53
58
  'ensure-publish-valid': import("eslint").Rule.RuleModule;
54
- 'ensure-native-and-af-exports-synced': import("eslint").Rule.RuleModule;
55
59
  'no-module-level-eval': import("eslint").Rule.RuleModule;
56
60
  'no-module-level-eval-nav4': import("eslint").Rule.RuleModule;
57
61
  'static-feature-flags': import("eslint").Rule.RuleModule;
@@ -61,10 +65,16 @@ declare const plugin: {
61
65
  'no-alias': import("eslint").Rule.RuleModule;
62
66
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
63
67
  'use-recommended-utils': import("eslint").Rule.RuleModule;
68
+ 'valid-gate-name': import("eslint").Rule.RuleModule;
64
69
  'no-sparse-checkout': import("eslint").Rule.RuleModule;
65
70
  'no-direct-document-usage': import("eslint").Rule.RuleModule;
66
71
  'no-set-immediate': import("eslint").Rule.RuleModule;
67
72
  'prefer-crypto-random-uuid': import("eslint").Rule.RuleModule;
73
+ 'no-barrel-entry-imports': import("eslint").Rule.RuleModule;
74
+ 'no-barrel-entry-jest-mock': import("eslint").Rule.RuleModule;
75
+ 'no-jest-mock-barrel-files': import("eslint").Rule.RuleModule;
76
+ 'no-relative-barrel-file-imports': import("eslint").Rule.RuleModule;
77
+ 'no-conversation-assistant-barrel-imports': import("eslint").Rule.RuleModule;
68
78
  };
69
79
  configs: {
70
80
  recommended: {
@@ -76,6 +86,7 @@ declare const plugin: {
76
86
  '@atlaskit/platform/inline-usage': "error";
77
87
  '@atlaskit/platform/prefer-fg': "error";
78
88
  '@atlaskit/platform/no-alias': "error";
89
+ '@atlaskit/platform/valid-gate-name': "error";
79
90
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
80
91
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
81
92
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -107,6 +118,7 @@ declare const plugin: {
107
118
  '@atlaskit/platform/inline-usage': "error";
108
119
  '@atlaskit/platform/prefer-fg': "error";
109
120
  '@atlaskit/platform/no-alias': "error";
121
+ '@atlaskit/platform/valid-gate-name': "error";
110
122
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
111
123
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
112
124
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -187,6 +199,7 @@ declare const configs: {
187
199
  '@atlaskit/platform/inline-usage': "error";
188
200
  '@atlaskit/platform/prefer-fg': "error";
189
201
  '@atlaskit/platform/no-alias': "error";
202
+ '@atlaskit/platform/valid-gate-name': "error";
190
203
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
191
204
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
192
205
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -218,6 +231,7 @@ declare const configs: {
218
231
  '@atlaskit/platform/inline-usage': "error";
219
232
  '@atlaskit/platform/prefer-fg': "error";
220
233
  '@atlaskit/platform/no-alias': "error";
234
+ '@atlaskit/platform/valid-gate-name': "error";
221
235
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
222
236
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
223
237
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,9 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type FileSystem } from '../shared/types';
3
+ /**
4
+ * Factory function to create the ESLint rule with a given file system.
5
+ * This enables testing with mock file systems.
6
+ */
7
+ export declare function createRule(fs: FileSystem): Rule.RuleModule;
8
+ declare const rule: Rule.RuleModule;
9
+ export default rule;
@@ -0,0 +1,9 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type FileSystem } from '../shared/types';
3
+ /**
4
+ * Factory function to create the ESLint rule with a given file system.
5
+ * This enables testing with mock file systems.
6
+ */
7
+ export declare function createRule(fs: FileSystem): Rule.RuleModule;
8
+ declare const rule: Rule.RuleModule;
9
+ export default rule;
@@ -0,0 +1,3 @@
1
+ import type { Rule } from 'eslint';
2
+ declare const rule: Rule.RuleModule;
3
+ export default rule;
@@ -0,0 +1,22 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ExportInfo, type FileSystem } from '../shared/types';
3
+ /**
4
+ * Validate and resolve a barrel file from an import path
5
+ * Returns null if not a valid relative barrel import
6
+ */
7
+ export declare function validateAndResolveBarrelFile({ importPath, basedir, workspaceRoot, fs, }: {
8
+ importPath: string;
9
+ basedir: string;
10
+ workspaceRoot: string;
11
+ fs: FileSystem;
12
+ }): {
13
+ resolvedPath: string;
14
+ exportMap: Map<string, ExportInfo>;
15
+ } | null;
16
+ /**
17
+ * Factory function to create the ESLint rule with a given file system.
18
+ * This enables testing with mock file systems.
19
+ */
20
+ export declare function createRule(fs: FileSystem): Rule.RuleModule;
21
+ declare const rule: Rule.RuleModule;
22
+ export default rule;
@@ -0,0 +1,5 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type FileSystem } from '../shared/types';
3
+ export declare function createRule(fs: FileSystem): Rule.RuleModule;
4
+ declare const rule: Rule.RuleModule;
5
+ export default rule;
@@ -0,0 +1,30 @@
1
+ import type { ExportInfo, FileSystem } from './types';
2
+ /**
3
+ * Get all named exports from a file.
4
+ * This extracts what names are exported from a file for star exports.
5
+ */
6
+ export declare function getNamedExportsFromFile({ filePath, fs, }: {
7
+ filePath: string;
8
+ fs: FileSystem;
9
+ }): Set<string>;
10
+ /**
11
+ * Check if an export map represents a barrel file (has re-exports from other files)
12
+ */
13
+ export declare function hasReExportsFromOtherFiles({ exportMap, sourceFilePath, }: {
14
+ exportMap: Map<string, ExportInfo>;
15
+ sourceFilePath: string;
16
+ }): boolean;
17
+ /**
18
+ * Parse export statements from a file to find where each export comes from.
19
+ * Returns a map of export name -> ExportInfo.
20
+ *
21
+ * This function recursively traces through nested barrels and cross-package re-exports
22
+ * to find the ultimate source file for each export.
23
+ */
24
+ export declare function parseBarrelExports({ barrelFilePath, depth, fs, workspaceRoot, visitedPackages, }: {
25
+ barrelFilePath: string;
26
+ depth?: number;
27
+ fs: FileSystem;
28
+ workspaceRoot?: string;
29
+ visitedPackages?: Set<string>;
30
+ }): Map<string, ExportInfo>;
@@ -0,0 +1,38 @@
1
+ import type { FileSystem } from './types';
2
+ /**
3
+ * The default folder paths that barrel import rules apply to.
4
+ * Only imports from packages within these folders will be checked.
5
+ * This can be overridden via lint rule options.
6
+ */
7
+ export declare const DEFAULT_TARGET_FOLDERS: string[];
8
+ /**
9
+ * Try to read file contents with error handling.
10
+ * Returns null if file cannot be read.
11
+ */
12
+ export declare function readFileContent({ filePath, fs, }: {
13
+ filePath: string;
14
+ fs: FileSystem;
15
+ }): string | null;
16
+ /**
17
+ * Check if a path is a relative import (starts with ./ or ../)
18
+ */
19
+ export declare function isRelativeImport(importPath: string): boolean;
20
+ /**
21
+ * Resolve the actual file path from an import path.
22
+ * Handles extension inference and index file resolution.
23
+ */
24
+ export declare function resolveImportPath({ basedir, importPath, fs, }: {
25
+ basedir: string;
26
+ importPath: string;
27
+ fs: FileSystem;
28
+ }): string | null;
29
+ /**
30
+ * Find the workspace root using git rev-parse --show-toplevel.
31
+ * The result is cached on fs.cache.gitRepoRoot to avoid repeated shell calls.
32
+ * Falls back to directory traversal if git command fails.
33
+ */
34
+ export declare function findWorkspaceRoot({ startPath, fs, applyToImportsFrom, }: {
35
+ startPath: string;
36
+ fs: FileSystem;
37
+ applyToImportsFrom?: string[];
38
+ }): string;
@@ -0,0 +1,47 @@
1
+ import type { TSESTree } from '@typescript-eslint/utils';
2
+ /**
3
+ * Shared utilities for jest.mock-related lint rules.
4
+ *
5
+ * These helpers are used by both `no-barrel-entry-jest-mock` (cross-package)
6
+ * and `no-jest-mock-barrel-files` (relative imports).
7
+ */
8
+ /**
9
+ * Check if a CallExpression node is a jest.mock() call
10
+ */
11
+ export declare function isJestMockCall(node: TSESTree.CallExpression): boolean;
12
+ /**
13
+ * Check if a node is a jest.requireActual() call
14
+ */
15
+ export declare function isJestRequireActual(node: TSESTree.Node): boolean;
16
+ /**
17
+ * Check if a node is a jest.requireMock() call
18
+ */
19
+ export declare function isJestRequireMock(node: TSESTree.Node): boolean;
20
+ /**
21
+ * Extract the import path string from a jest.mock/jest.requireMock/jest.requireActual call's arguments.
22
+ * Returns null if the path cannot be statically determined.
23
+ */
24
+ export declare function extractImportPath(node: TSESTree.CallExpression): string | null;
25
+ /**
26
+ * Find all jest.requireMock() calls in the AST whose import path matches a given target.
27
+ *
28
+ * The `matchPath` callback allows callers to provide their own path-matching strategy:
29
+ * - Cross-package rules can use simple string equality
30
+ * - Relative import rules can use normalized/resolved path comparison
31
+ */
32
+ export declare function findJestRequireMockCalls({ ast, matchPath, }: {
33
+ ast: TSESTree.Program;
34
+ matchPath: (candidatePath: string) => boolean;
35
+ }): TSESTree.CallExpression[];
36
+ /**
37
+ * Determine the best new import path for a jest.requireMock() call by inspecting
38
+ * the destructured symbols or property access at the call site.
39
+ *
40
+ * @param requireMockNode - The jest.requireMock() CallExpression node
41
+ * @param symbolToNewPath - Map from symbol name to the new mock path that provides it
42
+ * @returns The resolved new path, or null if it cannot be determined
43
+ */
44
+ export declare function resolveNewPathForRequireMock({ requireMockNode, symbolToNewPath, }: {
45
+ requireMockNode: TSESTree.CallExpression;
46
+ symbolToNewPath: Map<string, string>;
47
+ }): string | null;
@@ -0,0 +1,26 @@
1
+ import type { FileSystem } from './types';
2
+ /**
3
+ * Find the package directory for a given package name.
4
+ * Returns the absolute path to the package directory or null if not found.
5
+ *
6
+ * This function uses lazy scanning - it will scan platform/packages on first lookup
7
+ * and cache results in fs.cache for subsequent lookups.
8
+ *
9
+ * Note: Package resolution is NOT constrained by applyToImportsFrom. Any package under
10
+ * platform/packages can be resolved. Use isPackageInApplyToImportsFrom to check if a
11
+ * package should be processed by the lint rule.
12
+ */
13
+ export declare function findPackageInRegistry({ packageName, workspaceRoot, fs, }: {
14
+ packageName: string;
15
+ workspaceRoot: string;
16
+ fs: FileSystem;
17
+ }): string | null;
18
+ /**
19
+ * Check if a package is within one of the applyToImportsFrom folders.
20
+ * This can be used to quickly filter out packages that shouldn't be checked.
21
+ */
22
+ export declare function isPackageInApplyToImportsFrom({ packageDir, workspaceRoot, applyToImportsFrom, }: {
23
+ packageDir: string;
24
+ workspaceRoot: string;
25
+ applyToImportsFrom?: string[];
26
+ }): boolean;
@@ -0,0 +1,38 @@
1
+ import type { FileSystem } from './types';
2
+ /**
3
+ * Parse the package.json exports field and return a map of export paths to resolved file paths.
4
+ */
5
+ export declare function parsePackageExports({ packageDir, fs, }: {
6
+ packageDir: string;
7
+ fs: FileSystem;
8
+ }): Map<string, string>;
9
+ /**
10
+ * Find a matching export entry for a given source file path.
11
+ * Returns the export path (e.g., "./controllers/analytics") or null if not found.
12
+ */
13
+ export declare function findExportForSourceFile({ sourceFilePath, exportsMap, }: {
14
+ sourceFilePath: string;
15
+ exportsMap: Map<string, string>;
16
+ }): string | null;
17
+ /**
18
+ * Extract the package name and subpath from an import specifier.
19
+ * Returns null if the import is not a scoped package import.
20
+ */
21
+ export declare function extractPackageNameFromImport(moduleSpecifier: string): {
22
+ packageName: string;
23
+ subPath: string;
24
+ } | null;
25
+ /**
26
+ * Resolve a cross-package import to its package directory and export info.
27
+ * Returns null if the package is not in the target folder or cannot be resolved.
28
+ */
29
+ export declare function resolveCrossPackageImport({ moduleSpecifier, workspaceRoot, fs, }: {
30
+ moduleSpecifier: string;
31
+ workspaceRoot: string;
32
+ fs: FileSystem;
33
+ }): {
34
+ packageName: string;
35
+ packageDir: string;
36
+ exportPath: string;
37
+ entryFilePath: string;
38
+ } | null;
@@ -0,0 +1,13 @@
1
+ import type { FileSystem } from './types';
2
+ export declare const PERF_ENV_VAR = "INTERNAL_ESLINT_BARREL_PERF";
3
+ export declare function isPerfEnabled(): boolean;
4
+ export declare function perfInc({ fs, key, by }: {
5
+ fs: FileSystem;
6
+ key: string;
7
+ by?: number;
8
+ }): void;
9
+ export declare function perfTime<T>({ fs, key, fn }: {
10
+ fs: FileSystem;
11
+ key: string;
12
+ fn: () => T;
13
+ }): T;
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Directory entry returned by readdirSync with withFileTypes option.
3
+ */
4
+ export interface DirectoryEntry {
5
+ name: string;
6
+ isDirectory(): boolean;
7
+ isFile(): boolean;
8
+ }
9
+ /**
10
+ * State for the package registry cache.
11
+ * This is used to cache package name to directory mappings for efficient lookups.
12
+ */
13
+ export interface PackageRegistryCache {
14
+ /** Map of package name to absolute directory path */
15
+ packageNameToDir: Map<string, string>;
16
+ /** Set of directories that have been scanned (including those without packages) */
17
+ scannedDirectories: Set<string>;
18
+ /** yarn.lock mtime when cache was built (for invalidation) */
19
+ yarnLockMtime: number;
20
+ /** The workspace root this cache was built for (from package registry perspective) */
21
+ workspaceRoot: string | null;
22
+ }
23
+ /**
24
+ * Cache structure for file system operations.
25
+ * Contains both package registry cache and workspace root cache.
26
+ */
27
+ export interface FileSystemCache extends Partial<PackageRegistryCache> {
28
+ /** Cached git repository root (from git rev-parse --show-toplevel) */
29
+ gitRepoRoot?: string;
30
+ /**
31
+ * Cache of parsed package.json exports maps keyed by absolute package directory.
32
+ * This avoids repeated reads/parses during IDE lint runs.
33
+ */
34
+ packageExportsByDir?: Map<string, {
35
+ /** mtimeMs of package.json when this entry was computed. null means unknown (forces re-read). */
36
+ packageJsonMtimeMs: number | null;
37
+ exportsMap: Map<string, string>;
38
+ }>;
39
+ /**
40
+ * Cache of read file contents keyed by absolute file path.
41
+ * Used by barrel parsing to avoid repeated reads in IDE lint runs.
42
+ */
43
+ fileContentByPath?: Map<string, {
44
+ /** mtimeMs when this entry was cached. null means unknown (forces re-read). */
45
+ mtimeMs: number | null;
46
+ content: string;
47
+ }>;
48
+ /**
49
+ * Cache of parsed barrel exports keyed by barrel file path.
50
+ * Stores the barrel file mtime at time of parsing to support invalidation.
51
+ */
52
+ barrelExportsByPath?: Map<string, {
53
+ mtimeMs: number;
54
+ exports: Map<string, ExportInfo>;
55
+ }>;
56
+ /**
57
+ * Cache for resolveImportPath results keyed by basedir + importPath.
58
+ */
59
+ resolvedImportPathByKey?: Map<string, string | null>;
60
+ /**
61
+ * Optional perf counters and timers for debugging and optimization.
62
+ * Enabled by setting INTERNAL_ESLINT_BARREL_PERF.
63
+ */
64
+ perf?: {
65
+ installedExitHook: boolean;
66
+ counters: Record<string, number>;
67
+ timers: Record<string, number>;
68
+ };
69
+ }
70
+ /**
71
+ * File system abstraction for testability.
72
+ * This interface allows the core logic to be tested with mock file systems.
73
+ * The cache property holds package resolution state and can be passed as an empty
74
+ * object for tests to ensure fresh state for each test case.
75
+ */
76
+ export interface FileSystem {
77
+ existsSync(path: string): boolean;
78
+ readFileSync(path: string, encoding: 'utf-8'): string;
79
+ realpathSync(path: string): string;
80
+ statSync(path: string): {
81
+ isFile(): boolean;
82
+ mtimeMs?: number;
83
+ };
84
+ readdirSync(path: string, options: {
85
+ withFileTypes: true;
86
+ }): DirectoryEntry[];
87
+ /** Execute a command synchronously and return stdout. Returns null on error. */
88
+ execSync(command: string, options?: {
89
+ cwd?: string;
90
+ }): string | null;
91
+ /** Cache for package resolution and workspace root - will be populated lazily */
92
+ cache: FileSystemCache;
93
+ }
94
+ /**
95
+ * Real file system implementation using Node.js fs module.
96
+ */
97
+ export declare const realFileSystem: FileSystem;
98
+ /**
99
+ * Information about cross-package re-export origin.
100
+ */
101
+ export interface CrossPackageSource {
102
+ /** The package name (e.g., '@atlassian/package-b') */
103
+ packageName: string;
104
+ /** The export path within the package (e.g., '.' or './utils') */
105
+ exportPath: string;
106
+ }
107
+ /**
108
+ * Information about where an export originates.
109
+ */
110
+ export interface ExportInfo {
111
+ /** The absolute path to the file where this export originates */
112
+ path: string;
113
+ /** Whether this is a type-only export */
114
+ isTypeOnly: boolean;
115
+ /** Whether this is a re-export of a default export */
116
+ isDefaultExport?: boolean;
117
+ /** The original name of the symbol in the source file (for aliased exports) */
118
+ originalName?: string;
119
+ /** Information about cross-package re-export origin, if applicable */
120
+ crossPackageSource?: CrossPackageSource;
121
+ }
122
+ /**
123
+ * Context for package resolution operations.
124
+ */
125
+ export interface PackageResolutionContext {
126
+ packageName: string;
127
+ packageDir: string;
128
+ exportPath: string;
129
+ entryFilePath: string;
130
+ exportsMap: Map<string, string>;
131
+ }
@@ -15,7 +15,6 @@ declare const rules: {
15
15
  'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
16
16
  'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
17
17
  'ensure-publish-valid': import("eslint").Rule.RuleModule;
18
- 'ensure-native-and-af-exports-synced': import("eslint").Rule.RuleModule;
19
18
  'no-module-level-eval': import("eslint").Rule.RuleModule;
20
19
  'no-module-level-eval-nav4': import("eslint").Rule.RuleModule;
21
20
  'static-feature-flags': import("eslint").Rule.RuleModule;
@@ -25,10 +24,16 @@ declare const rules: {
25
24
  'no-alias': import("eslint").Rule.RuleModule;
26
25
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
27
26
  'use-recommended-utils': import("eslint").Rule.RuleModule;
27
+ 'valid-gate-name': import("eslint").Rule.RuleModule;
28
28
  'no-sparse-checkout': import("eslint").Rule.RuleModule;
29
29
  'no-direct-document-usage': import("eslint").Rule.RuleModule;
30
30
  'no-set-immediate': import("eslint").Rule.RuleModule;
31
31
  'prefer-crypto-random-uuid': import("eslint").Rule.RuleModule;
32
+ 'no-barrel-entry-imports': import("eslint").Rule.RuleModule;
33
+ 'no-barrel-entry-jest-mock': import("eslint").Rule.RuleModule;
34
+ 'no-jest-mock-barrel-files': import("eslint").Rule.RuleModule;
35
+ 'no-relative-barrel-file-imports': import("eslint").Rule.RuleModule;
36
+ 'no-conversation-assistant-barrel-imports': import("eslint").Rule.RuleModule;
32
37
  };
33
38
  declare const plugin: {
34
39
  meta: {
@@ -51,7 +56,6 @@ declare const plugin: {
51
56
  'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
52
57
  'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
53
58
  'ensure-publish-valid': import("eslint").Rule.RuleModule;
54
- 'ensure-native-and-af-exports-synced': import("eslint").Rule.RuleModule;
55
59
  'no-module-level-eval': import("eslint").Rule.RuleModule;
56
60
  'no-module-level-eval-nav4': import("eslint").Rule.RuleModule;
57
61
  'static-feature-flags': import("eslint").Rule.RuleModule;
@@ -61,10 +65,16 @@ declare const plugin: {
61
65
  'no-alias': import("eslint").Rule.RuleModule;
62
66
  'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
63
67
  'use-recommended-utils': import("eslint").Rule.RuleModule;
68
+ 'valid-gate-name': import("eslint").Rule.RuleModule;
64
69
  'no-sparse-checkout': import("eslint").Rule.RuleModule;
65
70
  'no-direct-document-usage': import("eslint").Rule.RuleModule;
66
71
  'no-set-immediate': import("eslint").Rule.RuleModule;
67
72
  'prefer-crypto-random-uuid': import("eslint").Rule.RuleModule;
73
+ 'no-barrel-entry-imports': import("eslint").Rule.RuleModule;
74
+ 'no-barrel-entry-jest-mock': import("eslint").Rule.RuleModule;
75
+ 'no-jest-mock-barrel-files': import("eslint").Rule.RuleModule;
76
+ 'no-relative-barrel-file-imports': import("eslint").Rule.RuleModule;
77
+ 'no-conversation-assistant-barrel-imports': import("eslint").Rule.RuleModule;
68
78
  };
69
79
  configs: {
70
80
  recommended: {
@@ -76,6 +86,7 @@ declare const plugin: {
76
86
  '@atlaskit/platform/inline-usage': "error";
77
87
  '@atlaskit/platform/prefer-fg': "error";
78
88
  '@atlaskit/platform/no-alias': "error";
89
+ '@atlaskit/platform/valid-gate-name': "error";
79
90
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
80
91
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
81
92
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -110,6 +121,7 @@ declare const plugin: {
110
121
  '@atlaskit/platform/inline-usage': "error";
111
122
  '@atlaskit/platform/prefer-fg': "error";
112
123
  '@atlaskit/platform/no-alias': "error";
124
+ '@atlaskit/platform/valid-gate-name': "error";
113
125
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
114
126
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
115
127
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -199,6 +211,7 @@ declare const configs: {
199
211
  '@atlaskit/platform/inline-usage': "error";
200
212
  '@atlaskit/platform/prefer-fg': "error";
201
213
  '@atlaskit/platform/no-alias': "error";
214
+ '@atlaskit/platform/valid-gate-name': "error";
202
215
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
203
216
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
204
217
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -233,6 +246,7 @@ declare const configs: {
233
246
  '@atlaskit/platform/inline-usage': "error";
234
247
  '@atlaskit/platform/prefer-fg': "error";
235
248
  '@atlaskit/platform/no-alias': "error";
249
+ '@atlaskit/platform/valid-gate-name': "error";
236
250
  '@atlaskit/platform/ensure-feature-flag-registration': "error";
237
251
  '@atlaskit/platform/ensure-test-runner-arguments': "error";
238
252
  '@atlaskit/platform/ensure-test-runner-nested-count': "warn";
@@ -0,0 +1,9 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type FileSystem } from '../shared/types';
3
+ /**
4
+ * Factory function to create the ESLint rule with a given file system.
5
+ * This enables testing with mock file systems.
6
+ */
7
+ export declare function createRule(fs: FileSystem): Rule.RuleModule;
8
+ declare const rule: Rule.RuleModule;
9
+ export default rule;
@@ -0,0 +1,9 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type FileSystem } from '../shared/types';
3
+ /**
4
+ * Factory function to create the ESLint rule with a given file system.
5
+ * This enables testing with mock file systems.
6
+ */
7
+ export declare function createRule(fs: FileSystem): Rule.RuleModule;
8
+ declare const rule: Rule.RuleModule;
9
+ export default rule;
@@ -0,0 +1,22 @@
1
+ import type { Rule } from 'eslint';
2
+ import { type ExportInfo, type FileSystem } from '../shared/types';
3
+ /**
4
+ * Validate and resolve a barrel file from an import path
5
+ * Returns null if not a valid relative barrel import
6
+ */
7
+ export declare function validateAndResolveBarrelFile({ importPath, basedir, workspaceRoot, fs, }: {
8
+ importPath: string;
9
+ basedir: string;
10
+ workspaceRoot: string;
11
+ fs: FileSystem;
12
+ }): {
13
+ resolvedPath: string;
14
+ exportMap: Map<string, ExportInfo>;
15
+ } | null;
16
+ /**
17
+ * Factory function to create the ESLint rule with a given file system.
18
+ * This enables testing with mock file systems.
19
+ */
20
+ export declare function createRule(fs: FileSystem): Rule.RuleModule;
21
+ declare const rule: Rule.RuleModule;
22
+ export default rule;