@atlaskit/eslint-plugin-platform 2.7.2 → 2.9.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.
- package/CHANGELOG.md +16 -0
- package/dist/cjs/index.js +19 -3
- package/dist/cjs/rules/ensure-use-sync-external-store-server-snapshot/index.js +41 -0
- package/dist/cjs/rules/feature-gating/valid-gate-name/index.js +60 -0
- package/dist/cjs/rules/import/no-barrel-entry-imports/index.js +1279 -0
- package/dist/cjs/rules/import/no-barrel-entry-jest-mock/index.js +1659 -0
- package/dist/cjs/rules/import/no-conversation-assistant-barrel-imports/index.js +43 -0
- package/dist/cjs/rules/import/no-jest-mock-barrel-files/index.js +1402 -0
- package/dist/cjs/rules/import/no-relative-barrel-file-imports/index.js +781 -0
- package/dist/cjs/rules/import/shared/barrel-parsing.js +511 -0
- package/dist/cjs/rules/import/shared/file-system.js +186 -0
- package/dist/cjs/rules/import/shared/jest-utils.js +244 -0
- package/dist/cjs/rules/import/shared/package-registry.js +263 -0
- package/dist/cjs/rules/import/shared/package-resolution.js +318 -0
- package/dist/cjs/rules/import/shared/perf.js +89 -0
- package/dist/cjs/rules/import/shared/types.js +67 -0
- package/dist/cjs/rules/visit-example-type-import-required/index.js +409 -0
- package/dist/es2019/index.js +19 -3
- package/dist/es2019/rules/ensure-use-sync-external-store-server-snapshot/index.js +43 -0
- package/dist/es2019/rules/feature-gating/valid-gate-name/index.js +52 -0
- package/dist/es2019/rules/import/no-barrel-entry-imports/index.js +1158 -0
- package/dist/es2019/rules/import/no-barrel-entry-jest-mock/index.js +1341 -0
- package/dist/es2019/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
- package/dist/es2019/rules/import/no-jest-mock-barrel-files/index.js +1180 -0
- package/dist/es2019/rules/import/no-relative-barrel-file-imports/index.js +742 -0
- package/dist/es2019/rules/import/shared/barrel-parsing.js +433 -0
- package/dist/es2019/rules/import/shared/file-system.js +174 -0
- package/dist/es2019/rules/import/shared/jest-utils.js +203 -0
- package/dist/es2019/rules/import/shared/package-registry.js +240 -0
- package/dist/es2019/rules/import/shared/package-resolution.js +253 -0
- package/dist/es2019/rules/import/shared/perf.js +83 -0
- package/dist/es2019/rules/import/shared/types.js +57 -0
- package/dist/es2019/rules/visit-example-type-import-required/index.js +375 -0
- package/dist/esm/index.js +19 -3
- package/dist/esm/rules/ensure-use-sync-external-store-server-snapshot/index.js +35 -0
- package/dist/esm/rules/feature-gating/valid-gate-name/index.js +53 -0
- package/dist/esm/rules/import/no-barrel-entry-imports/index.js +1272 -0
- package/dist/esm/rules/import/no-barrel-entry-jest-mock/index.js +1650 -0
- package/dist/esm/rules/import/no-conversation-assistant-barrel-imports/index.js +37 -0
- package/dist/esm/rules/import/no-jest-mock-barrel-files/index.js +1392 -0
- package/dist/esm/rules/import/no-relative-barrel-file-imports/index.js +774 -0
- package/dist/esm/rules/import/shared/barrel-parsing.js +500 -0
- package/dist/esm/rules/import/shared/file-system.js +176 -0
- package/dist/esm/rules/import/shared/jest-utils.js +231 -0
- package/dist/esm/rules/import/shared/package-registry.js +256 -0
- package/dist/esm/rules/import/shared/package-resolution.js +306 -0
- package/dist/esm/rules/import/shared/perf.js +80 -0
- package/dist/esm/rules/import/shared/types.js +61 -0
- package/dist/esm/rules/visit-example-type-import-required/index.js +402 -0
- package/dist/types/index.d.ts +28 -2
- package/dist/types/rules/ensure-use-sync-external-store-server-snapshot/index.d.ts +3 -0
- package/dist/types/rules/feature-gating/valid-gate-name/index.d.ts +3 -0
- package/dist/types/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
- package/dist/types/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
- package/dist/types/rules/import/no-conversation-assistant-barrel-imports/index.d.ts +3 -0
- package/dist/types/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
- package/dist/types/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
- package/dist/types/rules/import/shared/barrel-parsing.d.ts +30 -0
- package/dist/types/rules/import/shared/file-system.d.ts +38 -0
- package/dist/types/rules/import/shared/jest-utils.d.ts +55 -0
- package/dist/types/rules/import/shared/package-registry.d.ts +26 -0
- package/dist/types/rules/import/shared/package-resolution.d.ts +58 -0
- package/dist/types/rules/import/shared/perf.d.ts +13 -0
- package/dist/types/rules/import/shared/types.d.ts +131 -0
- package/dist/types/rules/visit-example-type-import-required/index.d.ts +4 -0
- package/dist/types-ts4.5/index.d.ts +28 -2
- package/dist/types-ts4.5/rules/import/no-barrel-entry-imports/index.d.ts +9 -0
- package/dist/types-ts4.5/rules/import/no-barrel-entry-jest-mock/index.d.ts +9 -0
- package/dist/types-ts4.5/rules/import/no-conversation-assistant-barrel-imports/index.d.ts +3 -0
- package/dist/types-ts4.5/rules/import/no-jest-mock-barrel-files/index.d.ts +22 -0
- package/dist/types-ts4.5/rules/import/no-relative-barrel-file-imports/index.d.ts +5 -0
- package/dist/types-ts4.5/rules/import/shared/barrel-parsing.d.ts +30 -0
- package/dist/types-ts4.5/rules/import/shared/file-system.d.ts +38 -0
- package/dist/types-ts4.5/rules/import/shared/jest-utils.d.ts +55 -0
- package/dist/types-ts4.5/rules/import/shared/package-registry.d.ts +26 -0
- package/dist/types-ts4.5/rules/import/shared/package-resolution.d.ts +58 -0
- package/dist/types-ts4.5/rules/import/shared/perf.d.ts +13 -0
- package/dist/types-ts4.5/rules/import/shared/types.d.ts +131 -0
- package/dist/types-ts4.5/rules/visit-example-type-import-required/index.d.ts +4 -0
- package/package.json +6 -2
- package/dist/cjs/rules/ensure-native-and-af-exports-synced/index.js +0 -158
- package/dist/es2019/rules/ensure-native-and-af-exports-synced/index.js +0 -146
- package/dist/esm/rules/ensure-native-and-af-exports-synced/index.js +0 -151
- /package/dist/types-ts4.5/rules/{ensure-native-and-af-exports-synced → ensure-use-sync-external-store-server-snapshot}/index.d.ts +0 -0
- /package/dist/{types/rules/ensure-native-and-af-exports-synced → types-ts4.5/rules/feature-gating/valid-gate-name}/index.d.ts +0 -0
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
* Find all jest.requireActual() calls in the AST whose import path matches a given target.
|
|
38
|
+
* Works identically to findJestRequireMockCalls but for requireActual.
|
|
39
|
+
*/
|
|
40
|
+
export declare function findJestRequireActualCalls({ ast, matchPath, }: {
|
|
41
|
+
ast: TSESTree.Program;
|
|
42
|
+
matchPath: (candidatePath: string) => boolean;
|
|
43
|
+
}): TSESTree.CallExpression[];
|
|
44
|
+
/**
|
|
45
|
+
* Determine the best new import path for a jest.requireMock() call by inspecting
|
|
46
|
+
* the destructured symbols or property access at the call site.
|
|
47
|
+
*
|
|
48
|
+
* @param requireMockNode - The jest.requireMock() CallExpression node
|
|
49
|
+
* @param symbolToNewPath - Map from symbol name to the new mock path that provides it
|
|
50
|
+
* @returns The resolved new path, or null if it cannot be determined
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveNewPathForRequireMock({ requireMockNode, symbolToNewPath, }: {
|
|
53
|
+
requireMockNode: TSESTree.CallExpression;
|
|
54
|
+
symbolToNewPath: Map<string, string>;
|
|
55
|
+
}): 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,58 @@
|
|
|
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
|
+
export interface ExportMatchResult {
|
|
10
|
+
exportPath: string;
|
|
11
|
+
/**
|
|
12
|
+
* When resolved through an entry-point wrapper, the name under which
|
|
13
|
+
* the symbol is exported from the entry-point file.
|
|
14
|
+
* Callers use this to override the barrel's `originalName` so the
|
|
15
|
+
* generated import matches the entry-point's export shape.
|
|
16
|
+
*/
|
|
17
|
+
entryPointExportName?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Find a matching export entry for a given source file path.
|
|
21
|
+
* Returns the export path (e.g., "./controllers/analytics") or null if not found.
|
|
22
|
+
*
|
|
23
|
+
* When `fs` is provided, also checks entry-point wrapper files. If an export resolves
|
|
24
|
+
* to a file inside a recognized entry-points folder (entry-points, entrypoints, etc.),
|
|
25
|
+
* the wrapper is parsed to see if it re-exports from `sourceFilePath`.
|
|
26
|
+
*
|
|
27
|
+
* `sourceExportName` is the name under which the symbol is exported from the source file
|
|
28
|
+
* (e.g. `'default'`). Used to look up the corresponding entry-point export name so the
|
|
29
|
+
* caller can generate the correct import style.
|
|
30
|
+
*/
|
|
31
|
+
export declare function findExportForSourceFile({ sourceFilePath, exportsMap, fs, sourceExportName, }: {
|
|
32
|
+
sourceFilePath: string;
|
|
33
|
+
exportsMap: Map<string, string>;
|
|
34
|
+
fs?: FileSystem;
|
|
35
|
+
sourceExportName?: string;
|
|
36
|
+
}): ExportMatchResult | null;
|
|
37
|
+
/**
|
|
38
|
+
* Extract the package name and subpath from an import specifier.
|
|
39
|
+
* Returns null if the import is not a scoped package import.
|
|
40
|
+
*/
|
|
41
|
+
export declare function extractPackageNameFromImport(moduleSpecifier: string): {
|
|
42
|
+
packageName: string;
|
|
43
|
+
subPath: string;
|
|
44
|
+
} | null;
|
|
45
|
+
/**
|
|
46
|
+
* Resolve a cross-package import to its package directory and export info.
|
|
47
|
+
* Returns null if the package is not in the target folder or cannot be resolved.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveCrossPackageImport({ moduleSpecifier, workspaceRoot, fs, }: {
|
|
50
|
+
moduleSpecifier: string;
|
|
51
|
+
workspaceRoot: string;
|
|
52
|
+
fs: FileSystem;
|
|
53
|
+
}): {
|
|
54
|
+
packageName: string;
|
|
55
|
+
packageDir: string;
|
|
56
|
+
exportPath: string;
|
|
57
|
+
entryFilePath: string;
|
|
58
|
+
} | 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,18 @@ 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;
|
|
37
|
+
'visit-example-type-import-required': import("eslint").Rule.RuleModule;
|
|
38
|
+
'ensure-use-sync-external-store-server-snapshot': import("eslint").Rule.RuleModule;
|
|
32
39
|
};
|
|
33
40
|
declare const plugin: {
|
|
34
41
|
meta: {
|
|
@@ -51,7 +58,6 @@ declare const plugin: {
|
|
|
51
58
|
'no-pre-post-install-scripts': import("eslint").Rule.RuleModule;
|
|
52
59
|
'no-invalid-storybook-decorator-usage': import("eslint").Rule.RuleModule;
|
|
53
60
|
'ensure-publish-valid': import("eslint").Rule.RuleModule;
|
|
54
|
-
'ensure-native-and-af-exports-synced': import("eslint").Rule.RuleModule;
|
|
55
61
|
'no-module-level-eval': import("eslint").Rule.RuleModule;
|
|
56
62
|
'no-module-level-eval-nav4': import("eslint").Rule.RuleModule;
|
|
57
63
|
'static-feature-flags': import("eslint").Rule.RuleModule;
|
|
@@ -61,10 +67,18 @@ declare const plugin: {
|
|
|
61
67
|
'no-alias': import("eslint").Rule.RuleModule;
|
|
62
68
|
'use-entrypoints-in-examples': import("eslint").Rule.RuleModule;
|
|
63
69
|
'use-recommended-utils': import("eslint").Rule.RuleModule;
|
|
70
|
+
'valid-gate-name': import("eslint").Rule.RuleModule;
|
|
64
71
|
'no-sparse-checkout': import("eslint").Rule.RuleModule;
|
|
65
72
|
'no-direct-document-usage': import("eslint").Rule.RuleModule;
|
|
66
73
|
'no-set-immediate': import("eslint").Rule.RuleModule;
|
|
67
74
|
'prefer-crypto-random-uuid': import("eslint").Rule.RuleModule;
|
|
75
|
+
'no-barrel-entry-imports': import("eslint").Rule.RuleModule;
|
|
76
|
+
'no-barrel-entry-jest-mock': import("eslint").Rule.RuleModule;
|
|
77
|
+
'no-jest-mock-barrel-files': import("eslint").Rule.RuleModule;
|
|
78
|
+
'no-relative-barrel-file-imports': import("eslint").Rule.RuleModule;
|
|
79
|
+
'no-conversation-assistant-barrel-imports': import("eslint").Rule.RuleModule;
|
|
80
|
+
'visit-example-type-import-required': import("eslint").Rule.RuleModule;
|
|
81
|
+
'ensure-use-sync-external-store-server-snapshot': import("eslint").Rule.RuleModule;
|
|
68
82
|
};
|
|
69
83
|
configs: {
|
|
70
84
|
recommended: {
|
|
@@ -76,9 +90,11 @@ declare const plugin: {
|
|
|
76
90
|
'@atlaskit/platform/inline-usage': "error";
|
|
77
91
|
'@atlaskit/platform/prefer-fg': "error";
|
|
78
92
|
'@atlaskit/platform/no-alias': "error";
|
|
93
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
79
94
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
80
95
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
81
96
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
97
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
82
98
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
83
99
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
84
100
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -110,9 +126,11 @@ declare const plugin: {
|
|
|
110
126
|
'@atlaskit/platform/inline-usage': "error";
|
|
111
127
|
'@atlaskit/platform/prefer-fg': "error";
|
|
112
128
|
'@atlaskit/platform/no-alias': "error";
|
|
129
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
113
130
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
114
131
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
115
132
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
133
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
116
134
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
117
135
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
118
136
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -137,6 +155,7 @@ declare const plugin: {
|
|
|
137
155
|
rules: {
|
|
138
156
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
139
157
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
158
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
140
159
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
141
160
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
142
161
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -164,6 +183,7 @@ declare const plugin: {
|
|
|
164
183
|
rules: {
|
|
165
184
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
166
185
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
186
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
167
187
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
168
188
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
169
189
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -199,9 +219,11 @@ declare const configs: {
|
|
|
199
219
|
'@atlaskit/platform/inline-usage': "error";
|
|
200
220
|
'@atlaskit/platform/prefer-fg': "error";
|
|
201
221
|
'@atlaskit/platform/no-alias': "error";
|
|
222
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
202
223
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
203
224
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
204
225
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
226
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
205
227
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
206
228
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
207
229
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -233,9 +255,11 @@ declare const configs: {
|
|
|
233
255
|
'@atlaskit/platform/inline-usage': "error";
|
|
234
256
|
'@atlaskit/platform/prefer-fg': "error";
|
|
235
257
|
'@atlaskit/platform/no-alias': "error";
|
|
258
|
+
'@atlaskit/platform/valid-gate-name': "error";
|
|
236
259
|
'@atlaskit/platform/ensure-feature-flag-registration': "error";
|
|
237
260
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
238
261
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
262
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
239
263
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
240
264
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
241
265
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -260,6 +284,7 @@ declare const configs: {
|
|
|
260
284
|
rules: {
|
|
261
285
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
262
286
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
287
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
263
288
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
264
289
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
265
290
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -287,6 +312,7 @@ declare const configs: {
|
|
|
287
312
|
rules: {
|
|
288
313
|
'@atlaskit/platform/ensure-test-runner-arguments': "error";
|
|
289
314
|
'@atlaskit/platform/ensure-test-runner-nested-count': "warn";
|
|
315
|
+
'@atlaskit/platform/ensure-use-sync-external-store-server-snapshot': "error";
|
|
290
316
|
'@atlaskit/platform/no-invalid-feature-flag-usage': "error";
|
|
291
317
|
'@atlaskit/platform/no-invalid-storybook-decorator-usage': "error";
|
|
292
318
|
'@atlaskit/platform/ensure-atlassian-team': "error";
|
|
@@ -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;
|
|
@@ -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,55 @@
|
|
|
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
|
+
* Find all jest.requireActual() calls in the AST whose import path matches a given target.
|
|
38
|
+
* Works identically to findJestRequireMockCalls but for requireActual.
|
|
39
|
+
*/
|
|
40
|
+
export declare function findJestRequireActualCalls({ ast, matchPath, }: {
|
|
41
|
+
ast: TSESTree.Program;
|
|
42
|
+
matchPath: (candidatePath: string) => boolean;
|
|
43
|
+
}): TSESTree.CallExpression[];
|
|
44
|
+
/**
|
|
45
|
+
* Determine the best new import path for a jest.requireMock() call by inspecting
|
|
46
|
+
* the destructured symbols or property access at the call site.
|
|
47
|
+
*
|
|
48
|
+
* @param requireMockNode - The jest.requireMock() CallExpression node
|
|
49
|
+
* @param symbolToNewPath - Map from symbol name to the new mock path that provides it
|
|
50
|
+
* @returns The resolved new path, or null if it cannot be determined
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveNewPathForRequireMock({ requireMockNode, symbolToNewPath, }: {
|
|
53
|
+
requireMockNode: TSESTree.CallExpression;
|
|
54
|
+
symbolToNewPath: Map<string, string>;
|
|
55
|
+
}): 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;
|