Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and apply formatter #564

Merged
merged 1 commit into from
Feb 21, 2024
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: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
"source.fixAll.eslint": "explicit"
},
"editor.quickSuggestions": {
"strings": true
Expand All @@ -18,4 +18,4 @@
"tilded",
"untilde"
]
}
}
1,399 changes: 900 additions & 499 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"build": "tsc -p ./tsconfig-build.json",
"clean": "rimraf dist/ build/ {src,test}/**/*.{js,js.map} *.tsbuildinfo",
"compile": "tsc -p .",
"lint": "eslint --fix --ext ts src/ test/",
"lint": "eslint --fix --report-unused-disable-directives --ext ts src/ test/",
"format": "prettier --cache --write 'src/**/*.ts' 'test/*.ts' 'test/core/*.ts'",
"precompile": "npm run lint && npm run format",
"prepublishOnly": "npm run build",
Expand Down Expand Up @@ -44,37 +44,37 @@
"node": ">= 18.0"
},
"dependencies": {
"commander": "^11.1.0",
"commander": "^12.0.0",
"cross-fetch": "^4.0.0",
"debug": "^4.3.4",
"glob": "^10.3.10",
"http-proxy-agent": "^7.0.0",
"https-proxy-agent": "^7.0.2",
"http-proxy-agent": "^7.0.2",
"https-proxy-agent": "^7.0.4",
"js-yaml": "^4.1.0",
"tslib": "^2.6.2",
"typescript": "^5.2.2"
"typescript": "^5.3.3"
},
"devDependencies": {
"@dtsgenerator/do-nothing": "^2.6.0",
"@dtsgenerator/eslint-config": "^0.6.7",
"@dtsgenerator/eslint-config": "^0.7.0",
"@dtsgenerator/replace-namespace": "^1.6.0",
"@dtsgenerator/single-quote": "^1.7.0",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@types/debug": "^4.1.10",
"@types/debug": "^4.1.12",
"@types/glob": "^8.1.0",
"@types/js-yaml": "^4.0.8",
"@types/mocha": "^10.0.3",
"@types/node": "^18.18.6",
"@types/js-yaml": "^4.0.9",
"@types/mocha": "^10.0.6",
"@types/node": "^18.19.17",
"cross-env": "^7.0.3",
"eslint": "^8.51.0",
"husky": "^8.0.3",
"lint-staged": "^15.0.2",
"mocha": "^10.2.0",
"eslint": "^8.56.0",
"husky": "^9.0.11",
"lint-staged": "^15.2.2",
"mocha": "^10.3.0",
"nyc": "^15.1.0",
"prettier": "^3.0.3",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"source-map-support": "^0.5.21",
"ts-node": "^10.9.1"
"ts-node": "^10.9.2"
},
"lint-staged": {
"**/*.ts": [
Expand Down
11 changes: 5 additions & 6 deletions src/core/astBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,12 @@ export function buildTupleTypeNode(
for (let i = 0; i < itemCount; i++) {
let node = typesIsArray(types)
? i < types.length
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
types[i]!
? types[i]!
: additionalItems !== undefined
? additionalItems === false
? buildNeverKeyword()
: additionalItems
: buildAnyKeyword()
? additionalItems === false
? buildNeverKeyword()
: additionalItems
: buildAnyKeyword()
: types;
if (minItems == null || i >= minItems) {
node = ts.factory.createOptionalTypeNode(node);
Expand Down
4 changes: 1 addition & 3 deletions src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ export interface Config {
target: ScriptTarget;
outputAST: boolean;

plugins: {
[pluginName: string]: boolean | Record<string, unknown>;
};
plugins: Record<string, boolean | Record<string, unknown>>;
}

interface InputConfig {
Expand Down
10 changes: 5 additions & 5 deletions src/core/dtsGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class DtsGenerator {

const postProcess = await this.getPostProcess(plugins.post);
const result = ts.transform(file, postProcess);
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion

const transformedNodes = result.transformed[0]!;

const transformedContent = config.outputAST
Expand Down Expand Up @@ -553,14 +553,14 @@ export default class DtsGenerator {
const additionalItems = schema.content.additionalItems
? this.normalizeContent(schema, '/additionalItems')
: schema.content.additionalItems === false
? false
: undefined;
? false
: undefined;

return additionalItems === undefined
? undefined
: additionalItems === false
? false
: this.generateTypeProperty(additionalItems, false);
? false
: this.generateTypeProperty(additionalItems, false);
};

if (items == null) {
Expand Down
13 changes: 5 additions & 8 deletions src/core/jsonSchema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
import * as JsonPointer from '../jsonPointer';
import { JsonSchemaDraft04 } from './jsonSchemaDraft04';
import { OpenApisV2 } from './openApiV2';
Expand Down Expand Up @@ -103,7 +102,7 @@ export function searchAllSubSchema(
});
};
const walkObject = (
obj: { [name: string]: JsonSchema } | undefined,
obj: Record<string, JsonSchema> | undefined,
paths: string[],
parentIds: string[],
): void => {
Expand Down Expand Up @@ -202,7 +201,7 @@ export function searchAllSubSchema(
}
function setSubIdToAnyObject<T>(
f: (t: T, keys: string[]) => void,
obj: { [key: string]: T } | undefined,
obj: Record<string, T> | undefined,
keys: string[],
): void {
if (obj == null) {
Expand Down Expand Up @@ -297,7 +296,7 @@ export function searchAllSubSchema(
const paths = keys
.slice(0, keys.length - 1)
.concat(inType + 'Parameters');
const properties: { [name: string]: JsonSchemaDraft04.Schema } = {};
const properties: Record<string, JsonSchemaDraft04.Schema> = {};
params.forEach(([key, _]) => {
properties[key] = {
$ref: createId(keys.concat(key)),
Expand Down Expand Up @@ -347,7 +346,6 @@ export function searchAllSubSchema(
}
const operationId = ops.operationId;
if (operationId) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
keys = [keys[0]!, convertKeyToTypeName(operationId)];
}
setSubIdToParameters(ops.parameters, keys.concat('parameters'));
Expand Down Expand Up @@ -446,7 +444,6 @@ export function searchAllSubSchema(
}
const operationId = ops.operationId;
if (operationId) {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
keys = [keys[0]!, convertKeyToTypeName(operationId)];
}
setSubIdToParameters(ops.parameters, keys.concat('parameters'));
Expand Down Expand Up @@ -476,7 +473,7 @@ export function searchAllSubSchema(
}

function setSubIdToObject(
obj: { [name: string]: JsonSchema } | undefined,
obj: Record<string, JsonSchema> | undefined,
paths: string[],
): void {
if (obj == null) {
Expand Down Expand Up @@ -558,7 +555,7 @@ export function selectSchemaType(content: JsonSchema | OpenApiSchema): {
);
}
if ('$schema' in content) {
const schema = content['$schema'] ?? '';
const schema = content.$schema ?? '';
if (/^https?:\/\/json-schema.org\/schema#?$/.test(schema)) {
return { type: 'Latest' };
}
Expand Down
17 changes: 4 additions & 13 deletions src/core/jsonSchemaDraft04.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-namespace */

export namespace JsonSchemaDraft04 {
Expand Down Expand Up @@ -31,18 +30,10 @@ export namespace JsonSchemaDraft04 {
minProperties?: Schema.Definitions.PositiveIntegerDefault0;
required?: Schema.Definitions.StringArray;
additionalProperties?: boolean | Schema;
definitions?: {
[name: string]: Schema;
};
properties?: {
[name: string]: Schema;
};
patternProperties?: {
[name: string]: Schema;
};
dependencies?: {
[name: string]: Schema | Schema.Definitions.StringArray;
};
definitions?: Record<string, Schema>;
properties?: Record<string, Schema>;
patternProperties?: Record<string, Schema>;
dependencies?: Record<string, Schema | Schema.Definitions.StringArray>;
enum?: any[];
type?:
| Schema.Definitions.SimpleTypes
Expand Down
21 changes: 6 additions & 15 deletions src/core/jsonSchemaDraft07.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable @typescript-eslint/no-namespace */

export namespace JsonSchemaDraft07 {
export type SchemaObject = {
export interface SchemaObject {
$id?: string; // uri-reference
$schema?: string; // uri
$ref?: string; // uri-reference
Expand Down Expand Up @@ -31,18 +30,10 @@ export namespace JsonSchemaDraft07 {
minProperties?: Schema.Definitions.NonNegativeIntegerDefault0;
required?: Schema.Definitions.StringArray;
additionalProperties?: Schema;
definitions?: {
[name: string]: Schema;
};
properties?: {
[name: string]: Schema;
};
patternProperties?: {
[name: string]: Schema;
};
dependencies?: {
[name: string]: Schema | Schema.Definitions.StringArray;
};
definitions?: Record<string, Schema>;
properties?: Record<string, Schema>;
patternProperties?: Record<string, Schema>;
dependencies?: Record<string, Schema | Schema.Definitions.StringArray>;
propertyNames?: Schema;
const?: any;
enum?: any[];
Expand All @@ -59,7 +50,7 @@ export namespace JsonSchemaDraft07 {
anyOf?: Schema.Definitions.SchemaArray;
oneOf?: Schema.Definitions.SchemaArray;
not?: Schema;
};
}
export type Schema = SchemaObject | boolean;
export namespace Schema {
export namespace Definitions {
Expand Down
Loading
Loading