Skip to content

Commit 9c39d61

Browse files
authored
feat: Prevent self-imports and fix build loop (#12309)
1 parent e2876a5 commit 9c39d61

7 files changed

Lines changed: 36 additions & 8 deletions

File tree

eslint.config.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,31 @@ export default tseslint.config(
161161
'default-case': 'error',
162162
},
163163
},
164+
{
165+
// Prevent self-imports in packages
166+
files: ['packages/core/src/**/*.{ts,tsx}'],
167+
rules: {
168+
'no-restricted-imports': [
169+
'error',
170+
{
171+
name: '@google/gemini-cli-core',
172+
message: 'Please use relative imports within the @google/gemini-cli-core package.',
173+
},
174+
],
175+
},
176+
},
177+
{
178+
files: ['packages/cli/src/**/*.{ts,tsx}'],
179+
rules: {
180+
'no-restricted-imports': [
181+
'error',
182+
{
183+
name: '@google/gemini-cli',
184+
message: 'Please use relative imports within the @google/gemini-cli package.',
185+
},
186+
],
187+
},
188+
},
164189
{
165190
files: ['packages/*/src/**/*.test.{ts,tsx}'],
166191
plugins: {

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,10 @@
127127
"lint-staged": {
128128
"*.{js,jsx,ts,tsx}": [
129129
"prettier --write",
130-
"eslint --fix --max-warnings 0"
130+
"eslint --fix --max-warnings 0 --no-warn-ignored"
131+
],
132+
"eslint.config.js": [
133+
"prettier --write"
131134
],
132135
"*.{json,md}": [
133136
"prettier --write"

packages/core/src/code_assist/oauth-credential-storage.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { type Credentials } from 'google-auth-library';
88
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
99
import { OAuthCredentialStorage } from './oauth-credential-storage.js';
1010
import type { OAuthCredentials } from '../mcp/token-storage/types.js';
11-
import { coreEvents } from '@google/gemini-cli-core';
11+
import { coreEvents } from '../utils/events.js';
1212

1313
import * as path from 'node:path';
1414
import * as os from 'node:os';
@@ -31,7 +31,7 @@ vi.mock('node:fs', () => ({
3131
}));
3232
vi.mock('node:os');
3333
vi.mock('node:path');
34-
vi.mock('@google/gemini-cli-core', () => ({
34+
vi.mock('../utils/events.js', () => ({
3535
coreEvents: {
3636
emitFeedback: vi.fn(),
3737
},

packages/core/src/code_assist/oauth-credential-storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import * as path from 'node:path';
1212
import * as os from 'node:os';
1313
import { promises as fs } from 'node:fs';
1414
import { GEMINI_DIR } from '../utils/paths.js';
15-
import { coreEvents } from '@google/gemini-cli-core';
15+
import { coreEvents } from '../utils/events.js';
1616

1717
const KEYCHAIN_SERVICE_NAME = 'gemini-cli-oauth';
1818
const MAIN_ACCOUNT_KEY = 'main-account';

packages/core/src/mcp/oauth-token-storage.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import { coreEvents } from '@google/gemini-cli-core';
7+
import { coreEvents } from '../utils/events.js';
88
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
99
import { promises as fs } from 'node:fs';
1010
import * as path from 'node:path';
@@ -34,7 +34,7 @@ vi.mock('../config/storage.js', () => ({
3434
},
3535
}));
3636

37-
vi.mock('@google/gemini-cli-core', () => ({
37+
vi.mock('../utils/events.js', () => ({
3838
coreEvents: {
3939
emitFeedback: vi.fn(),
4040
},

packages/core/src/mcp/oauth-token-storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
import { coreEvents } from '@google/gemini-cli-core';
7+
import { coreEvents } from '../utils/events.js';
88
import { promises as fs } from 'node:fs';
99
import * as path from 'node:path';
1010
import { Storage } from '../config/storage.js';

packages/core/src/telemetry/loggers.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ import * as metrics from './metrics.js';
9292
import { FileOperation } from './metrics.js';
9393
import * as sdk from './sdk.js';
9494
import { vi, describe, beforeEach, it, expect, afterEach } from 'vitest';
95-
import { type GeminiCLIExtension } from '@google/gemini-cli-core';
95+
import { type GeminiCLIExtension } from '../config/config.js';
9696
import {
9797
FinishReason,
9898
type CallableTool,

0 commit comments

Comments
 (0)