Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion .oxlintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"typescript/await-thenable": "error",
"typescript/no-floating-promises": "error",
"typescript/no-misused-promises": "error",
"typescript/no-misused-spread": "error",
"typescript/no-unsafe-enum-comparison": "error",
"typescript/no-unsafe-unary-minus": "error",
"typescript/no-duplicate-type-constituents": "error",
Expand Down Expand Up @@ -66,7 +67,10 @@
"typescript/no-unsafe-assignment": "off",
"typescript/no-unsafe-call": "off",
"typescript/no-unsafe-member-access": "off",
"typescript/no-unsafe-return": "off"
"typescript/no-unsafe-return": "off",

"vitest/no-conditional-tests": "error",
"vitest/hoisted-apis-on-top": "error"
},
"overrides": [
{
Expand Down
49 changes: 24 additions & 25 deletions lib/config/options/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,39 @@ describe('config/options/index', () => {

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

const defaults = Array.isArray(option.default)
? option.default
: [option.default];
for (const defVal of defaults) {
expect(option.allowedValues).toContain(defVal);
}
});
}
const defaults = Array.isArray(option.default)
? option.default
: [option.default];
for (const defVal of defaults) {
expect(option.allowedValues).toContain(defVal);
}
});
}
});

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

for (const option of opts) {
if (option.requiredIf) {
for (const req of option.requiredIf) {
for (const prop of req.siblingProperties) {
it(`${option.name}'s reference to ${prop.property} is valid`, () => {
expect(optionNames).toContain(prop.property);
});
for (const option of opts.filter((o) => o.requiredIf)) {
for (const req of option.requiredIf!) {
for (const prop of req.siblingProperties) {
it(`${option.name}'s reference to ${prop.property} is valid`, () => {
expect(optionNames).toContain(prop.property);
});

const foundOption = opts.filter((o) => o.name === prop.property);
if (foundOption?.length && foundOption[0].allowedValues) {
it(`${option.name}'s value for ${prop.property} is valid, according to allowedValues`, () => {
expect(foundOption[0].allowedValues).toContain(prop.value);
});
}
const foundOption = opts.filter((o) => o.name === prop.property);
// oxlint-disable-next-line vitest/no-conditional-tests -- TODO: fix me
if (foundOption?.length && foundOption[0].allowedValues) {
it(`${option.name}'s value for ${prop.property} is valid, according to allowedValues`, () => {
expect(foundOption[0].allowedValues).toContain(prop.value);
});
}
}
}
Expand Down
41 changes: 22 additions & 19 deletions lib/config/presets/internal/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,29 @@ describe('config/presets/internal/index', () => {
});

for (const [groupName, groupPresets] of Object.entries(internal.groups)) {
for (const [presetName, presetConfig] of Object.entries(groupPresets)) {
const preset = `${groupName}:${presetName}`;
if (presetName !== 'description' && !ignoredPresets.includes(preset)) {
it(`${preset} validates`, async () => {
try {
const { config } = await resolveConfigPresets(
massageConfig(presetConfig),
);
const configType = groupName === 'global' ? 'global' : 'repo';
const res = await validateConfig(configType, config, true);
expect(res.errors).toHaveLength(0);
expect(res.warnings).toHaveLength(0);
} catch (err) {
if (err.validationError) {
throw new Error(err.validationError);
}
throw err;
for (const [presetName, presetConfig] of Object.entries(
groupPresets,
).filter(
([key]) =>
key !== 'description' &&
!ignoredPresets.includes(`${groupName}:${key}`),
)) {
it(`${`${groupName}:${presetName}`} validates`, async () => {
try {
const { config } = await resolveConfigPresets(
massageConfig(presetConfig),
);
const configType = groupName === 'global' ? 'global' : 'repo';
const res = await validateConfig(configType, config, true);
expect(res.errors).toHaveLength(0);
expect(res.warnings).toHaveLength(0);
} catch (err) {
if (err.validationError) {
throw new Error(err.validationError);
}
});
}
throw err;
}
});
}
}

Expand Down
2 changes: 2 additions & 0 deletions lib/logger/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export default function prepareError(err: Error): Record<string, unknown> {
}

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,10 @@ export function parsePropsFile(
logger.trace(
`Found ${depVerExactMap.size} dependencies and ${depVerRegexMap.size} wildcard dependencies in ${VERSIONS_PROPS}.`,
);
return [depVerExactMap, new Map([...depVerRegexMap].sort().reverse())];
return [
depVerExactMap,
new Map(
[...depVerRegexMap].sort(([ka], [kb]) => ka.localeCompare(kb)).reverse(),
),
];
}
12 changes: 6 additions & 6 deletions lib/modules/manager/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ describe('modules/manager/index', () => {
});

describe('lockFileNames', () => {
for (const [name, mgr] of manager.getManagers()) {
if (mgr.supportsLockFileMaintenance) {
it(`has lockFileNames for ${name}`, () => {
expect(mgr.lockFileNames).toBeNonEmptyArray();
});
}
for (const [name, mgr] of [...manager.getManagers()].filter(
([_, mgr]) => mgr.supportsLockFileMaintenance,
)) {
it(`has lockFileNames for ${name}`, () => {
expect(mgr.lockFileNames).toBeNonEmptyArray();
});
}
});

Expand Down
10 changes: 5 additions & 5 deletions lib/modules/manager/mise/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@sindresorhus/is';
import { logger } from '../../../logger/index.ts';
import { regEx } from '../../../util/regex.ts';
import type { ToolingConfig } from '../asdf/upgradeable-tooling.ts';
import type { StaticTooling } from '../asdf/upgradeable-tooling.ts';
import type { PackageDependency, PackageFileContent } from '../types.ts';
import type { BackendToolingConfig } from './backends.ts';
import {
Expand Down Expand Up @@ -111,7 +111,7 @@ function getToolConfig(
toolName: string,
version: string,
toolOptions: MiseToolOptions,
): ToolingConfig | BackendToolingConfig | null {
): StaticTooling | BackendToolingConfig | null {
switch (backend) {
case '':
// If the tool name does not specify a backend, it should be a short name or an alias defined by users
Expand Down Expand Up @@ -160,7 +160,7 @@ function getToolConfig(
function getRegistryToolConfig(
short: string,
version: string,
): ToolingConfig | null {
): StaticTooling | null {
// Try to get the config from miseTooling first, then asdfTooling
return (
getConfigFromTooling(miseTooling, short, version) ??
Expand All @@ -172,7 +172,7 @@ function getConfigFromTooling(
toolingSource: Record<string, ToolingDefinition>,
name: string,
version: string,
): ToolingConfig | null {
): StaticTooling | null {
const toolDefinition = toolingSource[name];
if (!toolDefinition) {
return null;
Expand All @@ -188,7 +188,7 @@ function getConfigFromTooling(
function createDependency(
name: string,
version: string | null,
config: ToolingConfig | BackendToolingConfig | null,
config: StaticTooling | BackendToolingConfig | null,
): PackageDependency {
if (version === null) {
return {
Expand Down
Loading