Skip to content
Draft
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
23 changes: 23 additions & 0 deletions .oxfmtrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"semi": true,
"singleQuote": true,
"printWidth": 80,
"ignorePatterns": [
"**/.changeset/*.md",
"**/node_modules",
"**/templates",
"**/dist",
"**/.next",
"**/.nuxt",
"**/.output",
"**/.svelte-kit",
"**/.vitepress/cache",
"**/.vitepress/dist",
"**/test/generated",
"**/__snapshots__",
"**/CHANGELOG.md",
"pnpm-lock.yaml",
"**/*.vue",
"**/*.svelte"
]
}
64 changes: 64 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"$schema": "https://oxc.rs/schemas/oxlintrc.json",
"jsPlugins": [
"eslint-plugin-simple-import-sort",
"eslint-plugin-sort-destructure-keys",
"eslint-plugin-sort-keys-fix",
"eslint-plugin-typescript-sort-keys",
{
"name": "local-paths",
"specifier": "./eslint-rules/local-paths.js"
},
{
"name": "object-shorthand-custom",
"specifier": "./eslint-rules/object-shorthand.js"
}
],
"plugins": ["unicorn", "typescript", "oxc"],
"rules": {
"arrow-body-style": "error",
"no-prototype-builtins": "off",
"sort-imports": "off",
"typescript/ban-ts-comment": "off",
"typescript/consistent-type-imports": "warn",
"typescript/explicit-function-return-type": "off",
"typescript/explicit-module-boundary-types": "off",
"typescript/no-explicit-any": "off",
"typescript/no-non-null-assertion": "off",
"typescript/no-require-imports": "off",
"typescript/no-var-requires": "off",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
"sort-destructure-keys/sort-destructure-keys": "warn",
"sort-keys-fix/sort-keys-fix": "warn",
"typescript-sort-keys/interface": "warn",
"typescript-sort-keys/string-enum": "warn",
"local-paths/enforce-local-paths": "error",
"object-shorthand-custom/enforce": "error"
},
"env": {
"builtin": true
},
"globals": {
"NodeJS": true
},
"ignorePatterns": [
"**/.tsdown/",
"**/dist/",
"**/node_modules/",
"temp/",
"dev/.gen/",
"examples/openapi-ts-openai/src/client/**/*.ts",
"**/test/generated/",
"**/__snapshots__/",
"**/.next/",
"**/.nuxt/",
"**/.output/",
"**/.svelte-kit/",
"**/.vitepress/cache",
"**/.vitepress/dist",
"**/.angular",
"**/*.svelte",
"**/*.vue"
]
}
6 changes: 3 additions & 3 deletions dev/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"version": "0.0.0",
"private": true,
"type": "module",
"engines": {
"node": ">=20.19.0"
},
"scripts": {
"dev": "ts-node ./playground.ts"
},
Expand All @@ -23,5 +20,8 @@
"typescript": "5.9.3",
"valibot": "1.2.0",
"zod": "4.1.12"
},
"engines": {
"node": ">=20.19.0"
}
}
5 changes: 3 additions & 2 deletions docs/.vitepress/theme/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,9 @@ html.dark .sponsors-list li {
background-color: var(--vp-button-brand-bg);
}

