Skip to content

Commit a1d5a2f

Browse files
committed
fix: resolve ESLint errors and warnings
1 parent c25cd6d commit a1d5a2f

38 files changed

+137
-113
lines changed

eslint.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export default tseslint.config(
2828
String.raw`^.*/eslint(\.base)?\.config\.[cm]?js$`,
2929
String.raw`^.*/code-pushup\.(config|preset)(\.m?[jt]s)?$`,
3030
'^[./]+/tools/.*$',
31+
String.raw`^[./]+/(testing/)?test-setup-config/src/index\.js$`,
3132
],
3233
depConstraints: [
3334
{
@@ -127,7 +128,7 @@ export default tseslint.config(
127128
{
128129
// tests need only be compatible with local Node version
129130
// publishable packages should pick up version range from "engines" in their package.json
130-
files: ['e2e/**/*.ts', 'testing/**/*.ts'],
131+
files: ['e2e/**/*.ts', 'testing/**/*.ts', '**/*.test.ts'],
131132
settings: {
132133
node: {
133134
version: fs.readFileSync('.node-version', 'utf8'),

packages/ci/vitest.int.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { createIntTestConfig } from '../../testing/test-setup-config/src/index.js';
22

3-
let config = createIntTestConfig('ci');
3+
const baseConfig = createIntTestConfig('ci');
44

5-
config = {
6-
...config,
5+
const config = {
6+
...baseConfig,
77
test: {
8-
...config.test,
8+
...baseConfig.test,
99
setupFiles: [
10-
...(config.test!.setupFiles || []),
10+
...(baseConfig.test!.setupFiles || []),
1111
'../../testing/test-setup/src/lib/logger.mock.ts',
1212
],
1313
},

packages/ci/vitest.unit.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import { createUnitTestConfig } from '../../testing/test-setup-config/src/index.js';
22

3-
let config = createUnitTestConfig('ci');
3+
const baseConfig = createUnitTestConfig('ci');
44

5-
config = {
6-
...config,
5+
const config = {
6+
...baseConfig,
77
test: {
8-
...config.test,
8+
...baseConfig.test,
99
setupFiles: [
10-
...(config.test!.setupFiles || []),
10+
...(baseConfig.test!.setupFiles || []),
1111
'../../testing/test-setup/src/lib/logger.mock.ts',
1212
],
1313
},

packages/core/src/lib/implementation/execute-plugin.unit.test.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('executePlugin', () => {
2424
ReturnType<(typeof runnerModule)['executePluginRunner']>
2525
>;
2626

27-
beforeAll(() => {
27+
beforeEach(() => {
2828
readRunnerResultsSpy = vi.spyOn(runnerModule, 'readRunnerResults');
2929
executePluginRunnerSpy = vi.spyOn(runnerModule, 'executePluginRunner');
3030
});
@@ -35,11 +35,6 @@ describe('executePlugin', () => {
3535
});
3636

3737
it('should execute a valid plugin config and pass runner params', async () => {
38-
const executePluginRunnerSpy = vi.spyOn(
39-
runnerModule,
40-
'executePluginRunner',
41-
);
42-
4338
await expect(
4439
executePlugin(MINIMAL_PLUGIN_CONFIG_MOCK, {
4540
persist: {},
@@ -68,8 +63,6 @@ describe('executePlugin', () => {
6863
});
6964

7065
it('should try to read cache if cache.read is true', async () => {
71-
const readRunnerResultsSpy = vi.spyOn(runnerModule, 'readRunnerResults');
72-
7366
const validRunnerResult = {
7467
duration: 0, // readRunnerResults now automatically sets this to 0 for cache hits
7568
date: new Date().toISOString(), // readRunnerResults sets this to current time
@@ -106,12 +99,6 @@ describe('executePlugin', () => {
10699
});
107100

108101
it('should try to execute runner if cache.read is true and file not present', async () => {
109-
const readRunnerResultsSpy = vi.spyOn(runnerModule, 'readRunnerResults');
110-
const executePluginRunnerSpy = vi.spyOn(
111-
runnerModule,
112-
'executePluginRunner',
113-
);
114-
115102
readRunnerResultsSpy.mockResolvedValue(null);
116103
const runnerResult = {
117104
duration: 1000,

packages/core/src/lib/implementation/runner.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,15 @@ export async function executeRunnerConfig(
4545
await removeDirectoryIfExists(path.dirname(outputFile));
4646

4747
// transform unknownAuditOutputs to auditOutputs
48-
const audits = outputTransform ? await outputTransform(outputs) : outputs;
49-
50-
return audits;
48+
return outputTransform ? await outputTransform(outputs) : outputs;
5149
}
5250

5351
export async function executeRunnerFunction(
5452
runner: RunnerFunction,
5553
args: RunnerArgs,
5654
): Promise<unknown> {
5755
// execute plugin runner
58-
const audits = await runner(args);
59-
return audits;
56+
return runner(args);
6057
}
6158

6259
/**

packages/models/src/lib/implementation/validate.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type SchemaValidationContext = {
1111
*/
1212
type ZodInputLooseAutocomplete<T extends ZodType> =
1313
| z.input<T>
14+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
1415
| {}
1516
| null
1617
| undefined;

packages/models/src/lib/implementation/validate.unit.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('validate', () => {
1515
afterEach(async () => {
1616
// Allow any lingering async operations from transforms to complete
1717
// This prevents unhandled rejections in subsequent tests
18-
await new Promise(resolve => setImmediate(resolve));
18+
await new Promise(setImmediate);
1919
});
2020

2121
it('should return parsed data if valid', () => {

packages/models/src/lib/plugin-config.unit.test.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { describe, expect, it } from 'vitest';
2+
import { ZodError } from 'zod';
23
import {
34
type PluginConfig,
45
pluginConfigSchema,
@@ -164,28 +165,28 @@ describe('pluginUrlsSchema', () => {
164165
});
165166

166167
it('should throw for invalid URL', () => {
167-
expect(() => pluginUrlsSchema.parse('invalid')).toThrow();
168+
expect(() => pluginUrlsSchema.parse('invalid')).toThrow(ZodError);
168169
});
169170

170171
it('should throw for array with invalid URL', () => {
171172
expect(() =>
172173
pluginUrlsSchema.parse(['https://example.com', 'invalid']),
173-
).toThrow();
174+
).toThrow(ZodError);
174175
});
175176

176177
it('should throw for object with invalid URL', () => {
177-
expect(() => pluginUrlsSchema.parse({ invalid: 1 })).toThrow();
178+
expect(() => pluginUrlsSchema.parse({ invalid: 1 })).toThrow(ZodError);
178179
});
179180

180181
it('should throw for invalid negative weight', () => {
181-
expect(() =>
182-
pluginUrlsSchema.parse({ 'https://example.com': -1 }),
183-
).toThrow();
182+
expect(() => pluginUrlsSchema.parse({ 'https://example.com': -1 })).toThrow(
183+
ZodError,
184+
);
184185
});
185186

186187
it('should throw for invalid string weight', () => {
187188
expect(() =>
188189
pluginUrlsSchema.parse({ 'https://example.com': '1' }),
189-
).toThrow();
190+
).toThrow(ZodError);
190191
});
191192
});

packages/nx-plugin/src/executors/cli/executor.unit.test.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ describe('runAutorunExecutor', () => {
1616
beforeAll(() => {
1717
Object.entries(process.env)
1818
.filter(([k]) => k.startsWith('CP_'))
19-
.forEach(([k]) => delete process.env[k]);
19+
.forEach(([k]) => Reflect.deleteProperty(process.env, k));
2020
});
2121

2222
afterAll(() => {
23-
Object.entries(processEnvCP).forEach(([k, v]) => (process.env[k] = v));
23+
Object.entries(processEnvCP).forEach(([k, v]) =>
24+
Reflect.set(process.env, k, v),
25+
);
2426
});
2527

2628
beforeEach(() => {

packages/nx-plugin/src/executors/internal/cli.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { logger } from '@nx/devkit';
2-
31
export function createCliCommandString(options?: {
42
args?: Record<string, unknown>;
53
command?: string;

0 commit comments

Comments
 (0)