Skip to content

Commit 8579540

Browse files
authored
fix: resolve lint warnings (#338)
1 parent ddb2a3a commit 8579540

File tree

28 files changed

+38
-28
lines changed

28 files changed

+38
-28
lines changed

eslint.config.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ export default tseslint.config(
3535
...importPlugin.configs.recommended.rules,
3636
...react.configs.recommended.rules,
3737
...security.configs.recommended.rules,
38+
// CLI inherently works with dynamic file paths and Record lookups — these are false positives
39+
'security/detect-non-literal-fs-filename': 'off',
40+
'security/detect-object-injection': 'off',
3841
...react.configs['jsx-runtime'].rules,
3942
...reactHooks.configs.recommended.rules,
4043
'react-hooks/preserve-manual-memoization': 'warn',

src/cli/cdk/local-cdk-project.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class LocalCdkProject {
3232
*/
3333
exists(): boolean {
3434
const packageJson = path.join(this.projectDir, 'package.json');
35-
// eslint-disable-next-line security/detect-non-literal-fs-filename
35+
3636
return fs.existsSync(this.projectDir) && fs.existsSync(packageJson);
3737
}
3838

@@ -41,13 +41,12 @@ export class LocalCdkProject {
4141
* Throws an error if the project is missing or invalid.
4242
*/
4343
validate(): void {
44-
// eslint-disable-next-line security/detect-non-literal-fs-filename
4544
if (!fs.existsSync(this.projectDir)) {
4645
throw new Error(`CDK project not found at ${this.projectDir}. Run 'agentcore create' first.`);
4746
}
4847

4948
const packageJson = path.join(this.projectDir, 'package.json');
50-
// eslint-disable-next-line security/detect-non-literal-fs-filename
49+
5150
if (!fs.existsSync(packageJson)) {
5251
throw new Error(`Invalid CDK project: missing package.json in ${this.projectDir}`);
5352
}

src/cli/commands/add/__tests__/multi-agent-credentials.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable security/detect-non-literal-fs-filename */
21
import { runCLI } from '../../../../test-utils/index.js';
32
import { randomUUID } from 'node:crypto';
43
import { mkdir, readFile, rm, writeFile } from 'node:fs/promises';

src/cli/commands/create/action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export async function createProject(options: CreateProjectOptions): Promise<Crea
5858
try {
5959
// Create project directory
6060
onProgress?.(`Create ${name}/ project directory`, 'start');
61-
// eslint-disable-next-line security/detect-non-literal-fs-filename
61+
6262
await mkdir(projectRoot, { recursive: true });
6363
onProgress?.(`Create ${name}/ project directory`, 'done');
6464

src/cli/commands/create/validate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const MEMORY_OPTIONS = ['none', 'shortTerm', 'longAndShortTerm'] as const;
1919
/** Check if a folder with the given name already exists in the directory */
2020
export function validateFolderNotExists(name: string, cwd: string): true | string {
2121
const projectPath = join(cwd, name);
22-
// eslint-disable-next-line security/detect-non-literal-fs-filename
22+
2323
if (existsSync(projectPath)) {
2424
return `A folder named '${name}' already exists in this directory`;
2525
}

src/cli/commands/deploy/__tests__/deploy-teardown.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ describe('deploy with empty agents and deployed state (teardown)', () => {
4949
it('requires --yes to confirm teardown deploy when deployed state exists', async () => {
5050
// Write aws-targets.json so deploy can find the target
5151
const awsTargetsPath = join(projectDir, 'agentcore', 'aws-targets.json');
52-
// eslint-disable-next-line security/detect-non-literal-fs-filename
52+
5353
await writeFile(
5454
awsTargetsPath,
5555
JSON.stringify([{ name: 'default', account: '123456789012', region: 'us-east-1' }])
@@ -60,7 +60,7 @@ describe('deploy with empty agents and deployed state (teardown)', () => {
6060
const cliDir = join(projectDir, 'agentcore', '.cli');
6161
await mkdir(cliDir, { recursive: true });
6262
const deployedStatePath = join(cliDir, 'deployed-state.json');
63-
// eslint-disable-next-line security/detect-non-literal-fs-filename
63+
6464
await writeFile(
6565
deployedStatePath,
6666
JSON.stringify({

src/cli/commands/deploy/__tests__/deploy.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ describe('deploy without agents', () => {
2828

2929
beforeAll(async () => {
3030
noAgentTestDir = join(tmpdir(), `agentcore-deploy-noagent-${randomUUID()}`);
31-
// eslint-disable-next-line security/detect-non-literal-fs-filename
31+
3232
await mkdir(noAgentTestDir, { recursive: true });
3333

3434
// Create project without any agents
@@ -41,7 +41,7 @@ describe('deploy without agents', () => {
4141

4242
// Write aws-targets.json directly (replaces old 'add target' command)
4343
const awsTargetsPath = join(noAgentProjectDir, 'agentcore', 'aws-targets.json');
44-
// eslint-disable-next-line security/detect-non-literal-fs-filename
44+
4545
await writeFile(
4646
awsTargetsPath,
4747
JSON.stringify([{ name: 'default', account: '123456789012', region: 'us-east-1' }])

src/cli/commands/remove/__tests__/remove-all.test.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('remove all command', () => {
1111

1212
beforeAll(async () => {
1313
testDir = join(tmpdir(), `agentcore-remove-all-${randomUUID()}`);
14-
// eslint-disable-next-line security/detect-non-literal-fs-filename
14+
1515
await mkdir(testDir, { recursive: true });
1616

1717
// Create project with agent
@@ -53,7 +53,7 @@ describe('remove all command', () => {
5353
it('preserves aws-targets.json and deployed-state.json after remove all', async () => {
5454
// Write aws-targets.json so we can verify it's preserved
5555
const awsTargetsPath = join(projectDir, 'agentcore', 'aws-targets.json');
56-
// eslint-disable-next-line security/detect-non-literal-fs-filename
56+
5757
await writeFile(
5858
awsTargetsPath,
5959
JSON.stringify([{ name: 'default', account: '123456789012', region: 'us-east-1' }])
@@ -62,10 +62,10 @@ describe('remove all command', () => {
6262
// Simulate a deployed state entry so we can verify it is preserved
6363
// deployed-state.json lives in agentcore/.cli/
6464
const cliDir = join(projectDir, 'agentcore', '.cli');
65-
// eslint-disable-next-line security/detect-non-literal-fs-filename
65+
6666
await mkdir(cliDir, { recursive: true });
6767
const deployedStatePath = join(cliDir, 'deployed-state.json');
68-
// eslint-disable-next-line security/detect-non-literal-fs-filename
68+
6969
await writeFile(
7070
deployedStatePath,
7171
JSON.stringify({ targets: { default: { resources: { stackName: 'TestStack' } } } })
@@ -78,20 +78,20 @@ describe('remove all command', () => {
7878
expect(json.success).toBe(true);
7979

8080
// Verify aws-targets.json is preserved (NOT reset to empty)
81-
// eslint-disable-next-line security/detect-non-literal-fs-filename
81+
8282
const targetsAfter = JSON.parse(await readFile(awsTargetsPath, 'utf-8'));
8383
expect(targetsAfter.length, 'aws-targets.json should be preserved after remove all').toBe(1);
8484

8585
// Verify deployed-state.json is preserved (NOT reset to empty)
86-
// eslint-disable-next-line security/detect-non-literal-fs-filename
86+
8787
const deployedStateAfter = JSON.parse(await readFile(deployedStatePath, 'utf-8'));
8888
expect(
8989
Object.keys(deployedStateAfter.targets).length,
9090
'deployed-state.json targets should be preserved after remove all'
9191
).toBe(1);
9292

9393
// Verify agentcore.json agents ARE cleared
94-
// eslint-disable-next-line security/detect-non-literal-fs-filename
94+
9595
const schema = JSON.parse(await readFile(join(projectDir, 'agentcore', 'agentcore.json'), 'utf-8'));
9696
expect(schema.agents.length, 'Agents should be cleared after remove all').toBe(0);
9797
});

src/cli/commands/validate/__tests__/action.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ describe('handleValidate', () => {
150150
it('formats ConfigValidationError with its message', async () => {
151151
mockFindConfigRoot.mockReturnValue('/project/agentcore');
152152
const { ConfigValidationError } = await import('../../../../lib/index.js');
153-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-explicit-any
154153
mockReadProjectSpec.mockRejectedValue(new (ConfigValidationError as any)('field "name" is required'));
155154

156155
const result = await handleValidate({});

src/cli/logging/remove-logger.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable security/detect-object-injection, security/detect-non-literal-fs-filename */
21
import { CLI_LOGS_DIR, CLI_SYSTEM_DIR, CONFIG_DIR, findConfigRoot } from '../../lib';
32
import type { RemovalPreview } from '../operations/remove';
43
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';

0 commit comments

Comments
 (0)