.sponsors-list li > :is(.vp-doc a[href*='://'], .vp-doc a[target='_blank'])::after
{
.sponsors-list
li
> :is(.vp-doc a[href*='://'], .vp-doc a[target='_blank'])::after {
display: none;
}

Expand Down
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@docs/openapi-ts",
"version": "0.10.4",
"description": "Documentation for OpenAPI TypeScript.",
"private": true,
"description": "Documentation for OpenAPI TypeScript.",
"type": "module",
"scripts": {
"build": "vitepress build",
Expand Down
96 changes: 96 additions & 0 deletions eslint-rules/object-shorthand.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Custom ESLint rule for object-shorthand
* Enforces the use of shorthand syntax for object properties and methods
*
* This rule can be contributed back to Oxlint as it's a general-purpose rule
* not specific to this repository.
*/

const rule = {
create(context) {
const sourceCode = context.sourceCode || context.getSourceCode();

return {
Property(node) {
// Skip if it's a spread property or computed property
if (node.type === 'SpreadElement' || node.computed) {
return;
}

// Check for property shorthand (e.g., { x } instead of { x: x })
if (
node.value.type === 'Identifier' &&
node.key.type === 'Identifier' &&
node.key.name === node.value.name &&
!node.shorthand &&
!node.method
) {
context.report({
messageId: 'expectedPropertyShorthand',
node,
fix(fixer) {
// Replace "key: value" with "key"
const keyText = sourceCode.getText(node.key);
return fixer.replaceTextRange(
[node.key.range[0], node.value.range[1]],
keyText,
);
},
});
}

// Check for method shorthand (e.g., { foo() {} } instead of { foo: function() {} })
if (
node.value.type === 'FunctionExpression' &&
!node.value.generator &&
!node.value.async &&
!node.method &&
node.key.type === 'Identifier'
) {
context.report({
messageId: 'expectedMethodShorthand',
node,
fix(fixer) {
const keyText = sourceCode.getText(node.key);
const params =
sourceCode
.getText(node.value)
.match(/function\s*\((.*?)\)/)?.[1] || '';
const body = sourceCode.getText(node.value.body);

return fixer.replaceText(node, `${keyText}(${params}) ${body}`);
},
});
}
},
};
},

meta: {
docs: {
description:
'Enforce the use of shorthand syntax for object properties and methods',
category: 'ECMAScript 6',
recommended: false,
},
type: 'suggestion',
fixable: 'code',
messages: {
expectedPropertyShorthand: 'Expected property shorthand.',
expectedMethodShorthand: 'Expected method shorthand.',
},
schema: [],
},
};

const plugin = {
meta: {
name: 'object-shorthand-custom',
version: '1.0.0',
},
rules: {
enforce: rule,
},
};

export default plugin;
2 changes: 1 addition & 1 deletion examples/openapi-ts-angular-common/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@example/openapi-ts-angular-common",
"private": true,
"version": "0.0.0",
"private": true,
"scripts": {
"build": "ng build",
"dev": "ng serve",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import type { Middleware } from './utils.gen';
export type ResponseStyle = 'data' | 'fields';

export interface Config<T extends ClientOptions = ClientOptions>
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
extends
Omit<RequestInit, 'body' | 'headers' | 'method'>,
Omit<CoreConfig, 'headers'> {
/**
* Base URL for all requests made by this client.
Expand Down Expand Up @@ -71,7 +72,9 @@ export interface RequestOptions<
TResponseStyle extends ResponseStyle = 'fields',
ThrowOnError extends boolean = boolean,
Url extends string = string,
> extends Config<{
>
extends
Config<{
responseStyle: TResponseStyle;
throwOnError: ThrowOnError;
}>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

interface SerializeOptions<T>
extends SerializePrimitiveOptions,
SerializerOptions<T> {}
extends SerializePrimitiveOptions, SerializerOptions<T> {}

interface SerializePrimitiveOptions {
allowReserved?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi-ts-angular/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@example/openapi-ts-angular",
"private": true,
"version": "0.0.0",
"private": true,
"scripts": {
"build": "ng build",
"dev": "ng serve",
Expand Down
7 changes: 5 additions & 2 deletions examples/openapi-ts-angular/src/client/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import type { Middleware } from './utils.gen';
export type ResponseStyle = 'data' | 'fields';

export interface Config<T extends ClientOptions = ClientOptions>
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
extends
Omit<RequestInit, 'body' | 'headers' | 'method'>,
Omit<CoreConfig, 'headers'> {
/**
* Base URL for all requests made by this client.
Expand Down Expand Up @@ -71,7 +72,9 @@ export interface RequestOptions<
TResponseStyle extends ResponseStyle = 'fields',
ThrowOnError extends boolean = boolean,
Url extends string = string,
> extends Config<{
>
extends
Config<{
responseStyle: TResponseStyle;
throwOnError: ThrowOnError;
}>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

interface SerializeOptions<T>
extends SerializePrimitiveOptions,
SerializerOptions<T> {}
extends SerializePrimitiveOptions, SerializerOptions<T> {}

interface SerializePrimitiveOptions {
allowReserved?: boolean;
Expand Down
4 changes: 2 additions & 2 deletions examples/openapi-ts-axios/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@example/openapi-ts-axios",
"private": true,
"version": "0.0.35",
"private": true,
"type": "module",
"scripts": {
"build": "tsc && vite build",
Expand All @@ -22,8 +22,8 @@
"devDependencies": {
"@config/vite-base": "workspace:*",
"@hey-api/openapi-ts": "workspace:*",
"@types/react-dom": "19.0.1",
"@types/react": "19.0.1",
"@types/react-dom": "19.0.1",
"@typescript-eslint/eslint-plugin": "8.29.1",
"@typescript-eslint/parser": "8.29.1",
"@vitejs/plugin-react": "4.4.0-beta.1",
Expand Down
7 changes: 5 additions & 2 deletions examples/openapi-ts-axios/src/client/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ import type {
} from '../core/types.gen';

export interface Config<T extends ClientOptions = ClientOptions>
extends Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>,
extends
Omit<CreateAxiosDefaults, 'auth' | 'baseURL' | 'headers' | 'method'>,
CoreConfig {
/**
* Axios implementation. You can use this option to provide either an
Expand Down Expand Up @@ -63,7 +64,9 @@ export interface RequestOptions<
TData = unknown,
ThrowOnError extends boolean = boolean,
Url extends string = string,
> extends Config<{
>
extends
Config<{
throwOnError: ThrowOnError;
}>,
Pick<
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

interface SerializeOptions<T>
extends SerializePrimitiveOptions,
SerializerOptions<T> {}
extends SerializePrimitiveOptions, SerializerOptions<T> {}

interface SerializePrimitiveOptions {
allowReserved?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion examples/openapi-ts-fastify/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@example/openapi-ts-fastify",
"private": true,
"version": "0.1.16",
"private": true,
"type": "module",
"scripts": {
"openapi-ts": "openapi-ts",
Expand Down
7 changes: 4 additions & 3 deletions examples/openapi-ts-fastify/src/client/client/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import type { Middleware } from './utils.gen';
export type ResponseStyle = 'data' | 'fields';

export interface Config<T extends ClientOptions = ClientOptions>
extends Omit<RequestInit, 'body' | 'headers' | 'method'>,
CoreConfig {
extends Omit<RequestInit, 'body' | 'headers' | 'method'>, CoreConfig {
/**
* Base URL for all requests made by this client.
*/
Expand Down Expand Up @@ -69,7 +68,9 @@ export interface RequestOptions<
TResponseStyle extends ResponseStyle = 'fields',
ThrowOnError extends boolean = boolean,
Url extends string = string,
> extends Config<{
>
extends
Config<{
responseStyle: TResponseStyle;
throwOnError: ThrowOnError;
}>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// This file is auto-generated by @hey-api/openapi-ts

interface SerializeOptions<T>
extends SerializePrimitiveOptions,
SerializerOptions<T> {}
extends SerializePrimitiveOptions, SerializerOptions<T> {}

interface SerializePrimitiveOptions {
allowReserved?: boolean;
Expand Down
Loading
Loading