chore: migrate linting and formatting to Oxc
This commit is contained in:
+30
-33
@@ -1,64 +1,61 @@
|
||||
import { defineConfig, defineTransformer } from 'orval'
|
||||
import { defineConfig, defineTransformer } from "orval";
|
||||
|
||||
const selectedTag = 'twitter-lite-e2e'
|
||||
const selectedTag = "twitter-lite-e2e";
|
||||
const selectedOperationIds = new Set([
|
||||
'getUserByScreenName',
|
||||
'getUserTweets',
|
||||
'getTweetDetail',
|
||||
'getSearchTimeline',
|
||||
'getListLatestTweetsTimeline',
|
||||
])
|
||||
"getUserByScreenName",
|
||||
"getUserTweets",
|
||||
"getTweetDetail",
|
||||
"getSearchTimeline",
|
||||
"getListLatestTweetsTimeline",
|
||||
]);
|
||||
|
||||
const selectE2eOperations = defineTransformer((document) => {
|
||||
const foundOperationIds = new Set<string>()
|
||||
const foundOperationIds = new Set<string>();
|
||||
|
||||
for (const pathItem of Object.values(document.paths ?? {})) {
|
||||
if (!pathItem || typeof pathItem !== 'object') continue
|
||||
if (!pathItem || typeof pathItem !== "object") continue;
|
||||
|
||||
for (const candidate of Object.values(pathItem)) {
|
||||
if (
|
||||
!candidate ||
|
||||
typeof candidate !== 'object' ||
|
||||
typeof candidate !== "object" ||
|
||||
Array.isArray(candidate) ||
|
||||
!('operationId' in candidate)
|
||||
!("operationId" in candidate)
|
||||
) {
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
const operation = candidate as {
|
||||
operationId?: string
|
||||
tags?: string[]
|
||||
}
|
||||
operationId?: string;
|
||||
tags?: string[];
|
||||
};
|
||||
|
||||
if (
|
||||
operation.operationId &&
|
||||
selectedOperationIds.has(operation.operationId)
|
||||
) {
|
||||
foundOperationIds.add(operation.operationId)
|
||||
operation.tags = [...(operation.tags ?? []), selectedTag]
|
||||
if (operation.operationId && selectedOperationIds.has(operation.operationId)) {
|
||||
foundOperationIds.add(operation.operationId);
|
||||
operation.tags = [...(operation.tags ?? []), selectedTag];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const missingOperationIds = [...selectedOperationIds].filter(
|
||||
(operationId) => !foundOperationIds.has(operationId),
|
||||
)
|
||||
);
|
||||
if (missingOperationIds.length > 0) {
|
||||
throw new Error(
|
||||
`twitter-openapi is missing selected operations: ${missingOperationIds.join(', ')}`,
|
||||
)
|
||||
`twitter-openapi is missing selected operations: ${missingOperationIds.join(", ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
return document
|
||||
})
|
||||
return document;
|
||||
});
|
||||
|
||||
export default defineConfig({
|
||||
twitterOpenApi: {
|
||||
input: {
|
||||
target:
|
||||
'https://raw.githubusercontent.com/fa0311/twitter-openapi/590dae5c9f8575abc91d3774946bfe6f23960aba/dist/docs/openapi-3.0.yaml',
|
||||
"https://raw.githubusercontent.com/fa0311/twitter-openapi/590dae5c9f8575abc91d3774946bfe6f23960aba/dist/docs/openapi-3.0.yaml",
|
||||
filters: {
|
||||
mode: 'include',
|
||||
mode: "include",
|
||||
tags: [selectedTag],
|
||||
},
|
||||
override: {
|
||||
@@ -67,9 +64,9 @@ export default defineConfig({
|
||||
},
|
||||
output: {
|
||||
clean: true,
|
||||
client: 'fetch',
|
||||
mode: 'single',
|
||||
target: './e2e/generated/twitter-openapi/client.ts',
|
||||
client: "fetch",
|
||||
mode: "single",
|
||||
target: "./e2e/generated/twitter-openapi/client.ts",
|
||||
},
|
||||
},
|
||||
})
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user