Skip to content

Commit 6f37840

Browse files
authored
fix: resolve incomplete linting across projects (#1151)
1 parent 96e03ef commit 6f37840

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+159
-152
lines changed

eslint.config.js

Lines changed: 3 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
{
@@ -115,6 +116,7 @@ export default tseslint.config(
115116
files: ['**/*.ts', '**/*.js'],
116117
rules: {
117118
'n/file-extension-in-import': ['error', 'always'],
119+
'unicorn/number-literal-case': 'off',
118120
},
119121
},
120122
{
@@ -127,7 +129,7 @@ export default tseslint.config(
127129
{
128130
// tests need only be compatible with local Node version
129131
// publishable packages should pick up version range from "engines" in their package.json
130-
files: ['e2e/**/*.ts', 'testing/**/*.ts'],
132+
files: ['e2e/**/*.ts', 'testing/**/*.ts', '**/*.test.ts'],
131133
settings: {
132134
node: {
133135
version: fs.readFileSync('.node-version', 'utf8'),

nx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"options": {
7373
"command": "eslint",
7474
"args": [
75-
"{projectRoot}/**/*.ts",
75+
"'{projectRoot}/**/*.ts'",
7676
"{projectRoot}/package.json",
7777
"--config={projectRoot}/eslint.config.js",
7878
"--max-warnings=0",

packages/ci/vitest.int.config.ts

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

3-
let config = createIntTestConfig('ci');
4-
5-
config = {
6-
...config,
7-
test: {
8-
...config.test,
9-
setupFiles: [
10-
...(config.test!.setupFiles || []),
11-
'../../testing/test-setup/src/lib/logger.mock.ts',
12-
],
13-
},
14-
};
15-
16-
export default config;
3+
export default createIntTestConfig('ci');

packages/ci/vitest.unit.config.ts

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

3-
let config = createUnitTestConfig('ci');
4-
5-
config = {
6-
...config,
7-
test: {
8-
...config.test,
9-
setupFiles: [
10-
...(config.test!.setupFiles || []),
11-
'../../testing/test-setup/src/lib/logger.mock.ts',
12-
],
13-
},
14-
};
15-
16-
export default config;
3+
export default createUnitTestConfig('ci');

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(() => {

0 commit comments

Comments
 (0)