Replace ESLint with Biome for linting and formatting, update TypeScript configuration to target ESNext, and refactor code to use type imports. Add new biome.json configuration file and adjust test cases for error handling.

This commit is contained in:
Luke Hagar
2025-09-26 05:28:23 +00:00
parent efed32466f
commit e2ed313ad0
14 changed files with 164 additions and 155 deletions

View File

@@ -1,31 +0,0 @@
module.exports = {
root: true,
env: {
node: true,
es2020: true,
},
extends: [
'eslint:recommended',
'@typescript-eslint/recommended',
'prettier',
],
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 2020,
sourceType: 'module',
project: './tsconfig.json',
},
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': 'error',
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-non-null-assertion': 'warn',
'no-console': 'warn',
'prefer-const': 'error',
'no-var': 'error',
},
ignorePatterns: ['dist/', 'node_modules/', 'coverage/'],
};

44
biome.json Normal file
View File

@@ -0,0 +1,44 @@
{
"$schema": "https://biomejs.dev/schemas/2.2.4/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"includes": ["src/**/*.ts", "test/**/*.ts"]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineWidth": 100,
"lineEnding": "lf"
},
"linter": {
"enabled": true,
"rules": {
"recommended": true,
"correctness": {
"noUnusedVariables": "off",
"noUnusedFunctionParameters": "off"
},
"style": {
"useConst": "error"
},
"suspicious": {
"noConsole": "warn",
"noVar": "error"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double",
"semicolons": "always",
"trailingCommas": "es5"
}
}
}

View File

@@ -35,8 +35,8 @@
"test:coverage": "bun test --coverage", "test:coverage": "bun test --coverage",
"test:watch": "bun test --watch", "test:watch": "bun test --watch",
"test:ci": "bun test --reporter=verbose", "test:ci": "bun test --reporter=verbose",
"lint": "eslint src/**/*.ts test/**/*.ts --ext .ts", "lint": "biome lint src/ test/",
"lint:fix": "eslint src/**/*.ts test/**/*.ts --ext .ts --fix", "lint:fix": "biome lint --write src/ test/",
"type-check": "tsc --noEmit", "type-check": "tsc --noEmit",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"*.{json,md,yml,yaml}\"", "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"*.{json,md,yml,yaml}\"",
"format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" \"*.{json,md,yml,yaml}\"", "format:check": "prettier --check \"src/**/*.ts\" \"test/**/*.ts\" \"*.{json,md,yml,yaml}\"",
@@ -62,18 +62,14 @@
"prettier": "^3.0.0" "prettier": "^3.0.0"
}, },
"devDependencies": { "devDependencies": {
"@biomejs/biome": "^2.2.4",
"@types/bun": "latest", "@types/bun": "latest",
"@types/node": "^20.0.0", "@types/node": "^20.0.0",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.0.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"prettier": "^3.0.0", "prettier": "^3.0.0",
"typescript": "^5.0.0" "typescript": "^5.0.0"
}, },
"dependencies": { "dependencies": {
"js-yaml": "^4.1.0", "@types/js-yaml": "^4.0.0",
"@types/js-yaml": "^4.0.0" "js-yaml": "^4.1.0"
} }
} }

View File

