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:watch": "bun test --watch",
"test:ci": "bun test --reporter=verbose",
"lint": "eslint src/**/*.ts test/**/*.ts --ext .ts",
"lint:fix": "eslint src/**/*.ts test/**/*.ts --ext .ts --fix",
"lint": "biome lint src/ test/",
"lint:fix": "biome lint --write src/ test/",
"type-check": "tsc --noEmit",
"format": "prettier --write \"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"
},
"devDependencies": {
"@biomejs/biome": "^2.2.4",
"@types/bun": "latest",
"@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",
"typescript": "^5.0.0"
},
"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,
ExternalDocsKeys,
WebhookKeys,
OAuthFlowKeys,
ContactKeys,
LicenseKeys,
ComponentsKeys,
ServerVariableKeys,
type OAuthFlowKeys,
type ContactKeys,
type LicenseKeys,
type ComponentsKeys,
type ServerVariableKeys,
} 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 {
[context: string]: (
@@ -55,38 +55,38 @@ export function defineConfig(config: VendorModule): VendorModule {
}
// Type definitions with hover documentation
export type TopLevelKeys = typeof RootKeys[number];
export type InfoKeys = typeof InfoKeys[number];
export type OperationKeys = typeof OperationKeys[number];
export type ParameterKeys = typeof ParameterKeys[number];
export type SchemaKeys = typeof SchemaKeys[number];
export type ResponseKeys = typeof ResponseKeys[number];
export type SecuritySchemeKeys = typeof SecuritySchemeKeys[number];
export type ServerKeys = typeof ServerKeys[number];
export type TagKeys = typeof TagKeys[number];
export type ExternalDocsKeys = typeof ExternalDocsKeys[number];
export type WebhookKeys = typeof WebhookKeys[number];
export type OAuthFlowKeys = typeof OAuthFlowKeys[number];
export type ContactKeys = typeof ContactKeys[number];
export type LicenseKeys = typeof LicenseKeys[number];
export type ComponentsKeys = typeof ComponentsKeys[number];
export type ServerVariableKeys = typeof ServerVariableKeys[number];
export type TopLevelKeysType = typeof RootKeys[number];
export type InfoKeysType = typeof InfoKeys[number];
export type OperationKeysType = typeof OperationKeys[number];
export type ParameterKeysType = typeof ParameterKeys[number];
export type SchemaKeysType = typeof SchemaKeys[number];
export type ResponseKeysType = typeof ResponseKeys[number];
export type SecuritySchemeKeysType = typeof SecuritySchemeKeys[number];
export type ServerKeysType = typeof ServerKeys[number];
export type TagKeysType = typeof TagKeys[number];
export type ExternalDocsKeysType = typeof ExternalDocsKeys[number];
export type WebhookKeysType = typeof WebhookKeys[number];
export type OAuthFlowKeysType = typeof OAuthFlowKeys[number];
export type ContactKeysType = typeof ContactKeys[number];
export type LicenseKeysType = typeof LicenseKeys[number];
export type ComponentsKeysType = typeof ComponentsKeys[number];
export type ServerVariableKeysType = typeof ServerVariableKeys[number];
// Context-specific key types for better IntelliSense
export interface ContextKeys {
'top-level': TopLevelKeys;
'info': InfoKeys;
'operation': OperationKeys;
'parameter': ParameterKeys;
'schema': SchemaKeys;
'response': ResponseKeys;
'securityScheme': SecuritySchemeKeys;
'server': ServerKeys;
'tag': TagKeys;
'externalDocs': ExternalDocsKeys;
'webhook': WebhookKeys;
'definitions': SchemaKeys; // Definitions use schema keys
'securityDefinitions': SecuritySchemeKeys; // Security definitions use security scheme keys
'top-level': TopLevelKeysType;
'info': InfoKeysType;
'operation': OperationKeysType;
'parameter': ParameterKeysType;
'schema': SchemaKeysType;
'response': ResponseKeysType;
'securityScheme': SecuritySchemeKeysType;
'server': ServerKeysType;
'tag': TagKeysType;
'externalDocs': ExternalDocsKeysType;
'webhook': WebhookKeysType;
'definitions': SchemaKeysType; // Definitions use schema keys
'securityDefinitions': SecuritySchemeKeysType; // Security definitions use security scheme keys
}
// 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.
*/
import { before, after, ContextKeys } from './index.js';
import { before, after, type ContextKeys } from './index.js';
// Import vendor extensions statically
import { speakeasy } from './vendor/speakeasy.js';
@@ -68,7 +68,7 @@ export function getVendorExtensions(customVendorModules?: VendorModule[]): Recor
// Check for collisions before adding extensions
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 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 { getVendorExtensions } from './extensions/vendor-loader.js';

View File

@@ -9,13 +9,13 @@ describe('Coverage Tests', () => {
// Test with null content
expect(() => {
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
jsonParser?.parse('null', {});
}).toThrow();
// Test with undefined content
expect(() => {
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
jsonParser?.parse('undefined', {});
}).toThrow();
});
@@ -26,13 +26,13 @@ describe('Coverage Tests', () => {
// Test with string content
expect(() => {
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
jsonParser?.parse('"string"', {});
}).toThrow();
// Test with number content
expect(() => {
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
jsonParser?.parse('123', {});
}).toThrow();
});
@@ -43,7 +43,7 @@ describe('Coverage Tests', () => {
// Test with array content
expect(() => {
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
jsonParser?.parse('[]', {});
}).toThrow();
});
@@ -54,7 +54,7 @@ describe('Coverage Tests', () => {
// Test with malformed JSON
expect(() => {
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
jsonParser?.parse('{invalid json}', {});
}).toThrow('Failed to parse OpenAPI JSON');
});
@@ -65,7 +65,7 @@ describe('Coverage Tests', () => {
// Test with malformed YAML
expect(() => {
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
yamlParser?.parse('invalid: yaml: content:', {});
}).toThrow('Failed to parse OpenAPI YAML');
});
@@ -97,7 +97,7 @@ properties:
];
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 });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -113,7 +113,7 @@ info:
title: Test API
version: 1.0.0`;
// @ts-ignore We are testing edge cases
// @ts-expect-error We are testing edge cases
const result = yamlParser?.parse(testYaml, {});
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -131,7 +131,7 @@ info:
'200':
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -147,7 +147,7 @@ required: true
schema:
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -166,7 +166,7 @@ properties:
required:
- 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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -182,7 +182,7 @@ content:
schema:
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -196,7 +196,7 @@ content:
scheme: bearer
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -209,7 +209,7 @@ bearerFormat: JWT`;
const serverYaml = `url: https://api.example.com
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -222,7 +222,7 @@ description: Production server`;
const tagYaml = `name: users
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -235,7 +235,7 @@ description: User management operations`;
const externalDocsYaml = `url: https://example.com/docs
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -251,7 +251,7 @@ description: External documentation`;
'200':
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' });
expect(result).toBeDefined();
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 }, () => '');
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 }, () => '');
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 }, () => '');
expect(result).toBeDefined();

