diff --git a/.eslintrc b/.eslintrc index 08baa40..fd63b5c 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,12 +1,10 @@ { - "extends": ["@readme/eslint-config", "@readme/eslint-config/typescript"], + "extends": ["@readme/eslint-config", "@readme/eslint-config/typescript", "@readme/eslint-config/esm"], "root": true, "rules": { // `any` types are fine because we're dealing with a lot of unknown data. "@typescript-eslint/no-explicit-any": "off", - "unicorn/prefer-node-protocol": "error", - "you-dont-need-lodash-underscore/get": "off" } } diff --git a/package-lock.json b/package-lock.json index ad9844f..ad25a07 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "devDependencies": { "@commitlint/cli": "^17.7.1", "@commitlint/config-conventional": "^17.7.0", - "@readme/eslint-config": "^12.2.1", + "@readme/eslint-config": "^13.0.1", "@readme/oas-examples": "^5.12.0", "@types/har-format": "^1.2.12", "@types/lodash": "^4.14.198", @@ -2628,9 +2628,9 @@ } }, "node_modules/@readme/eslint-config": { - "version": "12.2.1", - "resolved": "https://registry.npmjs.org/@readme/eslint-config/-/eslint-config-12.2.1.tgz", - "integrity": "sha512-tkYhhH8BTkdH4CFuMSWSby+Z4+XscROyC6/rGHSV1Y3dmJuj35FjhwTCR/nsiOLDVDBkKuJY3v0G5oCSxfgtkQ==", + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/@readme/eslint-config/-/eslint-config-13.0.1.tgz", + "integrity": "sha512-sfcW8R1ed2xX/2Cedfrd/YeLsvwflSGWXS/e+IoJbCjIphuFybj5isW60UJyfQAlT3Rv/DU5CtNUBc6ZsxG05g==", "dev": true, "dependencies": { "@typescript-eslint/eslint-plugin": "^6.2.1", @@ -2648,6 +2648,7 @@ "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-react": "^7.33.1", "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-require-extensions": "^0.1.3", "eslint-plugin-testing-library": "^6.0.1", "eslint-plugin-typescript-sort-keys": "^3.0.0", "eslint-plugin-unicorn": "^48.0.1", @@ -2656,7 +2657,7 @@ "lodash.merge": "^4.6.2" }, "engines": { - "node": ">=14.18" + "node": ">=18" }, "peerDependencies": { "eslint": "^8.0.0", @@ -5899,6 +5900,18 @@ "semver": "bin/semver.js" } }, + "node_modules/eslint-plugin-require-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-require-extensions/-/eslint-plugin-require-extensions-0.1.3.tgz", + "integrity": "sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug==", + "dev": true, + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "eslint": "*" + } + }, "node_modules/eslint-plugin-testing-library": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-6.0.1.tgz", @@ -15191,9 +15204,9 @@ "integrity": "sha512-b0L7VWqbLZqOSSAFUrxS5ZwUfec35WDsAwwCH481vYnhk0dWO3nvmNVNCbP8CY4cXqwL1W4uCAnhDz+CUmXM3g==" }, "@readme/eslint-config": { - "version": "12.2.1", - "resolved": "https://registry.npmjs.org/@readme/eslint-config/-/eslint-config-12.2.1.tgz", - "integrity": "sha512-tkYhhH8BTkdH4CFuMSWSby+Z4+XscROyC6/rGHSV1Y3dmJuj35FjhwTCR/nsiOLDVDBkKuJY3v0G5oCSxfgtkQ==", + "version": "13.0.1", + "resolved": "https://registry.npmjs.org/@readme/eslint-config/-/eslint-config-13.0.1.tgz", + "integrity": "sha512-sfcW8R1ed2xX/2Cedfrd/YeLsvwflSGWXS/e+IoJbCjIphuFybj5isW60UJyfQAlT3Rv/DU5CtNUBc6ZsxG05g==", "dev": true, "requires": { "@typescript-eslint/eslint-plugin": "^6.2.1", @@ -15211,6 +15224,7 @@ "eslint-plugin-prettier": "^5.0.0", "eslint-plugin-react": "^7.33.1", "eslint-plugin-react-hooks": "^4.6.0", + "eslint-plugin-require-extensions": "^0.1.3", "eslint-plugin-testing-library": "^6.0.1", "eslint-plugin-typescript-sort-keys": "^3.0.0", "eslint-plugin-unicorn": "^48.0.1", @@ -17677,6 +17691,13 @@ "dev": true, "requires": {} }, + "eslint-plugin-require-extensions": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-require-extensions/-/eslint-plugin-require-extensions-0.1.3.tgz", + "integrity": "sha512-T3c1PZ9PIdI3hjV8LdunfYI8gj017UQjzAnCrxuo3wAjneDbTPHdE3oNWInOjMA+z/aBkUtlW5vC0YepYMZIug==", + "dev": true, + "requires": {} + }, "eslint-plugin-testing-library": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/eslint-plugin-testing-library/-/eslint-plugin-testing-library-6.0.1.tgz", diff --git a/package.json b/package.json index a0ecd29..e29c17e 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ }, "scripts": { "build": "tsup", - "lint": "eslint .", + "lint": "eslint . && tsc --noEmit", "prebuild": "rm -rf dist/", "prepack": "npm run build", "prepare": "husky install", @@ -55,7 +55,7 @@ "devDependencies": { "@commitlint/cli": "^17.7.1", "@commitlint/config-conventional": "^17.7.0", - "@readme/eslint-config": "^12.2.1", + "@readme/eslint-config": "^13.0.1", "@readme/oas-examples": "^5.12.0", "@types/har-format": "^1.2.12", "@types/lodash": "^4.14.198", diff --git a/src/index.ts b/src/index.ts index 0246c57..4946d71 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ -import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types'; +import type { AuthForHAR, DataForHAR, oasToHarOptions } from './lib/types.js'; import type { Extensions } from '@readme/oas-extensions'; import type { PostDataParams, Request } from 'har-format'; import type Oas from 'oas'; @@ -17,15 +17,15 @@ import type { import { parse as parseDataUrl } from '@readme/data-urls'; import { getExtension, PROXY_ENABLED, HEADERS } from '@readme/oas-extensions'; -import lodashGet from 'lodash/get'; -import lodashSet from 'lodash/set'; +import lodashGet from 'lodash/get.js'; +import lodashSet from 'lodash/set.js'; import { Operation, utils } from 'oas'; import { isRef } from 'oas/rmoas.types'; import removeUndefinedObjects from 'remove-undefined-objects'; -import configureSecurity from './lib/configure-security'; -import formatStyle from './lib/style-formatting'; -import { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils'; +import configureSecurity from './lib/configure-security.js'; +import formatStyle from './lib/style-formatting/index.js'; +import { getSafeRequestBody, getTypedFormatsInSchema, hasSchemaType } from './lib/utils.js'; const { jsonSchemaTypes, matchesMimeType } = utils; diff --git a/src/lib/configure-security.ts b/src/lib/configure-security.ts index 20258da..c7e824a 100644 --- a/src/lib/configure-security.ts +++ b/src/lib/configure-security.ts @@ -1,4 +1,4 @@ -import type { AuthForHAR } from './types'; +import type { AuthForHAR } from './types.js'; import type { OASDocument, SecuritySchemeObject } from 'oas/rmoas.types'; import { isRef } from 'oas/rmoas.types'; diff --git a/src/lib/style-formatting/index.ts b/src/lib/style-formatting/index.ts index 35bf888..0234b9c 100644 --- a/src/lib/style-formatting/index.ts +++ b/src/lib/style-formatting/index.ts @@ -1,9 +1,9 @@ -import type { StylizerConfig } from './style-serializer'; +import type { StylizerConfig } from './style-serializer.js'; import type { ParameterObject, SchemaObject } from 'oas/rmoas.types'; import qs from 'qs'; -import stylize from './style-serializer'; +import stylize from './style-serializer.js'; // Certain styles don't support empty values. function shouldNotStyleEmptyValues(parameter: ParameterObject) { diff --git a/src/lib/style-formatting/style-serializer.ts b/src/lib/style-formatting/style-serializer.ts index 7072e11..792cb65 100644 --- a/src/lib/style-formatting/style-serializer.ts +++ b/src/lib/style-formatting/style-serializer.ts @@ -29,7 +29,6 @@ function isObject(value: unknown) { export function encodeDisallowedCharacters( str: string, - // eslint-disable-next-line @typescript-eslint/default-param-last { escape, returnIfEncoded = false, @@ -39,7 +38,7 @@ export function encodeDisallowedCharacters( isAllowedReserved?: boolean; returnIfEncoded?: boolean; } = {}, - parse: boolean, + parse?: boolean, ) { if (typeof str === 'number') { str = (str as number).toString(); diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 3ccf81b..cecad32 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -1,6 +1,6 @@ import type { JSONSchema, SchemaObject } from 'oas/rmoas.types'; -import lodashGet from 'lodash/get'; +import lodashGet from 'lodash/get.js'; /** * Determine if a schema `type` is, or contains, a specific discriminator. diff --git a/test/auth.test.ts b/test/auth.test.ts index 4f9a262..276d9d3 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -1,7 +1,7 @@ import Oas from 'oas'; import { describe, it, expect } from 'vitest'; -import oasToHar from '../src'; +import oasToHar from '../src/index.js'; import securityQuirks from './__datasets__/security-quirks.json'; import security from './__datasets__/security.json'; diff --git a/test/index.test.ts b/test/index.test.ts index 79da2ef..fbfaa80 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -6,7 +6,7 @@ import toBeAValidHAR from 'jest-expect-har'; import Oas from 'oas'; import { describe, beforeEach, it, expect } from 'vitest'; -import oasToHar from '../src'; +import oasToHar from '../src/index.js'; import serverVariables from './__datasets__/server-variables.json'; diff --git a/test/lib/configure-security.test.ts b/test/lib/configure-security.test.ts index 8e00f34..f849deb 100644 --- a/test/lib/configure-security.test.ts +++ b/test/lib/configure-security.test.ts @@ -2,7 +2,7 @@ import type { OASDocument, SecuritySchemeObject } from 'oas/rmoas.types'; import { describe, it, expect } from 'vitest'; -import configureSecurity from '../../src/lib/configure-security'; +import configureSecurity from '../../src/lib/configure-security.js'; function createSecurityOAS(scheme: SecuritySchemeObject) { return { diff --git a/test/lib/style-formatting/index.test.ts b/test/lib/style-formatting/index.test.ts index 892ae0f..3c017db 100644 --- a/test/lib/style-formatting/index.test.ts +++ b/test/lib/style-formatting/index.test.ts @@ -1,11 +1,11 @@ -import type { DataForHAR } from '../../../src'; +import type { DataForHAR } from '../../../src/index.js'; import type { Request } from 'har-format'; import toBeAValidHAR from 'jest-expect-har'; import { describe, it, expect } from 'vitest'; -import oasToHar from '../../../src'; -import oasFixture from '../../__fixtures__/create-oas'; +import oasToHar from '../../../src/index.js'; +import oasFixture from '../../__fixtures__/create-oas.js'; import { emptyInput, undefinedInput, @@ -19,7 +19,7 @@ import { objectNestedObjectOfARidiculiousShape, objectInputEncoded, undefinedObjectInput, -} from '../../__fixtures__/style-data'; +} from '../../__fixtures__/style-data.js'; expect.extend({ toBeAValidHAR }); diff --git a/test/lib/style-formatting/multipart-form-data.test.ts b/test/lib/style-formatting/multipart-form-data.test.ts index 2d5e2af..eed4d5f 100644 --- a/test/lib/style-formatting/multipart-form-data.test.ts +++ b/test/lib/style-formatting/multipart-form-data.test.ts @@ -1,11 +1,11 @@ -import type { DataForHAR } from '../../../src'; +import type { DataForHAR } from '../../../src/index.js'; import type { PostDataParams } from 'har-format'; import toBeAValidHAR from 'jest-expect-har'; import { describe, it, expect } from 'vitest'; -import oasToHar from '../../../src'; -import oasFixture from '../../__fixtures__/create-oas'; +import oasToHar from '../../../src/index.js'; +import oasFixture from '../../__fixtures__/create-oas.js'; import { emptyInput, stringInput, @@ -16,7 +16,7 @@ import { objectNestedObject, objectNestedObjectOfARidiculiousShape, objectInputEncoded, -} from '../../__fixtures__/style-data'; +} from '../../__fixtures__/style-data.js'; expect.extend({ toBeAValidHAR }); diff --git a/test/parameters.test.ts b/test/parameters.test.ts index 57dc45e..bee603e 100644 --- a/test/parameters.test.ts +++ b/test/parameters.test.ts @@ -1,4 +1,4 @@ -import type { DataForHAR } from '../src'; +import type { DataForHAR } from '../src/index.js'; import type { Request } from 'har-format'; import type { OperationObject } from 'oas/rmoas.types'; @@ -6,7 +6,7 @@ import toBeAValidHAR from 'jest-expect-har'; import Oas from 'oas'; import { describe, beforeEach, it, expect } from 'vitest'; -import oasToHar from '../src'; +import oasToHar from '../src/index.js'; import commonParameters from './__datasets__/common-parameters.json'; diff --git a/test/requestBody.test.ts b/test/requestBody.test.ts index 6c44e32..3de989a 100644 --- a/test/requestBody.test.ts +++ b/test/requestBody.test.ts @@ -5,7 +5,7 @@ import toBeAValidHAR from 'jest-expect-har'; import Oas from 'oas'; import { describe, it, expect } from 'vitest'; -import oasToHar from '../src'; +import oasToHar from '../src/index.js'; import deeplyNestedJsonFormats from './__datasets__/deeply-nested-json-formats.json'; import multipartFormDataArrayOfFiles from './__datasets__/multipart-form-data/array-of-files.json';