Skip to content

chore: modernize package.json and TypeScript configuration #150

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

Merged
merged 10 commits into from
Jun 14, 2025
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
6 changes: 4 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: CI

on:
- pull_request
- push
pull_request:
branches: ["**"]
push:
branches: [main]

jobs:
ci:
Expand Down
2 changes: 0 additions & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @ts-check

import eslint from "@eslint/js";
import tseslint from "typescript-eslint";
import eslintConfigPrettier from "eslint-config-prettier";
Expand Down
19 changes: 6 additions & 13 deletions jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import type { Config } from "@jest/types";
import type { JestConfigWithTsJest } from "ts-jest";

const config: Config.InitialOptions = {
extensionsToTreatAsEsm: [".ts"],
const config = {
preset: "ts-jest/presets/default-esm",
moduleFileExtensions: ["ts", "js"],
setupFilesAfterEnv: ["./jest.setup.ts"],
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.ts$": [
"ts-jest",
{
useESM: true,
},
],
},
};
} satisfies JestConfigWithTsJest;

export default config;
module.exports = config;
83 changes: 56 additions & 27 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,66 @@
"name": "@api-platform/api-doc-parser",
"version": "0.16.8",
"description": "Transform an API documentation (Hydra, OpenAPI, GraphQL) in an intermediate representation that can be used for various tasks such as creating smart API clients, scaffolding code or building administration interfaces.",
"files": [
"*.md",
"lib",
"src"
"keywords": [
"api",
"api-platform",
"documentation",
"hydra",
"openapi",
"graphql",
"jsonld",
"json-schema",
"typescript",
"client"
],
"type": "module",
"exports": "./lib/index.js",
"main": "./lib/index.js",
"repository": "api-platform/api-doc-parser",
"homepage": "https://github.com/api-platform/api-doc-parser",
"bugs": "https://github.com/api-platform/api-doc-parser/issues",
"author": "Kévin Dunglas",
"repository": {
"type": "git",
"url": "git+https://github.com/api-platform/api-doc-parser.git"
},
"license": "MIT",
"author": "Kévin Dunglas",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./lib/index.js",
"default": "./lib/index.js"
},
"./package.json": "./package.json"
},
"main": "./lib/index.js",
"types": "./lib/index.d.ts",
"files": [
"lib",
"LICENSE",
"package.json",
"README.md"
],
"scripts": {
"build": "rm -rf lib && tsc --project tsconfig.build.json",
"build:watch": "tsc --watch",
"eslint-check": "eslint-config-prettier src/index.ts",
"lint": "eslint src",
"lint:fix": "eslint src --fix",
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"typecheck": "tsc --noEmit",
"typecheck:watch": "tsc --noEmit --watch"
},
"dependencies": {
"graphql": "^16.0.0",
"inflection": "^3.0.0",
"jsonld": "^8.3.2",
"jsonref": "^9.0.0",
"lodash.get": "^4.4.0"
},
"devDependencies": {
"@eslint/compat": "^1.2.5",
"@eslint/eslintrc": "^3.2.0",
"@eslint/js": "^9.19.0",
"@jest/globals": "29.7.0",
"@jest/types": "29.0.0",
"@types/inflection": "^1.13.0",
"@types/jest": "^29.0.0",
Expand All @@ -41,25 +84,11 @@
"typescript": "^5.7.0",
"typescript-eslint": "^8.22.0"
},
"dependencies": {
"graphql": "^16.0.0",
"inflection": "^3.0.0",
"jsonld": "^8.3.2",
"jsonref": "^9.0.0",
"lodash.get": "^4.4.0",
"tslib": "^2.0.0"
},
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules jest",
"lint": "eslint src",
"fix": "pnpm lint --fix",
"eslint-check": "eslint-config-prettier src/index.ts",
"build": "rm -rf lib/* && tsc",
"watch": "tsc --watch"
"packageManager": "[email protected]+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977",
"engines": {
"node": ">=18"
},
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"packageManager": "[email protected]+sha512.6540583f41cc5f628eb3d9773ecee802f4f9ef9923cc45b69890fb47991d4b092964694ec3a4f738a420c918a333062c8b925d312f42e4f0c263eb603551f977"
}
}
9 changes: 5 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/hydra/fetchJsonLd.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Document, JsonLd, RemoteDocument } from "jsonld/jsonld-spec";
import type { Document, JsonLd, RemoteDocument } from "jsonld/jsonld-spec.js";
import type { RequestInitExtended } from "./types.js";

const jsonLdMimeType = "application/ld+json";
Expand Down
2 changes: 1 addition & 1 deletion src/openapi3/parseOpenApi3Documentation.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Api } from "../Api.js";
import handleJson, { removeTrailingSlash } from "./handleJson.js";
import type { OpenAPIV3 } from "openapi-types";
import type { RequestInitExtended } from "./types";
import type { RequestInitExtended } from "./types.js";

export interface ParsedOpenApi3Documentation {
api: Api;
Expand Down
9 changes: 9 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
/* Emit */
"rootDir": "src"
},
"include": ["./src"],
"exclude": ["./src/**/*.test.ts"]
}
5 changes: 0 additions & 5 deletions tsconfig.eslint.json

This file was deleted.

46 changes: 34 additions & 12 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,41 @@
{
"compilerOptions": {
"target": "es6",
"module": "esnext",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "./lib",
/* Type checking */
// "exactOptionalPropertyTypes": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
// "noUncheckedIndexedAccess": true,
"noPropertyAccessFromIndexSignature": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"strict": true,

/* Modules */
"module": "NodeNext",
"noUncheckedSideEffectImports": true,
"types": ["jest"],

/* Language and Environment */
"lib": ["ES2022", "DOM"],
"moduleDetection": "force",
"target": "ES2022",

/* Output Formatting */
"noErrorTruncation": true,

/* Emit */
"declaration": true,
"declarationMap": true,
"rootDir": "./src",
"importHelpers": true,
"strict": true,
"esModuleInterop": true
"inlineSources": true,
"outDir": "lib",
"sourceMap": true,

/* Interop Constraints */
// "erasableSyntaxOnly": true,
"isolatedDeclarations": true,
"verbatimModuleSyntax": true
},
"exclude": [
"src/**/*.test.ts",
],
"include": ["./src"]
}