Skip to content

Commit d6c85ec

Browse files
authored
fix: lint errors (renovatebot#41808)
* fix: lint errors * test: fix lint
1 parent dd1a102 commit d6c85ec

File tree

7 files changed

+70
-57
lines changed

7 files changed

+70
-57
lines changed

.oxlintrc.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"typescript/await-thenable": "error",
3535
"typescript/no-floating-promises": "error",
3636
"typescript/no-misused-promises": "error",
37+
"typescript/no-misused-spread": "error",
3738
"typescript/no-unsafe-enum-comparison": "error",
3839
"typescript/no-unsafe-unary-minus": "error",
3940
"typescript/no-duplicate-type-constituents": "error",
@@ -66,7 +67,10 @@
6667
"typescript/no-unsafe-assignment": "off",
6768
"typescript/no-unsafe-call": "off",
6869
"typescript/no-unsafe-member-access": "off",
69-
"typescript/no-unsafe-return": "off"
70+
"typescript/no-unsafe-return": "off",
71+
72+
"vitest/no-conditional-tests": "error",
73+
"vitest/hoisted-apis-on-top": "error"
7074
},
7175
"overrides": [
7276
{

lib/config/options/index.spec.ts

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,40 +51,39 @@ describe('config/options/index', () => {
5151

5252
describe('every option with allowedValues and a default must have the default in allowedValues', () => {
5353
const opts = getOptions();
54-
for (const option of opts) {
55-
if (option.allowedValues && !isNullOrUndefined(option.default)) {
56-
it(`${option.name}: \`${option.default}\` is in ${JSON.stringify(option.allowedValues)}`, () => {
57-
expect(option.allowedValues).toBeDefined();
54+
for (const option of opts.filter(
55+
(o) => o.allowedValues && !isNullOrUndefined(o.default),
56+
)) {
57+
it(`${option.name}: \`${option.default}\` is in ${JSON.stringify(option.allowedValues)}`, () => {
58+
expect(option.allowedValues).toBeDefined();
5859

59-
const defaults = Array.isArray(option.default)
60-
? option.default
61-
: [option.default];
62-
for (const defVal of defaults) {
63-
expect(option.allowedValues).toContain(defVal);
64-
}
65-
});
66-
}
60+
const defaults = Array.isArray(option.default)
61+
? option.default
62+
: [option.default];
63+
for (const defVal of defaults) {
64+
expect(option.allowedValues).toContain(defVal);
65+
}
66+
});
6767
}
6868
});
6969

7070
describe('every option with a siblingProperties has a `property` that matches a known option', () => {
7171
const opts = getOptions();
7272
const optionNames = new Set(opts.map((o) => o.name));
7373

74-
for (const option of opts) {
75-
if (option.requiredIf) {
76-
for (const req of option.requiredIf) {
77-
for (const prop of req.siblingProperties) {
78-
it(`${option.name}'s reference to ${prop.property} is valid`, () => {
79-
expect(optionNames).toContain(prop.property);
80-
});
74+
for (const option of opts.filter((o) => o.requiredIf)) {
75+
for (const req of option.requiredIf!) {
76+
for (const prop of req.siblingProperties) {
77+
it(`${option.name}'s reference to ${prop.property} is valid`, () => {
78+
expect(optionNames).toContain(prop.property);
79+
});
8180

82-
const foundOption = opts.filter((o) => o.name === prop.property);
83-
if (foundOption?.length && foundOption[0].allowedValues) {
84-
it(`${option.name}'s value for ${prop.property} is valid, according to allowedValues`, () => {
85-
expect(foundOption[0].allowedValues).toContain(prop.value);
86-
});
87-
}
81+
const foundOption = opts.filter((o) => o.name === prop.property);
82+
// oxlint-disable-next-line vitest/no-conditional-tests -- TODO: fix me
83+
if (foundOption?.length && foundOption[0].allowedValues) {
84+
it(`${option.name}'s value for ${prop.property} is valid, according to allowedValues`, () => {
85+
expect(foundOption[0].allowedValues).toContain(prop.value);
86+
});
8887
}
8988
}
9089
}

lib/config/presets/internal/index.spec.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,29 @@ describe('config/presets/internal/index', () => {
2727
});
2828

2929
for (const [groupName, groupPresets] of Object.entries(internal.groups)) {
30-
for (const [presetName, presetConfig] of Object.entries(groupPresets)) {
31-
const preset = `${groupName}:${presetName}`;
32-
if (presetName !== 'description' && !ignoredPresets.includes(preset)) {
33-
it(`${preset} validates`, async () => {
34-
try {
35-
const { config } = await resolveConfigPresets(
36-
massageConfig(presetConfig),
37-
);
38-
const configType = groupName === 'global' ? 'global' : 'repo';
39-
const res = await validateConfig(configType, config, true);
40-
expect(res.errors).toHaveLength(0);
41-
expect(res.warnings).toHaveLength(0);
42-
} catch (err) {
43-
if (err.validationError) {
44-
throw new Error(err.validationError);
45-
}
46-
throw err;
30+
for (const [presetName, presetConfig] of Object.entries(
31+
groupPresets,
32+
).filter(
33+
([key]) =>
34+
key !== 'description' &&
35+
!ignoredPresets.includes(`${groupName}:${key}`),
36+
)) {
37+
it(`${`${groupName}:${presetName}`} validates`, async () => {
38+
try {
39+
const { config } = await resolveConfigPresets(
40+
massageConfig(presetConfig),
41+
);
42+
const configType = groupName === 'global' ? 'global' : 'repo';
43+
const res = await validateConfig(configType, config, true);
44+
expect(res.errors).toHaveLength(0);
45+
expect(res.warnings).toHaveLength(0);
46+
} catch (err) {
47+
if (err.validationError) {
48+
throw new Error(err.validationError);
4749
}
48-
});
49-
}
50+
throw err;
51+
}
52+
});
5053
}
5154
}
5255

lib/logger/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export default function prepareError(err: Error): Record<string, unknown> {
9595
}
9696

9797
const response: Record<string, unknown> = {
98+
// We want to loose class information, but keep enumerable properties of the error
99+
// oxlint-disable-next-line typescript/no-misused-spread
98100
...err,
99101
};
100102

lib/modules/manager/gradle/extract/consistent-versions-plugin.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,5 +209,10 @@ export function parsePropsFile(
209209
logger.trace(
210210
`Found ${depVerExactMap.size} dependencies and ${depVerRegexMap.size} wildcard dependencies in ${VERSIONS_PROPS}.`,
211211
);
212-
return [depVerExactMap, new Map([...depVerRegexMap].sort().reverse())];
212+
return [
213+
depVerExactMap,
214+
new Map(
215+
[...depVerRegexMap].sort(([ka], [kb]) => ka.localeCompare(kb)).reverse(),
216+
),
217+
];
213218
}

lib/modules/manager/index.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ describe('modules/manager/index', () => {
2525
});
2626

2727
describe('lockFileNames', () => {
28-
for (const [name, mgr] of manager.getManagers()) {
29-
if (mgr.supportsLockFileMaintenance) {
30-
it(`has lockFileNames for ${name}`, () => {
31-
expect(mgr.lockFileNames).toBeNonEmptyArray();
32-
});
33-
}
28+
for (const [name, mgr] of [...manager.getManagers()].filter(
29+
([_, mgr]) => mgr.supportsLockFileMaintenance,
30+
)) {
31+
it(`has lockFileNames for ${name}`, () => {
32+
expect(mgr.lockFileNames).toBeNonEmptyArray();
33+
});
3434
}
3535
});
3636

lib/modules/manager/mise/extract.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
} from '@sindresorhus/is';
99
import { logger } from '../../../logger/index.ts';
1010
import { regEx } from '../../../util/regex.ts';
11-
import type { ToolingConfig } from '../asdf/upgradeable-tooling.ts';
11+
import type { StaticTooling } from '../asdf/upgradeable-tooling.ts';
1212
import type { PackageDependency, PackageFileContent } from '../types.ts';
1313
import type { BackendToolingConfig } from './backends.ts';
1414
import {
@@ -111,7 +111,7 @@ function getToolConfig(
111111
toolName: string,
112112
version: string,
113113
toolOptions: MiseToolOptions,
114-
): ToolingConfig | BackendToolingConfig | null {
114+
): StaticTooling | BackendToolingConfig | null {
115115
switch (backend) {
116116
case '':
117117
// If the tool name does not specify a backend, it should be a short name or an alias defined by users
@@ -160,7 +160,7 @@ function getToolConfig(
160160
function getRegistryToolConfig(
161161
short: string,
162162
version: string,
163-
): ToolingConfig | null {
163+
): StaticTooling | null {
164164
// Try to get the config from miseTooling first, then asdfTooling
165165
return (
166166
getConfigFromTooling(miseTooling, short, version) ??
@@ -172,7 +172,7 @@ function getConfigFromTooling(
172172
toolingSource: Record<string, ToolingDefinition>,
173173
name: string,
174174
version: string,
175-
): ToolingConfig | null {
175+
): StaticTooling | null {
176176
const toolDefinition = toolingSource[name];
177177
if (!toolDefinition) {
178178
return null;
@@ -188,7 +188,7 @@ function getConfigFromTooling(
188188
function createDependency(
189189
name: string,
190190
version: string | null,
191-
config: ToolingConfig | BackendToolingConfig | null,
191+
config: StaticTooling | BackendToolingConfig | null,
192192
): PackageDependency {
193193
if (version === null) {
194194
return {

0 commit comments

Comments
 (0)