View File

@@ -14,7 +14,7 @@ describe('Custom Extensions Support', () => {
'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), {});
expect(result).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), {});
expect(result).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), {});
expect(result).toBeDefined();
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), {});
expect(result).toBeDefined();
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 }, () => '');
expect(result).toBeDefined();
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 }, () => '');
expect(result).toBeDefined();
expect(result).toContain('x-custom-field:');
@@ -148,7 +148,7 @@ describe('Custom Extensions Support', () => {
'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), {});
expect(result).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 }, () => '');
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 }, () => '');
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 }, () => '');
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 }, () => '');
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 }, () => '');
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 }, () => '');
expect(result).toBeDefined();

View File

@@ -17,7 +17,7 @@ paths:
'200':
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' });
expect(result).toBeDefined();
@@ -39,7 +39,7 @@ required:
- id
- 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' });
expect(result).toBeDefined();
@@ -58,7 +58,7 @@ description: User ID
schema:
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' });
expect(result).toBeDefined();
@@ -81,7 +81,7 @@ content:
name:
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' });
expect(result).toBeDefined();
@@ -106,7 +106,7 @@ post:
schema:
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' });
expect(result).toBeDefined();
@@ -124,7 +124,7 @@ scheme: bearer
bearerFormat: JWT
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' });
expect(result).toBeDefined();
@@ -140,7 +140,7 @@ description: JWT authentication`;
age: 30
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');
});
@@ -152,7 +152,7 @@ city: New York`;
age: 30
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' });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');
@@ -183,7 +183,7 @@ properties:
];
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 });
expect(result).toBeDefined();
expect(result?.type).toBe('openapi-yaml');

View File

@@ -220,7 +220,7 @@ describe('Integration Tests', () => {
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 }, () => '');
expect(result).toBeDefined();
@@ -369,7 +369,7 @@ describe('Integration Tests', () => {
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 }, () => '');
expect(result).toBeDefined();
@@ -420,7 +420,7 @@ describe('Integration Tests', () => {
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 }, () => '');
expect(result).toBeDefined();
@@ -447,7 +447,7 @@ describe('Integration Tests', () => {
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();
});
@@ -457,7 +457,7 @@ describe('Integration Tests', () => {
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();
});
@@ -467,7 +467,7 @@ describe('Integration Tests', () => {
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');
});
});
@@ -506,7 +506,7 @@ describe('Integration Tests', () => {
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 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 });
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 });
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 });
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 });
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 });
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 });
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 });
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 });
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 });
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 });
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 });
expect(result).toBeDefined();

View File

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

View File

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