@@ -18,13 +18,13 @@ import {
TagKeys, TagKeys,
ExternalDocsKeys, ExternalDocsKeys,
WebhookKeys, WebhookKeys,
OAuthFlowKeys, type OAuthFlowKeys,
ContactKeys, type ContactKeys,
LicenseKeys, type LicenseKeys,
ComponentsKeys, type ComponentsKeys,
ServerVariableKeys, type ServerVariableKeys,
} from '../keys.js'; } from '../keys.js';
import { getVendorExtensions as loadVendorExtensions, VendorModule } from './vendor-loader.js'; import { getVendorExtensions as loadVendorExtensions, type VendorModule } from './vendor-loader.js';
export interface VendorExtensions { export interface VendorExtensions {
[context: string]: ( [context: string]: (
@@ -55,38 +55,38 @@ export function defineConfig(config: VendorModule): VendorModule {
} }
// Type definitions with hover documentation // Type definitions with hover documentation
export type TopLevelKeys = typeof RootKeys[number]; export type TopLevelKeysType = typeof RootKeys[number];
export type InfoKeys = typeof InfoKeys[number]; export type InfoKeysType = typeof InfoKeys[number];
export type OperationKeys = typeof OperationKeys[number]; export type OperationKeysType = typeof OperationKeys[number];
export type ParameterKeys = typeof ParameterKeys[number]; export type ParameterKeysType = typeof ParameterKeys[number];
export type SchemaKeys = typeof SchemaKeys[number]; export type SchemaKeysType = typeof SchemaKeys[number];
export type ResponseKeys = typeof ResponseKeys[number]; export type ResponseKeysType = typeof ResponseKeys[number];
export type SecuritySchemeKeys = typeof SecuritySchemeKeys[number]; export type SecuritySchemeKeysType = typeof SecuritySchemeKeys[number];
export type ServerKeys = typeof ServerKeys[number]; export type ServerKeysType = typeof ServerKeys[number];
export type TagKeys = typeof TagKeys[number]; export type TagKeysType = typeof TagKeys[number];
export type ExternalDocsKeys = typeof ExternalDocsKeys[number]; export type ExternalDocsKeysType = typeof ExternalDocsKeys[number];
export type WebhookKeys = typeof WebhookKeys[number]; export type WebhookKeysType = typeof WebhookKeys[number];
export type OAuthFlowKeys = typeof OAuthFlowKeys[number]; export type OAuthFlowKeysType = typeof OAuthFlowKeys[number];
export type ContactKeys = typeof ContactKeys[number]; export type ContactKeysType = typeof ContactKeys[number];
export type LicenseKeys = typeof LicenseKeys[number]; export type LicenseKeysType = typeof LicenseKeys[number];
export type ComponentsKeys = typeof ComponentsKeys[number]; export type ComponentsKeysType = typeof ComponentsKeys[number];
export type ServerVariableKeys = typeof ServerVariableKeys[number]; export type ServerVariableKeysType = typeof ServerVariableKeys[number];
// Context-specific key types for better IntelliSense // Context-specific key types for better IntelliSense
export interface ContextKeys { export interface ContextKeys {
'top-level': TopLevelKeys; 'top-level': TopLevelKeysType;
'info': InfoKeys; 'info': InfoKeysType;
'operation': OperationKeys; 'operation': OperationKeysType;
'parameter': ParameterKeys; 'parameter': ParameterKeysType;
'schema': SchemaKeys; 'schema': SchemaKeysType;
'response': ResponseKeys; 'response': ResponseKeysType;
'securityScheme': SecuritySchemeKeys; 'securityScheme': SecuritySchemeKeysType;
'server': ServerKeys; 'server': ServerKeysType;
'tag': TagKeys; 'tag': TagKeysType;
'externalDocs': ExternalDocsKeys; 'externalDocs': ExternalDocsKeysType;
'webhook': WebhookKeys; 'webhook': WebhookKeysType;
'definitions': SchemaKeys; // Definitions use schema keys 'definitions': SchemaKeysType; // Definitions use schema keys
'securityDefinitions': SecuritySchemeKeys; // Security definitions use security scheme keys 'securityDefinitions': SecuritySchemeKeysType; // Security definitions use security scheme keys
} }
// Helper function to get available keys for a context // Helper function to get available keys for a context

View File

@@ -4,7 +4,7 @@
* Loads vendor extensions using static imports for ES module compatibility. * Loads vendor extensions using static imports for ES module compatibility.
*/ */
import { before, after, ContextKeys } from './index.js'; import { before, after, type ContextKeys } from './index.js';
// Import vendor extensions statically // Import vendor extensions statically
import { speakeasy } from './vendor/speakeasy.js'; import { speakeasy } from './vendor/speakeasy.js';
@@ -68,7 +68,7 @@ export function getVendorExtensions(customVendorModules?: VendorModule[]): Recor
// Check for collisions before adding extensions // Check for collisions before adding extensions
for (const [extensionKey, position] of Object.entries(contextExtensions)) { for (const [extensionKey, position] of Object.entries(contextExtensions)) {
if (extensions[context].hasOwnProperty(extensionKey)) { if (Object.hasOwn(extensions[context], extensionKey)) {
const existingVendor = extensionSources[context][extensionKey]; const existingVendor = extensionSources[context][extensionKey];
const currentVendor = vendorModule.info.name; const currentVendor = vendorModule.info.name;

View File

@@ -1,4 +1,4 @@
import { Plugin } from 'prettier'; import type { Plugin } from 'prettier';
import * as yaml from 'js-yaml'; import * as yaml from 'js-yaml';
import { getVendorExtensions } from './extensions/vendor-loader.js'; import { getVendorExtensions } from './extensions/vendor-loader.js';

View File

@@ -9,13 +9,13 @@ describe('Coverage Tests', () => {
// Test with null content // Test with null content
expect(() => { expect(() => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
jsonParser?.parse('null', {}); jsonParser?.parse('null', {});
}).toThrow(); }).toThrow();
// Test with undefined content // Test with undefined content
expect(() => { expect(() => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
jsonParser?.parse('undefined', {}); jsonParser?.parse('undefined', {});
}).toThrow(); }).toThrow();
}); });
@@ -26,13 +26,13 @@ describe('Coverage Tests', () => {
// Test with string content // Test with string content
expect(() => { expect(() => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
jsonParser?.parse('"string"', {}); jsonParser?.parse('"string"', {});
}).toThrow(); }).toThrow();
// Test with number content // Test with number content
expect(() => { expect(() => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
jsonParser?.parse('123', {}); jsonParser?.parse('123', {});
}).toThrow(); }).toThrow();
}); });
@@ -43,7 +43,7 @@ describe('Coverage Tests', () => {
// Test with array content // Test with array content
expect(() => { expect(() => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
jsonParser?.parse('[]', {}); jsonParser?.parse('[]', {});
}).toThrow(); }).toThrow();
}); });
@@ -54,7 +54,7 @@ describe('Coverage Tests', () => {
// Test with malformed JSON // Test with malformed JSON
expect(() => { expect(() => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
jsonParser?.parse('{invalid json}', {}); jsonParser?.parse('{invalid json}', {});
}).toThrow('Failed to parse OpenAPI JSON'); }).toThrow('Failed to parse OpenAPI JSON');
}); });
@@ -65,7 +65,7 @@ describe('Coverage Tests', () => {
// Test with malformed YAML // Test with malformed YAML
expect(() => { expect(() => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
yamlParser?.parse('invalid: yaml: content:', {}); yamlParser?.parse('invalid: yaml: content:', {});
}).toThrow('Failed to parse OpenAPI YAML'); }).toThrow('Failed to parse OpenAPI YAML');
}); });
@@ -97,7 +97,7 @@ properties:
]; ];
paths.forEach(path => { paths.forEach(path => {
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(testYaml, { filepath: path }); const result = yamlParser?.parse(testYaml, { filepath: path });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -113,7 +113,7 @@ info:
title: Test API title: Test API
version: 1.0.0`; version: 1.0.0`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(testYaml, {}); const result = yamlParser?.parse(testYaml, {});
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -131,7 +131,7 @@ info:
'200': '200':
description: Success`; description: Success`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(operationYaml, { filepath: 'paths/users.yaml' }); const result = yamlParser?.parse(operationYaml, { filepath: 'paths/users.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -147,7 +147,7 @@ required: true
schema: schema:
type: integer`; type: integer`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(parameterYaml, { filepath: 'components/parameters/UserId.yaml' }); const result = yamlParser?.parse(parameterYaml, { filepath: 'components/parameters/UserId.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -166,7 +166,7 @@ properties:
required: required:
- id`; - id`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(schemaYaml, { filepath: 'components/schemas/User.yaml' }); const result = yamlParser?.parse(schemaYaml, { filepath: 'components/schemas/User.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -182,7 +182,7 @@ content:
schema: schema:
type: object`; type: object`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(responseYaml, { filepath: 'components/responses/UserResponse.yaml' }); const result = yamlParser?.parse(responseYaml, { filepath: 'components/responses/UserResponse.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -196,7 +196,7 @@ content:
scheme: bearer scheme: bearer
bearerFormat: JWT`; bearerFormat: JWT`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(securityYaml, { filepath: 'components/securitySchemes/BearerAuth.yaml' }); const result = yamlParser?.parse(securityYaml, { filepath: 'components/securitySchemes/BearerAuth.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -209,7 +209,7 @@ bearerFormat: JWT`;
const serverYaml = `url: https://api.example.com const serverYaml = `url: https://api.example.com
description: Production server`; description: Production server`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(serverYaml, { filepath: 'servers/production.yaml' }); const result = yamlParser?.parse(serverYaml, { filepath: 'servers/production.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -222,7 +222,7 @@ description: Production server`;
const tagYaml = `name: users const tagYaml = `name: users
description: User management operations`; description: User management operations`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(tagYaml, { filepath: 'tags/users.yaml' }); const result = yamlParser?.parse(tagYaml, { filepath: 'tags/users.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -235,7 +235,7 @@ description: User management operations`;
const externalDocsYaml = `url: https://example.com/docs const externalDocsYaml = `url: https://example.com/docs
description: External documentation`; description: External documentation`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(externalDocsYaml, { filepath: 'externalDocs/api.yaml' }); const result = yamlParser?.parse(externalDocsYaml, { filepath: 'externalDocs/api.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -251,7 +251,7 @@ description: External documentation`;
'200': '200':
description: Success`; description: Success`;
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(webhookYaml, { filepath: 'webhooks/messageCreated.yaml' }); const result = yamlParser?.parse(webhookYaml, { filepath: 'webhooks/messageCreated.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -275,7 +275,7 @@ description: External documentation`;
} }
}; };
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -311,7 +311,7 @@ description: External documentation`;
} }
}; };
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -349,7 +349,7 @@ description: External documentation`;
} }
}; };
// @ts-ignore We are testing edge cases // @ts-expect-error We are testing edge cases
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();

View File

@@ -14,7 +14,7 @@ describe('Custom Extensions Support', () => {
'x-metadata': { 'custom': 'data' } 'x-metadata': { 'custom': 'data' }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonParser?.parse(JSON.stringify(testJson), {}); const result = jsonParser?.parse(JSON.stringify(testJson), {});
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.content).toBeDefined(); expect(result?.content).toBeDefined();
@@ -35,7 +35,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonParser?.parse(JSON.stringify(testJson), {}); const result = jsonParser?.parse(JSON.stringify(testJson), {});
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.content.info).toBeDefined(); expect(result?.content.info).toBeDefined();
@@ -61,7 +61,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonParser?.parse(JSON.stringify(testJson), {}); const result = jsonParser?.parse(JSON.stringify(testJson), {});
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.content.paths['/test'].get['x-rate-limit']).toBe(100); expect(result?.content.paths['/test'].get['x-rate-limit']).toBe(100);
@@ -88,7 +88,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonParser?.parse(JSON.stringify(testJson), {}); const result = jsonParser?.parse(JSON.stringify(testJson), {});
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.content.components.schemas.User['x-custom-type']).toBe('entity'); expect(result?.content.components.schemas.User['x-custom-type']).toBe('entity');
@@ -108,7 +108,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result).toContain('"x-custom-field"'); expect(result).toContain('"x-custom-field"');
@@ -129,7 +129,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = yamlPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = yamlPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result).toContain('x-custom-field:'); expect(result).toContain('x-custom-field:');
@@ -148,7 +148,7 @@ describe('Custom Extensions Support', () => {
'another-unknown': 'value' 'another-unknown': 'value'
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonParser?.parse(JSON.stringify(testJson), {}); const result = jsonParser?.parse(JSON.stringify(testJson), {});
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.content).toBeDefined(); expect(result?.content).toBeDefined();
@@ -169,7 +169,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -207,7 +207,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -249,7 +249,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -295,7 +295,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -330,7 +330,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -370,7 +370,7 @@ describe('Custom Extensions Support', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();

View File

@@ -17,7 +17,7 @@ paths:
'200': '200':
description: Success`; description: Success`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(testYaml, { filepath: 'openapi.yaml' }); const result = yamlParser?.parse(testYaml, { filepath: 'openapi.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -39,7 +39,7 @@ required:
- id - id
- name`; - name`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(schemaYaml, { filepath: 'components/schemas/User.yaml' }); const result = yamlParser?.parse(schemaYaml, { filepath: 'components/schemas/User.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -58,7 +58,7 @@ description: User ID
schema: schema:
type: integer`; type: integer`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(parameterYaml, { filepath: 'components/parameters/UserId.yaml' }); const result = yamlParser?.parse(parameterYaml, { filepath: 'components/parameters/UserId.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -81,7 +81,7 @@ content:
name: name:
type: string`; type: string`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(responseYaml, { filepath: 'components/responses/UserResponse.yaml' }); const result = yamlParser?.parse(responseYaml, { filepath: 'components/responses/UserResponse.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -106,7 +106,7 @@ post:
schema: schema:
type: object`; type: object`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(pathYaml, { filepath: 'paths/users.yaml' }); const result = yamlParser?.parse(pathYaml, { filepath: 'paths/users.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -124,7 +124,7 @@ scheme: bearer
bearerFormat: JWT bearerFormat: JWT
description: JWT authentication`; description: JWT authentication`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(securityYaml, { filepath: 'components/securitySchemes/BearerAuth.yaml' }); const result = yamlParser?.parse(securityYaml, { filepath: 'components/securitySchemes/BearerAuth.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -140,7 +140,7 @@ description: JWT authentication`;
age: 30 age: 30
city: New York`; city: New York`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
expect(() => yamlParser?.parse(nonOpenAPIYaml, { filepath: 'config/data.yaml' })).toThrow('Not an OpenAPI file'); expect(() => yamlParser?.parse(nonOpenAPIYaml, { filepath: 'config/data.yaml' })).toThrow('Not an OpenAPI file');
}); });
@@ -152,7 +152,7 @@ city: New York`;
age: 30 age: 30
city: New York`; city: New York`;
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(simpleYaml, { filepath: 'components/schemas/User.yaml' }); const result = yamlParser?.parse(simpleYaml, { filepath: 'components/schemas/User.yaml' });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');
@@ -183,7 +183,7 @@ properties:
]; ];
paths.forEach(path => { paths.forEach(path => {
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlParser?.parse(componentYaml, { filepath: path }); const result = yamlParser?.parse(componentYaml, { filepath: path });
expect(result).toBeDefined(); expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml'); expect(result?.type).toBe('openapi-yaml');

View File

@@ -220,7 +220,7 @@ describe('Integration Tests', () => {
content: openApiContent content: openApiContent
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -369,7 +369,7 @@ describe('Integration Tests', () => {
content: swaggerContent content: swaggerContent
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -420,7 +420,7 @@ describe('Integration Tests', () => {
content: yamlContent content: yamlContent
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = yamlPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -447,7 +447,7 @@ describe('Integration Tests', () => {
const malformedJson = '{"openapi": "3.0.0", "info": {'; const malformedJson = '{"openapi": "3.0.0", "info": {';
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
expect(() => jsonParser?.parse(malformedJson, {})).toThrow(); expect(() => jsonParser?.parse(malformedJson, {})).toThrow();
}); });
@@ -457,7 +457,7 @@ describe('Integration Tests', () => {
const malformedYaml = 'openapi: 3.0.0\ninfo:\n title: Test\n version: 1.0.0\n invalid: ['; const malformedYaml = 'openapi: 3.0.0\ninfo:\n title: Test\n version: 1.0.0\n invalid: [';
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
expect(() => yamlParser?.parse(malformedYaml, {})).toThrow(); expect(() => yamlParser?.parse(malformedYaml, {})).toThrow();
}); });
@@ -467,7 +467,7 @@ describe('Integration Tests', () => {
const nonOpenAPI = '{"name": "John", "age": 30}'; const nonOpenAPI = '{"name": "John", "age": 30}';
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
expect(() => jsonParser?.parse(nonOpenAPI, {})).toThrow('Not an OpenAPI file'); expect(() => jsonParser?.parse(nonOpenAPI, {})).toThrow('Not an OpenAPI file');
}); });
}); });
@@ -506,7 +506,7 @@ describe('Integration Tests', () => {
const startTime = Date.now(); const startTime = Date.now();
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
const endTime = Date.now(); const endTime = Date.now();

View File

@@ -20,7 +20,7 @@ describe('Key Ordering Tests', () => {
} }
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -73,7 +73,7 @@ describe('Key Ordering Tests', () => {
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -158,7 +158,7 @@ describe('Key Ordering Tests', () => {
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -265,7 +265,7 @@ describe('Key Ordering Tests', () => {
} }
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -319,7 +319,7 @@ describe('Key Ordering Tests', () => {
} }
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -392,7 +392,7 @@ describe('Key Ordering Tests', () => {
} }
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -438,7 +438,7 @@ describe('Key Ordering Tests', () => {
] ]
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -482,7 +482,7 @@ describe('Key Ordering Tests', () => {
] ]
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -521,7 +521,7 @@ describe('Key Ordering Tests', () => {
} }
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -554,7 +554,7 @@ describe('Key Ordering Tests', () => {
} }
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -598,7 +598,7 @@ describe('Key Ordering Tests', () => {
} }
} }
}; };
// @ts-ignore We are mocking things here so we don't need to pass a print function // @ts-expect-error We are mocking things here so we don't need to pass a print function
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 });
expect(result).toBeDefined(); expect(result).toBeDefined();

View File

@@ -29,14 +29,14 @@ describe('Prettier OpenAPI Plugin', () => {
}`; }`;
// Parse the JSON // Parse the JSON
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const parsed = jsonParser?.parse(inputJson, {}); const parsed = jsonParser?.parse(inputJson, {});
expect(parsed).toBeDefined(); expect(parsed).toBeDefined();
expect(parsed?.type).toBe('openapi-json'); expect(parsed?.type).toBe('openapi-json');
expect(parsed?.content).toBeDefined(); expect(parsed?.content).toBeDefined();
// Format the parsed content // Format the parsed content
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -76,14 +76,14 @@ info:
openapi: 3.0.0`; openapi: 3.0.0`;
// Parse the YAML // Parse the YAML
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const parsed = yamlParser?.parse(inputYaml, {}); const parsed = yamlParser?.parse(inputYaml, {});
expect(parsed).toBeDefined(); expect(parsed).toBeDefined();
expect(parsed?.type).toBe('openapi-yaml'); expect(parsed?.type).toBe('openapi-yaml');
expect(parsed?.content).toBeDefined(); expect(parsed?.content).toBeDefined();
// Format the parsed content // Format the parsed content
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = yamlPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => ''); const result = yamlPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -143,14 +143,14 @@ openapi: 3.0.0`;
}`; }`;
// Parse the JSON // Parse the JSON
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const parsed = jsonParser?.parse(inputJson, {}); const parsed = jsonParser?.parse(inputJson, {});
expect(parsed).toBeDefined(); expect(parsed).toBeDefined();
expect(parsed?.type).toBe('openapi-json'); expect(parsed?.type).toBe('openapi-json');
expect(parsed?.content).toBeDefined(); expect(parsed?.content).toBeDefined();
// Format the parsed content // Format the parsed content
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -195,14 +195,14 @@ describe('Key Ordering Tests', () => {
}`; }`;
// Parse the JSON // Parse the JSON
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const parsed = jsonParser?.parse(inputJson, {}); const parsed = jsonParser?.parse(inputJson, {});
expect(parsed).toBeDefined(); expect(parsed).toBeDefined();
expect(parsed?.type).toBe('openapi-json'); expect(parsed?.type).toBe('openapi-json');
expect(parsed?.content).toBeDefined(); expect(parsed?.content).toBeDefined();
// Format the parsed content // Format the parsed content
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -254,14 +254,14 @@ describe('Key Ordering Tests', () => {
}`; }`;
// Parse the JSON // Parse the JSON
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const parsed = jsonParser?.parse(inputJson, {}); const parsed = jsonParser?.parse(inputJson, {});
expect(parsed).toBeDefined(); expect(parsed).toBeDefined();
expect(parsed?.type).toBe('openapi-json'); expect(parsed?.type).toBe('openapi-json');
expect(parsed?.content).toBeDefined(); expect(parsed?.content).toBeDefined();
// Format the parsed content // Format the parsed content
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => parsed }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();

View File

@@ -18,7 +18,7 @@ describe('Simple Key Ordering Tests', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -71,7 +71,7 @@ describe('Simple Key Ordering Tests', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -122,7 +122,7 @@ describe('Simple Key Ordering Tests', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();
@@ -159,7 +159,7 @@ describe('Simple Key Ordering Tests', () => {
} }
}; };
// @ts-ignore We are mocking things here // @ts-expect-error We are mocking things here
const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => ''); const result = jsonPrinter?.print({ getValue: () => testData }, { tabWidth: 2 }, () => '');
expect(result).toBeDefined(); expect(result).toBeDefined();

View File

@@ -1,9 +1,9 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "ES2020", "target": "ESNext",
"module": "ESNext", "module": "ESNext",
"moduleResolution": "node", "moduleResolution": "node",
"lib": ["ES2020"], "lib": ["ESNext"],
"outDir": "./dist", "outDir": "./dist",
"rootDir": "./src", "rootDir": "./src",
"strict": true, "strict": true,