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
4 changes: 3 additions & 1 deletion ecosystem-tests/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,9 @@ async function installPackage() {
try {
// Ensure that there is a clean node_modules folder.
await run('rm', ['-rf', `./node_modules`]);
} catch (err) {}
} catch (err) {
// Best-effort cleanup; installation below can continue.
}

const packFile = getPackFile();
await fs.copyFile(packFile, `./${TAR_NAME}`);
Expand Down
7 changes: 1 addition & 6 deletions oxlint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const compatibilityRules = [
'import/first',
'import/newline-after-import',
'import/no-cycle',
'jsdoc/check-tag-names',
'jsdoc/no-defaults',
'jsdoc/require-param-description',
'logical-assignment-operators',
Expand All @@ -27,26 +26,22 @@ const compatibilityRules = [
'no-bitwise',
'no-case-declarations',
'no-else-return',
'no-empty',
'no-empty-function',
'no-eq-null',
'no-inline-comments',
'no-inner-declarations',
'no-lonely-if',
'no-negated-condition',
'no-nested-ternary',
'no-param-reassign',
'no-plusplus',
'no-promise-executor-return',
'no-shadow',
'no-sparse-arrays',
'no-throw-literal',
'no-unsafe-optional-chaining',
'no-unused-expressions',
'no-unused-vars',
'no-use-before-define',
'no-useless-concat',
'no-useless-escape',
'no-useless-return',
'no-var',
'no-void',
Expand Down Expand Up @@ -111,7 +106,6 @@ const compatibilityRules = [
'unicorn/no-useless-undefined',
'unicorn/numeric-separators-style',
'unicorn/prefer-at',
'unicorn/prefer-bigint-literals',
'unicorn/prefer-code-point',
'unicorn/prefer-event-target',
'unicorn/prefer-module',
Expand All @@ -138,6 +132,7 @@ module.exports = defineConfig({
},
rules: {
...Object.fromEntries(compatibilityRules.map((rule) => [rule, 'off'])),
'jsdoc/check-tag-names': ['error', { definedTags: ['jest-environment'] }],
'no-restricted-imports': [
'error',
{
Expand Down
6 changes: 4 additions & 2 deletions scripts/utils/check-version.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ const path = require('path');
const main = () => {
const pkg = require('../../package.json');
const version = pkg['version'];
if (!version) throw 'The version property is not set in the package.json file';
if (!version) throw new Error('The version property is not set in the package.json file');
if (typeof version !== 'string') {
throw `Unexpected type for the package.json version field; got ${typeof version}, expected string`;
throw new Error(
`Unexpected type for the package.json version field; got ${typeof version}, expected string`,
);
}

const versionFile = path.resolve(__dirname, '..', '..', 'src', 'version.ts');
Expand Down
4 changes: 3 additions & 1 deletion src/_vendor/partial-json-parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ const _parseJSON = (jsonString: string, allow: number) => {
if (jsonString[jsonString.length - 1] === '.')
return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf('.')));
return JSON.parse(jsonString.substring(0, jsonString.lastIndexOf('e')));
} catch (e) {}
} catch (e) {
// Fall through to report malformed input below.
}
}
throwMalformedError(String(e));
}
Expand Down
2 changes: 1 addition & 1 deletion src/_vendor/zod-to-json-schema/parsers/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const zodPatterns = {
/**
* `a-z` was added to replicate /i flag
*/
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9-]*\.)+[a-zA-Z]{2,}$/,
/**
* Constructed a valid Unicode RegExp
*
Expand Down
4 changes: 3 additions & 1 deletion src/auth/workload-identity-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ export class WorkloadIdentityAuth {

try {
body = JSON.parse(errorText);
} catch {}
} catch {
// Ignore non-JSON error bodies.
}

if (response.status === 400 || response.status === 401 || response.status === 403) {
throw new OAuthError(response.status as 400 | 401 | 403, body, response.headers);
Expand Down
6 changes: 2 additions & 4 deletions src/azure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,8 @@ export class AzureOpenAI extends OpenAI {
endpointEnd--;
}
baseURL = `${endpoint.slice(0, endpointEnd)}/openai`;
} else {
if (endpoint) {
throw new Errors.OpenAIError('baseURL and endpoint are mutually exclusive');
}
} else if (endpoint) {
throw new Errors.OpenAIError('baseURL and endpoint are mutually exclusive');
}

super({
Expand Down
8 changes: 3 additions & 5 deletions src/beta/realtime/internal-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,10 @@ export function buildRealtimeURL(
}
url.searchParams.set('api-version', client.apiVersion);
url.searchParams.set('deployment', config.model!);
} else if (hasCallID) {
url.searchParams.set('call_id', config.callID!);
} else {
if (hasCallID) {
url.searchParams.set('call_id', config.callID!);
} else {
url.searchParams.set('model', config.model!);
}
url.searchParams.set('model', config.model!);
}
return url;
}
2 changes: 1 addition & 1 deletion src/internal/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const createPathTagFunction = (pathEncoder = encodeURIPath) =>
invalidSegments.push({
start: match.index,
length: match[0].length,
error: `Value "${match[0]}" can\'t be safely passed as a path parameter`,
error: `Value "${match[0]}" can't be safely passed as a path parameter`,
});
}

Expand Down
8 changes: 3 additions & 5 deletions src/realtime/internal-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,10 @@ export function buildRealtimeURL(
url.searchParams.set('api-version', client.apiVersion);
url.searchParams.set('deployment', config.model!);
}
} else if (hasCallID) {
url.searchParams.set('call_id', config.callID!);
} else {
if (hasCallID) {
url.searchParams.set('call_id', config.callID!);
} else {
url.searchParams.set('model', config.model!);
}
url.searchParams.set('model', config.model!);
}
return url;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/internal/uploads-branches.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ describe('buffered multipart forms', () => {

test('rejects null and unsupported primitive values', async () => {
await expect(createForm({ value: null }, fetch)).rejects.toThrow('Received null for "value"');
await expect(createForm({ value: BigInt(1) }, fetch)).rejects.toThrow('Invalid value given to form');
await expect(createForm({ value: 1n }, fetch)).rejects.toThrow('Invalid value given to form');
});

test('rejects fetch implementations that stringify FormData objects', async () => {
Expand Down Expand Up @@ -304,7 +304,7 @@ describe('lazy multipart stream encoding', () => {
}

const options = await multipartFormRequestOptions(
{ body: { upload: toStreamingFile(chunks(), 'audio.wav'), invalid: BigInt(1) } },
{ body: { upload: toStreamingFile(chunks(), 'audio.wav'), invalid: 1n } },
fetch,
);

Expand Down
4 changes: 2 additions & 2 deletions tests/qs/stringify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('stringify()', function () {
});

test('stringifies bigints', function () {
var three = BigInt(3);
var three = 3n;
// @ts-expect-error
var encodeWithN = function (value, defaultEncoder, charset) {
var result = defaultEncoder(value, defaultEncoder, charset);
Expand Down Expand Up @@ -1958,7 +1958,7 @@ describe('stringify()', function () {
if (type === 'value') {
return defaultEncoder(str, defaultEncoder, charset, type).toUpperCase();
}
throw 'this should never happen! type: ' + type;
throw new Error('this should never happen! type: ' + type);
};

// st.deepEqual(stringify({ KeY: 'vAlUe' }, { encoder: encoder }), 'key=VALUE');
Expand Down
Loading